Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

helpers moved to $system (refactoring commit)

  • Loading branch information...
commit c23593e9a5741410991df8e17a45f8916277b548 1 parent d6f95f7
@yssk22 authored
View
50 apps/posts/_attachments/css/posts.css
@@ -21,6 +21,9 @@
.posts .sidebar ul li {
list-style: none;
}
+.posts .main .list .readmore {
+ width: 99%;
+}
.posts .main article.post {
margin-bottom: 10px;
}
@@ -50,10 +53,13 @@
}
.posts .main article.post footer {
border-top: 1px solid #dddddd;
- padding-top: 5px;
+ padding-top: 3px;
text-align: right;
vertical-align: top;
- margin-bottom: 30px;
+ margin-bottom: 40px;
+}
+.posts .main article.post footer .actions {
+ margin-top: 2px;
}
.posts .main article.post footer time.created_at {
display: none;
@@ -120,3 +126,43 @@
padding: 5px;
font-size: 10.5pt;
}
+.posts.admin .main article.post header {
+ float: left;
+ margin-right: 10px;
+ width: 270px;
+ padding-top: 3px;
+ padding-left: 10px;
+}
+.posts.admin .main article.post header h3 {
+ display: inline;
+ font-size: 10pt;
+ border: none;
+}
+.posts.admin .main article.post ul.tags {
+ float: left;
+ margin-right: 10px;
+ width: 150px;
+ padding-top: 3px;
+ text-align: left;
+}
+.posts.admin .main article.post ul.tags li {
+ display: inline;
+}
+.posts.admin .main article.post footer {
+ margin-right: 0;
+ padding-right: 0;
+ margin-right: 0;
+ border: 1px solid #dddddd;
+ padding-right: 10px;
+ padding-bottom: 3px;
+ margin-bottom: 3px;
+}
+.posts.admin .main article.post footer:nth-of-type(odd) {
+ background-color: #dddddd;
+}
+.posts.admin .main article.post footer:nth-of-type(even) {
+ background-color: #ffffff;
+}
+.posts.admin .main article.post .content {
+ display: none;
+}
View
50 apps/posts/_attachments/css/posts.less
@@ -14,6 +14,10 @@
}
}
+ .main .list .readmore {
+ width: 99%;
+ }
+
.main article.post {
margin-bottom: 10px;
header {
@@ -45,10 +49,13 @@
}
footer {
border-top: 1px solid @border-color;
- padding-top: 5px;
+ padding-top: 3px;
text-align: right;
vertical-align: top;
- margin-bottom: 30px;
+ margin-bottom: 40px;
+ .actions {
+ margin-top: 2px;
+ }
}
footer time.created_at {
@@ -93,3 +100,42 @@
}
}
}
+
+
+.posts.admin {
+ .main article.post {
+ header {
+ .span-7;
+ padding-top: 3px;
+ padding-left: 10px;
+ h3 {
+ display:inline;
+ font-size: 10pt;
+ border: none;
+ }
+ }
+ ul.tags {
+ .span-4;
+ padding-top: 3px;
+ text-align: left;
+ li {
+ display:inline;
+ }
+ }
+ footer {
+ .last;
+ border: 1px solid @border-color;
+ padding-right: 10px;
+ padding-bottom: 3px;
+ margin-bottom: 3px;
+ }
+ footer:nth-of-type(odd){
+ background-color: @border-color;
+ }
+ footer:nth-of-type(even){
+ background-color: #ffffff;
+ }
+
+ .content { display: none; }
+ }
+}
View
2  apps/posts/_attachments/js/posts.js
@@ -7,7 +7,7 @@
$.fn.bindList = function(){
var target = this;
var link = target.find('.readmore');
- console.log(link.prev().html());
+ link.button();
link.bind('click', function(e){
var last = link.prev();
var path = link.attr('data-apipath');
View
BIN  apps/system/_attachments/css/images/sunrise.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
26 apps/system/_attachments/css/system_helper.css
@@ -1,3 +1,29 @@
+h1.system.logo {
+ float: left;
+ margin-right: 10px;
+ width: 550px;
+}
+nav.system.accountNavigation ul {
+ float: left;
+ margin-right: 10px;
+ width: 230px;
+ margin-right: 0;
+ padding-right: 0;
+ margin-right: 0;
+ text-align: right;
+}
+nav.system.accountNavigation ul li {
+ display: inline;
+ padding-left: 10px;
+}
+nav.system.siteNavigation {
+ clear: both;
+}
+nav.system.siteNavigation ul li {
+ float: left;
+ margin-right: 10px;
+ width: 70px;
+}
a.system.login.twitter {
background-image: url('./images/login-twitter.png');
background-repeat: no-repeat;
View
23 apps/system/_attachments/css/system_helper.less
@@ -5,6 +5,29 @@
padding-bottom: 5px;
}
+h1.system.logo {
+ .span-14;
+}
+
+nav.system.accountNavigation {
+ ul {
+ .span-6;
+ .last;
+ text-align: right;
+ li {
+ display: inline;
+ padding-left: 10px;
+ }
+ }
+}
+
+nav.system.siteNavigation {
+ clear: both;
+ ul li {
+ .span-2;
+ }
+}
+
a.system.login.twitter {
.icon('./images/login-twitter.png');
}
View
34 apps/system/app.js
@@ -75,38 +75,8 @@ ddoc.init = function(app){
app.helpers(ddoc.helpers);
- app.helpers({
- required: function(){
- // saying that the layout uses $system helpers;
- this.css(app.set('home') + 'css/system_helper.css');
- },
-
- linkToLogin: function(provider, label){
- this.css(app.set('home') + 'css/system_helper.css');
- var url = app.set('home') + 'login/' + provider;
- return '<a href="' + url + '" class="system login ' + provider + '">' + label + '</a>';
- },
-
- linkToLogout: function(label){
- this.css(app.set('home') + 'css/system_helper.css');
- var url = app.set('home') + 'logout';
- return '<a href="' + url + '" class="system logout">' + label + '</a>';
- },
-
- linkToUser: function(userObj){
- this.css(app.set('home') + 'css/system_helper.css');
- var url = app.set('home') + 'profiles/' + encodeURIComponent(userObj.user_id);
- var klass = this.htmlescape(userObj.provider) || 'undefined';
- var label;
- if( klass == 'twitter' ){
- // http://tweetimag.es/
- label = this.sprintf('<img width="18" height="18" src="http://img.tweetimag.es/i/%s_m" /><span>%s</span>', userObj.user_name, this.htmlescape(userObj.user_name));
- }else{
- label = this.htmlescape(userObj.user_name);
- }
- return '<a href="' + url + '" class="system user ' + klass + '">' + label + '</a>';
- }
- });
+ app.helpers(require('./helpers')(app));
+ app.dynamicHelpers(require('./dynamicHelpers')(app));
};
couchapp.loadAttachments(ddoc, path.join(__dirname, '_attachments'));
View
9 apps/system/dynamicHelpers.js
@@ -0,0 +1,9 @@
+module.exports = function(app){
+ return {
+ installedApps: function(req, res){
+ console.log('added installedApps');
+ var site = app.parent;
+ return site.installedApps;
+ }
+ };
+}
View
56 apps/system/helpers.js
@@ -0,0 +1,56 @@
+module.exports = function(app){
+ return {
+ required: function(){
+ // saying that the layout uses $system helpers;
+ this.css(app.set('home') + 'css/system_helper.css');
+ },
+
+ logo: function(path){
+ path = path || '/';
+ imgPath = app.set('home') + 'css/images/sunrise.png';
+ return '<h1 class="system logo"><a href="' + path + '">' +
+ '<img src="' + imgPath + '" width="307" height="70" /></a></h1>';
+ },
+
+ accountNavigation : function(provider){
+ return '<nav class="system accountNavigation"><ul>' +
+ '<li>' + this.linkToUser(this.currentUser) + '</li>' +
+ '<li>' + (this.isLogin ? this.linkToLogout('Logout') : this.linkToLogin(provider, "Login")) + '</li>' +
+ "</ul></nav>";
+ },
+
+ siteNavigation: function(){
+ return '<nav class="system siteNavigation"><ul>' +
+ '<li><a href="/">Home</a>' +
+ (this.installedApps.map(function(appInfo){
+ return '<li><a href="' + appInfo.home + '">' + appInfo.menuName + '</a></li>';
+ })).join('\n') + '</ul></nav>';
+ },
+
+ linkToLogin: function(provider, label){
+ this.css(app.set('home') + 'css/system_helper.css');
+ var url = app.set('home') + 'login/' + provider;
+ return '<a href="' + url + '" class="system login ' + provider + '">' + label + '</a>';
+ },
+
+ linkToLogout: function(label){
+ this.css(app.set('home') + 'css/system_helper.css');
+ var url = app.set('home') + 'logout';
+ return '<a href="' + url + '" class="system logout">' + label + '</a>';
+ },
+
+ linkToUser: function(userObj){
+ this.css(app.set('home') + 'css/system_helper.css');
+ var url = app.set('home') + 'profiles/' + encodeURIComponent(userObj.user_id);
+ var klass = this.htmlescape(userObj.provider) || 'undefined';
+ var label;
+ if( klass == 'twitter' ){
+ // http://tweetimag.es/
+ label = this.sprintf('<img width="18" height="18" src="http://img.tweetimag.es/i/%s_m" /><span>%s</span>', userObj.user_name, this.htmlescape(userObj.user_name));
+ }else{
+ label = this.htmlescape(userObj.user_name);
+ }
+ return '<a href="' + url + '" class="system user ' + klass + '">' + label + '</a>';
+ }
+ }
+}
View
33 lib/site.js
@@ -66,6 +66,23 @@ exports.createSite = function(sitepath, options){
middlewares: middleware
});
site._installedApps = {};
+ site.__defineGetter__('installedApps', function(){
+ // TODO: cachable
+ return Object.keys(site._installedApps).map(function(k){
+ var app = site._installedApps[k];
+ var ddoc = app.ddoc;
+ return {
+ name: ddoc.name || k,
+ description: ddoc.description,
+ version: ddoc.version,
+ author: ddoc.author,
+ home: app.set('home'),
+ menuOrder: app._installOptions.menuOrder,
+ menuName: app._installOptions.menuName || ddoc.name || ddoc._id.split('/')[1]
+ };
+ }).sort(function(a, b){ return a.menuOrder > b.menuOrder; });
+ });
+
site.error(require('./middleware/error')(site.set('errors')));
site.helpers(require('./helpers'));
site.dynamicHelpers(require('./dynamicHelpers'));
@@ -110,22 +127,6 @@ exports.createSite = function(sitepath, options){
site.dynamicHelpers(helpers);
// update installedApps helper for view.
- site.helpers({
- installedApps: Object.keys(site._installedApps).map(function(k){
- var app = site._installedApps[k];
- var ddoc = app.ddoc;
- return {
- name: ddoc.name || k,
- description: ddoc.description,
- version: ddoc.version,
- author: ddoc.author,
- home: app.set('home'),
- menuOrder: app._installOptions.menuOrder,
- menuName: app._installOptions.menuName || ddoc.name || ddoc._id.split('/')[1]
- };
- }).sort(function(a, b){ return a.menuOrder > b.menuOrder; })
- });
-
// update helpers in all applicaitons
Object.keys(site._installedApps).forEach(function(k){
var app = site._installedApps[k];
View
18 template/_attachments/css/sunrise.less
@@ -2,24 +2,6 @@
margin-bottom: 10px;
}
-#siteHeader h1.logo {
- .span-15;
-}
-
-#accountNavigation ul {
- .span-6;
- text-align: right;
-}
-
-#accountNavigation ul li {
- display: inline;
- padding-left: 10px;
-}
-
-#siteNavigation ul li {
- .span-2;
-}
-
#siteFooter p.copyright {
text-align: center;
}
View
26 template/_attachments/templates/layout.ejs
@@ -18,29 +18,9 @@
</head>
<body>
<header id="siteHeader" class="container">
- <h1 class="logo">
- <a href="/">Sunrise</a>
- <span class="subTitle">Application container framework powered by node.js</span>
- </h1>
- <nav id="accountNavigation">
- <ul>
- <% if( isLogin ){ %>
- <li class="user"><%- $system.linkToUser(currentUser) %></li>
- <li class="user"><%- $system.linkToLogout("Logout") %></li>
- <% }else{ %>
- <li class="guest"><%- $system.linkToUser(currentUser) %></li>
- <li class="guest"><%- $system.linkToLogin('twitter', "Login") %></li>
- <% } %>
- </ul>
- </nav>
- <nav id="siteNavigation" class="clear">
- <ul>
- <li><a href="/">Home</a></li>
- <% installedApps.forEach(function(appInfo){ %>
- <li><a href="<%= appInfo.home %>"><%= appInfo.menuName %></a></li>
- <% }) %>
- </ul>
- </nav>
+ <%- $system.logo() %>
+ <%- $system.accountNavigation('twitter') %>
+ <%- $system.siteNavigation() %>
</header>
<hr />
<div id="main" class="container">
Please sign in to comment.
Something went wrong with that request. Please try again.