Skip to content

Commit 0ff0874

Browse files
lots of changes
1 parent 31e5976 commit 0ff0874

8 files changed

Lines changed: 61 additions & 24 deletions

File tree

public/js/app.js

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,20 @@
11
$(function(){
22

3-
4-
$('.projects').masonry({
5-
itemSelector: '.project',
6-
columnWidth: function( containerWidth ) {
7-
return containerWidth / 4;
3+
$('.projects').isotope({
4+
itemSelector: '.project'
5+
, animationEngine: 'jquery'
6+
, masonry: {
7+
columnWidth: 100
8+
}, getSortData : {
9+
date : function ( $elem ) {
10+
return $elem.attr('data-date');
11+
}, name : function ( $elem ) {
12+
return $elem.attr('data-name');
13+
}, contribs : function ( $elem ) {
14+
return $elem.attr('data-contribs');
815
}
916

10-
});
17+
}});
1118

1219
$('#newProject').click(function(){if(!window.username.length) window.location="http://hackdash.hhba.info/auth/twitter"; })
1320

@@ -62,4 +69,14 @@ $('#newProject').click(function(){if(!window.username.length) window.location="h
6269
}, function(){
6370
$(this).css('overflow', 'hidden');
6471
});
72+
73+
$('.sort').click(function(){
74+
var vid = $(this).attr('id');
75+
$('.projects').isotope({'sortBy': vid });
76+
});
77+
78+
twttr.anywhere(function (T) {
79+
T('.users a').hovercards({linkify: false});
80+
});
81+
6582
});

public/js/isotope.min.js

Lines changed: 8 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

public/styles/main.css

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,3 +84,8 @@ h3 {
8484
line-height: 27px;
8585
}
8686

87+
88+
#contribs {
89+
margin-top: 10px;
90+
}
91+

public/styles/style.css

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@ body {
66
a {
77
color: #00B7FF;
88
}
9+

routes/index.js

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -157,10 +157,10 @@ app.get('/decline/:pid/:uid', function(req, res){
157157
app.post('/projects/new', isAuth, function(req, res){
158158
if(req.body.title && req.body.description){
159159
var hash = Math.floor(Math.random() * 9999999 + 1);
160-
console.log(req.body);
161160
var project = {
162161
id: hash
163162
, title: req.body.title
163+
, created_at: Date.now()
164164
, owner_id: req.user.id
165165
, owner_username: req.user.username
166166
, description: req.body.description
@@ -214,9 +214,16 @@ app.post('/projects/edit/:id', isAuth, isOwner, function(req, res){
214214
});
215215

216216
app.get('/projects/remove/:id', isAuth, isOwner, function(req, res){
217-
client.del('hhba:projects:' + req.params.id, function(err){
218-
res.redirect('/dashboard');
219-
search.remove(req.params.id);
217+
client.get('hhba:projects:' + req.params.id, function(err, project){
218+
project = JSON.parse(project);
219+
if(project.contributors.length == 1) {
220+
client.del('hhba:projects:' + req.params.id, function(err){
221+
res.redirect('/dashboard');
222+
search.remove(req.params.id);
223+
});
224+
} else {
225+
res.redirect('/dashboard');
226+
}
220227
});
221228
});
222229

@@ -234,7 +241,7 @@ app.get('/search', function(req, res){
234241
return !!project;
235242
});
236243
var user = req.user || {'username': ''};
237-
res.render('dashboard', {projects: projects, user: user});
244+
res.render('dashboard', {projects: projects, user: user, q: req.query.q});
238245
});
239246
});
240247
});

views/dashboard.jade

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,15 @@ block content
1515
.span3.logo
1616
img(src="/images/logo.png", width="225")
1717

18-
.span3
18+
.span3#sort
19+
h3 filtrar
20+
button.span4.btn-large.sort.btn#date Fecha
21+
button.span4.btn-large.sort.btn#name Nombre
22+
button.span8.btn-large.sort.btn#contribs Cant. de usuarios
23+
1924
.span3
2025
form.well.form-search(action="/search", method="get")
21-
input.input-medium.search-query(type="text", name="q")
26+
input.input-medium.search-query(type="text", name="q", value=("undefined" == typeof q) ? '' : q)
2227
button.btn(type="submit") Buscar
2328

2429
.span3
@@ -30,9 +35,9 @@ block content
3035
img.span12(src="/images/new-project.png")
3136

3237

33-
.row-fluid.projects
38+
.row-fluid.projects#projects
3439
each project, index in projects
35-
.project.well
40+
.project.well(data-contribs=project.contributors.length, data-name=project.title, data-date=("undefined" == typeof project.created_at) ? 0 : project.created_at)
3641
if(user.username == "blejman")
3742
a(href="/projects/remove/"+project.id, style="float:right") x
3843
h3.title #{project.title}

views/edit.jade

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ form.form-horizontal(action="/projects/edit/" + project.id, method="POST")
1919
.form-actions
2020
button.btn.btn-primary(type="submit") Guardar
2121
button.btn.cancel Cerrar
22-
a.btn.btn-danger(href="/projects/remove/" + project.id) Borrar proyecto
22+
if(project.contributors.length === 1)
23+
a.btn.btn-danger(href="/projects/remove/" + project.id) Borrar proyecto
2324

2425
h3 Usuarios pendientes
2526

views/layout.jade

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,5 @@ html
1515
script(src="/js/jquery.min.js")
1616
script(src="/js/isotope.min.js")
1717
script(src="/js/bootstrap.min.js")
18+
script(src="http://platform.twitter.com/anywhere.js?id=YOUR_API_KEY&v=1")
1819
script(src="/js/app.js")

0 commit comments

Comments
 (0)