~fabrixxm/lesanaweb

b3d356ddc8bea2011667d5b40918117cf8938ece — fabrixxm 5 months ago 3f144e4
Listing pages use default order
2 files changed, 14 insertions(+), 16 deletions(-)

M app.py
M templates/index.html
M app.py => app.py +13 -15
@@ 80,18 80,8 @@ def about():

@app.route('/search.html')
def search():
    page = int(request.args.get('p', 1))
    q = request.args.get('q', ' ')
    if (page < 1):
        page = 1

    pagestart = (page - 1) * PAGESIZE
    pageend = pagestart + PAGESIZE
    
    collection.start_search(q)
    entries = list(collection.get_search_results(pagestart, pageend))
    return render_template('index.html', q=q, page=page, entries=entries, settings=collection.settings)

    return _list_search(q)

@app.route('/<eid>.html')
def entry(eid):


@@ 106,16 96,24 @@ def entry(eid):

    return render_template('entry.html', entry=entry, settings=collection.settings)


@app.route('/', methods=['GET'])
def index():
    pagestart = 0
    return _list_search()


def _list_search(q=None):
    page = int(request.args.get('p', 1))
    if (page < 1):
        page = 1

    pagestart = (page - 1) * PAGESIZE
    pageend = pagestart + PAGESIZE
    
    if q is None:
        collection.start_search('*')
    else:
        collection.start_search(q)
    entries = list(collection.get_search_results(pagestart, pageend))
    return render_template('index.html', q=q, page=page, entries=entries, settings=collection.settings)

    entries = list(collection.get_all_documents())[pagestart:pageend]
    return render_template('index.html', page=page, entries=entries, settings=collection.settings)


M templates/index.html => templates/index.html +1 -1
@@ 5,7 5,7 @@
{% block content %}
        <header>
            <h1>{{ settings.name }}</h1>
            <aside><form method="get" action="{{ url_for('search') }}"><input name="q" value="{{ q }}"><input type="submit" value="Search"></form></aside>
            <aside><form method="get" action="{{ url_for('search') }}"><input name="q" value="{% if q %}{{ q }}{% endif %}"><input type="submit" value="Search"></form></aside>
        </header>
        <ul>
            {% for entry in entries %}