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

Commit

Permalink
Steem post working
Browse files Browse the repository at this point in the history
Issue #2
Steem module can now display post content
Installed showdown.min.js to parse the markdown.
  • Loading branch information
toniwidmo committed Nov 23, 2017
1 parent a389fd8 commit 6f05f57
Show file tree
Hide file tree
Showing 6 changed files with 60 additions and 12 deletions.
2 changes: 1 addition & 1 deletion config.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
{"label": "Home", "type": "static", "args": "home.html"},
{"label": "Profile", "type": "steem", "args": {"show":"profile", "user":"antonchanning"}},
{"label": "Posts", "type": "steem", "args": {"show":"posts", "user":"antonchanning", "tag":"blockpress"}},
{"label": "Post", "type": "steem", "args": {"show":"post", "postid":"somepost"}},
{"label": "Post", "type": "steem", "args": {"show":"post", "user":"antonchanning", "postid":"blockpress-the-ajax-blockchain-cms"}},
{"label": "Link", "type": "link", "args": "https://blockpress.me"}
]
}
3 changes: 3 additions & 0 deletions lib/showdown/showdown.min.js

Large diffs are not rendered by default.

File renamed without changes.
11 changes: 11 additions & 0 deletions module/steem/steem-post.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<div id="steem-post">
<h1 id="steem-post-title"></h1>
<div id="steem-post-meta">
<div id="steem-post-author"></div>
<div id="steem-post-date"></div>
</div>
<div id="steem-post-content"></div>
<div id="steem-post-footer">
<div id="steem-post-votes"></div>
</div>
</div>
45 changes: 40 additions & 5 deletions module/steem/steem.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ function steem_load(args) {
console.log("posts");
break;
case "post":
console.log("post");
getSteemPost(args.user,args.postid);
console.log("post: "+args.user+" "+args.postid);
break;
}
}
Expand Down Expand Up @@ -56,11 +57,31 @@ function displaySteemPost(post) {
// Display template
$('#contentArea').html(content);

console.log(steem_post.body);

var converter = new showdown.Converter();
var body_html = converter.makeHtml(steem_post.body);

console.log(body_html);
// Then add post values
$("#steem-post-content").html(body_html);
}
function getSteemPost(postid) {
function getSteemPostTemplate(err, post) {
// Save profile in global variable
steem_post = post;

// Get template from theme
var theme_template = "/theme/"+config.theme+"/steem-post.html";
$.ajax(theme_template).done(displaySteemProfile).fail(function(){
// Else use default template
$.ajax("/module/steem/steem-post.html").done(displaySteemPost);
});

content = 'post';
}
function getSteemPost(username,postid) {
//
displaySteemPost("Post content")
steem.api.getContent(username, postid, function(err, result){getSteemPostTemplate(err, result)});
}

function simpleReputation(raw_reputation) {
Expand Down Expand Up @@ -108,12 +129,26 @@ function getSteemProfile(username) {
steem.api.getAccounts([username], function(err, profile){getSteemProfileTemplate(err, profile)});
}

//Load the showdown library (for parsing markdown)
$.getScript( "lib/showdown/showdown.min.js").done(function( script, textStatus ) {
console.log( textStatus );
console.log( "showdown.min.js load was performed." );
})
.fail(function( jqxhr, settings, exception ) {
console.log( exception );
console.log( jqxhr.status );
console.log( settings );
$( "div.log" ).text( "Triggered ajaxError handler." );
});

var steem_profile, steem_post, steem_posts;

//Load the steem javascript API
$.getScript( "module/steem/steem.min.js", function( data, textStatus, jqxhr ) {
$.getScript( "lib/steem-js/steem.min.js", function( data, textStatus, jqxhr ) {
console.log( data ); // Data returned
console.log( textStatus ); // Success
console.log( jqxhr.status ); // 200
console.log( "Load was performed." );
console.log( "steem.min.js load was performed." );
});

console.log( "XXXXX" ); // Data returned
11 changes: 5 additions & 6 deletions theme/dark/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,11 @@ img{
color: #04B486;
}

#contentArea {
width: 70%;
margin-right:auto;
margin-left:auto;
}
#contentArea h1{
font-size: 1.1em;
font-family: "Lucida Sans Unicode", "Lucida Grande", sans-serif;
Expand All @@ -94,7 +99,6 @@ img{
color:#04B486;
margin-bottom: 0.5em;
text-align: left;
width: 70%;
margin-right:auto;
margin-left:auto;
}
Expand All @@ -105,31 +109,27 @@ img{
color:#04B486;
margin-bottom: 0.5em;
text-align: left;
width: 70%;
margin-right:auto;
margin-left:auto;
}

#contentArea ul{
display: block;
list-style-type: disc;
width: 70%;
margin-right:auto;
margin-left:auto;

}
#contentArea li{
font-size: 1em;
color:#FFFFFF;
width: 70%;
margin-right:auto;
margin-left:auto;
padding: 0.5em;
}
#contentArea p{
font-size: 1em;
color:#FFFFFF;
width: 70%;
margin-right:auto;
margin-left:auto;
text-align: left;
Expand Down Expand Up @@ -171,7 +171,6 @@ img{
/* Steem Content Module Themes */
/* Steem Profile */
#profile-banner {
width: 70%;
width: 1000px;
height: 180px;
margin-right:auto;
Expand Down

0 comments on commit 6f05f57

Please sign in to comment.