Move brand names to g, basic queue page
This commit is contained in:
parent
d034d8e989
commit
245377b17a
6 changed files with 54 additions and 22 deletions
|
@ -1,5 +1,5 @@
|
||||||
import os
|
import os
|
||||||
from flask import Flask
|
from flask import Flask, g
|
||||||
from flask.ext.sqlalchemy import SQLAlchemy
|
from flask.ext.sqlalchemy import SQLAlchemy
|
||||||
from . import config, log
|
from . import config, log
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% if title %}
|
{% if title %}
|
||||||
<title>{{ title }} - {{ appname }}</title>
|
<title>{{ title }} - {{ g.appname }}</title>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
|
@ -20,7 +20,7 @@
|
||||||
<div class="container" style="height:50%">
|
<div class="container" style="height:50%">
|
||||||
<nav class="navbar navbar-default navbar-upper">
|
<nav class="navbar navbar-default navbar-upper">
|
||||||
<div class="navbar-header">
|
<div class="navbar-header">
|
||||||
<a class="navbar-brand navbar-brand-upper" href="">{{ appbrand }}</a>
|
<a class="navbar-brand navbar-brand-upper" href="">{{ g.appbrand }}</a>
|
||||||
</div>
|
</div>
|
||||||
</nav>
|
</nav>
|
||||||
<nav class="navbar navbar-static-top navbar-lower">
|
<nav class="navbar navbar-static-top navbar-lower">
|
||||||
|
@ -31,6 +31,9 @@
|
||||||
<li> <a href="/tags">Tags</a> </li>
|
<li> <a href="/tags">Tags</a> </li>
|
||||||
<li> <a href="/add">Add new</a> </li>
|
<li> <a href="/add">Add new</a> </li>
|
||||||
<li> <a href="/login">Log in</a> </li>
|
<li> <a href="/login">Log in</a> </li>
|
||||||
|
{% if session.authorized %}
|
||||||
|
<li> <a href="/queue">Queue</a> </li>
|
||||||
|
{% endif %}
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
<ul class="nav navbar-nav navbar-right">
|
<ul class="nav navbar-nav navbar-right">
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
{% extends "base.html" %}
|
{% extends "base.html" %}
|
||||||
{% block content %}
|
{% block content %}
|
||||||
|
|
||||||
{% if authorized %}
|
{% if session.authorized %}
|
||||||
|
|
||||||
<center>
|
<center>
|
||||||
<h3><br />Authorization key accepted<br /><br />Access granted</h3>
|
<h3><br />Authorization key accepted<br /><br />Access granted</h3>
|
||||||
|
|
23
smash/templates/queue.html
Normal file
23
smash/templates/queue.html
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
{% extends "base.html" %}
|
||||||
|
{% block content %}
|
||||||
|
|
||||||
|
{% if quotes %}
|
||||||
|
{% for quote in quotes %}
|
||||||
|
<a class="quote-link" href="quote/{{ quote.id }}">#{{ quote.id }}</a>
|
||||||
|
<a class="rate-positive">+</a> ({{quote.rating}}) <a class="rate-negative">-</a></br>
|
||||||
|
<div class="quote">
|
||||||
|
<p>{{ quote.content|safe }}</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="tags">
|
||||||
|
|
||||||
|
Tags:
|
||||||
|
{% for tag in quote.tags %}
|
||||||
|
<a href="tag/{{tag.name}}" class="badge"> {{tag.name}} </a>
|
||||||
|
{% endfor %}
|
||||||
|
|
||||||
|
</div>
|
||||||
|
{% endfor %}
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
{% endblock %}
|
|
@ -2,7 +2,7 @@
|
||||||
{% block content %}
|
{% block content %}
|
||||||
|
|
||||||
{% for tag in tags %}
|
{% for tag in tags %}
|
||||||
<a class="badge">{{tag}}</a><br />
|
<a class="badge">{{tag.name}}</a><br />
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import datetime
|
import datetime
|
||||||
import logging
|
import logging
|
||||||
import psycopg2
|
import psycopg2
|
||||||
from flask import render_template, Markup, request, abort, session
|
from flask import render_template, Markup, request, abort, session, g
|
||||||
|
|
||||||
from smash.models_sqlalchemy import *
|
from smash.models_sqlalchemy import *
|
||||||
from smash import app, conf, db
|
from smash import app, conf, db
|
||||||
|
@ -13,6 +13,12 @@ def timestamp():
|
||||||
return datetime.datetime.now().strftime("%H:%M:%S %d/%m/%y")
|
return datetime.datetime.now().strftime("%H:%M:%S %d/%m/%y")
|
||||||
|
|
||||||
|
|
||||||
|
@app.before_request
|
||||||
|
def before_request():
|
||||||
|
g.appname = conf.config['APPNAME']
|
||||||
|
g.appbrand = conf.config['APPBRAND']
|
||||||
|
|
||||||
|
|
||||||
@app.route('/')
|
@app.route('/')
|
||||||
def index():
|
def index():
|
||||||
welcome = "<p>Welcome to the quote archive.</p>"
|
welcome = "<p>Welcome to the quote archive.</p>"
|
||||||
|
@ -24,8 +30,6 @@ def index():
|
||||||
|
|
||||||
return render_template(
|
return render_template(
|
||||||
"index.html",
|
"index.html",
|
||||||
appname=conf.config['APPNAME'],
|
|
||||||
appbrand=conf.config['APPBRAND'],
|
|
||||||
title="Quotes",
|
title="Quotes",
|
||||||
welcometext=welcome,
|
welcometext=welcome,
|
||||||
newstext=news
|
newstext=news
|
||||||
|
@ -40,9 +44,6 @@ def login_page():
|
||||||
|
|
||||||
return render_template(
|
return render_template(
|
||||||
"login.html",
|
"login.html",
|
||||||
authorized=session.get('authorized', None),
|
|
||||||
appname=conf.config['APPNAME'],
|
|
||||||
appbrand=conf.config['APPBRAND']
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@ -56,13 +57,26 @@ def latest():
|
||||||
|
|
||||||
return render_template(
|
return render_template(
|
||||||
"latest.html",
|
"latest.html",
|
||||||
appname=conf.config['APPNAME'],
|
|
||||||
appbrand=conf.config['APPBRAND'],
|
|
||||||
title="Latest",
|
title="Latest",
|
||||||
quotes=quotes
|
quotes=quotes
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@app.route('/queue')
|
||||||
|
def queue():
|
||||||
|
quotes = Quote.query.filter_by(approved=False).order_by(Quote.id).all()
|
||||||
|
|
||||||
|
# Replace line breaks with html breaks and escape special characters
|
||||||
|
for quote in quotes:
|
||||||
|
quote.content = str(Markup.escape(quote.content)).replace('\n', '</br>')
|
||||||
|
|
||||||
|
return render_template(
|
||||||
|
"queue.html",
|
||||||
|
title="Queue",
|
||||||
|
quotes=quotes
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
@app.route('/quote/<int:id>')
|
@app.route('/quote/<int:id>')
|
||||||
def quote(id):
|
def quote(id):
|
||||||
quote = Quote.query.filter_by(id=id, approved=True).first()
|
quote = Quote.query.filter_by(id=id, approved=True).first()
|
||||||
|
@ -77,8 +91,6 @@ def quote(id):
|
||||||
quote.content = str(Markup.escape(quote.content)).replace('\n', '</br>')
|
quote.content = str(Markup.escape(quote.content)).replace('\n', '</br>')
|
||||||
return render_template(
|
return render_template(
|
||||||
"latest.html",
|
"latest.html",
|
||||||
appname=conf.config['APPNAME'],
|
|
||||||
appbrand=conf.config['APPBRAND'],
|
|
||||||
title="Quote #{}".format(quote.id),
|
title="Quote #{}".format(quote.id),
|
||||||
quotes=[quote,]
|
quotes=[quote,]
|
||||||
)
|
)
|
||||||
|
@ -86,12 +98,10 @@ def quote(id):
|
||||||
|
|
||||||
@app.route('/tags')
|
@app.route('/tags')
|
||||||
def tags():
|
def tags():
|
||||||
tags = [x[0] for x in db.select("tags", "name")]
|
tags = Tag.query.order_by(Tag.name).all()
|
||||||
|
|
||||||
return render_template(
|
return render_template(
|
||||||
"tags.html",
|
"tags.html",
|
||||||
appname=conf.config['APPNAME'],
|
|
||||||
appbrand=conf.config['APPBRAND'],
|
|
||||||
title="Tags",
|
title="Tags",
|
||||||
tags=tags
|
tags=tags
|
||||||
)
|
)
|
||||||
|
@ -126,8 +136,6 @@ def add_new():
|
||||||
|
|
||||||
return render_template(
|
return render_template(
|
||||||
"message.html",
|
"message.html",
|
||||||
appname=conf.config['APPNAME'],
|
|
||||||
appbrand=conf.config['APPBRAND'],
|
|
||||||
alertclass="alert-success",
|
alertclass="alert-success",
|
||||||
message="Quote added succesfully. It will need to be reviewed by the administrators before it shows up."
|
message="Quote added succesfully. It will need to be reviewed by the administrators before it shows up."
|
||||||
)
|
)
|
||||||
|
@ -140,7 +148,5 @@ def add_new():
|
||||||
elif request.method == 'GET':
|
elif request.method == 'GET':
|
||||||
return render_template(
|
return render_template(
|
||||||
"add.html",
|
"add.html",
|
||||||
appname=conf.config['APPNAME'],
|
|
||||||
appbrand=conf.config['APPBRAND'],
|
|
||||||
title="Add new"
|
title="Add new"
|
||||||
)
|
)
|
||||||
|
|
Loading…
Add table
Reference in a new issue