~fabrixxm/lesanaweb

1ffa92fcf3d85a5b8a24ee52f1c3e92c6299227f — fabrixxm 1 year, 1 month ago 3e6859b
use 'url_for()' not hardwired paths, link title to index
2 files changed, 13 insertions(+), 10 deletions(-)

M app.py
M templates/index.html
M app.py => app.py +3 -3
@@ 18,16 18,16 @@ collection = Collection(COLLECTIONPATH)

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

    collection.start_search(q)
    data = list(collection.get_search_results(page, PAGESIZE))
    data = list(collection.get_search_results(page - 1, PAGESIZE))
    return render_template('index.html', q=q, page=page, data=data)


@app.route('/', methods=['GET'])
def hello_world():
def index():
    pagestart = 0
    page = int(request.args.get('p', 1))
    pagestart = (page - 1) * PAGESIZE

M templates/index.html => templates/index.html +10 -7
@@ 34,9 34,8 @@
             margin:0;
             display: inline-block;
         }
         body > header > span {
         }
        
         body > header > h1 > a { color: #000; }

         body > section {
             padding: 1em;
             background-color: #f2f2f2;


@@ 65,7 64,7 @@
    </head>
    <body>
        <header>
            <h1>Linkopedia</h1>
            <h1><a href="{{ url_for('index') }}">Linkopedia</a></h1>
            <span>I Bookmark del <a href="https://gl-como.it/">GL-Como</a></span>
        </header>
        <section>


@@ 82,20 81,24 @@
                        {{ doc.added }}
                        {{ "-" if doc.tags|count > 0 }}
                        {% for tag in doc.tags %}
                        <a href="/search.html?q=tag:{{ tag|urlencode }}">{{ tag }}</a>{{ ", " if not loop.last }}
                        <a href="{{ url_for('search') }}?q=tag:{{tag|urlencode}}">{{ tag }}</a>{{ ", " if not loop.last }}
                        {% endfor %}
                        </footer>
                </dd>
                {% endfor %}
            </dl>
            {% if data|count > 0 %}
                <a id="nextpage" href="/?p={{ page + 1 }}">altro</a>
                {% if q %}
                    <a id="nextpage" href="{{ url_for('search', q=q, p=page+1) }}">altro</a>
                {% else %}
                    <a id="nextpage" href="{{ url_for('index', p=page+1) }}">altro</a>
                {% endif %}
            {% else %}
                <div class="placeholder">nessun risultato</div>
            {% endif %}
        </section>
        <footer>
            <form method="get" action="/search.html"><input name="q" placeholder="cerca..."></form>
            <form method="get" action="{{ url_for('search') }}l"><input name="q" placeholder="cerca..."></form>
        </footer>
    </body>
</html>