Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
removing extra code from edit and post pages
- Loading branch information
Showing
16 changed files
with
160 additions
and
375 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,77 +1,13 @@ | ||
function Blog(app) { | ||
// var converter = new Showdown.converter(); | ||
|
||
function stripScripts(s) { | ||
return s && s.replace(/<script(.|\n)*?>/g, ''); | ||
}; | ||
|
||
function safe(s,cap) { | ||
if (cap && cap < s.length) { | ||
s = s.substring(0,cap); | ||
s += '...'; | ||
} | ||
return s && s.replace(/<(.|\n)*?>/g, ''); | ||
}; | ||
|
||
function author(author) { | ||
if (!author) return ''; | ||
if (!author.url) return '<span class="author">by ' + safe(author.name) + '</span>'; | ||
return '<span class="author">by <a href="'+author.url+'">' | ||
+ safe(author.name) + '</a></span>'; | ||
}; | ||
|
||
|
||
function niceDate(date) { | ||
return '<span class="date">' | ||
+ app.prettyDate(date) | ||
+'</span>'; | ||
}; | ||
|
||
this.postToEntry = function(post, id) { | ||
return '<li><h3><a href="'+app.showPath('post',id)+'">' | ||
+ safe(post.title) | ||
+ '</a></h3>' | ||
+ niceDate(post.created_at) | ||
+ '<div class="body">' | ||
+ post.summary | ||
+ '</div>' | ||
+ '</li>'; | ||
} | ||
|
||
this.postToHTML = function(post) { | ||
return niceDate(post.created_at) | ||
+ '<div class="body">' | ||
+ stripScripts(post.html) | ||
+ '</div>'; | ||
}; | ||
|
||
this.commentListing = function(c) { | ||
return '<li><h4>' | ||
+ author(c.commenter) + ', ' | ||
+ app.prettyDate(c.created_at) | ||
+ '</h4>' | ||
+ '<img class="gravatar" src="http://www.gravatar.com/avatar/'+c.commenter.gravatar+'.jpg?s=40&d=identicon"/>' | ||
+'<p>'+ stripScripts(c.html) | ||
+ '</p>' | ||
+ '</li>'; | ||
}; | ||
|
||
this.makeTwitterLinks = function(text) { | ||
return text.replace(/ @([^ .,]+)/g, ' <a href="http://twitter.com/$1">@$1</a>'); | ||
}; | ||
|
||
this.formatBody = function(body, format) { | ||
if (format == 'markdown') { | ||
var converter = new Showdown.converter(); | ||
return this.makeTwitterLinks(converter.makeHtml(body)); | ||
return converter.makeHtml(body); | ||
} else if (format == 'textile') { | ||
return superTextile(body); | ||
} else { | ||
return body; | ||
} | ||
} | ||
|
||
this.editing = function(docid) { | ||
$('h1').html('Editing <a href="'+app.showPath('post',docid)+'">'+docid+'</a>'); | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,7 @@ | ||
$.couch.app(function(app) { | ||
// $('.date').prettyDate(); | ||
$('.date').prettyDate(); | ||
|
||
$("#account").evently($.extend(true, | ||
app.ddoc.vendor.couchapp.evently.account, | ||
app.ddoc.evently.account), app); | ||
|
||
|
||
// todo browse by tags | ||
app.design.view("tags",{ | ||
descending: true, | ||
group: true, | ||
success: function(json) { | ||
var total = 0; | ||
for(var idx in json.rows) { | ||
total += json.rows[idx].value; | ||
} | ||
var tags = []; | ||
for(var idx in json.rows) { | ||
var percent = Math.ceil(Math.pow((json.rows[idx].value / total), 0.25) * 200); | ||
tags.push('<span style="font-size:'+percent+'%;">' + json.rows[idx].key + '</span>'); | ||
} | ||
$("#tags-front").append(tags.join(", ")); | ||
} | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,17 @@ | ||
function(e, r) { | ||
var app = $$(this).app; | ||
var path = app.require("vendor/couchapp/commonjs/path").init(app.req); | ||
return { | ||
var data = { | ||
name : r.userCtx.name, | ||
uri_name : encodeURIComponent(r.userCtx.name), | ||
auth_db : encodeURIComponent(r.info.authentication_db), | ||
newPostPath : path.show("edit") | ||
auth_db : encodeURIComponent(r.info.authentication_db) | ||
}; | ||
if (app.req.path.indexOf("post-page") == -1) { | ||
data.postPath = path.show("edit")+"/"; | ||
data.postMessage = "New post."; | ||
} else { | ||
data.postPath = path.show("edit", app.req.query.startkey[0]); | ||
data.postMessage = "Edit this post."; | ||
} | ||
return data; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
<span>Welcome | ||
<a target="_new" href="/_utils/document.html?{{auth_db}}/org.couchdb.user%3A{{uri_name}}">{{name}}</a>! | ||
<a href="#logout">Logout?</a> | ||
<a href="{{newPostPath}}">New post.</a> | ||
<a href="{{postPath}}">{{postMessage}}</a> | ||
</span> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.