~sircmpwn/hnstats

b7c5187db705e6c26fcda0c9c592d44b3521fb48 — Drew DeVault 6 years ago dd48beb
Add title-changes page
3 files changed, 41 insertions(+), 0 deletions(-)

M app.py
M templates/index.html
A templates/title-changes.html
M app.py => app.py +14 -0
@@ 50,6 50,20 @@ def post_json(post_id):
        abort(404)
    return Response(article_json(article), mimetype='application/json')

@app.route("/title-changes")
def title_changes():
    start = (request.args.get("start") or 0) * 25
    results = TitleChange.query\
            .order_by(TitleChange.id.desc()) \
            .offset(start) \
            .limit(26) \
            .all()
    return render_template("title-changes.html",
            url="/title-changes",
            title_changes=results[:25],
            end=len(results) < 26,
            start=start // 25)

@app.route("/deleted-10")
def deleted_10():
    start = (request.args.get("start") or 0) * 25

M templates/index.html => templates/index.html +1 -0
@@ 49,6 49,7 @@
    {% endfor %}
  </tbody>
</table>
<a href="/title-changes">View more <i class="fa fa-caret-right"></i></a>
<h3>Recent URL changes</h3>
<table>
  <tbody>

A templates/title-changes.html => templates/title-changes.html +26 -0
@@ 0,0 1,26 @@
{% extends "layout.html" %}
{% block content %}
<h3>Title changes</h3>
<table>
  <tbody>
    {% for change in title_changes %}
    <tr>
      <td>
        <a href="/post/{{ change.article_id }}">
          {{ change.article_id }}
        </a>
      </td>
      <td>{{ change.previous_title }}</td>
      <td style="width: 32px; vertical-align: middle;"><i class="fa fa-arrow-right"></i></td>
      <td>{{ change.updated_title }}</td>
    </tr>
    {% endfor %}
  </tbody>
</table>
{% if start != 0 %}
<a href="{{ url }}?start={{ start - 1 }}"><i class="fa fa-caret-left"></i> Previous</a>
{% endif %}
{% if not end %}
<a href="{{ url }}?start={{ start + 1 }}" class="pull-right">Next <i class="fa fa-caret-right"></i></a>
{% endif %}
{% endblock %}