diff --git a/blog.scss b/blog.scss
index 19021d1..1d25d1f 100644
--- a/blog.scss
+++ b/blog.scss
@@ -1,3 +1,12 @@
+@mixin responsive-block($bw) {
+ @media (max-width: 700px) {
+ max-width: $bw+20%;
+ }
+ @media (max-width: 500px) {
+ max-width: $bw+40%;
+ }
+}
+
.post-text {
text-align: center;
}
@@ -13,9 +22,48 @@
.post-content {
max-width: 50%;
text-align: justify;
+ font-size: 1.5em;
+ @include responsive-block(50);
+}
+
+.comment-block {
+ max-width: 30%;
+ @include responsive-block(30);
}
.comments {
margin-top: 5%;
- max-width: 30%;
+ @extend .comment-block;
+}
+
+.comment {
+ margin-top: 2%;
+ max-width: 40%;
+ @include responsive-block(45);
+}
+
+.comments-loader {
+ margin-top: 2%;
+}
+
+.comment-body {
+ margin-left: 10px;
+ margin-right: 10px;
+}
+
+.postnav {
+ @extend .post-text;
+}
+
+.rounded-button {
+ border-radius: 13px;
+}
+
+.maxinput {
+ background-color: grey;
+}
+
+.maxwarn {
+ margin-top: 15px;
+ @extend .comment-block;
}
diff --git a/comment.py b/comment.py
new file mode 100644
index 0000000..ccc1d42
--- /dev/null
+++ b/comment.py
@@ -0,0 +1,18 @@
+from json import dumps
+
+def comment(author, title, text):
+ return {
+ "title" : title,
+ "author" : author,
+ "text" : text
+ }
+
+
+testcomments = {
+ 1 : dumps(
+ [
+ comment("Anonymous Coward", "Some comment?", "super duper awesome comment here"),
+ comment("Anonymous Coward 3", "Something? IDEK", "super duper worse comment here"),
+ comment("Anonymous Coward 2", "Some other comment?", "super duper dang terrible comment here")
+ ])
+ }
diff --git a/scripts/blog.js b/scripts/blog.js
index 9b48a28..f57961f 100644
--- a/scripts/blog.js
+++ b/scripts/blog.js
@@ -3,3 +3,5 @@ riot.mount("post",
"creator" : "wes",
"title" : "A cool post here"
});
+
+riot.mount("bbutton");
diff --git a/scripts/tags.js b/scripts/tags.js
index 2ab1e7c..3051e04 100644
--- a/scripts/tags.js
+++ b/scripts/tags.js
@@ -1,13 +1,104 @@
-riot.tag2('comments', '', '', '', function(opts) {
+riot.tag2('bbutton', '', '', '', function(opts) {
});
-riot.tag2('post', '
{opts.title}
By {opts.creator}
{content}
', '', '', function(opts) {
+riot.tag2('comment', '', '', '', function(opts) {
+});
+
+riot.tag2('comments', ' You\'ve reached the max comment size
', '', '', function(opts) {
+
+comments = [];
+maxlength = 700;
+
+placeholder = "Comment here!";
+focused = false;
+maxed = false;
+warn = false;
+disabled = "";
+loading = true;
+
+this.clearplaceholder = function() {
+ if (!this.focused) {
+ this.update({
+ "placeholder" : "",
+ "focused" : true
+ })
+ }
+}.bind(this)
+
+this.checkplaceholder = function() {
+ if (this.textarea.value.trim().length == 0) {
+ this.update({
+ "placeholder" : "Comment here!",
+ "focused" : false
+ });
+ }
+}.bind(this)
+
+this.closewarning = function() {
+ this.update({"warn" : false});
+}.bind(this)
+
+this.echo = function(ev) {
+ if (this.textarea.value.length >= maxlength) {
+ this.update({
+ "maxed" : "maxinput",
+ "warn" : true
+ });
+ }
+ else {
+ this.update({
+ "maxed" : false,
+ "warn" : false
+ });
+ window.setTimeout(this.closewarning, 5000);
+ }
+}.bind(this)
+
+var self = this;
+
+this.getComments = function(pid) {
+ fetch("/comments/"+pid)
+ .then(
+ function(resp) {
+ return resp.text();
+ })
+ .then(
+ function(body) {
+ self.update(
+ {
+ "comments" : JSON.parse(body),
+ "loading" : false
+ });
+ });
+}.bind(this)
+
+this.on("mount",
+ function() {
+ this.getComments(self.opts.pid);
+ });
+
+});
+
+riot.tag2('post', '
{opts.title}
By {opts.creator}
{content}
', '', '', function(opts) {
var self = this;
+
+this.loading = false;
+this.prevloading = "";
+this.nextloading = "";
+
+this.nomore = false
this.pid = 1;
content = "";
this.prev = function() {
- if (self.pid > 0) {
+ if (self.prevloading || self.nextloading) {
+ return;
+ }
+ self.prevloading = " loading";
+ if (self.nomore) {
+ self.nomore = false;
+ }
+ if (self.pid > 1) {
self.pid--;
self.setPost(self.pid);
self.update();
@@ -15,20 +106,39 @@ this.prev = function() {
}.bind(this)
this.next = function() {
- self.pid++;
- self.setPost(self.pid);
- self.update();
+ if (self.nextloading || self.prevloading) {
+ return;
+ }
+ self.nextloading = " loading";
+ console.log(self.pid);
+ console.log(self.nomore);
+ if (!self.nomore) {
+ self.pid++;
+ self.setPost(self.pid);
+ self.update();
+ }
}.bind(this)
this.setPost = function(pid) {
+ self.update();
+ self.loading = true;
fetch("/switchpost/"+pid)
.then(
function(resp) {
- return resp.text();
+ return resp.text();
})
.then(
function(body) {
- self.content = R.join(" ")(R.repeat(body, 20));
+ if (body === "false") {
+ self.nomore = true;
+ }
+ else {
+ self.content = R.join(" ")(R.repeat(body, 20));
+ }
+
+ self.loading = false;
+ self.prevloading = "";
+ self.nextloading = "";
self.update();
});
}
diff --git a/styles/blog.min.css b/styles/blog.min.css
index 7fee167..e69de29 100644
--- a/styles/blog.min.css
+++ b/styles/blog.min.css
@@ -1,10 +0,0 @@
-.post-text, .blog-title, .post {
- text-align: center; }
-
-.post-content {
- max-width: 50%;
- text-align: justify; }
-
-.comments {
- margin-top: 5%;
- max-width: 30%; }
diff --git a/tags/bbutton.tag b/tags/bbutton.tag
new file mode 100644
index 0000000..275c2c6
--- /dev/null
+++ b/tags/bbutton.tag
@@ -0,0 +1,4 @@
+
+
+
diff --git a/tags/comment.tag b/tags/comment.tag
new file mode 100644
index 0000000..0c1f13f
--- /dev/null
+++ b/tags/comment.tag
@@ -0,0 +1,12 @@
+
+
+
diff --git a/tags/comments.tag b/tags/comments.tag
index d4303f7..604121a 100644
--- a/tags/comments.tag
+++ b/tags/comments.tag
@@ -1,8 +1,103 @@
-
diff --git a/tags/post.tag b/tags/post.tag
index a344cd8..a357017 100644
--- a/tags/post.tag
+++ b/tags/post.tag
@@ -1,21 +1,39 @@
-
+
+
+
+
+
+
{ opts.title }
By { opts.creator }
{ content }
-
+
+
+
-
-
{title} by {author}