Skip to content

Commit

Permalink
[refactor] refactored profile
Browse files Browse the repository at this point in the history
  • Loading branch information
pgte committed Sep 13, 2012
1 parent bd0ccd7 commit e70c70d
Show file tree
Hide file tree
Showing 12 changed files with 60 additions and 79 deletions.
6 changes: 4 additions & 2 deletions public/css/bootstrap.css
Expand Up @@ -3469,7 +3469,8 @@ a.badge:hover {
}

.label-important,
.badge-important {
.badge-important,
.label-rejected {
background-color: #b94a48;
}

Expand All @@ -3489,7 +3490,8 @@ a.badge:hover {
}

.label-success,
.badge-success {
.badge-success,
.label-approved {
background-color: #468847;
}

Expand Down
6 changes: 3 additions & 3 deletions server/routes/article_request.js
@@ -1,6 +1,6 @@
var bubble = require('bubble');

module.exports = function(options) {
module.exports = function(options, articleRequest) {

return {

Expand All @@ -9,7 +9,7 @@ module.exports = function(options) {
var self = this;
var res = this.res;

var b = bubble(function(err) {
var b = bubble(function(err, markup) {
if (err) {
console.error(err);
res.writeHead(500);
Expand All @@ -24,7 +24,7 @@ module.exports = function(options) {
};

res.writeHead(200, {'Content-Type': 'text/html'});
res.end(templates('/article/preview.html').call(self, article));
res.end(options.templates('/article/preview.html').call(self, article));

});

Expand Down
4 changes: 2 additions & 2 deletions server/routes/profile.js
Expand Up @@ -16,10 +16,10 @@ module.exports = function(options) {
return res.end(err.stack);
}
res.writeHead(200, {'Content-Type': 'text/html'});
res.end(options.templates('/profile/index.html').call(self, articleRequests));
res.end(options.templates('/profile.html').call(self, articleRequests));
});
}),

'/article-requests': require('./article_request')(options)
'/article-requests': require('./article_request')(options, articleRequest)
};
};
22 changes: 22 additions & 0 deletions server/templates/profile.html
@@ -0,0 +1,22 @@
<div class="row-fluid content">

<div class="span8 article-status" role="main">
<article>
<h1>Your article submissions</h1>
<ul class="unstyled" id="article-requests">

<li class="article-request"><a href="#" class="article-request-link">› Nam luctus aliquam tincidunt. Maecenas at nisi purus, nec posuere diam. </a>
<span class="label">Approved</span>
</li>

</ul>

</article>
</div>
<!-- /.span8 -->

<div class="span4" role="complementary">
</div>
<!-- /.span4 -->

</div>
29 changes: 29 additions & 0 deletions server/templates/profile.js
@@ -0,0 +1,29 @@
module.exports = function(html, templates, conf, bind, Map, content) {

var map = Map();
map.className('article-request').to('article-request');
map.className('article-request-link').to('title');
map.className('article-request-link').use('url').as('href');
map.className('label').use('class').as('class');
map.className('label').to('state');

return function(articleRequests) {

var data = {
'article-request': articleRequests.length ? articleRequests.map(function(articleRequest) {
return {
'url': '/profile/article-requests/' + encodeURIComponent(articleRequest._id),
'title': '› ' + articleRequest.title,
'state': articleRequest.state,
'class': 'label label-' + articleRequest.state
};

}) : 'You have none.'
};

return templates('/layout.html').call(this, {
main: bind(html, data, map),
title: 'Profile - Article Requests'
});
};
};
1 change: 0 additions & 1 deletion server/templates/profile/approved.html

This file was deleted.

1 change: 0 additions & 1 deletion server/templates/profile/article_request.html

This file was deleted.

23 changes: 0 additions & 23 deletions server/templates/profile/article_request.js

This file was deleted.

28 changes: 0 additions & 28 deletions server/templates/profile/index.html

This file was deleted.

17 changes: 0 additions & 17 deletions server/templates/profile/index.js

This file was deleted.

1 change: 0 additions & 1 deletion server/templates/profile/pending.html

This file was deleted.

1 change: 0 additions & 1 deletion server/templates/profile/rejected.html

This file was deleted.

0 comments on commit e70c70d

Please sign in to comment.