Browse Source

first commit

pull/1/head
wes 8 years ago
parent
commit
aa9f512c1c
  1. 6
      Makefile
  2. 21
      blog.scss
  3. 5
      scripts/blog.js
  4. 41
      scripts/tags.js
  5. 10
      styles/blog.min.css
  6. 1
      styles/spectre.min.css
  7. 8
      tags/comments.tag
  8. 48
      tags/post.tag
  9. 3
      tags/posts.tag
  10. 23
      templates/index.html
  11. 37
      website.py

6
Makefile

@ -0,0 +1,6 @@
default:
sass blog.scss > styles/blog.min.css
riot tags/ scripts/tags.js
watch:
while true; do make ; inotifywait -qre close_write .; done

21
blog.scss

@ -0,0 +1,21 @@
.post-text {
text-align: center;
}
.blog-title {
@extend .post-text;
}
.post {
@extend .post-text;
}
.post-content {
max-width: 50%;
text-align: justify;
}
.comments {
margin-top: 5%;
max-width: 30%;
}

5
scripts/blog.js

@ -0,0 +1,5 @@
riot.mount("post",
{
"creator" : "wes",
"title" : "A cool post here"
});

41
scripts/tags.js

@ -0,0 +1,41 @@
riot.tag2('comments', '<textarea class="form-input comments centered" name="textarea" rows="10" cols="50"> Comment here! </textarea>', '', '', function(opts) {
});
riot.tag2('post', '<div class="post centered"> <h4>{opts.title}</h4> <h5>By {opts.creator}</h5> <p class="post-content centered text-break">{content}</p> <comments> </comments> <button onclick="{prev}">Previous Post</button> <button onclick="{next}">Next Post</button> </div>', '', '', function(opts) {
var self = this;
this.pid = 1;
content = "";
this.prev = function() {
if (self.pid > 0) {
self.pid--;
self.setPost(self.pid);
self.update();
}
}.bind(this)
this.next = function() {
self.pid++;
self.setPost(self.pid);
self.update();
}.bind(this)
this.setPost = function(pid) {
fetch("/switchpost/"+pid)
.then(
function(resp) {
return resp.text();
})
.then(
function(body) {
self.content = R.join(" ")(R.repeat(body, 20));
self.update();
});
}
this.on("mount", function() { this.setPost(self.pid) });
});
riot.tag2('posts', '<yield></yield>', '', '', function(opts) {
});

10
styles/blog.min.css

@ -0,0 +1,10 @@
.post-text, .blog-title, .post {
text-align: center; }
.post-content {
max-width: 50%;
text-align: justify; }
.comments {
margin-top: 5%;
max-width: 30%; }

1
styles/spectre.min.css

File diff suppressed because one or more lines are too long

8
tags/comments.tag

@ -0,0 +1,8 @@
<comments>
<textarea class="form-input comments centered"
name="textarea"
rows="10"
cols="50">
Comment here!
</textarea>
</comments>

48
tags/post.tag

@ -0,0 +1,48 @@
<post>
<div class="post centered">
<h4>{ opts.title }</h4>
<h5>By { opts.creator }</h5>
<p class="post-content centered text-break">{ content }</p>
<comments>
</comments>
<button onclick={prev}>Previous Post</button>
<button onclick={next}>Next Post</button>
</div>
<script>
var self = this;
this.pid = 1;
content = "";
prev() {
if (self.pid > 0) {
self.pid--;
self.setPost(self.pid);
self.update();
}
}
next() {
self.pid++;
self.setPost(self.pid);
self.update();
}
this.setPost = function(pid) {
fetch("/switchpost/"+pid)
.then(
function(resp) {
return resp.text();
})
.then(
function(body) {
self.content = R.join(" ")(R.repeat(body, 20));
self.update();
});
}
this.on("mount", function() { this.setPost(self.pid) });
</script>
</post>

3
tags/posts.tag

@ -0,0 +1,3 @@
<posts>
<yield/>
</posts>

23
templates/index.html

@ -1,17 +1,8 @@
{% extends "bootstrap/base.html" %}
{% block head %}
{{super()}}
<meta name="viewport" content="width=device-width, initial-scale=1">
<header class="text-center nav navbar">
<section class="centered page-top navbar-section">
<div class="container">
<div class="columns">
<div class="title column col-md-9"><h1>blargh</h1></div>
<div class="logo column col-md-3">
</div>
</div>
</div>
<h1 class="blog-title">Neverwhere 1.5</h1>
</section>
</header>
{% endblock %}
@ -20,7 +11,9 @@
<body>
{% block content %}
<posts></posts>
<posts>
<post></post>
</posts>
{% endblock %}
@ -29,17 +22,17 @@
{% block styles %}
{{super()}}
<link rel="stylesheet" href="/styles/spectre.min.css">
<link rel="stylesheet" href="/styles/blog.min.css">
{% endblock %}
{% block scripts %}
{{super()}}
<script type="text/javascript" src="https://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="https://cdnjs.cloudflare.com/ajax/libs/riot/2.4.1/riot+compiler.min.js"></script>
<script type="text/javascript" src="/scripts/tags.min.js"></script>
<script type="text/javascript" src="/scripts/blog.min.js"></script>
<script type="text/javascript" src="/scripts/tags.js"></script>
<script type="text/javascript" src="/scripts/blog.js"></script>
{% endblock %}
</body>

37
website.py

@ -1,7 +1,7 @@
#! /usr/bin/python2
from functools import partial
from flask import Blueprint, abort, Flask, render_template, flash, request, send_from_directory
from flask import abort, Flask, render_template, flash, request, send_from_directory
from flask_bootstrap import Bootstrap
from flask_appconfig import AppConfig
@ -30,30 +30,43 @@ def cacheit(key, thunk):
return cached
def NeverWhere(configfile=None):
blueprint = Blueprint("NeverWhere",__name__, template_folder="templates")
@blueprint.route('/favicon.ico')
app = Flask(__name__)
app.config["TEMPLATES_AUTO_RELOAD"] = True
#def favicon():
#return send_from_directory("/srv/http/goal/favicon.ico",
#'favicon.ico', mimetype='image/vnd.microsoft.icon')
@blueprint.route("/", methods=("GET", "POST"))
@app.route("/", methods=("GET", "POST"))
def index():
print "matched index"
return render_template("index.html")
@blueprint.route("./scripts/<filename>")
@app.route("/scripts/<filename>", methods=("GET", "POST"))
def send_script(filename):
return send_from_directory(app.config["scripts"], filename)
print "matched scripts route"
return send_from_directory("/home/wes/riotblog/scripts/", filename)
@blueprint.route("./styles/<filename>")
@app.route("/styles/<filename>", methods=("GET", "POST"))
def send_style(filename):
return send_from_directory(app.config["styles"], filename)
return send_from_directory("./styles", filename)
@app.route("/switchpost/<pid>")
def switchPost(pid):
posts = {
"1" : "Post one! ",
"2" : "Post two! "
}
return posts.get(pid, "Nothing here!")
@app.route("/<path:path>")
def page_not_found(path):
return "Custom failure message"
app = Flask(__name__)
app.register_blueprint(blueprint, url_prefix="/")
Bootstrap(app)
app.config["scripts"] = "./scripts"
app.config["styles"] = "./styles"
app.run(debug=True)
return app
app = NeverWhere()

Loading…
Cancel
Save