diff --git a/flash_cards.py b/flash_cards.py index b815231..f8dfb71 100644 --- a/flash_cards.py +++ b/flash_cards.py @@ -62,6 +62,8 @@ def index(): @app.route('/cards') def cards(): + if not session.get('logged_in'): + return redirect(url_for('login')) db = get_db() cur = db.execute('SELECT type, front, back, known FROM cards ORDER BY id DESC') cards = cur.fetchall() @@ -71,7 +73,7 @@ def cards(): @app.route('/add', methods=['POST']) def add_card(): if not session.get('logged_in'): - abort(401) + return redirect(url_for('login')) db = get_db() db.execute('INSERT INTO cards (type, front, back) VALUES (?, ?, ?)', [request.form['type'], @@ -83,13 +85,24 @@ def add_card(): return redirect(url_for('cards')) +@app.route('/general') +def general(): + if not session.get('logged_in'): + return redirect(url_for('login')) + return render_template('general.html') + + +@app.route('/code') +def code(): + if not session.get('logged_in'): + return redirect(url_for('login')) + return render_template('code.html') + + @app.route('/login', methods=['GET', 'POST']) def login(): error = None if request.method == 'POST': - # return request.form['username'] + " / " + app.config['USERNAME'] + " / " \ - # + request.form['password'] + " / " + app.config['PASSWORD'] - if request.form['username'] != app.config['USERNAME']: error = 'Invalid username' elif request.form['password'] != app.config['PASSWORD']: diff --git a/static/style.css b/static/style.css index 466f615..64b9077 100644 --- a/static/style.css +++ b/static/style.css @@ -1,18 +1,4 @@ -body { font-family: sans-serif; background: #eee; } -a, h1, h2 { color: #377ba8; } -h1, h2 { font-family: 'Georgia', serif; margin: 0; } -h1 { border-bottom: 2px solid #eee; } -h2 { font-size: 1.2em; } - -.page { margin: 2em auto; width: 80%; border: 5px solid #ccc; - padding: 0.8em; background: white; } -.entries { list-style: none; margin: 0; padding: 0; } -.entries li { margin: 0.8em 1.2em; } -.entries li h2 { margin-left: -1em; } -.add-entry { font-size: 0.9em; border-bottom: 1px solid #ccc; } -.add-entry dl { font-weight: bold; } -.metanav { text-align: right; font-size: 0.8em; padding: 0.3em; - margin-bottom: 1em; background: #fafafa; } -.flash { background: #cee5F5; padding: 0.5em; - border: 1px solid #aacbe2; } -.error { background: #f0d6d6; padding: 0.5em; } +.toggleSelected { + background-color: #62b06b; + color: #ffffff; +} diff --git a/templates/cards.html b/templates/cards.html index a3884f2..041c3fd 100644 --- a/templates/cards.html +++ b/templates/cards.html @@ -2,42 +2,85 @@ {% block body %} {% if session.logged_in %}
-
-
- -
-
- -
-
- -
-
-
- -
-
-
-
+ +
+ + + +
+
+ + +
+
+ + +
+
+ +
{% endif %} -
- -{% endblock %} \ No newline at end of file + +
+ + + + {% for card in cards %} +
+

{{ card.front }}

+ {% if card.type == 1 %} + {{ card.back|replace("\n", "
") }} + {% else %} +
{{ card.back|safe }}
+ {% endif %} +
+
+ {% else %} +
  • Unbelievable. No cards here so far. + {% endfor %} + + + +{% endblock %} diff --git a/templates/code.html b/templates/code.html new file mode 100644 index 0000000..58d5dce --- /dev/null +++ b/templates/code.html @@ -0,0 +1,4 @@ +{% extends "layout.html" %} +{% block body %} + code +{% endblock %} \ No newline at end of file diff --git a/templates/general.html b/templates/general.html new file mode 100644 index 0000000..3838823 --- /dev/null +++ b/templates/general.html @@ -0,0 +1,4 @@ +{% extends "layout.html" %} +{% block body %} + general +{% endblock %} \ No newline at end of file diff --git a/templates/layout.html b/templates/layout.html index 6dac244..212c7d5 100644 --- a/templates/layout.html +++ b/templates/layout.html @@ -1,20 +1,55 @@ -CS Flash Cards - -
    -

    CS Flash Cards

    -
    - {% if not session.logged_in %} - log in - {% else %} - cards -   -   - log out - {% endif %} + + + CS Flash Cards + + + + + + +
    +
    +
    + +
    + + + + {% for message in get_flashed_messages() %} + + {% endfor %} + {% block body %}{% endblock %} +
    +
    - {% for message in get_flashed_messages() %} -
    {{ message }}
    - {% endfor %} - {% block body %}{% endblock %} -
    \ No newline at end of file + + + diff --git a/templates/login.html b/templates/login.html index d44fb95..9cdc490 100644 --- a/templates/login.html +++ b/templates/login.html @@ -1,7 +1,7 @@ {% extends "layout.html" %} {% block body %}

    Login

    - {% if error %}

    Error: {{ error }}{% endif %} + {% if error %}

    {% endif %}
    Username: