10 changed files with 1 additions and 322 deletions
@ -1,17 +0,0 @@ |
|||
[uwsgi] |
|||
wsgi_file = /srv/http/riotblog/website.py |
|||
chdir = /srv/http/riotblog/ |
|||
module = website |
|||
callable = app |
|||
virtualenv = /srv/http/riotblog/venv |
|||
uid = http |
|||
gid = http |
|||
|
|||
master = true |
|||
processes = 5 |
|||
|
|||
socket = /tmp/blog.sock |
|||
chown-socket = http:http |
|||
chmod-socket = 660 |
|||
vacuum = true |
|||
die-on-term = true |
@ -1,13 +0,0 @@ |
|||
[Unit] |
|||
Description=My Blargh |
|||
After=network.target |
|||
|
|||
[Service] |
|||
User=http |
|||
Group=http |
|||
WorkingDirectory=/srv/http/riotblog |
|||
ExecStart=/usr/bin/uwsgi --ini /srv/http/riotblog/blog.ini |
|||
Environment="RIOTBLOG_SETTINGS=/srv/http/riotblog/riotblog_prod.cfg" |
|||
|
|||
[Install] |
|||
WantedBy=multi.user.target |
@ -1,28 +0,0 @@ |
|||
#! /usr/bin/python |
|||
|
|||
import couchdb |
|||
from flask import jsonify |
|||
from flask_marshmallow import Marshmallow |
|||
|
|||
class Posts: |
|||
def __init__(self, host=None, port=None): |
|||
if host is None: |
|||
host = "localhost" |
|||
if port is None: |
|||
port = "5984" |
|||
|
|||
self.client = couchdb.Server("http://%s:%s" % (host, port)) |
|||
|
|||
self.db = self.client["blog"] |
|||
|
|||
def savepost(self, title="", content="", author=""): |
|||
doc = { |
|||
"title" : title, |
|||
"content" : content, |
|||
"author" : author |
|||
} |
|||
return jsonify(self.db.save(doc)) |
|||
|
|||
def getposts(self, limit, start): |
|||
result = self.db.iterview("blogPosts/blog-posts", 10, include_docs=True, limit=limit, skip=start) |
|||
return jsonify(list(result)) |
@ -1,44 +0,0 @@ |
|||
appdirs==1.4.3 |
|||
cffi==1.9.1 |
|||
click==6.7 |
|||
CouchDB==1.1 |
|||
cryptography==1.7.2 |
|||
dominate==2.3.1 |
|||
elasticsearch==5.1.0 |
|||
elasticsearch-dsl==5.1.0 |
|||
Fabric==1.13.1 |
|||
Flask==0.12 |
|||
flask-appconfig==0.11.1 |
|||
Flask-Bootstrap==3.3.7.1 |
|||
Flask-Login==0.4.0 |
|||
flask-marshmallow==0.7.0 |
|||
Flask-WTF==0.14.2 |
|||
greenlet==0.4.12 |
|||
idna==2.2 |
|||
itsdangerous==0.24 |
|||
Jinja2==2.9.4 |
|||
lxml==3.7.2 |
|||
MarkupSafe==0.23 |
|||
marshmallow==2.13.5 |
|||
packaging==16.8 |
|||
paramiko==2.1.1 |
|||
pbr==1.10.0 |
|||
pyasn1==0.2.1 |
|||
pycparser==2.17 |
|||
pyparsing==2.2.0 |
|||
PySocks==1.6.6 |
|||
python-dateutil==2.6.0 |
|||
python-memcached==1.58 |
|||
pyxdg==0.25 |
|||
requests==2.13.0 |
|||
six==1.10.0 |
|||
stevedore==1.20.0 |
|||
urllib3==1.19.1 |
|||
uWSGI==2.0.14 |
|||
virtualenv==15.1.0 |
|||
virtualenv-clone==0.2.6 |
|||
virtualenvwrapper==4.7.2 |
|||
visitor==0.1.3 |
|||
Werkzeug==0.11.15 |
|||
WTForms==2.1 |
|||
youtube-dl==2017.1.28 |
File diff suppressed because one or more lines are too long
@ -1,70 +0,0 @@ |
|||
.post-text, .ltb-title, .post, .postnav { |
|||
text-align: center; } |
|||
|
|||
.navigate { |
|||
width: 20% !important; |
|||
margin-bottom: 25px !important; |
|||
margin: auto !important; } |
|||
|
|||
.navigate-tab { |
|||
border: thin solid; |
|||
border-radius: 5px !important; |
|||
margin-bottom: 5px; |
|||
margin-left: 2px; |
|||
margin-right: 2px; } |
|||
.navigate-tab:hover { |
|||
background-color: #5764c6; } |
|||
|
|||
.navigate-item:hover { |
|||
color: white !important; } |
|||
|
|||
.content-box, .projects-box, .posts-box { |
|||
margin-top: 10px; |
|||
display: flex !important; |
|||
/* defines flexbox */ |
|||
flex-direction: column !important; |
|||
/* top to bottom */ |
|||
justify-content: space-between !important; |
|||
/* first item at start, last at end */ |
|||
position: relative !important; } |
|||
|
|||
.projects-box { |
|||
height: 350px !important; } |
|||
|
|||
.posts-box { |
|||
height: 250px !important; } |
|||
|
|||
.content { |
|||
margin: auto; |
|||
max-width: 40%; } |
|||
@media (max-width: 1000px) { |
|||
.content { |
|||
max-width: 60%; } } |
|||
@media (max-width: 800px) { |
|||
.content { |
|||
max-width: 70%; } } |
|||
@media (max-width: 400px) { |
|||
.content { |
|||
max-width: 80%; } } |
|||
|
|||
.post-content { |
|||
max-width: 100%; |
|||
font-family: 'Open Sans',sans-serif; |
|||
font-size: 1.4em; |
|||
line-height: 1.6em; |
|||
color: #3A4145; } |
|||
|
|||
.rounded-button { |
|||
border-radius: 13px; } |
|||
|
|||
.maxinput { |
|||
background-color: grey; } |
|||
|
|||
.maxwarn { |
|||
margin-top: 15px; } |
|||
|
|||
.footer { |
|||
margin-top: 10%; } |
|||
|
|||
.editor { |
|||
height: 100% !important; } |
File diff suppressed because one or more lines are too long
@ -1,20 +0,0 @@ |
|||
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" |
|||
<meta name="viewport" content="width=device-width, initial-scale=1"> |
|||
<head> |
|||
<link rel="stylesheet" href="/styles/primop.me.min.css"> |
|||
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css"> |
|||
<meta name="viewport" content="width=device-width, initial-scale=1"> |
|||
</head> |
|||
<html> |
|||
<body> |
|||
<section class="text-center nav navbar centered page-top navbar-section"> |
|||
<h1 class="blog-title">Wesley Kerfoot</h1> |
|||
</section> |
|||
<app csrf_token="{{ csrf_token() }}"></app> |
|||
<footer class="footer"> |
|||
</footer> |
|||
|
|||
<script src="https://unpkg.com/axios/dist/axios.min.js"></script> |
|||
<script type="text/javascript" src="/scripts/riotblog.min.js"></script> |
|||
</body> |
|||
</html> |
@ -1,115 +0,0 @@ |
|||
#! /usr/bin/python3 |
|||
from functools import partial |
|||
|
|||
from flask import abort, Flask, render_template, flash, request, send_from_directory, jsonify |
|||
from werkzeug.local import Local, LocalProxy, LocalManager |
|||
from flask_appconfig import AppConfig |
|||
from flask_login import LoginManager, login_required |
|||
from flask_wtf.csrf import CSRFProtect |
|||
|
|||
from urllib.parse import unquote |
|||
from urllib.parse import quote, unquote |
|||
from json import dumps, loads |
|||
|
|||
from werkzeug.contrib.cache import MemcachedCache |
|||
cache = MemcachedCache(['127.0.0.1:11211']) |
|||
|
|||
import os |
|||
|
|||
from posts import Posts |
|||
from projects import getProjects |
|||
|
|||
posts = Posts() |
|||
login_manager = LoginManager() |
|||
|
|||
def cacheit(key, thunk): |
|||
""" |
|||
Tries to find a cached version of ``key'' |
|||
If there is no cached version then it will |
|||
evaluate thunk (which must be a generator) |
|||
and cache that, then return the result |
|||
""" |
|||
cached = cache.get(quote(key)) |
|||
if cached is None: |
|||
result = list(thunk()) |
|||
cache.set(quote(key), result) |
|||
return result |
|||
return cached |
|||
|
|||
def NeverWhere(configfile=None): |
|||
app = Flask(__name__) |
|||
app.config["TEMPLATES_AUTO_RELOAD"] = True |
|||
app.config["COUCHDB_SERVER"] = "http://localhost:5984" |
|||
app.config["COUCHDB_DATABASE"] = "blog" |
|||
#def favicon(): |
|||
#return send_from_directory("/srv/http/goal/favicon.ico", |
|||
#'favicon.ico', mimetype='image/vnd.microsoft.icon') |
|||
|
|||
@app.route("/blog/projects", methods=("GET",)) |
|||
def projects(): |
|||
return jsonify(cacheit("projects", getProjects)) |
|||
|
|||
@app.route("/blog/stuff", methods=("GET",)) |
|||
def stuff(): |
|||
return render_template("projects.html") |
|||
|
|||
@app.route("/blog/", methods=("GET", "POST")) |
|||
def index(): |
|||
print("matched index") |
|||
return render_template("index.html") |
|||
|
|||
@app.route("/blog/scripts/<filename>", methods=("GET", "POST")) |
|||
def send_script(filename): |
|||
print("matched scripts route") |
|||
return send_from_directory("/srv/http/riotblog/scripts", filename) |
|||
|
|||
@app.route("/blog/styles/<filename>", methods=("GET", "POST")) |
|||
def send_style(filename): |
|||
return send_from_directory("/srv/http/riotblog/styles", filename) |
|||
|
|||
@app.route("/blog/switchpost/<pid>") |
|||
def getposts(pid): |
|||
try: |
|||
index = int(pid) |
|||
except ValueError: |
|||
index = 0 |
|||
return posts.getposts(index+1, index) |
|||
|
|||
# editor routes |
|||
|
|||
@app.route("/blog/editor/", methods=("GET", "POST")) |
|||
@login_required |
|||
def editor(): |
|||
""" |
|||
View the post editor, requires auth |
|||
""" |
|||
return render_template("write.html") |
|||
|
|||
@app.route("/blog/insert/", methods=("POST",)) |
|||
@login_required |
|||
def insert(): |
|||
""" |
|||
Insert a post, requires auth |
|||
""" |
|||
return posts.savepost(**request.form) |
|||
|
|||
# default, not found error |
|||
|
|||
@app.route("/<path:path>") |
|||
def page_not_found(path): |
|||
return "Oops, couldn't find that :/" |
|||
|
|||
return app |
|||
|
|||
app = NeverWhere() |
|||
|
|||
app.config.from_envvar('RIOTBLOG_SETTINGS') |
|||
|
|||
login_manager.init_app(app) |
|||
|
|||
csrf = CSRFProtect() |
|||
|
|||
csrf.init_app(app) |
|||
|
|||
if __name__ == "__main__": |
|||
NeverWhere("./appconfig").run(host="localhost", port=8001, debug=True) |
Loading…
Reference in new issue