Permalink
Browse files

[refactor] refactored profile

  • Loading branch information...
1 parent bd0ccd7 commit e70c70dc3cc8ef8365018e8f1bd15d1c89b36761 @pgte pgte committed Sep 13, 2012
View
@@ -3469,7 +3469,8 @@ a.badge:hover {
}
.label-important,
-.badge-important {
+.badge-important,
+.label-rejected {
background-color: #b94a48;
}
@@ -3489,7 +3490,8 @@ a.badge:hover {
}
.label-success,
-.badge-success {
+.badge-success,
+.label-approved {
background-color: #468847;
}
@@ -1,6 +1,6 @@
var bubble = require('bubble');
-module.exports = function(options) {
+module.exports = function(options, articleRequest) {
return {
@@ -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);
@@ -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));
});
View
@@ -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)
};
};
@@ -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>
@@ -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 +0,0 @@
-<span class="label label-success">Approved</span>
@@ -1 +0,0 @@
-<a href="#" class="article-request">› Nam luctus aliquam tincidunt. Maecenas at nisi purus, nec posuere diam. </a>
@@ -1,23 +0,0 @@
-module.exports = function(html, templates, conf, bind, Map, content) {
-
- var map = Map();
- map['class']('article-request').use('title');
- map['class']('article-request').use('url').as('href');
-
- return function(articleRequest) {
-
- var data = {
- 'url': '/profile/article-requests/' + encodeURIComponent(articleRequest._id),
- 'title': articleRequest.title
- };
-
- var label;
- try {
- label = templates('/profile/' + articleRequest.state + '.html').call(this);
- } catch(err) {
- console.error(err);
- }
-
- return '<li>' + bind(html, data, map) + label + '</li>';
- };
-};
@@ -1,28 +0,0 @@
-<div class="row-fluid content">
-
- <div class="span8 article-status" role="main">
- <article>
- <h1>Your article requests</h1>
- <ul class="unstyled" id="article-requests">
-
- <!--
- <li><a href="#">› Etiam lacinia, nulla eu interdum venenatis, sapien dolor egestas leo, et iaculis orci augue ac velit. </a><span class="label label-success">Approved</span></li>
- <li><a href="#">› Donec sollicitudin sem tortor. Duis ut pellentesque mi. </a><span class="label label-important">Rejected</span></li>
- <li><a href="#">› Nam luctus aliquam tincidunt. Maecenas at nisi purus, nec posuere diam. </a><span class="label">Pending</span></li>
- <li><a href="#">› Etiam lacinia, nulla eu interdum venenatis, sapien dolor egestas leo, et iaculis orci augue ac velit. </a><span class="label label-success">Approved</span></li>
- <li><a href="#">› Donec sollicitudin sem tortor. Duis ut pellentesque mi. </a><span class="label label-important">Rejected</span></li>
- <li><a href="#">› Nam luctus aliquam tincidunt. Maecenas at nisi purus, nec posuere diam. </a><span class="label">Pending</span></li>
- <li><a href="#">› Etiam lacinia, nulla eu interdum venenatis, sapien dolor egestas leo, et iaculis orci augue ac velit. </a><span class="label label-success">Approved</span></li>
- <li><a href="#">› Donec sollicitudin sem tortor. Duis ut pellentesque mi. </a><span class="label label-success">Approved</span></li>
- -->
- </ul>
-
- </article>
- </div>
- <!-- /.span8 -->
-
- <div class="span4" role="complementary">
- </div>
- <!-- /.span4 -->
-
-</div>
@@ -1,17 +0,0 @@
-module.exports = function(html, templates, conf, bind, Map, content) {
-
- return function(articleRequests) {
-
- var data = {
- 'article-requests': articleRequests.map(function(articleRequest) {
- return templates('/profile/article_request.html').call(this, articleRequest);
- }).join('')
- };
-
- var main = bind(html, data);
- return templates('/layout.html').call(this, {
- main: main,
- title: 'Profile - Article Requests'
- });
- };
-};
@@ -1 +0,0 @@
-<span class="label">Pending</span>
@@ -1 +0,0 @@
-<span class="label label-important">Rejected</span>

0 comments on commit e70c70d

Please sign in to comment.