drime

French rhyme dictionary with web and CLI interface
git clone https://a3nm.net/git/drime/
Log | Files | Refs | README

commit 0ebeb3d9dc0482b324d08b017748a6054e4676c8
parent d0e879fc93c88d6b6fc838a1d7e42e494faf8842
Author: Antoine Amarilli <a3nm@a3nm.net>
Date:   Tue, 27 Dec 2011 03:22:02 +0100

change design, add json

Diffstat:
drime.py | 12++++++++++--
static/main.css | 39+++++++++++++++++++++++++++++++--------
templates/error.html | 2+-
templates/notfound.html | 3+--
templates/page.html | 3+++
templates/results.html | 2+-
6 files changed, 47 insertions(+), 14 deletions(-)

diff --git a/drime.py b/drime.py @@ -1,12 +1,16 @@ #!/usr/bin/python3 -O import query -from flask import Flask, render_template, request +from flask import Flask, render_template, request, jsonify app = Flask(__name__) @app.route('/') def root(): + return render_template('index.html', title="drime", noform=True) + +@app.route('/about') +def about(): return render_template('about.html', title="drime") @app.route('/query') @@ -40,7 +44,11 @@ def q(): return render_template('disambig.html', **d) else: d['result'] = r[r.keys()[0]] - return render_template('results.html', **d) + # TODO better + if request.args.get('json'): + return jsonify(d) + else: + return render_template('results.html', **d) except query.BadValues: d['mode'] = 'query' return render_template('error.html', **d) diff --git a/static/main.css b/static/main.css @@ -1,5 +1,5 @@ h1 { - background: #0c0; + background: #040; float: left; margin: 0; margin-right: 0.3em; @@ -11,7 +11,7 @@ h1 { padding: 1em; } -h1 a { +h1 a, #about { color: white; text-decoration: none; } @@ -19,6 +19,7 @@ h1 a { header { background: black; overflow: auto; + color: white; } #about a { @@ -35,10 +36,6 @@ body { display: none; } -label { - color: white; -} - .num { text-align: center; } @@ -57,11 +54,11 @@ table, .faketable { vertical-align: super; } -#nsyl { +header #nsyl { width: 6em; } -#query { +header #query { width: 12em; } @@ -126,3 +123,29 @@ header form input { #col_eye { width: 7%; }*/ + +#bigform { + max-width: 25em; + border: 3px outset #040; + padding: 1em; + background: #040; + color: white; + margin: auto; + margin-top: 4em; + overflow: auto; +} + +#bigform input { + margin-bottom: 0.7em; + width: 50%; +} + +#bigform label { +} + +#bigform #submit { + float: right; + margin-top: 0.3em; + margin-bottom: 0; + width: 7em; +} diff --git a/templates/error.html b/templates/error.html @@ -1,6 +1,6 @@ {% extends "page.html" %} {% block body %} -<p>Invalid values supplied. Need some <a href="/#help">help</a>?</p> +<p>Invalid values supplied. Need some <a href="/about#help">help</a>?</p> {% endblock %} diff --git a/templates/notfound.html b/templates/notfound.html @@ -2,7 +2,6 @@ {% block body %} <p>No known word matches this query. Make sure you're using a word from the -dictionary. Need some <a - href="/#help">help</a>?</p> +dictionary. Need some <a href="/about#help">help</a>?</p> {% endblock %} diff --git a/templates/page.html b/templates/page.html @@ -9,6 +9,8 @@ <body> <header> <h1><a href="/">drime</a></h1> + <sup><a id="about" href="/about">about</a></sup> + {% if not noform %} <form method="GET" action="query"> <label class="redundant" for="query">Word</label> <input id="query" name="query" @@ -27,6 +29,7 @@ gender?</label> <input type="submit" value="Search" /> </form> + {% endif %} </header> <div id="body"> {% block body %} diff --git a/templates/results.html b/templates/results.html @@ -14,7 +14,7 @@ for: <strong>{{ keys[0][-1] }}</strong></p> <table> <tr> <th id="col_word">word</th> - <th id="col_pron">pron<a href="/#pron" class="help">?</a></th> + <th id="col_pron">pron<a href="/about/#pron" class="help">?</a></th> <th id="col_phon">phon</th> <th id="col_eye">eye</th> <th id="col_freq">freq</th>