Skip to content
This repository was archived by the owner on Apr 13, 2023. It is now read-only.

Commit d74c0c3

Browse files
committed
Added games index sorting
1 parent 4a371cc commit d74c0c3

File tree

7 files changed

+60
-48
lines changed

7 files changed

+60
-48
lines changed

app/public/css/main.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/routes/games/index.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,19 @@ var router = require('express').Router(),
22
Game = require('../../models/game'),
33
Pagination = require('../../helpers/pagination');
44

5-
router.get('/:local(page)?/:number([0-9]+)?', function(req, res)
5+
router.get('/:order(alphabetical|latest)?/:local(page)?/:number([0-9]+)?', function(req, res)
66
{
7+
var order = req.params.order || 'alphabetical';
78
Game.getAll().count(function(err, count)
89
{
9-
var nav = new Pagination('/games', count, req.params.number);
10+
var nav = new Pagination('/games/'+order, count, req.params.number);
1011
res.render('games/index',
1112
{
1213
pagination: nav.result,
14+
order: order,
1315
games: Game.getAll()
1416
.select('title slug thumbnail releases')
15-
.sort('title')
17+
.sort(order == 'alphabetical' ? 'title' : '-updated')
1618
.skip(nav.start || 0)
1719
.limit(nav.itemsPerPage)
1820
});

app/routes/users/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ router.get('/', function(req, res)
115115
{
116116
res.render('users/index',
117117
{
118-
users: User.getAll(req.user._id).select('name'),
118+
users: User.getAll(req.user._id).select('name username'),
119119
error: req.flash('error'),
120120
errors: req.flash('errors'),
121121
success: req.flash('success')

app/views/games/index.jade

Lines changed: 29 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -4,24 +4,32 @@ append title
44
| Edit Game -
55

66
append content
7-
.col-sm-12
8-
a.btn.btn-sm.btn-default.pull-right(href="/games/add")
9-
span.glyphicon.glyphicon-pencil
10-
| Add
11-
h3 Games
12-
if !games.length
13-
.alert.alert-warning.text-center No games have been added.
14-
|
15-
a.btn.btn-warning.btn-sm(href="/games/add") Add Game
16-
else
17-
.row
18-
for game in games
19-
.col-md-2.col-sm-3.col-xs-6
20-
a.game(data-toggle="tooltip" title=game.title href="/games/game/#{game.slug}")
21-
if game.thumbnail && game.thumbnail.length
22-
img.preview(src="data:image/png;base64,#{game.thumbnail}")
23-
else
24-
img.preview(src="/images/none.png")
25-
span.title=game.title
26-
span.badge=game.releases.length
27-
.row: include ../partials/pagination
7+
.col-sm-12: .panel.panel-default
8+
.panel-heading
9+
.pull-right
10+
| Sort by:
11+
.btn-group
12+
a.btn.btn-sm.btn-default(class=(order=='alphabetical' ? 'disabled' : '') href="/games/alphabetical") title
13+
a.btn.btn-sm.btn-default(class=(order=='latest' ? 'disabled' : '') href="/games/latest") updated
14+
|
15+
a.btn.btn-sm.btn-default(href="/games/add")
16+
span.glyphicon.glyphicon-pencil
17+
| Add
18+
h3.panel-title Games
19+
.panel-body
20+
if !games.length
21+
.alert.alert-warning.text-center No games have been added.
22+
|
23+
a.btn.btn-warning.btn-sm(href="/games/add") Add Game
24+
else
25+
.row
26+
for game in games
27+
.col-md-2.col-sm-3.col-xs-6
28+
a.game(data-toggle="tooltip" title=game.title href="/games/game/#{game.slug}")
29+
if game.thumbnail && game.thumbnail.length
30+
img.preview(src="data:image/png;base64,#{game.thumbnail}")
31+
else
32+
img.preview(src="/images/none.png")
33+
span.title=game.title
34+
span.badge=game.releases.length
35+
.row: include ../partials/pagination

app/views/groups/index.jade

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,23 @@ append title
44
| Edit Group -
55

66
append content
7-
.col-sm-12
8-
a.btn.btn-sm.btn-default.pull-right(href="/groups/add")
9-
span.glyphicon.glyphicon-pencil
10-
| Add
11-
h3 Groups
12-
if !groups.length
13-
.alert.alert-warning.text-center No groups have been added.
14-
|
15-
a.btn.btn-warning.btn-sm(href="/groups/add") Add Group
16-
else
17-
.row
18-
for group in groups
19-
.col-md-3.col-sm-4.col-xs-6
20-
a.group(href="/groups/group/#{group.slug}")
21-
if group.logo && group.logo.length
22-
img.logo.logo-lg(src="data:image/png;base64,#{group.logo}")
23-
| #{group.name}
24-
.row: include ../partials/pagination
7+
.col-sm-12: .panel.panel-default
8+
.panel-heading
9+
a.btn.btn-sm.btn-default.pull-right(href="/groups/add")
10+
span.glyphicon.glyphicon-pencil
11+
| Add
12+
h3.panel-title Groups
13+
.panel-body
14+
if !groups.length
15+
.alert.alert-warning.text-center No groups have been added.
16+
|
17+
a.btn.btn-warning.btn-sm(href="/groups/add") Add Group
18+
else
19+
.row
20+
for group in groups
21+
.col-md-3.col-sm-4.col-xs-6
22+
a.group(href="/groups/group/#{group.slug}")
23+
if group.logo && group.logo.length
24+
img.logo.logo-lg(src="data:image/png;base64,#{group.logo}")
25+
| #{group.name}
26+
.row: include ../partials/pagination

app/views/users/index.jade

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,7 @@ append content
1616
.alert.alert-warning No users to edit.
1717
else
1818
include ../partials/feedback
19-
.form-group
20-
.col-sm-12
19+
.form-group: .col-sm-12
2120
select.content-select.form-control(name="userId", required, autofocus)
2221
option Edit User...
2322
for user in users

src/main.less

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ p { overflow: hidden }
189189
}
190190

191191
.panel-heading {
192-
.btn.pull-right {
192+
.pull-right {
193193
margin: -6px;
194194
}
195195
}
@@ -256,6 +256,7 @@ p { overflow: hidden }
256256
margin-bottom:15px;
257257
border-radius: 4px;
258258
display: block;
259+
min-height: 86px;
259260
&:hover {
260261
text-decoration: none;
261262
border-color:#999;
@@ -264,7 +265,7 @@ p { overflow: hidden }
264265

265266
.game {
266267
border: 1px solid #ddd;
267-
268+
border-radius: 4px;
268269
display:block;
269270
position:relative;
270271
margin-bottom:15px;

0 commit comments

Comments
 (0)