Browse Source

updates

pull/1/head
wes 8 years ago
parent
commit
e05c5e8121
  1. 3
      fabfile.py
  2. 20
      src/comment.py
  3. 9
      src/scripts/comment.tag
  4. 23
      src/scripts/comments.tag
  5. 14
      src/scripts/decision.tag
  6. 8
      src/scripts/post.tag
  7. 5
      src/scripts/riotblog.js
  8. 6
      src/styles/riotblog.scss
  9. 2
      src/styles/spectre.min.css
  10. 19
      src/templates/decisions.html
  11. 2
      src/templates/index.html
  12. 8
      src/templates/write.html
  13. 11
      src/website.py

3
fabfile.py

@ -72,9 +72,10 @@ def update():
@task @task
def locbuild(): def locbuild():
local("rm -rf ./build")
local("mkdir -p build/{scripts,styles}") local("mkdir -p build/{scripts,styles}")
local("cp requirements.txt ./build/requirements.txt") local("cp requirements.txt ./build/requirements.txt")
#buildLocalVenv() buildLocalVenv()
buildScss() buildScss()
buildJS() buildJS()
copyFiles() copyFiles()

20
src/comment.py

@ -1,7 +1,13 @@
from json import dumps from json import dumps
def comment(author, title, text): from random import randint
from time import time
def comment(author, title, text, t):
return { return {
"time" : t,
"id" : randint(1,2**32-1),
"title" : title, "title" : title,
"author" : author, "author" : author,
"text" : text "text" : text
@ -11,14 +17,14 @@ def comment(author, title, text):
testcomments = { testcomments = {
1 : dumps( 1 : dumps(
[ [
comment("Anonymous Coward 0", "Some comment?", "super duper awesome comment here"), comment("Person 1", "Two", "A Comment here", 1),
comment("Anonymous Coward 1", "Something? IDEK", "super duper worse comment here"), comment("Person 2", "One", "Some other comment", 2),
comment("Anonymous Coward 2", "Some other comment?", "super duper dang terrible comment here") comment("Person 3", "Three", "My opinion is correct", 3)
]), ]),
2 : dumps( 2 : dumps(
[ [
comment("Anonymous Coward 3", "Some comment?", "super duper awesome comment here"), comment("Person 1", "Two", "A cool terrible Comment here", 1),
comment("Anonymous Coward 4", "Something? IDEK", "super duper worse comment here"), comment("Person 2", "One", "Some other awful comment", 2),
comment("Anonymous Coward 5", "Some other comment?", "super duper dang terrible comment here") comment("Person 3", "Three", "My opinion is not correct", 3)
]) ])
} }

9
src/scripts/comment.tag

@ -2,15 +2,16 @@
<div class="comment centered"> <div class="comment centered">
<div class="card"> <div class="card">
<div class="card-header"> <div class="card-header">
<h4 class="card-title">{title} by {author}</h4> <h4 class="card-title">Comment posted by {author}</h4>
</div> </div>
<div class="card-body comment-body"> <div class="card-body comment-body">
{R.join(" ")(R.repeat(text, 20))} { text }
</div> </div>
<button if={delete !== undefined} onclick={delete} class="btn">
Delete this comment
</button>
</div> </div>
</div> </div>
<script> <script>
import { default as R } from 'ramda';
this.R = R;
</script> </script>
</comment> </comment>

23
src/scripts/comments.tag

@ -1,6 +1,6 @@
<comments> <comments>
<div if={loading} class="loading comments-loader"></div> <div if={loading} class="loading comments-loader"></div>
<comment if={!loading} each={this.comments} data="{this}"></comment> <comment if={!loading} each={R.sortBy(R.prop("time"), R.values(this.comments))} data="{this}"></comment>
<textarea onfocus={clearplaceholder} <textarea onfocus={clearplaceholder}
onblur={checkplaceholder} onblur={checkplaceholder}
oninput={echo} oninput={echo}
@ -12,6 +12,9 @@
maxlength={this.maxlength}> maxlength={this.maxlength}>
{ placeholder } { placeholder }
</textarea> </textarea>
<button onclick={submit} class="btn comment-submit">
Submit Comment
</button>
<div if={this.warn} class="toast toast-danger maxwarn centered"> <div if={this.warn} class="toast toast-danger maxwarn centered">
<button <button
onclick={this.closewarning} onclick={this.closewarning}
@ -21,11 +24,13 @@
</div> </div>
<script> <script>
import 'whatwg-fetch'; import 'whatwg-fetch';
import { default as R } from 'ramda';
this.R = R;
this.comments = []; this.comments = [];
this.maxlength = 700; this.maxlength = 700;
this.placeholder = "Comment here!"; this.placeholder = "Comment on this post";
this.focused = false; this.focused = false;
this.maxed = ""; this.maxed = "";
this.warn = false; this.warn = false;
@ -80,14 +85,26 @@ getComments(pid) {
}) })
.then( .then(
function(body) { function(body) {
var parsed =JSON.parse(body);
parsed.map(function(comment) { self.comments[comment["id"]] = comment; } );
self.update();
self.update( self.update(
{ {
"comments" : JSON.parse(body),
"loading" : false "loading" : false
}); });
}); });
} }
submit() {
var id = Math.random();
this.comments[id] = {
"author" : "name",
"text" : this.refs.textarea.value,
"delete" : (() => { delete self.comments[id]; self.update(); })
};
this.update();
}
this.on("mount", this.on("mount",
function() { function() {
this.getComments(self.opts.pid); this.getComments(self.opts.pid);

14
src/scripts/decision.tag

@ -0,0 +1,14 @@
<decision>
<h1 class="blog-title">IDK What this would do</h1>
<h2 class="blog-title">Complete the current step before moving ahead</h2>
<ul class="step">
<li each={steps} data={this} class={"step-item"+ (active ? " active" : "")}>
<a href="#" class="tooltip" data-tooltip={stepname}>{stepname}</a>
</li>
</ul>
<script>
this.steps = [];
</script>
</decision>

8
src/scripts/post.tag

@ -10,8 +10,10 @@
<div if={!(this.loading || this.nomore)} class="post centered"> <div if={!(this.loading || this.nomore)} class="post centered">
<h4>{ opts.title }</h4> <h4>{ opts.title }</h4>
<h5>By { opts.creator }</h5> <h5>Posted by { opts.creator }</h5>
<p class="post-content centered text-break">{ this.content }</p> <p class="post-content centered text-break">
{ this.content }
</p>
<div class="divider"></div> <div class="divider"></div>
<comments pid={this.pid}> <comments pid={this.pid}>
@ -76,7 +78,7 @@ setPost(pid) {
self.update() self.update()
} }
else { else {
self.content = R.join(" ")(R.repeat(body, 20)); self.content = body;
route(`/${pid}`); route(`/${pid}`);
} }

5
src/scripts/riotblog.js

@ -4,11 +4,12 @@ import './comment.tag';
import './bbutton.tag'; import './bbutton.tag';
import './post.tag'; import './post.tag';
import './posts.tag'; import './posts.tag';
import "./decision.tag";
riot.mount("post", riot.mount("post",
{ {
"creator" : "wes", "creator" : "author"
"title" : "A cool post here"
}); });
riot.mount("decision");
riot.mount("bbutton"); riot.mount("bbutton");

6
src/styles/riotblog.scss

@ -1,7 +1,11 @@
.post-text, .blog-title, .post, .postnav { .post-text, .ltb-title, .post, .postnav {
text-align: center; text-align: center;
} }
.comment-submit {
margin-top: 10px;
}
.post-content { .post-content {
max-width: 50%; max-width: 50%;
text-align: justify; text-align: justify;

2
src/styles/spectre.min.css

File diff suppressed because one or more lines are too long

19
src/templates/decisions.html

@ -0,0 +1,19 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
<meta name="viewport" content="width=device-width, initial-scale=1">
<header class="text-center nav navbar">
<section class="centered page-top navbar-section">
</section>
</header>
<html>
<body>
<decision>
</decision>
<footer class="footer">
</footer>
<link rel="stylesheet" href="/blog/styles/spectre.min.css">
<link rel="stylesheet" href="/blog/styles/blog.min.css">
<script type="text/javascript" src="/blog/scripts/blog.min.js"></script>
</body>
</html>

2
src/templates/index.html

@ -2,7 +2,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1"> <meta name="viewport" content="width=device-width, initial-scale=1">
<header class="text-center nav navbar"> <header class="text-center nav navbar">
<section class="centered page-top navbar-section"> <section class="centered page-top navbar-section">
<h1 class="blog-title">nowhere</h1> <h1 class="blog-title">blog title</h1>
</section> </section>
</header> </header>

8
src/templates/write.html

@ -22,17 +22,13 @@
{% block styles %} {% block styles %}
<link rel="stylesheet" href="/blog/styles/spectre.min.css"> <link rel="stylesheet" href="/blog/styles/spectre.min.css">
<link rel="stylesheet" href="/blog/styles/riotblog.min.css"> <link rel="stylesheet" href="/blog/styles/blog.min.css">
{% endblock %} {% endblock %}
{% block scripts %} {% block scripts %}
<script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/fetch/1.0.0/fetch.min.js"></script>
<script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/ramda/0.22.1/ramda.min.js"></script>
<script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/riot/2.6.7/riot+compiler.min.js"></script>
<script type="text/javascript" src="//cdn.jsdelivr.net/riot-route/3.0.2/route.min.js"></script>
<script type="text/javascript" src="/blog/scripts/tags.min.js"></script> <script type="text/javascript" src="/blog/scripts/tags.min.js"></script>
<script type="text/javascript" src="/blog/scripts/riotblog.min.js"></script> <script type="text/javascript" src="/blog/scripts/blog.min.js"></script>
{% endblock %} {% endblock %}
</body> </body>

11
src/website.py

@ -17,7 +17,7 @@ cache = MemcachedCache(['127.0.0.1:11211'])
import os import os
from posts import Posts from posts import Posts
posts = Posts() #posts = Posts()
def cacheit(key, thunk): def cacheit(key, thunk):
""" """
@ -43,6 +43,11 @@ def NeverWhere(configfile=None):
#return send_from_directory("/srv/http/goal/favicon.ico", #return send_from_directory("/srv/http/goal/favicon.ico",
#'favicon.ico', mimetype='image/vnd.microsoft.icon') #'favicon.ico', mimetype='image/vnd.microsoft.icon')
@app.route("/blog/decision/", methods=("GET", "POST"))
def decision():
print("matched decision")
return render_template("decisions.html")
@app.route("/blog/", methods=("GET", "POST")) @app.route("/blog/", methods=("GET", "POST"))
def index(): def index():
print("matched index") print("matched index")
@ -60,8 +65,8 @@ def NeverWhere(configfile=None):
@app.route("/blog/switchpost/<pid>") @app.route("/blog/switchpost/<pid>")
def switchPost(pid): def switchPost(pid):
posts = { posts = {
"1" : "Post one is now changed as before! ", "1" : "post 1",
"2" : "Post two here and it's changed again and again! " "2" : "post 2"
} }
return posts.get(pid, "false") return posts.get(pid, "false")

Loading…
Cancel
Save