~sircmpwn/hnstats

00775ce3574dc4e382c83fb69b74a0acc5c994db — Drew DeVault 6 years ago cec4122
Add URL changes page
2 files changed, 40 insertions(+), 0 deletions(-)

M app.py
A templates/url-changes.html
M app.py => app.py +14 -0
@@ 64,6 64,20 @@ def title_changes():
            end=len(results) < 26,
            start=start // 25)

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

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

A templates/url-changes.html => templates/url-changes.html +26 -0
@@ 0,0 1,26 @@
{% extends "layout.html" %}
{% block content %}
<h3>URL changes</h3>
<table>
  <tbody>
    {% for change in url_changes %}
    <tr>
      <td>
        <a href="/post/{{ change.article_id }}">
          {{ change.article_id }}
        </a>
      </td>
      <td><a href="{{ change.previous_url }}">{{ domain(change.previous_url) }}</a></td>
      <td style="width: 32px; vertical-align: middle;"><i class="fa fa-arrow-right"></i></td>
      <td><a href="{{ change.updated_url }}">{{ domain(change.updated_url) }}</a></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 %}