~melmon/at-channel

58f0344d828bd935cb091832756b34ca50419123 — Melmon 3 years ago c91fb19
added simple index page
3 files changed, 33 insertions(+), 1 deletions(-)

M atch/__init__.py
A atch/index.py
A atch/templates/index.html
M atch/__init__.py => atch/__init__.py +2 -1
@@ 1,5 1,5 @@
import os
from . import db, board, thread
from . import db, board, thread, index
from flask import Flask, render_template, current_app




@@ 27,6 27,7 @@ def create_app(test_config=None):
    db.init_app(app)
    app.register_blueprint(board.bp)
    app.register_blueprint(thread.bp)
    app.register_blueprint(index.bp)
    app.register_error_handler(404, four_oh_four)

    return app

A atch/index.py => atch/index.py +14 -0
@@ 0,0 1,14 @@
from flask import Blueprint, flash, g, redirect, render_template, request, session, url_for, abort, jsonify
from atch.db import get_db

bp = Blueprint('index', __name__)


@bp.route('/')
def index():
    db = get_db()
    boards = db.execute(
        'SELECT uri, name FROM  boards ORDER BY uri'
    ).fetchall()

    return render_template('index.html', boards=boards)

A atch/templates/index.html => atch/templates/index.html +17 -0
@@ 0,0 1,17 @@
{% extends "base.html" %}

{% block header %}
    <h1>{% block title %}Welcome to @channel{% endblock %}</h1>
{% endblock %}

{% block content %}
    @channel is a simple message board, letting you create and reply to threads about all sorts of different things, with markdown support coming soon. Feel free to browse the boards below.
    <div id="board_list">
        {% for b in boards %}
            <p class="board_link"><a href="{{ url_for("board.browse_board", uri=b["uri"]) }}">/{{ b["uri"] }}/ - {{ b["name"] }}</a></p>
        {% endfor %}
    </div>
{% endblock %}

{% block scripts %}
{% endblock %}
\ No newline at end of file