1. Lars Yencken
  2. simsearch

Commits

Lars Yencken  committed 21c7b04

Adds an about page, and stub help & feedback pages.

- Unifies use of blueprint CSS framework on every page.
- Improves base template with navigation and copy text.
- Adds a static app to hold the new pages.

  • Participants
  • Parent commits 4b7ef9b
  • Branches default

Comments (0)

Files changed (20)

File simsearch/media/css/common.css

View file
+/*
+ * common.css
+ */
+
+
+#copy {
+    bottom: 0;
+    font: 300 1.2em "Helvetica Neue", Helvetica, "Arial Unicode MS", Arial, sans-serif;
+    position: absolute;
+    right: 1em;
+    text-align: right;
+    margin-bottom: 1em;
+    color: #505050;
+}
+#copy a {
+    color: #303090;
+}
+#copy a:hover {
+    text-decoration: underline;
+}
+
+#nav {
+    bottom: top;
+    font: 300 1.2em "Helvetica Neue", Helvetica, "Arial Unicode MS", Arial, sans-serif;
+    position: absolute;
+    right: 1em;
+    margin-top: 1em;
+    text-align: right;
+    color: #505050;
+}
+#nav a {
+    color: #303090;
+}
+#nav a:hover {
+    text-decoration: underline;
+}

File simsearch/media/css/lookup.css

View file
 a img {border: none;}
 
 .similarKanji {
-    font-size: 2em;
+    font-size: 3em;
     font-family: MS Gothic;
 }
 
 }
 
 #pivotKanji {
-    font-size: 2em;
+    font-size: 3em;
     font-family: MS Gothic;
 }
 
     opacity:0.01;
 }
 
-input { border:1px solid #505050; font-size:20px; vertical-align:top; }
+#seedLookup > input {
+    border:1px solid #505050;
+    font-size:20px;
+    vertical-align: top; 
+    margin-top: 0px;
+    margin-bottom: 0px;
+}
 
 .error {
     position: absolute; 
     text-align: center;
     font: 300 .9em "Helvetica Neue", Helvetica, "Arial Unicode MS", Arial, sans-serif;
 }
-
-#copy {
-    bottom: 0;
-    font: 300 .9em "Helvetica Neue", Helvetica, "Arial Unicode MS", Arial, sans-serif;
-    position: absolute;
-    right: 1em;
-    text-align: right;
-    color: #505050;
-}
-#copy a {
-    color: #303090;
-}
-#copy a:hover {
-    text-decoration: underline;
-}

File simsearch/media/css/static.css

View file
+/*
+ * static.css
+ */
+
+.container { width: 550px; }
+#pivot { font-size: 200px; vertical-align: middle; text-align: right; }
+.readings > tbody > tr > th { text-align: right; vertical-align: top; }
+td, th, p, h1, h2, h3 { font: 300 "Helvetica Neue", Helvetica, "Arial Unicode MS",
+Arial, sans-serif; }
+p, li, td, th { font-size: 1.2em }
+p { margin-left: 2em; } 
+h3 { font-size: 1.3em; margin-bottom: 0.3em; }
+h2 { font-size: 2em; margin-bottom: 0.2em; }
+
+a { text-decoration: none; }
+a:hover { text-decoration: underline; }

File simsearch/search/__init__.py

View file
+# -*- coding: utf-8 -*-
+#
+#  __init__.py
+#  simsearch
+# 
+#  Created by Lars Yencken on 14-09-2010.
+#  Copyright 2010 Lars Yencken. All rights reserved.
+#
+
+def build():
+    import models
+    models.build()
+
+# vim: ts=4 sw=4 sts=4 et tw=78:

File simsearch/search/management/commands/build.py

View file
 """
 
 from django.core.management.base import BaseCommand, CommandError
-from simsearch.search.models import build
+from django.conf import settings
 
 class Command(BaseCommand):
     help = 'Builds the initial similarity database.'
 
     def handle(self, *args, **kwargs):
-        build()
+        for app_name in settings.INSTALLED_APPS:
+            app = __import__(app_name)
+            if hasattr(app, 'build'):
+                print app
+                app.build()
 
 # vim: ts=4 sw=4 sts=4 et tw=78:

File simsearch/search/templates/search/index.html

View file
 
   <div class="error" id="errorMessage" style="opacity:0.00"></div>
 
-  <p id="copy">
-    Visual kanji search (<a
-    href="http://bitbucket.org/lars512/simsearch/">r{{revision.number}}:{{revision.short}}</a>)
-  </p>
 {% endblock %}

File simsearch/settings.py

View file
     'djangotoolbox',
     'simsearch.search',
     'simsearch.translate',
+    'simsearch.static',
 )
 
 # The source of stroke data for each character

File simsearch/static/__init__.py

Empty file added.

File simsearch/static/models.py

View file
+from django.db import models
+
+# Create your models here.

File simsearch/static/templates/static/about.html

View file
+{% extends "static/base.html" %}
+
+{% block inner_content %}
+<h1>About SimSearch</h1>
+
+<h2>What is it?</h2>
+
+<p>SimSearch is a visual search-by-similarity for Japanese kanji. Suppose you
+encounter a kanji you don't know, but it looks very similar to one you do know.
+In this case, you can enter in the one you know as a query, and navigate
+through the similarity space until you find the kanji you are looking for.</p>
+
+<h2>How does it work?</h2>
+
+<p>In order to determine how similar two kanji are to one another, we use the
+<em>stroke edit distance</em> between the two kanji [1]. In other words, we
+look at the sequence of strokes used to write each character, and determine how
+many changes you'd need to make to turn one kanji's series of strokes into that
+of the other kanji. Research so far has that this measure best matches human
+judgements of similarity [2].</p>
+
+<p>Secondly, search is also adaptive. That is, it will adapt to whatever people
+actually find similar when they do searches using the system. For this, we use
+Q-learning [3], a well known algorithm for learning the best action to take in
+a state space. Q-learning has been used in a wide variety of search
+applications, including game players for board games which learn from
+experience.</p>
+
+<h2>How can I help?</h2>
+
+<p>If you're a learner of Japanese, or a native speaker, please give the system
+a try, and send me some <a href="{% url feedback %}">feedback</a>. If you're a
+programmer, note that SimSearch is open source, so feel free to suggest new
+improvements, or even try running your own site.</p>
+
+<hr>
+
+<h2>References</h2>
+<ol>
+<li>Wikipedia: <a
+href="http://en.wikipedia.org/wiki/Levenshtein_distance">Levenshtein
+distance</a></li>
+<li>Yencken, Lars and Baldwin, Timothy: “Measuring and predicting orthographic
+associations: modelling the similarity of Japanese kanji”, in <em>Proceedings of
+COLING 2008</em>, Manchester, UK (2008)</li>
+<li>Wikipedia: <a
+href="http://en.wikipedia.org/wiki/Q-learning">Q-learning</a></li>
+</ol>
+
+{% endblock %}

File simsearch/static/templates/static/base.html

View file
+{% extends "base.html" %}
+
+{% block headers %}
+<link rel="stylesheet" href="{{MEDIA_URL}}css/static.css" type="text/css"
+  media="screen, projection, print">
+{% endblock %}
+
+{% block content %}
+<div class="container">
+  <div class="span-15 last">
+    <hr class="space" style="height: 4em" />
+    {% block inner_content %}
+    {% endblock %}
+  </div>
+</div>
+{% endblock %}

File simsearch/static/templates/static/feedback.html

View file
+{% extends "static/base.html" %}
+
+{% block inner_content %}
+<h1>Feedback</h1>
+
+<!-- XXX put a feedback form here -->
+{% endblock %}

File simsearch/static/templates/static/help.html

View file
+{% extends "static/base.html" %}
+
+{% block inner_content %}
+<h1>Help</h1>
+
+<!-- XXX write some help text here -->
+{% endblock %}

File simsearch/static/tests.py

View file
+"""
+This file demonstrates two different styles of tests (one doctest and one
+unittest). These will both pass when you run "manage.py test".
+
+Replace these with more appropriate tests for your application.
+"""
+
+from django.test import TestCase
+
+class SimpleTest(TestCase):
+    def test_basic_addition(self):
+        """
+        Tests that 1 + 1 always equals 2.
+        """
+        self.failUnlessEqual(1 + 1, 2)
+
+__test__ = {"doctest": """
+Another way to test that 1 + 1 is equal to 2.
+
+>>> 1 + 1 == 2
+True
+"""}
+

File simsearch/static/urls.py

View file
+# -*- coding: utf-8 -*-
+#
+#  urls.py
+#  simsearch
+# 
+#  Created by Lars Yencken on 14-09-2010.
+#  Copyright 2010 Lars Yencken. All rights reserved.
+#
+
+"""
+Urlconf for static pages.
+"""
+
+from django.conf.urls.defaults import patterns, url
+
+urlpatterns = patterns('simsearch.static.views',
+    url(r'^help/$',     'help',     name='help'),
+    url(r'^feedback/$', 'feedback', name='feedback'),
+    url(r'^about/$',    'about',    name='about'),
+)
+
+# vim: ts=4 sw=4 sts=4 et tw=78:

File simsearch/static/views.py

View file
+# -*- coding: utf-8 -*-
+#
+#  views.py
+#  simsearch
+# 
+#  Created by Lars Yencken on 14-09-2010.
+#  Copyright 2010 Lars Yencken. All rights reserved.
+#
+
+"""
+Static page views.
+"""
+
+from django.shortcuts import render_to_response
+from django.template import RequestContext
+
+def help(request):
+    return render_to_response("static/help.html", {},
+            context_instance=RequestContext(request))
+
+def feedback(request):
+    return render_to_response("static/feedback.html", {},
+            context_instance=RequestContext(request))
+
+def about(request):
+    return render_to_response("static/about.html", {},
+            context_instance=RequestContext(request))
+
+# vim: ts=4 sw=4 sts=4 et tw=78:
+

File simsearch/templates/base.html

View file
 <head>
 	<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
 	<title>Visual kanji search</title>
+  <link rel="stylesheet" href="{{MEDIA_URL}}css/blueprint/screen.css"
+    type="text/css" media="screen, projection">
+  <link rel="stylesheet" href="{{MEDIA_URL}}css/blueprint/print.css"
+    type="text/css" media="print">
+  <!--[if lt IE 8]>
+    <link rel="stylesheet" href="{{MEDIA_URL}}css/blueprint/ie.css"
+      type="text/css" media="screen, projection">
+  <![endif]-->
+  <link rel="stylesheet" href="{{MEDIA_URL}}css/common.css" 
+    type="text/css" media="screen, projection" />
   {% block headers %}
   {% endblock %}
 
 </head>
 
 <body {% block body_tags %}{% endblock %}>
+{% block navigation %}
+<p id="nav">
+  <a href="{% url search_index %}">Search</a> /
+  <a href="{% url help %}">Help</a> /
+  <a href="{% url feedback %}">Feedback</a> /
+  <a href="{% url about %}">About</a>
+</p>
+{% endblock %}
+
 {% block content %}
 {% endblock %}
+
+{% block copy %}
+<p id="copy">
+  Visual kanji search (<a
+  href="http://bitbucket.org/lars512/simsearch/">r{{revision.number}}:{{revision.short}}</a>)
+</p>
+{% endblock %}
 </body>
 
 </html>

File simsearch/translate/__init__.py

View file
+# -*- coding: utf-8 -*-
+#
+#  __init__.py
+#  simsearch
+# 
+#  Created by Lars Yencken on 14-09-2010.
+#  Copyright 2010 Lars Yencken. All rights reserved.
+#
+
+def build():
+    import models
+    models.Translation.build()
+
+# vim: ts=4 sw=4 sts=4 et tw=78:

File simsearch/translate/templates/translate/kanji.html

View file
   .readings > tbody > tr > th { text-align: right; vertical-align: top; }
   td, th, p, h2, h3 { font: 300 "Helvetica Neue", Helvetica, "Arial Unicode MS",
     Arial, sans-serif; }
-  p, li, td, th { font-size: .9em }
+  p, li, td, th { font-size: 1.2em }
   h3 { font-size: 1.3em; margin-bottom: 0.3em; }
   h2 { font-size: 2em }
 </style>

File simsearch/urls.py

View file
 
 _patterns = ['',
     (r'^translate/', include('simsearch.translate.urls')),
+    (r'', include('simsearch.static.urls')),
     (r'', include('simsearch.search.urls')),
 ]