[flaxcode] r1319 committed - Added DB list page

1 view
Skip to first unread message

codesite...@google.com

unread,
Jun 22, 2010, 11:02:29 AM6/22/10
to flax-c...@googlegroups.com
Revision: 1319
Author: banoffi
Date: Tue Jun 22 08:01:29 2010
Log: Added DB list page
http://code.google.com/p/flaxcode/source/detail?r=1319

Added:
/trunk/applications/flax_core_examples/search_app/templates/list.mako
Modified:
/trunk/applications/flax_core_examples/search_app/search_app.py
/trunk/applications/flax_core_examples/search_app/templates/base.mako

=======================================
--- /dev/null
+++ /trunk/applications/flax_core_examples/search_app/templates/list.mako
Tue Jun 22 08:01:29 2010
@@ -0,0 +1,11 @@
+<%inherit file="/base.mako" />
+
+<%def name="head_tags()">
+</%def>
+
+<h1>flax.core simple search</h1>
+<h2>pick a database:</h2>
+
+% for db in dbs:
+ <p><a href="/${db}/search">${db}</a></p>
+% endfor
=======================================
--- /trunk/applications/flax_core_examples/search_app/search_app.py Tue Jun
22 04:20:34 2010
+++ /trunk/applications/flax_core_examples/search_app/search_app.py Tue Jun
22 08:01:29 2010
@@ -14,9 +14,25 @@
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.

-"""Minimal web app for searching flax.core databases.
-
-FIXME: facets and ranges
+"""Minimal example web app for searching flax.core databases, demonstrating
+searching, filters, facets and ranges.
+
+To run this app, you will need
+
+ - xapian, with Python bindings ( http://xapian.org/ )
+ - flax.core ( http://code.google.com/p/flaxcode/source/checkout )
+ - web.py framework ( http://webpy.org/ )
+ - mako templates ( http://www.makotemplates.org/ )
+
+You will also need one or more xapian databases created with a flax.core
+indexer (such as applications/flax_core_examples/xml_indexer in the
flaxcode
+repository).
+
+Run the search app from the command line:
+
+ $ python search_app.py
+
+And point a browser at http://localhost:8080/ to choose and search a
database.

"""

@@ -28,14 +44,26 @@
import xapian
import flax.core

+# change this to the directory that contains the flax.core databases
DBDIR = '/tmp/flaxdemo'

mlookup = TemplateLookup(directories=['templates'])

urls = (
- '^/(\w*)$', 'search',
+ '^/$', 'list',
+ '^/(\w*)/search$', 'search',
)

+class list:
+ def GET(self):
+ web.header('Content-Type','text/html; charset=utf-8', unique=True)
+ dbs = [x for x in os.listdir(DBDIR) if x[0] != '.' and
+ os.path.isdir(os.path.join(DBDIR, x))]
+
+ t = mlookup.get_template('list.mako')
+ return t.render_unicode(
+ dbs=dbs).encode('utf-8', 'ignore')
+
class search:
def GET(self, dbname):
web.header('Content-Type','text/html; charset=utf-8', unique=True)
=======================================
--- /trunk/applications/flax_core_examples/search_app/templates/base.mako
Mon Jun 21 04:49:19 2010
+++ /trunk/applications/flax_core_examples/search_app/templates/base.mako
Tue Jun 22 08:01:29 2010
@@ -4,6 +4,9 @@
<head>
${self.head_tags()}
<style type="text/css">
+ body {
+ font-family: helvetica, arial;
+ }
.hit {
margin: 20px 0px 20px 0px;
}

Reply all
Reply to author
Forward
0 new messages