Extract handlebars helpers to individual files
This commit is contained in:
parent
a5978dd36f
commit
26c5111294
|
@ -3,3 +3,48 @@ require 'helpers/helpers'
|
||||||
require 'helpers/urls'
|
require 'helpers/urls'
|
||||||
require 'helpers/status_image_formats'
|
require 'helpers/status_image_formats'
|
||||||
require 'helpers/github_url_properties'
|
require 'helpers/github_url_properties'
|
||||||
|
|
||||||
|
Travis.Handlebars = {}
|
||||||
|
|
||||||
|
require 'helpers/label'
|
||||||
|
require 'helpers/input'
|
||||||
|
require 'helpers/tipsy'
|
||||||
|
require 'helpers/capitalize'
|
||||||
|
require 'helpers/github_commit_link'
|
||||||
|
require 'helpers/format_time'
|
||||||
|
require 'helpers/format_duration'
|
||||||
|
require 'helpers/format_commit'
|
||||||
|
require 'helpers/format_sha'
|
||||||
|
require 'helpers/format_message'
|
||||||
|
require 'helpers/format_config'
|
||||||
|
require 'helpers/short_compare_shas'
|
||||||
|
require 'helpers/mb'
|
||||||
|
|
||||||
|
Ember.Handlebars.registerHelper('label', Travis.Handlebars.label)
|
||||||
|
Ember.Handlebars.registerHelper('input', Travis.Handlebars.input)
|
||||||
|
Ember.Handlebars.registerHelper('tipsy', Travis.Handlebars.tipsy)
|
||||||
|
Ember.Handlebars.registerHelper('travis-errors', Travis.Handlebars.travisErrors)
|
||||||
|
Ember.Handlebars.registerHelper('travis-field', Travis.Handlebars.travisField)
|
||||||
|
|
||||||
|
Ember.Handlebars.registerBoundHelper('capitalize', Travis.Handlebars.capitalize)
|
||||||
|
Ember.Handlebars.registerBoundHelper('githubCommitLink', Travis.Handlebars.githubCommitLink)
|
||||||
|
Ember.Handlebars.registerBoundHelper('formatTime', Travis.Handlebars.formatTime)
|
||||||
|
Ember.Handlebars.registerBoundHelper('formatDuration', Travis.Handlebars.formatDuration)
|
||||||
|
Ember.Handlebars.registerBoundHelper('formatCommit', Travis.Handlebars.formatCommit, 'sha', 'branch')
|
||||||
|
Ember.Handlebars.registerBoundHelper('formatSha', Travis.Handlebars.formatSha)
|
||||||
|
Ember.Handlebars.registerBoundHelper('formatMessage', Travis.Handlebars.formatMessage)
|
||||||
|
Ember.Handlebars.registerBoundHelper('formatConfig', Travis.Handlebars.formatConfig)
|
||||||
|
Ember.Handlebars.registerBoundHelper('shortCompareShas', Travis.Handlebars.shortCompareShas)
|
||||||
|
Ember.Handlebars.registerBoundHelper('mb', Travis.Handlebars.mb)
|
||||||
|
|
||||||
|
Ember.LinkView.reopen
|
||||||
|
init: ->
|
||||||
|
@_super()
|
||||||
|
eventName = Ember.get(this, 'eventName')
|
||||||
|
if Ember.get(this, 'trackEvent')
|
||||||
|
@on(eventName, this, @_trackEvent)
|
||||||
|
@on(eventName, this, @_invoke)
|
||||||
|
|
||||||
|
_trackEvent: (event) ->
|
||||||
|
event.preventDefault()
|
||||||
|
|
||||||
|
|
9
assets/scripts/app/helpers/capitalize.coffee
Normal file
9
assets/scripts/app/helpers/capitalize.coffee
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
safe = Travis.Helpers.safe
|
||||||
|
|
||||||
|
capitalize = (value, options) ->
|
||||||
|
if value?
|
||||||
|
safe $.capitalize(value)
|
||||||
|
else
|
||||||
|
''
|
||||||
|
|
||||||
|
Travis.Handlebars.capitalize = capitalize
|
7
assets/scripts/app/helpers/format_commit.coffee
Normal file
7
assets/scripts/app/helpers/format_commit.coffee
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
safe = Travis.Helpers.safe
|
||||||
|
formatCommitHelper = Travis.Helpers.formatCommit
|
||||||
|
|
||||||
|
formatCommit = (commit) ->
|
||||||
|
safe formatCommitHelper(commit.get('sha'), commit.get('branch')) if commit
|
||||||
|
|
||||||
|
Travis.Handlebars.formatCommit = formatCommit
|
8
assets/scripts/app/helpers/format_config.coffee
Normal file
8
assets/scripts/app/helpers/format_config.coffee
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
formatConfigHelper = Travis.Helpers.formatConfig
|
||||||
|
safe = Travis.Helpers.safe
|
||||||
|
|
||||||
|
formatConfig = (config, options) ->
|
||||||
|
safe formatConfigHelper(config)
|
||||||
|
|
||||||
|
Travis.Handlebars.formatConfig = formatConfig
|
||||||
|
|
7
assets/scripts/app/helpers/format_duration.coffee
Normal file
7
assets/scripts/app/helpers/format_duration.coffee
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
timeInWords = Travis.Helpers.timeInWords
|
||||||
|
safe = Travis.Helpers.safe
|
||||||
|
|
||||||
|
formatDuration = (duration, options) ->
|
||||||
|
safe timeInWords(duration)
|
||||||
|
|
||||||
|
Travis.Handlebars.formatDuration = formatDuration
|
7
assets/scripts/app/helpers/format_message.coffee
Normal file
7
assets/scripts/app/helpers/format_message.coffee
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
formatMessageHelper = Travis.Helpers.formatMessageHelper
|
||||||
|
safe = Travis.Helpers.safe
|
||||||
|
|
||||||
|
formatMessage = (message, options) ->
|
||||||
|
safe formatMessageHelper(message, options.hash)
|
||||||
|
|
||||||
|
Travis.Handlebars.formatMessage = formatMessage
|
7
assets/scripts/app/helpers/format_sha.coffee
Normal file
7
assets/scripts/app/helpers/format_sha.coffee
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
formatShaHelper = Travis.Helpers.formatSha
|
||||||
|
safe = Travis.Helpers.safe
|
||||||
|
|
||||||
|
formatSha = (sha) ->
|
||||||
|
safe formatShaHelper(sha)
|
||||||
|
|
||||||
|
Travis.Handlebars.formatSha = formatSha
|
7
assets/scripts/app/helpers/format_time.coffee
Normal file
7
assets/scripts/app/helpers/format_time.coffee
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
timeAgoInWords = Travis.Helpers.timeAgoInWords
|
||||||
|
safe = Travis.Helpers.safe
|
||||||
|
|
||||||
|
formatTime = (value, options) ->
|
||||||
|
safe timeAgoInWords(value) || '-'
|
||||||
|
|
||||||
|
Travis.Handlebars.formatTime = formatTime
|
13
assets/scripts/app/helpers/github_commit_link.coffee
Normal file
13
assets/scripts/app/helpers/github_commit_link.coffee
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
formatConfig = Travis.Helpers.formatConfig
|
||||||
|
githubCommitUrl = Travis.Urls.githubCommit
|
||||||
|
safe = Travis.Helpers.safe
|
||||||
|
|
||||||
|
githubCommitLink = (slug, commitSha) ->
|
||||||
|
return '' unless commitSha
|
||||||
|
sha = Handlebars.Utils.escapeExpression formatCommit(commitSha)
|
||||||
|
return sha unless slug
|
||||||
|
url = Handlebars.Utils.escapeExpression githubCommitUrl(slug, sha)
|
||||||
|
|
||||||
|
safe '<a class="github-link only-on-hover" href="' + url + '">' + sha + '</a>'
|
||||||
|
|
||||||
|
Travis.Handlebars.githubCommitLink = githubCommitLink
|
|
@ -1,178 +1 @@
|
||||||
safe = (string) ->
|
|
||||||
new Handlebars.SafeString(string)
|
|
||||||
|
|
||||||
Ember.Handlebars.helper('mb', (size) ->
|
|
||||||
if size
|
|
||||||
(size / 1024 / 1024).toFixed(2)
|
|
||||||
, 'size')
|
|
||||||
|
|
||||||
Ember.LinkView.reopen
|
|
||||||
init: ->
|
|
||||||
@_super()
|
|
||||||
eventName = Ember.get(this, 'eventName')
|
|
||||||
if Ember.get(this, 'trackEvent')
|
|
||||||
@on(eventName, this, @_trackEvent)
|
|
||||||
@on(eventName, this, @_invoke)
|
|
||||||
|
|
||||||
_trackEvent: (event) ->
|
|
||||||
event.preventDefault()
|
|
||||||
|
|
||||||
FormFieldRowView = Ember.View.extend
|
|
||||||
invalid: Ember.computed.notEmpty('errors.[]')
|
|
||||||
classNameBindings: ['invalid']
|
|
||||||
classNames: 'field'
|
|
||||||
|
|
||||||
LabelView = Ember.View.extend(
|
|
||||||
tagName: 'label'
|
|
||||||
|
|
||||||
attributeBindings: ['for', 'accesskey', 'form']
|
|
||||||
classNameBindings: ['class']
|
|
||||||
)
|
|
||||||
|
|
||||||
Ember.Handlebars.registerHelper('label', (options) ->
|
|
||||||
view = LabelView
|
|
||||||
|
|
||||||
name = options.hash.for
|
|
||||||
if name
|
|
||||||
labels = @get('_labels')
|
|
||||||
unless labels
|
|
||||||
labels = Ember.Object.create()
|
|
||||||
@set('_labels', labels)
|
|
||||||
|
|
||||||
# for now I support only label + input in their own context
|
|
||||||
id = labels.get(name)
|
|
||||||
unless id
|
|
||||||
id = "#{name}-#{Math.round(Math.random() * 1000000)}"
|
|
||||||
labels.set(name, id)
|
|
||||||
|
|
||||||
options.hash.for = id
|
|
||||||
options.hashTypes.for = 'STRING'
|
|
||||||
options.hashContexts.for = this
|
|
||||||
if options.hash.content
|
|
||||||
options.fn = Ember.Handlebars.compile("{{view.content}}")
|
|
||||||
|
|
||||||
Ember.Handlebars.helpers.view.call(this, view, options)
|
|
||||||
)
|
|
||||||
|
|
||||||
originalInputHelper = Ember.Handlebars.helpers.input
|
|
||||||
|
|
||||||
Ember.Handlebars.registerHelper('input', (options) ->
|
|
||||||
# for now I can match label only with the property name
|
|
||||||
# passed here matches the label
|
|
||||||
name = (options.hash.value || options.hash.checked)
|
|
||||||
id = options.hash.id
|
|
||||||
|
|
||||||
# generate id only if it's not given
|
|
||||||
if name && !name.match(/\./) && !id
|
|
||||||
labels = @get('_labels')
|
|
||||||
unless labels
|
|
||||||
labels = Ember.Object.create()
|
|
||||||
@set('_labels', labels)
|
|
||||||
|
|
||||||
# for now I support only label + input in their own context
|
|
||||||
id = labels.get(name)
|
|
||||||
unless id
|
|
||||||
id = "#{name}-#{Math.round(Math.random() * 1000000)}"
|
|
||||||
labels.set(name, id)
|
|
||||||
|
|
||||||
options.hash.id = id
|
|
||||||
options.hashTypes.id = 'STRING'
|
|
||||||
options.hashContexts.id = this
|
|
||||||
|
|
||||||
originalInputHelper.call(this, options)
|
|
||||||
)
|
|
||||||
|
|
||||||
Ember.Handlebars.registerHelper('travis-field', (name, options) ->
|
|
||||||
errors = @get('errors').for(name)
|
|
||||||
template = options.fn
|
|
||||||
delete options.fn
|
|
||||||
|
|
||||||
view = FormFieldRowView.create(
|
|
||||||
controller: this
|
|
||||||
template: template
|
|
||||||
errors: errors
|
|
||||||
name: name
|
|
||||||
classNameBindings: ['name']
|
|
||||||
)
|
|
||||||
|
|
||||||
Ember.Handlebars.helpers.view.call(this, view, options)
|
|
||||||
)
|
|
||||||
|
|
||||||
Travis.ErrorsView = Ember.View.extend
|
|
||||||
tagName: 'span'
|
|
||||||
template: Ember.Handlebars.compile("{{#each view.errors}}{{message}}{{/each}}")
|
|
||||||
classNames: ['error']
|
|
||||||
classNameBindings: ['codes']
|
|
||||||
attributeBindings: ['style']
|
|
||||||
style: (->
|
|
||||||
'display: none' unless @get('show')
|
|
||||||
).property('show')
|
|
||||||
codes: (->
|
|
||||||
@get('errors').mapBy('code')
|
|
||||||
).property('@errors')
|
|
||||||
show: Ember.computed.notEmpty('errors.[]')
|
|
||||||
|
|
||||||
Ember.Handlebars.registerHelper('travis-errors', (name, options) ->
|
|
||||||
errors = @get('errors').for(name)
|
|
||||||
view = Travis.ErrorsView.create(
|
|
||||||
controller: this
|
|
||||||
errors: errors
|
|
||||||
)
|
|
||||||
|
|
||||||
Ember.Handlebars.helpers.view.call(this, view, options)
|
|
||||||
)
|
|
||||||
|
|
||||||
Handlebars.registerHelper 'tipsy', (text, tip) ->
|
|
||||||
safe '<span class="tool-tip" original-title="' + tip + '">' + text + '</span>'
|
|
||||||
|
|
||||||
Ember.Handlebars.registerBoundHelper 'capitalize', (value, options) ->
|
|
||||||
if value?
|
|
||||||
safe $.capitalize(value)
|
|
||||||
else
|
|
||||||
''
|
|
||||||
|
|
||||||
Ember.Handlebars.helper('githubCommitLink', (slug, commitSha) ->
|
|
||||||
return '' unless commitSha
|
|
||||||
sha = Handlebars.Utils.escapeExpression Travis.Helpers.formatCommit(commitSha)
|
|
||||||
return sha unless slug
|
|
||||||
url = Handlebars.Utils.escapeExpression Travis.Urls.githubCommit(slug, sha)
|
|
||||||
|
|
||||||
safe '<a class="github-link only-on-hover" href="' + url + '">' + sha + '</a>'
|
|
||||||
)
|
|
||||||
|
|
||||||
Ember.Handlebars.registerBoundHelper 'formatTime', (value, options) ->
|
|
||||||
safe Travis.Helpers.timeAgoInWords(value) || '-'
|
|
||||||
|
|
||||||
Ember.Handlebars.registerBoundHelper 'formatDuration', (duration, options) ->
|
|
||||||
safe Travis.Helpers.timeInWords(duration)
|
|
||||||
|
|
||||||
Ember.Handlebars.helper('formatCommit', (commit) ->
|
|
||||||
safe Travis.Helpers.formatCommit(commit.get('sha'), commit.get('branch')) if commit
|
|
||||||
, 'sha', 'branch')
|
|
||||||
|
|
||||||
Ember.Handlebars.helper 'formatSha', (sha) ->
|
|
||||||
safe Travis.Helpers.formatSha(sha)
|
|
||||||
|
|
||||||
Ember.Handlebars.registerBoundHelper 'pathFrom', (url, options) ->
|
|
||||||
safe Travis.Helpers.pathFrom(url)
|
|
||||||
|
|
||||||
Ember.Handlebars.helper 'formatMessage', (message, options) ->
|
|
||||||
safe Travis.Helpers.formatMessage(message, options.hash)
|
|
||||||
|
|
||||||
Ember.Handlebars.registerBoundHelper 'formatConfig', (config, options) ->
|
|
||||||
safe Travis.Helpers.formatConfig(config)
|
|
||||||
|
|
||||||
Ember.Handlebars.registerBoundHelper 'shortCompareShas', (url, options) ->
|
|
||||||
path = Travis.Helpers.pathFrom(url)
|
|
||||||
if path.indexOf('...') >= 0
|
|
||||||
shas = path.split('...')
|
|
||||||
"#{shas[0][0..6]}..#{shas[1][0..6]}"
|
|
||||||
else
|
|
||||||
path
|
|
||||||
|
|
||||||
Ember.Handlebars.registerBoundHelper 'formatLog', (log, options) ->
|
|
||||||
parentView = @get 'parentView'
|
|
||||||
repo = parentView.get(options.repo)
|
|
||||||
item = parentView.get(options.item)
|
|
||||||
Travis.Helpers.formatLog(log, repo, item) || ''
|
|
||||||
|
|
||||||
|
|
|
@ -53,9 +53,6 @@ formatMessage = (message, options) ->
|
||||||
message = message.replace /\n/g, '<br/>'
|
message = message.replace /\n/g, '<br/>'
|
||||||
message
|
message
|
||||||
|
|
||||||
pathFrom = (url) ->
|
|
||||||
(url || '').split('/').pop()
|
|
||||||
|
|
||||||
timeAgoInWords = (date) ->
|
timeAgoInWords = (date) ->
|
||||||
timeago.distanceInWords date
|
timeago.distanceInWords date
|
||||||
|
|
||||||
|
@ -140,13 +137,15 @@ configKeys = (config) ->
|
||||||
return [] unless config
|
return [] unless config
|
||||||
intersect(Object.keys(config), Object.keys(config_keys_map))
|
intersect(Object.keys(config), Object.keys(config_keys_map))
|
||||||
|
|
||||||
|
pathFrom = (url) ->
|
||||||
|
(url || '').split('/').pop()
|
||||||
|
|
||||||
Travis.Helpers =
|
Travis.Helpers =
|
||||||
configKeys: configKeys
|
configKeys: configKeys
|
||||||
githubify: githubify
|
githubify: githubify
|
||||||
timeInWords: timeInWords
|
timeInWords: timeInWords
|
||||||
durationFrom: durationFrom
|
durationFrom: durationFrom
|
||||||
timeAgoInWords: timeAgoInWords
|
timeAgoInWords: timeAgoInWords
|
||||||
pathFrom: pathFrom
|
|
||||||
formatMessage: formatMessage
|
formatMessage: formatMessage
|
||||||
formatConfig: formatConfig
|
formatConfig: formatConfig
|
||||||
formatSha: formatSha
|
formatSha: formatSha
|
||||||
|
@ -154,3 +153,4 @@ Travis.Helpers =
|
||||||
colorForState: colorForState
|
colorForState: colorForState
|
||||||
safe: safe
|
safe: safe
|
||||||
compact: compact
|
compact: compact
|
||||||
|
pathFrom: pathFrom
|
||||||
|
|
28
assets/scripts/app/helpers/input.coffee
Normal file
28
assets/scripts/app/helpers/input.coffee
Normal file
|
@ -0,0 +1,28 @@
|
||||||
|
originalInputHelper = Ember.Handlebars.helpers.input
|
||||||
|
|
||||||
|
input = (options) ->
|
||||||
|
# for now I can match label only with the property name
|
||||||
|
# passed here matches the label
|
||||||
|
name = (options.hash.value || options.hash.checked)
|
||||||
|
id = options.hash.id
|
||||||
|
|
||||||
|
# generate id only if it's not given
|
||||||
|
if name && !name.match(/\./) && !id
|
||||||
|
labels = @get('_labels')
|
||||||
|
unless labels
|
||||||
|
labels = Ember.Object.create()
|
||||||
|
@set('_labels', labels)
|
||||||
|
|
||||||
|
# for now I support only label + input in their own context
|
||||||
|
id = labels.get(name)
|
||||||
|
unless id
|
||||||
|
id = "#{name}-#{Math.round(Math.random() * 1000000)}"
|
||||||
|
labels.set(name, id)
|
||||||
|
|
||||||
|
options.hash.id = id
|
||||||
|
options.hashTypes.id = 'STRING'
|
||||||
|
options.hashContexts.id = this
|
||||||
|
|
||||||
|
originalInputHelper.call(this, options)
|
||||||
|
|
||||||
|
Travis.Handlebars.input = input
|
32
assets/scripts/app/helpers/label.coffee
Normal file
32
assets/scripts/app/helpers/label.coffee
Normal file
|
@ -0,0 +1,32 @@
|
||||||
|
LabelView = Ember.View.extend(
|
||||||
|
tagName: 'label'
|
||||||
|
|
||||||
|
attributeBindings: ['for', 'accesskey', 'form']
|
||||||
|
classNameBindings: ['class']
|
||||||
|
)
|
||||||
|
|
||||||
|
label = (options) ->
|
||||||
|
view = LabelView
|
||||||
|
|
||||||
|
name = options.hash.for
|
||||||
|
if name
|
||||||
|
labels = @get('_labels')
|
||||||
|
unless labels
|
||||||
|
labels = Ember.Object.create()
|
||||||
|
@set('_labels', labels)
|
||||||
|
|
||||||
|
# for now I support only label + input in their own context
|
||||||
|
id = labels.get(name)
|
||||||
|
unless id
|
||||||
|
id = "#{name}-#{Math.round(Math.random() * 1000000)}"
|
||||||
|
labels.set(name, id)
|
||||||
|
|
||||||
|
options.hash.for = id
|
||||||
|
options.hashTypes.for = 'STRING'
|
||||||
|
options.hashContexts.for = this
|
||||||
|
if options.hash.content
|
||||||
|
options.fn = Ember.Handlebars.compile("{{view.content}}")
|
||||||
|
|
||||||
|
Ember.Handlebars.helpers.view.call(this, view, options)
|
||||||
|
|
||||||
|
Travis.Handlebars.label = label
|
5
assets/scripts/app/helpers/mb.coffee
Normal file
5
assets/scripts/app/helpers/mb.coffee
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
fn = (size) ->
|
||||||
|
if size
|
||||||
|
(size / 1024 / 1024).toFixed(2)
|
||||||
|
|
||||||
|
Travis.Handlebars.mb = fn
|
11
assets/scripts/app/helpers/short_compare_shas.coffee
Normal file
11
assets/scripts/app/helpers/short_compare_shas.coffee
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
pathFrom = Travis.Helpers.pathFrom
|
||||||
|
|
||||||
|
fn = (url, options) ->
|
||||||
|
path = pathFrom(url)
|
||||||
|
if path.indexOf('...') >= 0
|
||||||
|
shas = path.split('...')
|
||||||
|
"#{shas[0][0..6]}..#{shas[1][0..6]}"
|
||||||
|
else
|
||||||
|
path
|
||||||
|
|
||||||
|
Travis.Handlebars.shortCompareShas = fn
|
|
@ -1,41 +1,41 @@
|
||||||
require 'helper/urls'
|
require 'helpers/urls'
|
||||||
|
|
||||||
ccXmlUrl = Travis.Urls.ccXml
|
ccXmlUrl = Travis.Urls.ccXml
|
||||||
statusImageUrl = Travis.Urls.statusImage
|
statusImageUrl = Travis.Urls.statusImage
|
||||||
|
|
||||||
urlRepo: ( (slug) ->
|
urlRepo = ( (slug) ->
|
||||||
"https://#{location.host}/#{slug}"
|
"https://#{location.host}/#{slug}"
|
||||||
)
|
)
|
||||||
|
|
||||||
markdownStatusImage: ( (url, slug, branch) ->
|
markdownStatusImage = ( (url, slug, branch) ->
|
||||||
"[})](#{url})"
|
"[})](#{url})"
|
||||||
)
|
)
|
||||||
|
|
||||||
textileStatusImage: ( (url, slug, branch) ->
|
textileStatusImage = ( (url, slug, branch) ->
|
||||||
"!#{statusImageUrl(slug, branch)}!:#{url}"
|
"!#{statusImageUrl(slug, branch)}!:#{url}"
|
||||||
)
|
)
|
||||||
|
|
||||||
rdocStatusImage: ( (url, slug, branch) ->
|
rdocStatusImage = ( (url, slug, branch) ->
|
||||||
"{<img src=\"#{statusImageUrl(slug, branch)}\" alt=\"Build Status\" />}[#{url}]"
|
"{<img src=\"#{statusImageUrl(slug, branch)}\" alt=\"Build Status\" />}[#{url}]"
|
||||||
)
|
)
|
||||||
|
|
||||||
asciidocStatusImage: ( (url, slug, branch) ->
|
asciidocStatusImage = ( (url, slug, branch) ->
|
||||||
"image:#{statusImageUrl(slug, branch)}[\"Build Status\", link=\"#{url}\"]"
|
"image:#{statusImageUrl(slug, branch)}[\"Build Status\", link=\"#{url}\"]"
|
||||||
)
|
)
|
||||||
|
|
||||||
rstStatusImage: ( (url, slug, branch) ->
|
rstStatusImage = ( (url, slug, branch) ->
|
||||||
".. image:: #{statusImageUrl(slug, branch)}\n :target: #{url}"
|
".. image:: #{statusImageUrl(slug, branch)}\n :target: #{url}"
|
||||||
)
|
)
|
||||||
|
|
||||||
podStatusImage: ( (url, slug, branch) ->
|
podStatusImage = ( (url, slug, branch) ->
|
||||||
"=for HTML <a href=\"#{url}\"><img src=\"#{statusImageUrl(slug, branch)}\"></a>"
|
"=for HTML <a href=\"#{url}\"><img src=\"#{statusImageUrl(slug, branch)}\"></a>"
|
||||||
)
|
)
|
||||||
|
|
||||||
ccxmlStatusUrl: ( (slug) ->
|
ccxmlStatusUrl = ( (slug) ->
|
||||||
ccXmlUrl(slug)
|
ccXmlUrl(slug)
|
||||||
)
|
)
|
||||||
|
|
||||||
format: (version, slug, branch) ->
|
format = (version, slug, branch) ->
|
||||||
url = urlRepo(slug)
|
url = urlRepo(slug)
|
||||||
|
|
||||||
switch version
|
switch version
|
||||||
|
|
6
assets/scripts/app/helpers/tipsy.coffee
Normal file
6
assets/scripts/app/helpers/tipsy.coffee
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
safe = Travis.Helpers.safe
|
||||||
|
|
||||||
|
tipsy = (text, tip) ->
|
||||||
|
safe '<span class="tool-tip" original-title="' + tip + '">' + text + '</span>'
|
||||||
|
|
||||||
|
Travis.Handlebars.tipsy = tipsy
|
26
assets/scripts/app/helpers/travis-errors.coffee
Normal file
26
assets/scripts/app/helpers/travis-errors.coffee
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
notEmpty = Ember.computed.notEmpty
|
||||||
|
|
||||||
|
ErrorsView = Ember.View.extend
|
||||||
|
tagName: 'span'
|
||||||
|
template: Ember.Handlebars.compile("{{#each view.errors}}{{message}}{{/each}}")
|
||||||
|
classNames: ['error']
|
||||||
|
classNameBindings: ['codes']
|
||||||
|
attributeBindings: ['style']
|
||||||
|
style: (->
|
||||||
|
'display: none' unless @get('show')
|
||||||
|
).property('show')
|
||||||
|
codes: (->
|
||||||
|
@get('errors').mapBy('code')
|
||||||
|
).property('@errors')
|
||||||
|
show: notEmpty('errors.[]')
|
||||||
|
|
||||||
|
fn = (name, options) ->
|
||||||
|
errors = @get('errors').for(name)
|
||||||
|
view = ErrorsView.create(
|
||||||
|
controller: this
|
||||||
|
errors: errors
|
||||||
|
)
|
||||||
|
|
||||||
|
Ember.Handlebars.helpers.view.call(this, view, options)
|
||||||
|
|
||||||
|
Travis.Handlebars.travisErrors = fn
|
23
assets/scripts/app/helpers/travis-field.coffee
Normal file
23
assets/scripts/app/helpers/travis-field.coffee
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
notEmpty = Ember.computed.notEmpty
|
||||||
|
|
||||||
|
FormFieldRowView = Ember.View.extend
|
||||||
|
invalid: notEmpty('errors.[]')
|
||||||
|
classNameBindings: ['invalid']
|
||||||
|
classNames: 'field'
|
||||||
|
|
||||||
|
fn = (name, options) ->
|
||||||
|
errors = @get('errors').for(name)
|
||||||
|
template = options.fn
|
||||||
|
delete options.fn
|
||||||
|
|
||||||
|
view = FormFieldRowView.create(
|
||||||
|
controller: this
|
||||||
|
template: template
|
||||||
|
errors: errors
|
||||||
|
name: name
|
||||||
|
classNameBindings: ['name']
|
||||||
|
)
|
||||||
|
|
||||||
|
Ember.Handlebars.helpers.view.call(this, view, options)
|
||||||
|
|
||||||
|
Travis.Handlebars.travisField = fn
|
|
@ -61,7 +61,6 @@ require 'routes/getting_started'
|
||||||
require 'routes/insufficient_oauth_permissions'
|
require 'routes/insufficient_oauth_permissions'
|
||||||
require 'routes/job'
|
require 'routes/job'
|
||||||
require 'routes/main/index'
|
require 'routes/main/index'
|
||||||
require 'routes/main/error'
|
|
||||||
require 'routes/main/my_repositories'
|
require 'routes/main/my_repositories'
|
||||||
require 'routes/main/recent'
|
require 'routes/main/recent'
|
||||||
require 'routes/main/repositories'
|
require 'routes/main/repositories'
|
||||||
|
|
Loading…
Reference in New Issue
Block a user