diff --git a/assets/scripts/app/helpers.coffee b/assets/scripts/app/helpers.coffee index bcbd98c1..98608e18 100644 --- a/assets/scripts/app/helpers.coffee +++ b/assets/scripts/app/helpers.coffee @@ -1,3 +1,4 @@ require 'helpers/handlebars' require 'helpers/helpers' require 'helpers/urls' +require 'helpers/status_image_formatter' diff --git a/assets/scripts/app/helpers/status_image_formatter.coffee b/assets/scripts/app/helpers/status_image_formatter.coffee new file mode 100644 index 00000000..b346a5c3 --- /dev/null +++ b/assets/scripts/app/helpers/status_image_formatter.coffee @@ -0,0 +1,50 @@ +@Travis.StatusImageFormatter = + slug: null + url: null + branch: null + + format: (version, slug, branch) -> + @slug = slug + @branch = branch + @url = @urlRepo() + + switch version + when 'Image URL' then @statusImageUrl() + when 'Markdown' then @markdownStatusImage() + when 'Textile' then @textileStatusImage() + when 'RDOC' then @rdocStatusImage() + when 'AsciiDoc' then @asciidocStatusImage() + when 'Rst' then @rstStatusImage() + when 'POD' then @podStatusImage() + + urlRepo: (-> + "https://#{location.host}/#{@slug}" + ) + + statusImageUrl: (-> + Travis.Urls.statusImage(@slug, @branch) + ) + + markdownStatusImage: (-> + "[![Build Status](#{@statusImageUrl()})](#{@url})" + ) + + textileStatusImage: (-> + "!#{@statusImageUrl()}!:#{@url}" + ) + + rdocStatusImage: (-> + "{\"Build}[#{@url}]" + ) + + asciidocStatusImage: (-> + "image:#{@statusImageUrl()}[\"Build Status\", link=\"#{@url}\"]" + ) + + rstStatusImage: (-> + ".. image:: #{@statusImageUrl()}\n :target: #{@url}" + ) + + podStatusImage: (-> + "=for HTML " + ) diff --git a/assets/scripts/app/templates/status_images.hbs b/assets/scripts/app/templates/status_images.hbs index 1b314730..4cff16a6 100644 --- a/assets/scripts/app/templates/status_images.hbs +++ b/assets/scripts/app/templates/status_images.hbs @@ -7,31 +7,8 @@ {{/if}}

+

- - -

-

- - -

-

- - -

-

- - -

-

- - -

-

- - -

-

- - + +

diff --git a/assets/scripts/app/views/status_images.coffee b/assets/scripts/app/views/status_images.coffee index a9a9ea88..2b3b75a6 100644 --- a/assets/scripts/app/views/status_images.coffee +++ b/assets/scripts/app/views/status_images.coffee @@ -9,10 +9,21 @@ Travis.StatusImagesView = Em.View.extend jobBinding: 'toolsView.job' branchesBinding: 'repo.branches' + formats: [ + 'Image URL', + 'Markdown', + 'Textile', + 'RDOC', + 'AsciiDoc', + 'Rst', + 'POD' + ] + didInsertElement: -> @_super.apply(this, arguments) @setStatusImageBranch() + @setStatusImageFormat() @show() show: -> @@ -21,9 +32,9 @@ Travis.StatusImagesView = Em.View.extend close: -> @destroy() - urlRepo: (-> - "https://#{location.host}/#{@get('repo.slug')}" - ).property('repo.slug') + setStatusImageFormat: (-> + @set('statusImageFormat', @formats[0]) + ) setStatusImageBranch: (-> if @get('repo.branches.isLoaded') @@ -32,30 +43,7 @@ Travis.StatusImagesView = Em.View.extend @set('statusImageBranch', null) ).observes('repo.branches', 'repo.branches.isLoaded', 'build.commit.branch') - statusImageUrl: (-> - Travis.Urls.statusImage(@get('repo.slug'), @get('statusImageBranch.commit.branch')) - ).property('repo.slug', 'statusImageBranch') + statusString: (-> + Travis.StatusImageFormatter.format(@get('statusImageFormat'), @get('repo.slug'), @get('statusImageBranch.commit.branch')) + ).property('statusImageFormat', 'repo.slug', 'statusImageBranch.commit.branch') - markdownStatusImage: (-> - "[![Build Status](#{@get('statusImageUrl')})](#{@get('urlRepo')})" - ).property('statusImageUrl') - - textileStatusImage: (-> - "!#{@get('statusImageUrl')}!:#{@get('urlRepo')}" - ).property('statusImageUrl') - - rdocStatusImage: (-> - "{\"Build}[#{@get('urlRepo')}]" - ).property('statusImageUrl') - - asciidocStatusImage: (-> - "image:#{@get('statusImageUrl')}[\"Build Status\", link=\"#{@get('urlRepo')}\"]" - ).property('statusImageUrl') - - rstStatusImage: (-> - ".. image:: #{@get('statusImageUrl')} :target: #{@get('urlRepo')}" - ).property('statusImageUrl') - - podStatusImage: (-> - "=for HTML " - ).property('statusImageUrl') diff --git a/assets/styles/app/popup.sass b/assets/styles/app/popup.sass index c7308790..14d944d3 100644 --- a/assets/styles/app/popup.sass +++ b/assets/styles/app/popup.sass @@ -49,11 +49,11 @@ p margin: 10px 0 label - width: 80px + width: 100px display: inline-block input border: 1px solid $color-border-light - width: 505px + width: 485px padding: 4px @include border-radius(3px)