changes for pro

This commit is contained in:
Sven Fuchs 2012-11-15 16:31:54 +01:00
parent 81c0549d1d
commit 216724af64
9 changed files with 56 additions and 38 deletions

View File

@ -48,7 +48,7 @@
user = @storeUser(data.user) if data?.user
@set('state', if user then 'signed-in' else 'signed-out')
@set('user', if user then user else undefined)
@afterSignIn()
@afterSignIn(user) if data
afterSignIn: ->
@get('app.router').send('afterSignIn', @readAfterSignInPath())

View File

@ -6,7 +6,6 @@ Travis.ReposController = Ember.ArrayController.extend
isLoadedBinding: 'content.isLoaded'
init: ->
@activate(@defaultTab)
Ember.run.later(@updateTimes.bind(this), Travis.INTERVALS.updateTimes)
updateTimes: ->
@ -16,6 +15,7 @@ Travis.ReposController = Ember.ArrayController.extend
Ember.run.later(@updateTimes.bind(this), Travis.INTERVALS.updateTimes)
activate: (tab, params) ->
tab ||= @defaultTab
@set('tab', tab)
this["view#{$.camelize(tab)}"](params)

View File

@ -1,29 +1,35 @@
Travis.Pusher = (key) ->
@init(key) if key
@init(key) # if key
this
$.extend Travis.Pusher,
CHANNELS: ['common']
CHANNEL_PREFIX: ''
ENCRYPTED: false
$.extend Travis.Pusher.prototype,
active_channels: []
init: (key) ->
Pusher.warn = @warn.bind(this)
@pusher = new Pusher(key)
@subscribe(channel) for channel in Travis.Pusher.CHANNELS
@pusher = new Pusher(key, encrypted: Travis.Pusher.ENCRYPTED)
@subscribeAll(Travis.Pusher.CHANNELS) if Travis.Pusher.CHANNELS
subscribeAll: (channels) ->
for channel in channels
name = @prefix(channel)
unless @pusher.channels.find(name)
channel = @pusher.channels.add(name, this)
channel.bind_all((event, data) => @receive(event, data))
@pusher.subscribeAll()
subscribe: (channel) ->
if @pusher && @active_channels.indexOf(channel) == -1
@active_channels.push(channel)
@pusher.subscribe(@prefix(channel)).bind_all((event, data) => @receive(event, data))
channel = @prefix(channel)
@pusher.subscribe(channel).bind_all((event, data) => @receive(event, data)) unless @pusher?.channel(channel)
unsubscribe: (channel) ->
ix = @active_channels.indexOf(channel)
if @pusher && ix == -1
@active_channels.splice(ix, 1)
@pusher.unsubscribe(@prefix(channel))
channel = @prefix(channel)
@pusher.unsubscribe(channel) if @pusher?.channel(channel)
prefix: (channel) ->
"#{Travis.Pusher.CHANNEL_PREFIX}#{channel}"

View File

@ -163,14 +163,15 @@ Travis.Router = Ember.Router.extend
home: Ember.Route.extend
route: '/'
connectOutlets: (router) ->
router.get('applicationView').connectLayout 'home'
$('body').attr('id', 'home')
router.get('applicationController').connectOutlet 'left', 'repos'
router.get('applicationController').connectOutlet 'right', 'sidebar'
router.get('applicationController').connectOutlet 'top', 'top'
router.get('applicationController').connectOutlet 'main', 'repo'
router.get('applicationController').connectOutlet 'flash', 'flash'
router.get('repoController').set('repos', router.get('reposController'))
router.get('applicationView').connectLayout 'home'
$('body').attr('id', 'home')
router.get('applicationController').connectOutlet 'left', 'repos'
router.get('applicationController').connectOutlet 'right', 'sidebar'
router.get('applicationController').connectOutlet 'top', 'top'
router.get('applicationController').connectOutlet 'main', 'repo'
router.get('applicationController').connectOutlet 'flash', 'flash'
router.get('reposController').activate()
router.get('repoController').set('repos', router.get('reposController'))
show: Ember.Route.extend
route: '/'

View File

@ -18,7 +18,7 @@
<li {{bindAttr class="view.classProfile"}}>
<p class="handle">
<a class="signed-out" href="#" {{action signIn target="Travis.app"}}>{{t layouts.top.github_login}}</a>
<a class="signed-in" {{action showProfile href=true}}><img {{bindAttr src="view.gravatarUrl"}}>{{user.name}}</a>
<a class="signed-in" {{action showProfile href=true}}><img {{bindAttr src="view.gravatarUrl"}}>{{view.userName}}</a>
<span class="signing-in">Signing in</span>
</p>
<ul>

View File

@ -10,22 +10,7 @@
<p class="description">{{description}}</p>
<ul class="github-stats">
<li class="language">
{{lastBuildLanguage}}
</li>
<li>
<a class="watchers" title="Watchers" {{bindAttr href="view.urlGithubWatchers"}}>
{{stats.watchers}}
</a>
</li>
<li>
<a class="forks" title="Forks" {{bindAttr href="view.urlGithubNetwork"}}>
{{stats.forks}}
</a>
</li>
</ul>
{{view Travis.RepoShowStatsView}}
{{view Travis.RepoShowTabsView}}
{{view Travis.RepoShowToolsView}}
{{/with}}

View File

@ -0,0 +1,17 @@
<ul class="github-stats">
<!-- <li class="language">
{{lastBuildLanguage}}
</li> -->
<li>
<a class="watchers" title="Watchers" {{bindAttr href="view.urlGithubWatchers"}}>
{{view.stats.watchers}}
</a>
</li>
<li>
<a class="forks" title="Forks" {{bindAttr href="view.urlGithubNetwork"}}>
{{view.stats.forks}}
</a>
</li>
</ul>

View File

@ -11,12 +11,17 @@
isEmpty: (->
@get('repos.isLoaded') && @get('repos.length') == 0
).property('repos.length')
).property('repos.isLoaded', 'repos.length')
urlGithub: (->
Travis.Urls.githubRepo(@get('repo.slug'))
).property('repo.slug'),
RepoShowStatsView: Travis.View.extend
templateName: 'repos/show/stats'
repoBinding: 'parentView.repo'
statsBinding: 'repo.stats'
urlGithubWatchers: (->
Travis.Urls.githubWatchers(@get('repo.slug'))
).property('repo.slug'),

View File

@ -5,6 +5,10 @@
tabBinding: 'controller.tab'
userBinding: 'controller.user'
userName: (->
@get('user.name') || @get('user.login')
).property('user.login', 'user.name')
gravatarUrl: (->
"#{location.protocol}//www.gravatar.com/avatar/#{@get('user.gravatarId')}?s=24&d=mm"
).property('user.gravatarId')