This commit is contained in:
Sven Fuchs 2012-06-24 15:39:15 +02:00
parent aea4375860
commit 2af55e9387
16 changed files with 144 additions and 144 deletions

View File

@ -10,11 +10,9 @@ require 'templates'
require 'controllers'
require 'routes'
# Travis = window.Travis
Travis.store = DS.Store.extend(
revision: 4
adapter: Travis.RestAdapter.create()
# adapter: Travis.FixtureAdapter.create()
).create()
Travis.initialize()

View File

@ -3,12 +3,7 @@ Travis.RepositoriesController = Em.ArrayController.extend()
Travis.RepositoryController = Em.ObjectController.extend(Travis.Urls.Repository)
Travis.TabsController = Em.Controller.extend()
Travis.HistoryController = Em.ArrayController.extend()
Travis.JobController = Em.ObjectController.extend()
Travis.LoadingController = Em.Controller.extend()
Travis.BuildController = Em.ObjectController.extend
classes: (->
Travis.Helpers.colorForResult(@getPath('content.result'))
).property('content.result')
Travis.BuildController = Em.ObjectController.extend(Travis.Urls.Commit)
Travis.JobController = Em.ObjectController.extend(Travis.Urls.Commit)

View File

@ -1,5 +1,4 @@
require 'ext/ember/bound_helper'
require 'travis/log'
safe = (string) ->
new Handlebars.SafeString(string)
@ -20,16 +19,13 @@ Ember.registerBoundHelper 'formatDuration', (duration, options) ->
safe Travis.Helpers.timeInWords(duration)
Ember.registerBoundHelper 'formatCommit', (commit, options) ->
if commit
branch = commit.get('branch') || ''
branch = " (#{branch})" if branch
safe (commit.get('sha') || '').substr(0, 7) + branch
safe Travis.Helpers.formatCommit(commit.get('sha'), commit.get('branch')) if commit
Ember.registerBoundHelper 'formatSha', (sha, options) ->
safe (sha || '').substr(0, 7)
safe Travis.Helpers.formatSha(sha)
Ember.registerBoundHelper 'pathFrom', (url, options) ->
safe (url || '').split('/').pop()
safe Travis.Helpers.pathFrom(url)
Ember.registerBoundHelper 'formatMessage', (message, options) ->
safe Travis.Helpers.formatMessage(message, options)
@ -38,5 +34,5 @@ Ember.registerBoundHelper 'formatConfig', (config, options) ->
safe Travis.Helpers.formatConfig(config)
Ember.registerBoundHelper 'formatLog', (log, options) ->
Travis.Log.filter(log) if log
Travis.Helpers.formatLog(log) || ''

View File

@ -1,7 +1,18 @@
require 'travis/log'
@Travis.Helpers =
safe: (string) ->
new Handlebars.SafeString(string)
colorForResult: (result) ->
(if result is 0 then 'green' else (if result is 1 then 'red' else null))
formatCommit: (sha, branch) ->
Travis.Helpers.formatSha(sha) + if branch then " (#{branch})" else ''
formatSha: (sha) ->
(sha || '').substr(0, 7)
formatConfig: (config) ->
config = $.only config, 'rvm', 'gemfile', 'env', 'otp_release', 'php', 'node_js', 'scala', 'jdk', 'python', 'perl'
values = $.map config, (value, key) ->
@ -14,6 +25,12 @@
message = message.split(/\n/)[0] if options.short
@_emojize(@_escape(message)).replace /\n/g, '<br/>'
formatLog: (log) ->
Travis.Log.filter(log)
pathFrom: (url) ->
(url || '').split('/').pop()
timeAgoInWords: (date) ->
$.timeago.distanceInWords date

View File

@ -20,17 +20,17 @@
'%@.png'.fmt @get('slug')
).property('slug')
Commit:
urlAuthor: (->
'mailto:%@'.fmt @getPath('commit.authorEmail')
).property('commit')
urlCommitter: (->
'mailto:%@'.fmt @getPath('commit.committerEmail')
).property('commit')
Build:
githubCommit: (->
'http://github.com/%@/commit/%@'.fmt @getPath('repository.slug'), @getPath('commit.sha')
).property('repository.slug', 'commit.sha')
Commit:
urlAuthor: (->
'mailto:%@'.fmt @getPath('commit.authorEmail')
).property()
urlCommitter: (->
'mailto:%@'.fmt @getPath('commit.committerEmail')
).property()

View File

@ -1,13 +1,13 @@
require 'travis/model'
@Travis.Repository = Travis.Model.extend
slug: DS.attr('string')
description: DS.attr('string')
last_build_id: DS.attr('number')
last_build_number: DS.attr('string')
last_build_result: DS.attr('number')
last_build_started_at: DS.attr('string')
last_build_finished_at: DS.attr('string')
slug: DS.attr('string')
description: DS.attr('string')
lastBuildId: DS.attr('number')
lastBuildNumber: DS.attr('string')
lastBuildResult: DS.attr('number')
lastBuildStarted_at: DS.attr('string')
lastBuildFinished_at: DS.attr('string')
primaryKey: 'slug'
@ -29,11 +29,11 @@ require 'travis/model'
(@get('slug') || @_id).split('/')[1]
).property('owner', 'name'),
last_build_duration: (->
duration = @getPath('data.last_build_duration')
duration = Travis.Helpers.durationFrom(@get('last_build_started_at'), @get('last_build_finished_at')) unless duration
lastBuildDuration: (->
duration = @getPath('data.lastBuildDuration')
duration = Travis.Helpers.durationFrom(@get('lastBuildStarted_at'), @get('lastBuildFinished_at')) unless duration
duration
).property('data.last_build_duration', 'last_build_started_at', 'last_build_finished_at')
).property('data.lastBuildDuration', 'lastBuildStartedAt', 'lastBuildFinishedAt')
stats: (->
# @get('_stats') || $.get("https://api.github.com/repos/#{@get('slug')}", (data) =>
@ -46,8 +46,8 @@ require 'travis/model'
Travis.Repository.select(self.get('id'))
tick: ->
@notifyPropertyChange 'last_build_duration'
@notifyPropertyChange 'last_build_finished_at'
@notifyPropertyChange 'lastBuildDuration'
@notifyPropertyChange 'lastBuildFinishedAt'
@Travis.Repository.reopenClass
recent: ->

View File

@ -12,7 +12,7 @@ require 'travis/model'
state: DS.attr('string')
name: DS.attr('string')
host: DS.attr('string')
last_seen_at: DS.attr('string')
lastSeenAt: DS.attr('string')
isTesting: (->
@get('state') == 'working' && !!@getPath('payload.config')

View File

@ -19,6 +19,7 @@ require 'hax0rs'
connectOutlets: (router) ->
repositories = Travis.Repository.find()
router.set('repositories', repositories)
router.set('job', undefined)
router.connectLeft(repositories)
index: Em.Route.extend
@ -30,9 +31,9 @@ require 'hax0rs'
repositories = router.get('repositories')
onceLoaded repositories, =>
repository = repositories.get('firstObject')
build = Travis.Build.find(repository.get('last_build_id'))
build = Travis.Build.find(repository.get('lastBuildId'))
router.connectRepository(repository)
router.connectTabs(repository)
router.connectTabs()
router.connectBuild(build)
repository: Em.Route.extend
@ -45,9 +46,7 @@ require 'hax0rs'
router.deserializeRepository(params)
connectOutlets: (router, repository) ->
router.set('repository', repository)
router.connectRepository(repository)
router.connectTabs(repository)
current: Em.Route.extend
route: '/'
@ -56,7 +55,7 @@ require 'hax0rs'
repository = router.get('repository')
onceLoaded repository, -> # TODO should not need to wait here, right?
build = repository.get('lastBuild')
router.connectTabs(repository)
router.connectTabs()
router.connectBuild(build)
builds: Em.Route.extend
@ -65,6 +64,7 @@ require 'hax0rs'
connectOutlets: (router) ->
repository = router.get('repository')
onceLoaded repository, => # TODO hrm, otherwise it gets builds?repository_id=null
router.connectTabs()
router.connectBuilds(repository.get('builds'))
build: Em.Route.extend
@ -72,7 +72,7 @@ require 'hax0rs'
connectOutlets: (router, build) ->
build = Travis.Build.find(build.id) unless build instanceof Travis.Build # what?
router.setPath('tabsController.build', build)
router.connectTabs(build)
router.connectBuild(build)
job: Em.Route.extend
@ -80,8 +80,7 @@ require 'hax0rs'
connectOutlets: (router, job) ->
job = Travis.Job.find(job.id) unless job instanceof Travis.Job # what?
router.setPath('tabsController.build', job.get('build'))
router.setPath('tabsController.job', job)
router.connectTabs(job.get('build'), job)
router.connectJob(job)
@ -89,10 +88,13 @@ require 'hax0rs'
@get('applicationController').connectOutlet(outletName: 'left', name: 'repositories', context: repositories)
connectRepository: (repository) ->
@set('repository', repository)
@get('applicationController').connectOutlet(outletName: 'main', name: 'repository', context: repository)
connectTabs: (repository) ->
@setPath('tabsController.repository', repository)
connectTabs: (build, job) ->
@setPath('tabsController.repository', @get('repository'))
@setPath('tabsController.build', build)
@setPath('tabsController.job', job)
@get('repositoryController').connectOutlet(outletName: 'tabs', name: 'tabs')
connectBuilds: (builds) ->

View File

@ -2,7 +2,7 @@
<dl class="summary clearfix">
<div class="left">
<dt>{{t builds.name}}</dt>
<dd class="number"><a {{bindAttr href="urlBuild"}}>{{number}}</a></dd>
<dd class="number"><a {{action viewBuild href=true}}>{{number}}</a></dd>
<dt class="finished_at_label">{{t builds.finished_at}}</dt>
<dd class="finished_at timeago" {{bindAttr title="finished_at"}}>{{formatTime finished_at}}</dd>
<dt>{{t builds.duration}}</dt>
@ -18,7 +18,7 @@
{{/if}}
{{#if commit.authorName}}
<dt>{{t builds.author}}</dt>
<dd class="author"><a {{bindAttr href="view.urlAuthor"}}>{{commit.authorName}}</a></dd>
<dd class="author"><a {{bindAttr href="urlAuthor"}}>{{commit.authorName}}</a></dd>
{{/if}}
{{#if commit.committerName}}
<dt>{{t builds.committer}}</dt>
@ -37,7 +37,8 @@
{{#if isLoaded}}
{{#if view.isMatrix}}
{{view Travis.JobsView}}
{{view Travis.JobsView jobsBinding="view.requiredJobs" required="true"}}
{{view Travis.JobsView jobsBinding="view.allowedFailureJobs"}}
{{else}}
{{view Travis.LogView contextBinding="jobs.firstObject"}}
{{/if}}

View File

@ -1,30 +1,11 @@
<table id="jobs">
<caption>{{t jobs.build_matrix}}</caption>
<thead>
<tr>
{{#each configKeys}}
<th>{{this}}</th>
{{/each}}
</tr>
</thead>
<tbody>
{{#each view.requiredJobs}}
<tr {{bindAttr class="color"}}>
<td class="number"><a {{action viewJob href=true}}>#{{number}}</a></td>
<td class="duration" {{bindAttr title="started_at"}}>{{formatDuration duration}}</td>
<td class="finished_at timeago" {{bindAttr title="finished_at"}}>{{formatTime finished_at}}</td>
{{#each configValues}}
<td>{{this}}</td>
{{/each}}
</tr>
{{/each}}
</tbody>
</table>
{{#if view.isFailureMatrix}}
<table id="allow_failure_builds">
{{#if view.jobs.length}}
<table id="jobs">
<caption>
{{t jobs.allowed_failures}}{{whats_this allow_failure_help}}
{{#if view.required}}
{{t jobs.build_matrix}}
{{else}}
{{t jobs.allowed_failures}}{{whats_this allow_failure_help}}
{{/if}}
</caption>
<thead>
<tr>
@ -34,7 +15,7 @@
</tr>
</thead>
<tbody>
{{#each allowedFailureJobs}}
{{#each view.jobs}}
<tr {{bindAttr class="color"}}>
<td class="number"><a {{action viewJob href=true}}>#{{number}}</a></td>
<td class="duration" {{bindAttr title="started_at"}}>{{formatDuration duration}}</td>
@ -47,24 +28,25 @@
</tbody>
</table>
<div id="allow_failure_help" class="context_help">
<div class="context_help_caption">{{t "jobs.allowed_failures"}}</div>
<div class="context_help_body">
<p>
Allowed Failures are items in your build matrix that are allowed to
fail without causing the entire build to be shown as failed. This lets you add
in experimental and preparatory builds to test against versions or
configurations that you are not ready to officially support.
</p>
<p>
You can define allowed failures in the build matrix as follows:
</p>
<pre>
matrix:
allow_failures:
- rvm: ruby-head
</pre>
{{#unless view.required}}
<div id="allow_failure_help" class="context_help">
<div class="context_help_caption">{{t "jobs.allowed_failures"}}</div>
<div class="context_help_body">
<p>
Allowed Failures are items in your build matrix that are allowed to
fail without causing the entire build to be shown as failed. This lets you add
in experimental and preparatory builds to test against versions or
configurations that you are not ready to officially support.
</p>
<p>
You can define allowed failures in the build matrix as follows:
</p>
<pre>
matrix:
allow_failures:
- rvm: ruby-head
</pre>
</div>
</div>
</div>
{{/unless}}
{{/if}}

View File

@ -1,8 +1,8 @@
<div {{bindAttr class="color"}}>
<div {{bindAttr class="classes"}}>
<dl class="summary clearfix">
<div class="left">
<dt>Job</dt>
<dd class="number"><a {{bindAttr href="urlJob"}}>{{number}}</a></dd>
<dd class="number"><a {{action viewJob href=true}}>{{number}}</a></dd>
<dt class="finished_at_label">{{t jobs.finished_at}}</dt>
<dd class="finished_at timeago" {{bindAttr title="finished_at"}}>{{formatTime finished_at}}</dd>
<dt>{{t jobs.duration}}</dt>
@ -12,17 +12,17 @@
<div class="right">
<dt>{{t jobs.commit}}</dt>
<dd class="commit-hash"><a {{bindAttr href="urlGithubCommit"}}>{{formatCommit commit}}</a></dd>
{{#if commit.compare_url}}
{{#if commit.compareUrl}}
<dt>{{t jobs.compare}}</dt>
<dd class="compare_view"><a {{bindAttr href="commit.compare_url"}}>{{pathFrom commit.compare_url}}</a></dd>
<dd class="compare_view"><a {{bindAttr href="commit.compareUrl"}}>{{pathFrom commit.compareUrl}}</a></dd>
{{/if}}
{{#if commit.author_name}}
{{#if commit.authorName}}
<dt>{{t jobs.author}}</dt>
<dd class="author"><a {{bindAttr href="urlAuthor"}}>{{commit.author_name}}</a></dd>
<dd class="author"><a {{bindAttr href="urlAuthor"}}>{{commit.authorName}}</a></dd>
{{/if}}
{{#if commit.committer_name}}
{{#if commit.committerName}}
<dt>{{t jobs.committer}}</dt>
<dd class="committer"><a {{bindAttr href="urlCommitter"}}>{{commit.committer_name}}</a></dd>
<dd class="committer"><a {{bindAttr href="urlCommitter"}}>{{commit.committerName}}</a></dd>
{{/if}}
</div>

View File

@ -1 +0,0 @@
loading stuff ...

View File

@ -5,14 +5,14 @@
<li {{bindAttr class="view.classes"}}>
<div class="wrapper">
<a {{action viewCurrent href=true}} class="slug">{{slug}}</a>
<a {{action viewBuild href=true context="view.lastBuild"}} class="build">#{{last_build_number}}</a>
<a {{action viewBuild href=true context="lastBuild"}} class="build">#{{lastBuildNumber}}</a>
</div>
<p class="summary">
<span class="duration_label">{{t repositories.duration}}:</span>
<abbr class="duration" {{bindAttr title="last_build_started_at"}}>{{formatDuration last_build_duration}}</abbr>,
<abbr class="duration" {{bindAttr title="lastBuildStartedAt"}}>{{formatDuration lastBuildDuration}}</abbr>,
<span class="finished_at_label">{{t repositories.finished_at}}:</span>
<abbr class="finished_at timeago" {{bindAttr title="last_build_finished_at"}}>{{formatTime last_build_finished_at}}</abbr>
<abbr class="finished_at timeago" {{bindAttr title="lastBuildFinishedAt"}}>{{formatTime lastBuildFinished_at}}</abbr>
</p>
{{#if description}}
<p class="description">{{description}}</p>

View File

@ -1,25 +1,31 @@
Travis.ApplicationView = Em.View.extend templateName: 'application'
Travis.RepositoriesView = Em.View.extend templateName: 'repositories/list'
Travis.ApplicationView = Em.View.extend
templateName: 'application'
Travis.RepositoriesView = Em.View.extend
templateName: 'repositories/list'
Travis.RepositoriesItemView = Em.View.extend
classes: (->
color = Travis.Helpers.colorForResult(@getPath('context.last_build_result'))
color = Travis.Helpers.colorForResult(@getPath('repository.lastBuildResult'))
classes = ['repository', color]
classes.push 'selected' if @getPath('context.selected')
classes.push 'selected' if @getPath('repository.selected')
classes.join(' ')
).property('context.last_build_result', 'context.selected')
).property('repository.lastBuildResult', 'repository.selected')
lastBuild: (->
owner: @getPath('context.owner')
name: @getPath('context.name')
id: @getPath('context.last_build_id')
).property('context.last_build_id')
owner: @getPath('repository.owner')
name: @getPath('repository.name')
id: @getPath('repository.lastBuildId')
).property('repository.owner', 'repository.name', 'repository.lastBuildId')
Travis.RepositoryView = Em.View.extend
templateName: 'repositories/show'
Travis.RepositoryView = Em.View.extend templateName: 'repositories/show'
Travis.TabsView = Em.View.extend templateName: 'repositories/tabs'
Travis.HistoryView = Em.View.extend templateName: 'builds/list'
Travis.LoadingView = Em.View.extend templateName: 'loading'
Travis.TabsView = Em.View.extend
templateName: 'repositories/tabs'
Travis.HistoryView = Em.View.extend
templateName: 'builds/list'
Travis.BuildsItemView = Em.View.extend
classes: (->
@ -29,25 +35,32 @@ Travis.BuildsItemView = Em.View.extend
Travis.BuildView = Em.View.extend
templateName: 'builds/show'
classes: (->
Travis.Helpers.colorForResult(@get('result'))
).property('result')
isMatrix: (->
@getPath('context.data.job_ids.length') > 1
).property() # TODO if i bind this to 'context.data.job_ids.length', that breaks the entire view (as if context was always undefined)
requiredJobs: (->
@getPath('context.jobs').filter((job) -> job.get('allow_failure') != true)
).property() # TODO same here with binding to 'context.data.job_ids'
allowedFailureJobs: (->
@getPath('context.jobs').filter((job) -> job.get('allow_failure'))
).property()
Travis.JobsView = Em.View.extend
templateName: 'jobs/list'
isFailureMatrix: (->
@getPath('context.allowedFailureJobs.length') > 0
).property('context.allowedFailureJobs.length')
Travis.JobView = Em.View.extend
templateName: 'jobs/show'
requiredJobs: (->
@getPath('context.jobs').filter (job) -> job.get('allow_failure') != true
).property('context.jobs')
classes: (->
Travis.Helpers.colorForResult(@get('result'))
).property('result')
allowedFailureJobs: (->
@getPath('context.jobs').filter (job) -> job.get('allow_failure')
).property('context.jobs')
Travis.JobView = Em.View.extend templateName: 'jobs/show'
Travis.LogView = Em.View.extend templateName: 'jobs/log'
Travis.LogView = Em.View.extend
templateName: 'jobs/log'

View File

@ -6,10 +6,10 @@
exec: /(<p.*?\/a>[\/\w]*.rvm\/rubies\/[\S]*?\/(ruby|rbx|jruby) .*?<\/p>)/g
filter: (log) ->
log = @escapeHtml(log)
log = @escape(log)
log = @deansi(log)
log = log.replace(/\r/g, '')
log = @numberLines(log)
log = @number(log)
log = @fold(log)
log = log.replace(/\n/g, '')
log
@ -17,19 +17,18 @@
stripPaths: (log) ->
log.replace /\/home\/vagrant\/builds(\/[^\/\n]+){2}\//g, ''
escapeHtml: (log) ->
escape: (log) ->
Handlebars.Utils.escapeExpression log
escapeRuby: (log) ->
log.replace /#<(\w+.*?)>/, '#&lt;$1&gt;'
numberLines: (log) ->
number: (log) ->
result = ''
$.each log.trim().split('\n'), (ix, line) ->
number = ix + 1
path = Travis.Log.location().substr(1).replace(/\/L\d+/, '') + '/L' + number
result += '<p><a href=\'#%@\' id=\'%@\' name=\'L%@\'>%@</a>%@</p>\n'.fmt(path, path, number, number, line)
result.trim()
deansi: (log) ->
@ -43,7 +42,6 @@
part.bold and classes.push('bold')
part.italic and classes.push('italic')
text += (if classes.length then ('<span class=\'' + classes.join(' ') + '\'>' + part.text + '</span>') else part.text)
text.replace /\033/g, ''
fold: (log) ->
@ -52,7 +50,6 @@
log = log.replace(pattern, ->
'<div class=\'fold ' + name + '\'>' + arguments[1].trim() + '</div>'
)
log
unfold: (log) ->

File diff suppressed because one or more lines are too long