Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

progress with posting. add post to the page

  • Loading branch information...
commit 637544ad753b95847f2b66d40c77341aad821f5d 1 parent bdc9e6c
@marynaaleksandrova marynaaleksandrova authored
Showing with 29 additions and 39 deletions.
  1. +29 −11 public/js/app.js
  2. +0 −13 views/community.jade
  3. +0 −15 views/thread.jade
View
40 public/js/app.js
@@ -51,8 +51,7 @@ $(function(){
repo.read('master', 'README.md', function(err, content){
if(!err && content){
- var mdConverter = new Showdown.converter();
- var html = mdConverter.makeHtml(content);
+ var html = makeHtml(content);
$page.find('.details p').html(html);
}
});
@@ -119,6 +118,19 @@ $(function(){
console.log("sha", sha);
if(err){
alert("Error hapenned");
+ } else{
+ var message = {
+ html: makeHtml(text)
+ };
+ message.commit = {
+ published: moment().fromNow(),
+ published_at: moment().format()
+ };
+ message.commit.author = {
+ url: cUnity.user.profileUrl,
+ avatar_url: cUnity.user.avatar
+ };
+ renderArrayItem(message, $messagesListEl, 'topic-page-message-tpl');
}
});
});
@@ -144,7 +156,6 @@ $(function(){
repo.commits(sha, function(err, commits){
commits = _.first(commits, commits.length - 1);
console.log("commits", commits);
- var mdConverter = new Showdown.converter();
var i = 0;
for(; i < commits.length; i++){
var k = commits.length - i - 1;
@@ -154,13 +165,13 @@ $(function(){
commit.published_at = commit.commit.author.date;
commit.published = moment(commit.published_at).fromNow();
file.commit = commit;
- file.html = mdConverter.makeHtml(file.content);
+ file.html = makeHtml(file.content);
}
}
console.log("new files", files);
$messagesListEl.spin(false);
renderArray(files, $messagesListEl, 'topic-page-message-tpl');
- });
+ });
});
@@ -169,6 +180,10 @@ $(function(){
});
}
+ function makeHtml(md){
+ var mdConverter = new Showdown.converter();
+ return mdConverter.makeHtml(md);
+ }
function getAuthRepo(community){
var gh = new Github({
@@ -211,14 +226,17 @@ $(function(){
next();
}
- function renderArray(array, containerEl, templateName){
- var i = 0;
+ function renderArrayItem(item, containerEl, templateName){
var tplStr = $('#' + templateName).html();
var tpl = _.template(tplStr);
- for(; i < array.length; i++){
- var html = tpl(array[i]);
- containerEl.append(html);
- }
+ var html = tpl(item);
+ containerEl.append(html);
+ }
+
+ function renderArray(array, containerEl, templateName){
+ _.each(array, function(item){
+ renderArrayItem(item, containerEl, templateName);
+ });
}
// ROUTER
View
13 views/community.jade
@@ -1,13 +0,0 @@
-doctype 5
-html(lang="en")
- head
- meta(charset="utf-8")
- title TODO!!
- meta(name="description", content="TODO")
- meta(name="keywords", content="TODO")
- meta(name="author", content="Anton Podviaznikov")
- script(src="/app.js")
- body
- - each thread in threads
- p
- a(href="/#{communityUrl}/#{thread.name}")= thread.name
View
15 views/thread.jade
@@ -1,15 +0,0 @@
-doctype 5
-html(lang="en")
- head
- meta(charset="utf-8")
- title TODO!!
- meta(name="description", content="TODO")
- meta(name="keywords", content="TODO")
- meta(name="author", content="Anton Podviaznikov")
- script(src="/app.js")
- body
- - each message in messages
- section
- div!= message.html
- footer
- span= message.author.login
Please sign in to comment.
Something went wrong with that request. Please try again.