Progress with quote view
This commit is contained in:
parent
9e988edb82
commit
02adb46e58
2 changed files with 29 additions and 5 deletions
|
@ -6,8 +6,19 @@
|
|||
<a class="quote-link" href="quote/{{ quote[0] }}">#{{ quote[0] }}</a>
|
||||
<a class="rate-positive">+</a> ({{quote[1]}}) <a class="rate-negative">-</a></br>
|
||||
<div class="quote">
|
||||
{{ quote[2]|safe }}</br></br></br>
|
||||
<p>{{ quote[2]|safe }}</p>
|
||||
</div>
|
||||
|
||||
<div class="tags">
|
||||
|
||||
Tags:
|
||||
{% for tag in quote[3] %}
|
||||
<a href="#" class="badge"> {{tag}} </a>
|
||||
{% endfor %}
|
||||
|
||||
</div>
|
||||
|
||||
</br> </br>
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
|
||||
|
|
|
@ -1,8 +1,11 @@
|
|||
import datetime
|
||||
from flask import render_template
|
||||
import logging
|
||||
from flask import render_template, Markup
|
||||
|
||||
from smash import app, conf, db
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
@app.route('/')
|
||||
def index():
|
||||
|
@ -27,7 +30,7 @@ def index():
|
|||
@app.route('/latest')
|
||||
def latest():
|
||||
quotes = reversed(db.select("quotes", "id, rating, content"))
|
||||
quotes = [(q[0], q[1], q[2].replace('<', '<').replace('>', '>').replace('\n', '</br>')) for q in quotes]
|
||||
quotes = [(q[0], q[1], bytes(Markup.escape(q[2]), 'utf-8').decode('utf-8').replace('\n', '</br>')) for q in quotes]
|
||||
|
||||
return render_template(
|
||||
"latest.html",
|
||||
|
@ -44,11 +47,18 @@ def quote(id):
|
|||
if len(quote)<1:
|
||||
return "No such quote."
|
||||
else:
|
||||
|
||||
tags = db.select("tagsToQuotes", "tagid", "quoteid='{}'".format(quote[0][0]))
|
||||
tags_str = []
|
||||
for tag in tags:
|
||||
tags_str.append(db.select("tags", "name", "id='{}'".format(tag[0]))[0][0])
|
||||
|
||||
quote = [
|
||||
(
|
||||
quote[0][0],
|
||||
quote[0][1],
|
||||
quote[0][2],replace('<', '<').replace('>', '>').replace('\n', '</br>')
|
||||
bytes(Markup.escape(quote[0][2]), 'utf-8').decode('utf-8').replace('\n', '</br>'),
|
||||
tags_str
|
||||
)
|
||||
]
|
||||
return render_template(
|
||||
|
@ -72,4 +82,7 @@ def tags():
|
|||
|
||||
@app.route('/search', methods=['POST'])
|
||||
def search():
|
||||
pass
|
||||
if request.method == 'POST':
|
||||
return 'success'
|
||||
else:
|
||||
return 'Invalid request.'
|
||||
|
|
Loading…
Add table
Reference in a new issue