Browse Source

"Read More" button

pull/1/head
wes 7 years ago
parent
commit
f65f86d50c
  1. 5
      src/scripts/app.tag
  2. 59
      src/scripts/browse.tag

5
src/scripts/app.tag

@ -16,11 +16,6 @@
<div class="app-body">
<section class="text-center nav navbar centered navbar-section">
<sidebar
if={this.active.get("posts")}
name="Filter By Category"
items={state.categories}>
</sidebar>
</section>
<div id="menu"

59
src/scripts/browse.tag

@ -1,27 +1,32 @@
<browse>
<menu
name="Categories"
items={opts.state.categories}
onfilter={filterCategories}
>
</menu>
<loading if={loading}></loading>
<div
if={!loading}
style={cardStyle}
class="card content"
each={result in opts.state.results}
>
<div class="card-header">
<a
onclick={openPost(result[1].id)}
>
<div class="content">
<menu
name="Categories"
items={opts.state.categories}
onfilter={filterCategories}
>
</menu>
<loading if={loading}></loading>
<div
if={!loading}
style={cardStyle}
class="card"
each={result in opts.state.results}
>
<div class="card-header">
<h3 class="card-title">
{ result[1].title } by { result[1].author }
</h3>
</a>
</div>
<div class="card-body">
</div>
<div class="card-body">
<raw content="{ converter.makeHtml(result[1].content) }"></raw>
<a
style={linkStyle}
onclick={openPost(result[1].id)}
>
Read More
</a>
</div>
</div>
</div>
@ -31,28 +36,34 @@ import './menu.tag';
import './loading.tag';
import route from 'riot-route';
import { default as RiotControl } from 'riotcontrol';
import { default as showdown } from 'showdown';
var self = this;
self.route = route;
self.loading = false;
self.converter = new showdown.Converter();
self.openPost = (id) => {
return ((ev) => {
console.log(id);
console.log(RiotControl.trigger);
RiotControl.trigger("openpost", id);
});
};
self.cardStyle = {
"margin" : "auto"
"margin" : "auto",
"margin-top" : "8px"
};
self.linkStyle = {
"cursor" : "pointer"
};
self.filterCategories = (category) => {
return ((ev) => {
self.update({"loading" : true});
ev.preventDefault();
self.update({"loading" : true});
self.route(`browse/${category}`);
window.cached(`/blog/getbrowse/${category}/0`)
.then((resp) => { return resp.json() })

Loading…
Cancel
Save