Skip to content

Commit d65ace0

Browse files
committed
add bootstrap and layout for feed page
1 parent 97d3579 commit d65ace0

File tree

4 files changed

+36
-19
lines changed

4 files changed

+36
-19
lines changed

public/css/style.css

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ a {
1313
}
1414

1515
main {
16-
max-width: 600px;
16+
/*max-width: 600px;*/
1717
}
1818

1919
img {
@@ -44,6 +44,6 @@ button, input[type="submit"] {
4444
}
4545

4646
.vote {
47-
width: 100px;
48-
margin: 0 0 40px;
47+
/*width: 100px;
48+
margin: 0 0 40px;*/
4949
}

public/js/main.js

Lines changed: 30 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11

22
// EXAMPLE - FEED PAGE
33
if ($('main').hasClass('feed') ) {
4+
let postInsert = '.feed-insert'
45
steem.api.setOptions({ url: 'wss://rpc.buildteam.io' });
56
steem.api.getState('/trending/', (err, result) => {
67

@@ -10,13 +11,18 @@ if ($('main').hasClass('feed') ) {
1011

1112
var converter = new showdown.Converter()
1213
var html = converter.makeHtml(result.content[post].body)
14+
var placeholder = document.createElement('div');
15+
placeholder.innerHTML = html;
16+
var image = placeholder.querySelector('img');
17+
var plainText = placeholder.textContent || placeholder.innerText || "";
1318

1419
resultsArray.push({
1520
id: result.content[post].id,
1621
title: result.content[post].title,
1722
author: result.content[post].author,
18-
body: html,
19-
permlink: result.content[post].permlink
23+
body: plainText,
24+
permlink: result.content[post].permlink,
25+
image: image ? image.getAttribute('src') : ''
2026
})
2127
}
2228

@@ -25,22 +31,30 @@ if ($('main').hasClass('feed') ) {
2531
});
2632

2733
resultsArray.forEach( (post, i, arr) => {
28-
2934
let template = `
30-
<div data-post-id="${post.id}">
31-
<h3><a href="">${post.title}</a> - ${post.author}</h3>
32-
<p>${ (post.body).substring(0, 250) }...</p>
33-
<form method="post">
34-
<input type="hidden" name="postId" value="${post.id}">
35-
<input type="hidden" name="author" value="${post.author}">
36-
<input type="hidden" name="permlink" value="${post.permlink}">
37-
<input type="submit" class="vote" value="Vote">
38-
</form>
39-
</div>`
40-
$('main').append(template)
35+
<div class="col-md-4" data-post-id="${post.id}">
36+
<div class="card mb-4 box-shadow">
37+
<img class="card-img-top" data-src="${post.image}" alt="Thumbnail [100%x225]" style="height: 225px; width: 100%; display: block;" src="${post.image}" data-holder-rendered="true">
38+
<div class="card-body">
39+
<h5 class="card-title">${post.title}</h5>
40+
<p class="card-text">${ (post.body).substring(0, 150) }..</p>
41+
<div class="d-flex justify-content-between align-items-center">
42+
<div class="btn-group">
43+
<form method="post">
44+
<input type="hidden" name="postId" value="${post.id}">
45+
<input type="hidden" name="author" value="${post.author}">
46+
<input type="hidden" name="permlink" value="${post.permlink}">
47+
<button type="button" class="btn btn-sm btn-outline-secondary vote">Vote</button>
48+
</form>
49+
<button type="button" class="btn btn-sm btn-outline-secondary">Edit</button>
50+
</div>
51+
</div>
52+
</div>
53+
</div>
54+
</div>
55+
`
56+
$(postInsert).append(template)
4157
})
42-
43-
4458
});
4559

4660
$('main').on('click', '.vote',(e) => {

views/feed.pug

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,7 @@ block content
55

66
main.feed
77
h1 Feed - /Trending
8+
.container
9+
.row.feed-insert
810

911
script(src='/js/showdown.min.js')

views/layout.pug

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ html
33
head
44
title= title
55
link(rel='stylesheet', href='/css/style.css')
6+
link(rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous")
67
body
78
block content
89
script(src="https://code.jquery.com/jquery-3.2.1.min.js"

0 commit comments

Comments
 (0)