From dfdc3926903fcb3d6691ef1298160a15f623b60e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Josef=20=C5=A0im=C3=A1nek?=
Date: Mon, 12 May 2014 02:14:52 +0200
Subject: [PATCH 1/3] Trim status image modal.
Closes https://github.com/travis-ci/travis-ci/issues/1900
---
assets/scripts/app/helpers.coffee | 1 +
.../app/helpers/status_image_formatter.coffee | 50 +++++++++++++++++++
.../scripts/app/templates/status_images.hbs | 29 ++---------
assets/scripts/app/views/status_images.coffee | 46 +++++++----------
assets/styles/app/popup.sass | 4 +-
5 files changed, 73 insertions(+), 57 deletions(-)
create mode 100644 assets/scripts/app/helpers/status_image_formatter.coffee
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: (->
+ "[})](#{@url})"
+ )
+
+ textileStatusImage: (->
+ "!#{@statusImageUrl()}!:#{@url}"
+ )
+
+ rdocStatusImage: (->
+ "{
}[#{@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: (->
- "[})](#{@get('urlRepo')})"
- ).property('statusImageUrl')
-
- textileStatusImage: (->
- "!#{@get('statusImageUrl')}!:#{@get('urlRepo')}"
- ).property('statusImageUrl')
-
- rdocStatusImage: (->
- "{
}[#{@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)
From cf82a50268ad8f1ce0cfb4f93ee1fd6f200f403e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Josef=20=C5=A0im=C3=A1nek?=
Date: Mon, 12 May 2014 02:27:51 +0200
Subject: [PATCH 2/3] Add cc.xml status url.
---
assets/scripts/app/helpers/status_image_formatter.coffee | 5 +++++
assets/scripts/app/views/status_images.coffee | 3 ++-
2 files changed, 7 insertions(+), 1 deletion(-)
diff --git a/assets/scripts/app/helpers/status_image_formatter.coffee b/assets/scripts/app/helpers/status_image_formatter.coffee
index b346a5c3..376a1f01 100644
--- a/assets/scripts/app/helpers/status_image_formatter.coffee
+++ b/assets/scripts/app/helpers/status_image_formatter.coffee
@@ -16,6 +16,7 @@
when 'AsciiDoc' then @asciidocStatusImage()
when 'Rst' then @rstStatusImage()
when 'POD' then @podStatusImage()
+ when 'cc.xml' then @ccxmlStatusUrl()
urlRepo: (->
"https://#{location.host}/#{@slug}"
@@ -48,3 +49,7 @@
podStatusImage: (->
"=for HTML
"
)
+
+ ccxmlStatusUrl: (->
+ "#{Travis.config.api_endpoint}/repos/#{@slug}/cc.xml"
+ )
diff --git a/assets/scripts/app/views/status_images.coffee b/assets/scripts/app/views/status_images.coffee
index 2b3b75a6..cf574cb5 100644
--- a/assets/scripts/app/views/status_images.coffee
+++ b/assets/scripts/app/views/status_images.coffee
@@ -16,7 +16,8 @@ Travis.StatusImagesView = Em.View.extend
'RDOC',
'AsciiDoc',
'Rst',
- 'POD'
+ 'POD',
+ 'cc.xml'
]
didInsertElement: ->
From 75d58816ca66efbc8e72f4b04c1615c97cad9581 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Josef=20=C5=A0im=C3=A1nek?=
Date: Mon, 12 May 2014 02:47:37 +0200
Subject: [PATCH 3/3] Use textarea instead of input for build status images and
links.
---
assets/scripts/app/templates/status_images.hbs | 2 +-
assets/scripts/app/views.coffee | 1 +
assets/scripts/app/views/status_image_input.coffee | 3 +++
assets/styles/app/popup.sass | 4 +++-
4 files changed, 8 insertions(+), 2 deletions(-)
create mode 100644 assets/scripts/app/views/status_image_input.coffee
diff --git a/assets/scripts/app/templates/status_images.hbs b/assets/scripts/app/templates/status_images.hbs
index 4cff16a6..2b103afe 100644
--- a/assets/scripts/app/templates/status_images.hbs
+++ b/assets/scripts/app/templates/status_images.hbs
@@ -10,5 +10,5 @@
-
+ {{view Travis.StatusImageInput valueBinding="view.statusString" class="url" rows=3}}
diff --git a/assets/scripts/app/views.coffee b/assets/scripts/app/views.coffee
index 4fa13d04..bc04546c 100644
--- a/assets/scripts/app/views.coffee
+++ b/assets/scripts/app/views.coffee
@@ -60,3 +60,4 @@ require 'views/stats'
require 'views/signin'
require 'views/top'
require 'views/status_images'
+require 'views/status_image_input'
diff --git a/assets/scripts/app/views/status_image_input.coffee b/assets/scripts/app/views/status_image_input.coffee
new file mode 100644
index 00000000..dd8c4530
--- /dev/null
+++ b/assets/scripts/app/views/status_image_input.coffee
@@ -0,0 +1,3 @@
+Travis.StatusImageInput = Em.TextArea.extend
+ click: ->
+ @get('element').select()
diff --git a/assets/styles/app/popup.sass b/assets/styles/app/popup.sass
index 14d944d3..5a683036 100644
--- a/assets/styles/app/popup.sass
+++ b/assets/styles/app/popup.sass
@@ -51,10 +51,12 @@
label
width: 100px
display: inline-block
- input
+ vertical-align: top
+ textarea
border: 1px solid $color-border-light
width: 485px
padding: 4px
+ resize: vertical
@include border-radius(3px)
#regenerate-key