Skip to content
This repository has been archived by the owner on Dec 11, 2023. It is now read-only.

Commit

Permalink
Nested comments
Browse files Browse the repository at this point in the history
Issue #14 Nested comments load recursively and support for styling them
added to all existing themes.
  • Loading branch information
toniwidmo committed Apr 15, 2018
1 parent d36b4e4 commit cfbebc3
Show file tree
Hide file tree
Showing 7 changed files with 144 additions and 18 deletions.
3 changes: 2 additions & 1 deletion module/steem/steem-comment.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
<div class="steem_comment steem_comment_{steem_comment_author}">
<div class="steem_comment steem_comment_{steem_comment_author}" id="{steem_comment_permlink}">
<div class="steem_comment_meta">
<span class="steem_comment_author"><a href="javascript:getSteemProfile('{steem_comment_author}');">{steem_comment_author}</a></span>
<span class="steem_posts_date">{steem_comment_date}</span>
</div>
<span class="steem_comment">{steem_comment}</span>
<div class="steem-comments" id="{steem_comment_permlink}_comments"></div>
</div>
4 changes: 2 additions & 2 deletions module/steem/steem-post.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ <h1 id="steem-post-title"></h1>
<div id="steem-post-footer">
<div id="steem-post-votes"></div>
</div>
<div id="steem-post-comments">
<div class="steem-comments"></div>
<div id="steem-post-comments" >
<div class="steem-comments" id="{steem_post_permlink}_comments"></div>
<div>Add comments via:
<a href="https://steemit.com/{steem_post_category}/@{steem_post_author}/{steem_post_permlink}#comments">Steemit</a>,
<a href="https//busy.org/{steem_post_category}/@{steem_post_author}/{steem_post_permlink}">Busy</a> or
Expand Down
33 changes: 19 additions & 14 deletions module/steem/steem.js
Original file line number Diff line number Diff line change
Expand Up @@ -161,26 +161,31 @@ function getSteemPosts(usernames,tags,count,lastPermlink) {
steem.api.getDiscussionsByAuthorBeforeDate(usernames, lastPermlink, '2100-01-01T00:00:00', count, function(err, result){displaySteemPosts(err, result)});
//displaySteemPosts(['AAA']);
}
function displaySteemComments(err, comments) {
console.log('displaySteemComments');
function displaySteemComment(comment_obj,target) {
var converter = new showdown.Converter();
author = comment_obj.author;
comment = converter.makeHtml(comment_obj.body);

template = steem_comment_template;
template = template.replace(/{steem_comment}/g,comment);
template = template.replace(/{steem_comment_author}/g,comment_obj.author);
template = template.replace(/{steem_comment_permlink}/g,comment_obj.permlink);

created_date=new Date(comment_obj.created);
display_date = created_date.toLocaleDateString(config.dateformat.locale, config.dateformat.options);
template = template.replace(/{steem_comment_date}/g,display_date);
$(target).append(template).show(500);

if(comment_obj.children > 0) getSteemComments(comment_obj.author,comment_obj.permlink);
}
function displaySteemComments(err, comments) {
var author, comment, template, created_date, display_date, commentsLength = comments.length;
for (var i = 0; i < commentsLength; i++) {
comment_obj = comments[i];
author = comment_obj.author;
comment = converter.makeHtml(comment_obj.body);
console.log(comment_obj);

template = steem_comment_template;
template = template.replace(/{steem_comment}/g,comment);
template = template.replace(/{steem_comment_author}/g,comment_obj.author);

created_date=new Date(comment_obj.created);
display_date = created_date.toLocaleDateString(config.dateformat.locale, config.dateformat.options);
template = template.replace(/{steem_comment_date}/g,display_date);
console.log(template);
$('.steem-comments').append(template);
displaySteemComment(comment_obj,'#'+comment_obj.parent_permlink+'_comments');
}
console.log(comments);
}
function getSteemComments(username,permlink) {
console.log('getSteemComments username: '+username+' & permlink: '+permlink);
Expand Down
35 changes: 35 additions & 0 deletions theme/anton/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -305,3 +305,38 @@ a:active{
display: inline-block;
vertical-align: top;
}
#steem-post-comments {
width: 70%;
margin-right:auto;
margin-left:auto;
}
#steem-post-comments div.steem_comment {
margin:0;
padding:1em;
color: #eff;
}
#steem-post-comments div.steem_comment .steem_comment_meta {
font-size: 0.6em;
}
#steem-post-comments div.steem_comment:nth-child(odd) {
background-color: #261919;
}
#steem-post-comments div.steem_comment:nth-child(even) {
background-color: #191313;
}
div.steem_comment:nth-child(odd)>.steem-comments {
background-color: #191313;
}
div.steem_comment:nth-child(even)>.steem-comments {
background-color: #261919;
}
.steem-comments {
padding: 1px;
display: none;
}
#steem-post-comments div.steem_comment p {
margin:0;
padding:1em;
width: 100%;
color: #cee;
}
28 changes: 28 additions & 0 deletions theme/dana/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,34 @@ footer span{
margin: 0;
border: none;
}
/* steem post comments */
#steem-post-comments {
border-top: 1px solid #000;
padding: 0.7em;
}
#steem-post-comments span.steem_comment {
padding-right:0.7em;
}
#steem-post-comments div.steem_comment {
margin:0;
padding-left:1em;
padding-right:0;
padding-top:0.7em;
}
#steem-post-comments div.steem_comment .steem_comment_meta {
font-size: 0.6em;
}
.steem-comments {
padding-left: 1px;
padding-right:0;
display: none;
}
#steem-post-comments div.steem_comment p {
margin:0;
padding-left:1em;
padding-right:0;
width: 100%;
}

@media only screen and (max-width: 800px) {

Expand Down
29 changes: 29 additions & 0 deletions theme/henrik/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,35 @@ img{
color: #585858;
}

/* steem post comments */
#steem-post-comments {
border-top: 1px solid #000;
padding: 0.5em;
}
#steem-post-comments span.steem_comment {
padding-right:0.5em;
}
#steem-post-comments div.steem_comment {
margin:0;
padding-left:1.5em;
padding-right:0;
padding-top:0.5em;
}
#steem-post-comments div.steem_comment .steem_comment_meta {
font-size: 0.8em;
}
.steem-comments {
padding-left: 1px;
padding-right:0;
display: none;
}
#steem-post-comments div.steem_comment p {
margin:0;
padding-left:1em;
padding-right:0;
width: 100%;
}

#footer-menu li{
display: inline-block;
padding-top: 5px;
Expand Down
30 changes: 29 additions & 1 deletion theme/simple/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ img{
#contentArea img{
display: block;
margin: auto;
width: 70%;
max-width: 70%;
}

/*Footer styles*/
Expand Down Expand Up @@ -275,6 +275,34 @@ div.steem_posts_meta{
margin-bottom: 0.7em;
font-style: italic;
}
/* steem post comments */
#steem-post-comments {
border-top: 1px solid #000;
padding: 0.7em;
}
#steem-post-comments span.steem_comment {
padding-right:0.7em;
}
#steem-post-comments div.steem_comment {
margin:0;
padding-left:1em;
padding-right:0;
padding-top:0.7em;
}
#steem-post-comments div.steem_comment .steem_comment_meta {
font-size: 0.6em;
}
.steem-comments {
padding-left: 1px;
padding-right:0;
display: none;
}
#steem-post-comments div.steem_comment p {
margin:0;
padding-left:1em;
padding-right:0;
width: 100%;
}

@media only screen and (max-width: 800px) {

Expand Down

0 comments on commit cfbebc3

Please sign in to comment.