travis-web/app/utils/urls.coffee
Piotr Sarnacki 0578af0c4c Don't set default avatar url on ENV
Fingerprinting filter that Brocolli uses to add checksums to filenames
apparently is very greedy. When a URL that has a valid image is present
in ENV, fingerprint filter will going to wipe out the entire config's
meta tag value with fingerprinted url with an asset host.
2015-02-16 15:14:10 +01:00

46 lines
1.6 KiB
CoffeeScript

`import config from 'travis/config/environment'`
plainTextLog = (id) ->
"#{config.apiEndpoint}/jobs/#{id}/log.txt?deansi=true"
githubPullRequest = (slug, pullRequestNumber) ->
"#{config.sourceEndpoint}/#{slug}/pull/#{pullRequestNumber}"
githubCommit = (slug, sha) ->
"#{config.sourceEndpoint}/#{slug}/commit/#{sha}"
githubRepo = (slug) ->
"#{config.sourceEndpoint}/#{slug}"
githubWatchers = (slug) ->
"#{config.sourceEndpoint}/#{slug}/watchers"
githubNetwork = (slug) ->
"#{config.sourceEndpoint}/#{slug}/network"
githubAdmin = (slug) ->
"#{config.sourceEndpoint}/#{slug}/settings/hooks#travis_minibucket"
statusImage = (slug, branch) ->
if config.pro
token = Travis.__container__.lookup('controller:currentUser').get('token')
"#{location.protocol}//#{location.host}/#{slug}.svg?token=#{token}" + if branch then "&branch=#{branch}" else ''
else
"#{location.protocol}//#{location.host}/#{slug}.svg" + if branch then "?branch=#{encodeURIComponent(branch)}" else ''
ccXml = (slug) ->
if config.pro
token = Travis.__container__.lookup('controller:currentUser').get('token')
"##{config.apiEndpoint}/repos/#{slug}/cc.xml?token=#{token}"
else
"#{config.apiEndpoint}/repos/#{slug}/cc.xml"
email = (email) ->
"mailto:#{email}"
gravatarImage = (email, size) ->
avatarDefaultUrl = 'https://travis-ci.org/images/ui/default-avatar.png'
"https://www.gravatar.com/avatar/#{md5(email)}?s=#{size}&d=#{encodeURIComponent(avatarDefaultUrl)}"
`export { plainTextLog, githubPullRequest, githubCommit, githubRepo, githubWatchers, githubNetwork, githubAdmin, statusImage, ccXml, email, gravatarImage }`