Browse Source

fix riotcontrol bugs

pull/1/head
wes 8 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} show={menuActive}
class="mobile-menu tab tab-block menu"> class="mobile-menu tab tab-block menu">
<li <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" : "")} class={"navigate-tab tab-item " + (parent.active.get(page) ? "active" : "")}
data-is="navtab" data-is="navtab"
active={parent.active.get(page)} active={parent.active.get(page)}
@ -47,7 +47,7 @@
<ul class="hide-md hide-sm hide-xs navigate tab tab-block"> <ul class="hide-md hide-sm hide-xs navigate tab tab-block">
<li <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" : "")} class={"navigate-tab tab-item " + (parent.active.get(page) ? "active" : "")}
data-is="navtab" data-is="navtab"
active={parent.active.get(page)} 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 = { self.state = {
"page" : self.opts.page, "page" : self.opts.page,
"results" : self.decode(self.opts.results), "results" : self.decode(self.opts.results),
@ -221,8 +212,7 @@ to(name) {
} }
self.on("mount", () => { self.on("mount", () => {
window.RiotControl.addStore(new riot.observable()); window.RiotControl.on("openpost",
RiotControl.on("openpost",
(id) => { (id) => {
console.log("caught the event in the app tag"); console.log("caught the event in the app tag");
console.log(`the id is ${id}`); 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.base('/blog/')
self.route("/", () => { self.route(`/posts/${self.state._id}`); }); self.route("/", () => { self.route(`/posts/${self.state._id}`); });
self.route("/posts", () => { 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); route.start(true);
}); });
self.on("unmount", () => {
RiotControl.off("openpost");
RiotControl.off("postswitch");
})
</script> </script>
</app> </app>

28
src/scripts/browse.tag

@ -1,7 +1,7 @@
<browse> <browse>
<div class="content container"> <div class="browse-content container">
<div class="columns"> <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 <categoryfilter
name="Categories" name="Categories"
category={category} category={category}
@ -10,7 +10,7 @@
> >
</categoryfilter> </categoryfilter>
</div> </div>
<div class="column col-sm-12 col-10"> <div class="column col-sm-12 col-9">
<loading if={loading}></loading> <loading if={loading}></loading>
<div <div
if={!loading} if={!loading}
@ -54,7 +54,7 @@ self.converter = new showdown.Converter();
self.openPost = (id) => { self.openPost = (id) => {
return ((ev) => { 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> </script>
</browse> </browse>

8
src/scripts/post.tag

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

1
src/scripts/riotblog.js

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

14
src/styles/riotblog.scss

@ -278,6 +278,20 @@ p, h6, h4 {
height: 250px !important; 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 { .content {
margin: auto; margin: auto;
max-width: 80%; max-width: 80%;

2
src/website.py

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

Loading…
Cancel
Save