Browse files

ui for picking a sort. closes #140.

  • Loading branch information...
1 parent dc337ac commit 24c3d25f28c7f907cb02d5a063351fc0ce49a7a6 Visnu Pitiyanuvath committed Aug 31, 2011
Showing with 34 additions and 11 deletions.
  1. +1 −1 controllers/teams.coffee
  2. +9 −1 helpers/index.coffee
  3. +14 −1 public/stylesheets/application.styl
  4. +8 −5 views/teams/entries.jade
  5. +2 −3 views/teams/index.jade
View
2 controllers/teams.coffee
@@ -36,7 +36,7 @@ app.get /^\/teams(\/pending)?\/?$/, (req, res, next) ->
# also services / possibly
app.get /^\/(entries)?\/?$/, (req, res, next) ->
page = (req.param('page') or 1) - 1
- sort = if _.include(Vote.dimensions, req.param('sort')) then req.param('sort') else 'overall'
+ sort = if _.include(Vote.dimensions.concat('popularity'), req.param('sort')) then req.param('sort') else 'overall'
query = { 'entry.votable': true, lastDeploy: {$ne: null} }
query.search = new RegExp(req.param('q'), 'i') if req.param('q')
query.peopleIds = ($size: 1) if req.param('sort') == 'solo'
View
10 helpers/index.coffee
@@ -1,4 +1,5 @@
_ = require 'underscore'
+qs = require 'querystring'
md = require 'discount'
mongoose = require 'mongoose'
@@ -7,7 +8,7 @@ module.exports = (app) ->
app.helpers
inspect: require('util').inspect
- qs: require('querystring')
+ qs: qs
_: _
markdown: (str) -> if str? then md.parse str, md.flags.noHTML else ''
@@ -79,3 +80,10 @@ module.exports = (app) ->
(thing) ->
if u = req.user
u.admin or (u.id is thing.id)
+
+ urlFor: (req, res) ->
+ (options) ->
+ q = _.clone req.query
+ delete q._pjax
+ _.extend q, options
+ req.url.split('?')[0] + '?' + qs.stringify(q)
View
15 public/stylesheets/application.styl
@@ -870,21 +870,34 @@ form.vote
margin-left 1em
span.all
margin-left 1em
+ ul.sorts
+ font-size small
+ li
+ display inline
+ margin-right 1ex
+ &.current
+ inverted()
+ padding 2px 5px
+ a
+ color white
ul.teams
overflow hidden
+ margin 0
> li
box-shadow inset 0 0 5px hsla(0, 0%, 0%, 0.1)
background-color hsl(0, 0%, 95%)
background-color hsla(0, 0%, 95%, 0.5)
padding 10px
border-radius 2px
- margin 1em 0
+ margin-bottom 1em
padding 20px
position relative
h2, h3, h4, .description
margin-left 174px
h2, h3, h4
margin-top 0px
+ h2
+ margin-right 100px
img.screenshot
width 160px
height 93px
View
13 views/teams/entries.jade
@@ -4,8 +4,12 @@ h1 Entries (#{teams.count})
form.search
input( type: 'search', name: 'q', value: req.query.q, placeholder: 'Search' )
-span.all See
- a( href: '/teams' ) all teams
+ul.sorts
+ li Order by:
+ - each k in [ 'Overall', 'Solo', 'Popularity', 'Utility / Fun', 'Design', 'Innovation', 'Completeness' ]
+ - s = k.split(' ')[0].toLowerCase()
+ li( class: (req.query.sort || 'overall') === s ? 'current' : '' )
+ a( href: urlFor({ sort: s }) )= k
- if (req.user && req.user.contestant)
p Don't see your team?
@@ -29,6 +33,5 @@ ul.teams
h3= team.scores[sort].toFixed(2)
.dimension= sort
.clear
- - q = req.query
- - q.page = (+req.query.page || 1) + 1
- .more: a( href: req.url.split('?')[0] + '?' + qs.stringify(q) ) more
+ - nextPage = (+req.query.page || 1) + 1
+ .more: a( href: urlFor({ page: nextPage }) ) more
View
5 views/teams/index.jade
@@ -22,6 +22,5 @@ ul.teams
li: a( href: '/people/' + m )= m.login
.location= locations(members)
.description!= markdown(team.description)
- - q = req.query
- - q.page = (+req.query.page || 1) + 1
- .more: a( href: req.url.split('?')[0] + '?' + qs.stringify(q) ) more
+ - nextPage = (+req.query.page || 1) + 1
+ .more: a( href: urlFor({ page: nextPage }) ) more

0 comments on commit 24c3d25

Please sign in to comment.