Browse Source

fix riotcontrol bugs

pull/1/head
wes 7 years ago
parent
commit
0c43db04a8
  1. 31
      src/scripts/app.tag
  2. 28
      src/scripts/browse.tag
  3. 8
      src/scripts/post.tag
  4. 1
      src/scripts/riotblog.js
  5. 14
      src/styles/riotblog.scss
  6. 2
      src/website.py

31
src/scripts/app.tag

@ -33,7 +33,7 @@
show={menuActive}
class="mobile-menu tab tab-block menu">
<li
each="{page in ['posts', 'projects', 'links', 'about']}"
each="{page in ['browse', 'projects', 'links', 'about']}"
class={"navigate-tab tab-item " + (parent.active.get(page) ? "active" : "")}
data-is="navtab"
active={parent.active.get(page)}
@ -47,7 +47,7 @@
<ul class="hide-md hide-sm hide-xs navigate tab tab-block">
<li
each="{page in ['posts', 'projects', 'links', 'about']}"
each="{page in ['browse', 'projects', 'links', 'about']}"
class={"navigate-tab tab-item " + (parent.active.get(page) ? "active" : "")}
data-is="navtab"
active={parent.active.get(page)}
@ -129,15 +129,6 @@ document.addEventListener("click", function(event) {
}
});
window.RiotControl.on("postswitch",
(ev) => {
self.update(
{
"currentPage" : ev.title
})
}
);
self.state = {
"page" : self.opts.page,
"results" : self.decode(self.opts.results),
@ -221,8 +212,7 @@ to(name) {
}
self.on("mount", () => {
window.RiotControl.addStore(new riot.observable());
RiotControl.on("openpost",
window.RiotControl.on("openpost",
(id) => {
console.log("caught the event in the app tag");
console.log(`the id is ${id}`);
@ -230,6 +220,16 @@ self.on("mount", () => {
}
);
window.RiotControl.on("postswitch",
(ev) => {
console.log("updating the title");
self.update(
{
"currentPage" : ev.title
})
}
);
self.route.base('/blog/')
self.route("/", () => { self.route(`/posts/${self.state._id}`); });
self.route("/posts", () => { self.route(`/posts/${self.state._id}`); });
@ -244,10 +244,5 @@ self.on("mount", () => {
route.start(true);
});
self.on("unmount", () => {
RiotControl.off("openpost");
RiotControl.off("postswitch");
})
</script>
</app>

28
src/scripts/browse.tag

@ -1,7 +1,7 @@
<browse>
<div class="content container">
<div class="browse-content container">
<div class="columns">
<div class="column hide-xs hide-sm hide-md col-2">
<div class="column hide-xs hide-sm hide-md col-3">
<categoryfilter
name="Categories"
category={category}
@ -10,7 +10,7 @@
>
</categoryfilter>
</div>
<div class="column col-sm-12 col-10">
<div class="column col-sm-12 col-9">
<loading if={loading}></loading>
<div
if={!loading}
@ -54,7 +54,7 @@ self.converter = new showdown.Converter();
self.openPost = (id) => {
return ((ev) => {
RiotControl.trigger("openpost", id);
self.route(`/posts/${id}`);
});
};
@ -88,5 +88,25 @@ self.filterCategories = (category) => {
})
}
self.getInitial = () => {
self.update({"loading" : true});
window.cached(`/blog/getbrowse/0`)
.then((resp) => { return resp.json() })
.then((results) => {
self.opts.state.results = results;
self.update({
"loading" : false
});
});
}
self.on("mount", () => {
console.log("XXX");
console.log(self.opts.state.category_filter);
if (!self.opts.state.category_filter) {
self.getInitial();
}
});
</script>
</browse>

8
src/scripts/post.tag

@ -29,6 +29,7 @@
</p>
<div class="divider"></div>
</div>
<categories></categories>
</div>
<div
data-is="postcontrols"
@ -42,7 +43,6 @@
</div>
</div>
<script>
import './loading.tag';
import './raw.tag';
import './social.tag';
import './postcontrols.tag';
@ -68,10 +68,6 @@ self.swipe = false;
self.start = false;
self.end = false;
self.on("unmount", () => {
window.RiotControl.off("postswitch");
});
prev(ev) {
ev.preventDefault();
self.end = false;
@ -130,8 +126,6 @@ updatePost(postcontent) {
self.loading = false;
self.prevloading = "";
self.nextloading = "";
self.route("/posts/"+self._id);
window.RiotControl.trigger("postswitch", {"title" : self.title});
self.parent.update();

1
src/scripts/riotblog.js

@ -15,6 +15,7 @@ import 'whatwg-fetch';
window.cache = {};
window.riot = riot;
window.RiotControl = RiotControl;
window.RiotControl.addStore(new riot.observable());
window.cached = fetchCached({
fetch: fetch,

14
src/styles/riotblog.scss

@ -278,6 +278,20 @@ p, h6, h4 {
height: 250px !important;
}
.browse-content {
margin: auto;
max-width: 90%;
@media (max-width: 1000px) {
max-width: 95%;
}
@media (max-width: 800px) {
max-width: 97%;
}
@media (max-width: 400px) {
max-width: 100%;
}
}
.content {
margin: auto;
max-width: 80%;

2
src/website.py

@ -75,7 +75,7 @@ def NeverWhere(configfile=None):
"postcontent" : postcontent,
"links" : dumps([]),
"projects" : dumps([]),
"category_filter" : dumps([]),
"category_filter" : dumps(False),
"categories" : cacheit("categories", lambda : dumps(posts.categories()))
}

Loading…
Cancel
Save