Browse Source

update patch and other misc fixes

pull/1/head
wes 7 years ago
parent
commit
d691805530
  1. 12
      build/requirements.txt
  2. 4
      build/scripts/tags.min.js
  3. 8
      build/templates/index.html
  4. 21
      build/website.py
  5. 20
      fabfile.py
  6. 2
      requirements.txt
  7. 2
      src/tags/comments.tag
  8. 2
      src/tags/post.tag
  9. 8
      src/templates/index.html
  10. 21
      src/website.py

12
build/requirements.txt

@ -0,0 +1,12 @@
appdirs==1.4.0
click==6.7
Flask==0.12
flask-appconfig==0.11.1
itsdangerous==0.24
Jinja2==2.9.5
MarkupSafe==0.23
packaging==16.8
pyparsing==2.1.10
python-memcached==1.58
six==1.10.0
Werkzeug==0.11.15

4
build/scripts/tags.min.js

@ -57,7 +57,7 @@ this.echo = function(ev) {
var self = this;
this.getComments = function(pid) {
fetch("/comments/"+pid)
fetch("/blog/comments/"+pid)
.then(
function(resp) {
return resp.text();
@ -122,7 +122,7 @@ this.next = function() {
this.setPost = function(pid) {
self.update();
self.loading = true;
fetch("/switchpost/"+pid)
fetch("/blog/switchpost/"+pid)
.then(
function(resp) {
return resp.text();

8
build/templates/index.html

@ -24,8 +24,8 @@
{% block styles %}
<link rel="stylesheet" href="/styles/spectre.min.css">
<link rel="stylesheet" href="/styles/riotblog.min.css">
<link rel="stylesheet" href="/blog/styles/spectre.min.css">
<link rel="stylesheet" href="/blog/styles/riotblog.min.css">
{% endblock %}
@ -34,8 +34,8 @@
<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="/scripts/tags.min.js"></script>
<script type="text/javascript" src="/scripts/riotblog.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>
{% endblock %}
</body>

21
build/website.py

@ -39,21 +39,21 @@ def NeverWhere(configfile=None):
#return send_from_directory("/srv/http/goal/favicon.ico",
#'favicon.ico', mimetype='image/vnd.microsoft.icon')
@app.route("/", methods=("GET", "POST"))
@app.route("/blog/", methods=("GET", "POST"))
def index():
print("matched index")
return render_template("index.html")
@app.route("/scripts/<filename>", methods=("GET", "POST"))
@app.route("/blog/scripts/<filename>", methods=("GET", "POST"))
def send_script(filename):
print("matched scripts route")
return send_from_directory("./scripts", filename)
return send_from_directory("/srv/http/riotblog/scripts", filename)
@app.route("/styles/<filename>", methods=("GET", "POST"))
@app.route("/blog/styles/<filename>", methods=("GET", "POST"))
def send_style(filename):
return send_from_directory("./styles", filename)
return send_from_directory("/srv/http/riotblog/styles", filename)
@app.route("/switchpost/<pid>")
@app.route("/blog/switchpost/<pid>")
def switchPost(pid):
posts = {
"1" : "Post one is changed! ",
@ -62,7 +62,7 @@ def NeverWhere(configfile=None):
return posts.get(pid, "false")
@app.route("/comments/<pid>")
@app.route("/blog/comments/<pid>")
def comments(pid):
sleep(5);
try:
@ -71,7 +71,7 @@ def NeverWhere(configfile=None):
print(e)
return dumps([])
@app.route("/insert/<pid>")
@app.route("/blog/insert/<pid>")
def insert(pid):
print("inserting new post")
@ -79,10 +79,9 @@ def NeverWhere(configfile=None):
def page_not_found(path):
return "Custom failure message"
app.run(debug=True)
return app
app = NeverWhere()
if __name__ == "__main__":
NeverWhere("./appconfig").run(host="localhost", port=8001, debug=True)
#if __name__ == "__main__":
#NeverWhere("./appconfig").run(host="localhost", port=8001, debug=True)

20
fabfile.py

@ -23,26 +23,32 @@ def minifyJS():
@task
def buildVenv():
local("virtualenv -p $(which python3) ./venv")
with prefix("source ./venv/bin/activate"):
local("pip3 install -r requirements.txt")
local("mv venv ./build/")
with cd("~/build"):
run("virtualenv -p $(which python3) ~/build/venv")
with prefix("source ~/build/venv/bin/activate"):
run("pip3 install -r requirements.txt")
@task
def copyFiles():
local("cp ./{blog.ini,blog.service} ./build/")
local("cp ./{blog.ini,blog.service,requirements.txt} ./build/")
local("cp ./src/*py ./build/")
local("cp ./src/styles/*.css ./build/styles/")
local("cp -r ./src/templates ./build/templates")
@task
def upload():
run("rm -r ~/build")
run("mkdir -p ~/build")
rsync_project(local_dir="./build/", remote_dir="~/build/", delete=True, exclude=[".git"])
@task
def serveUp():
sudo("cp -r /home/wes/build /srv/riotblog")
sudo("rm -r /srv/http/riotblog")
sudo("cp -r /home/wes/build /srv/http/riotblog")
sudo("cp /home/wes/build/blog.service /etc/systemd/system/blog.service")
sudo("systemctl daemon-reload")
sudo("systemctl enable blog.service")
sudo("systemctl restart blog.service")
@task(default=True)
def build():
@ -51,7 +57,7 @@ def build():
buildTags()
buildScss()
minifyJS()
buildVenv()
copyFiles()
upload()
buildVenv()
serveUp()

2
requirements.txt

@ -1,10 +1,12 @@
appdirs==1.4.0
click==6.7
Flask==0.12
flask-appconfig==0.11.1
itsdangerous==0.24
Jinja2==2.9.5
MarkupSafe==0.23
packaging==16.8
pyparsing==2.1.10
python-memcached==1.58
six==1.10.0
Werkzeug==0.11.15

2
src/tags/comments.tag

@ -78,7 +78,7 @@ echo(ev) {
var self = this;
getComments(pid) {
fetch("/comments/"+pid)
fetch("/blog/comments/"+pid)
.then(
function(resp) {
return resp.text();

2
src/tags/post.tag

@ -61,7 +61,7 @@ next() {
this.setPost = function(pid) {
self.update();
self.loading = true;
fetch("/switchpost/"+pid)
fetch("/blog/switchpost/"+pid)
.then(
function(resp) {
return resp.text();

8
src/templates/index.html

@ -24,8 +24,8 @@
{% block styles %}
<link rel="stylesheet" href="/styles/spectre.min.css">
<link rel="stylesheet" href="/styles/riotblog.min.css">
<link rel="stylesheet" href="/blog/styles/spectre.min.css">
<link rel="stylesheet" href="/blog/styles/riotblog.min.css">
{% endblock %}
@ -34,8 +34,8 @@
<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="/scripts/tags.min.js"></script>
<script type="text/javascript" src="/scripts/riotblog.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>
{% endblock %}
</body>

21
src/website.py

@ -39,21 +39,21 @@ def NeverWhere(configfile=None):
#return send_from_directory("/srv/http/goal/favicon.ico",
#'favicon.ico', mimetype='image/vnd.microsoft.icon')
@app.route("/", methods=("GET", "POST"))
@app.route("/blog/", methods=("GET", "POST"))
def index():
print("matched index")
return render_template("index.html")
@app.route("/scripts/<filename>", methods=("GET", "POST"))
@app.route("/blog/scripts/<filename>", methods=("GET", "POST"))
def send_script(filename):
print("matched scripts route")
return send_from_directory("./scripts", filename)
return send_from_directory("/srv/http/riotblog/scripts", filename)
@app.route("/styles/<filename>", methods=("GET", "POST"))
@app.route("/blog/styles/<filename>", methods=("GET", "POST"))
def send_style(filename):
return send_from_directory("./styles", filename)
return send_from_directory("/srv/http/riotblog/styles", filename)
@app.route("/switchpost/<pid>")
@app.route("/blog/switchpost/<pid>")
def switchPost(pid):
posts = {
"1" : "Post one is changed! ",
@ -62,7 +62,7 @@ def NeverWhere(configfile=None):
return posts.get(pid, "false")
@app.route("/comments/<pid>")
@app.route("/blog/comments/<pid>")
def comments(pid):
sleep(5);
try:
@ -71,7 +71,7 @@ def NeverWhere(configfile=None):
print(e)
return dumps([])
@app.route("/insert/<pid>")
@app.route("/blog/insert/<pid>")
def insert(pid):
print("inserting new post")
@ -79,10 +79,9 @@ def NeverWhere(configfile=None):
def page_not_found(path):
return "Custom failure message"
app.run(debug=True)
return app
app = NeverWhere()
if __name__ == "__main__":
NeverWhere("./appconfig").run(host="localhost", port=8001, debug=True)
#if __name__ == "__main__":
#NeverWhere("./appconfig").run(host="localhost", port=8001, debug=True)

Loading…
Cancel
Save