added pagination to index page, light styling

This commit is contained in:
Kyle Mahan 2015-01-28 08:20:16 -08:00
parent 4afa1e94ac
commit fd022023b5
5 changed files with 46 additions and 15 deletions

8
uwsgi.ini Normal file
View file

@ -0,0 +1,8 @@
[uwsgi]
master=true
processes=4
threads=2
socket=/tmp/uwsgi.sock
chmod-socket=666
module=woodwind:wsgi
pidfile=/tmp/woodwind.pid

View file

@ -21,11 +21,16 @@ body {
}
main {
header, main {
max-width: 600px;
margin: 0 auto;
}
header {
margin-bottom: 1em;
}
article {
margin-bottom: 2em;
box-shadow: $box-shadow;
@ -36,7 +41,7 @@ article {
max-width: 100%;
}
header {
&> header {
img {
max-width: 64px;
max-height: 64px;
@ -44,8 +49,13 @@ article {
float: left;
border-radius: 4px;
}
color: $armadillo;
border-bottom: 1px solid $armadillo;
color: $lunar-green;
border-bottom: 1px solid $sirocco;
margin-bottom: 0.5em;
}
footer {
margin-top: 0.5em;
}
h1 {

View file

@ -7,7 +7,8 @@
{% block head %}{% endblock %}
</head>
<body>
<main>
<header>
{% if current_user.is_authenticated() %}
<div class="logged-in">{{ current_user.domain }}</div>
{% else %}
@ -16,9 +17,13 @@
<button type="submit">Login</button>
</form>
{% endif %}
{% block header %}{% endblock %}
{% for message in get_flashed_messages() %}
<div class="flash">{{ message | safe }}</div>
{% endfor %}
</header>
<main>
{% block body %}{% endblock %}
</main>
</body>

View file

@ -1,10 +1,12 @@
{% extends "base.jinja2" %}
{% block body %}
<form action="{{ url_for('.subscribe') }}" method="POST">
{% block header %}
<form action="{{ url_for('.subscribe') }}" method="POST">
<input type="text" id="origin" name="origin" placeholder="Feed URL" />
<button type="submit" id="subscribe">Subscribe</button>
</form>
{% endblock header %}
{% block body %}
{% for entry in entries %}
<article>
@ -25,9 +27,8 @@
{{ entry.content_cleaned() }}
</div>
{% endif %}
<div>
<footer>
<a href="{{ entry.permalink }}">{{ entry.published }}</a>
</div>
<form action="{{ current_user.micropub_endpoint }}" method="POST">
<input type="hidden" name="access_token" value="{{current_user.access_token}}"/>
@ -36,6 +37,8 @@
<button type="submit">Like</button>
</form>
</footer>
<!--
<form action="{{ current_user.micropub_endpoint }}" method="POST">
<input type="hidden" name="access_token" value="{{current_user.access_token}}"/>
@ -48,4 +51,6 @@
</article>
{% endfor %}
<a href="{{ url_for(request.endpoint, page=page+1)}}">Older</a>
{% endblock body %}

View file

@ -15,14 +15,17 @@ ui = flask.Blueprint('ui', __name__)
@ui.route('/')
def index():
page = int(flask.request.args.get('page', 1))
if flask_login.current_user.is_authenticated():
feed_ids = [f.id for f in flask_login.current_user.feeds]
entries = Entry.query.filter(
Entry.feed_id.in_(feed_ids)).order_by(
Entry.published.desc()).limit(100).all()
per_page = flask.current_app.config.get('PER_PAGE', 30)
offset = (page - 1) * per_page
feed_ids = set(f.id for f in flask_login.current_user.feeds)
entries = Entry.query.filter(Entry.feed_id.in_(feed_ids))\
.order_by(Entry.published.desc())\
.offset(offset).limit(per_page).all()
else:
entries = []
return flask.render_template('feed.jinja2', entries=entries)
return flask.render_template('feed.jinja2', entries=entries, page=page)
@ui.route('/install')