Permalink
Browse files

started reimplementing wals fuinctionality in new framework

  • Loading branch information...
1 parent fc7222b commit 065bfa89264cde57fae3f06851517474cd5dc9a9 @xrotwang xrotwang committed Jan 28, 2013
Showing with 1,936 additions and 0 deletions.
  1. +4 −0 CHANGES.txt
  2. +2 −0 MANIFEST.in
  3. +14 −0 README.txt
  4. +72 −0 development.ini
  5. +27 −0 setup.cfg
  6. +45 −0 setup.py
  7. +77 −0 wals3/__init__.py
  8. +15 −0 wals3/adapters.py
  9. +23 −0 wals3/locale/en/LC_MESSAGES/wotw.po
  10. +23 −0 wals3/locale/wals3.pot
  11. +14 −0 wals3/maps.py
  12. +91 −0 wals3/models.py
  13. +1 −0 wals3/scripts/__init__.py
  14. +120 −0 wals3/scripts/initializedb.py
  15. BIN wals3/static/header.gif
  16. BIN wals3/static/icons/a000.png
  17. BIN wals3/static/icons/c000.png
  18. BIN wals3/static/icons/c00d.png
  19. BIN wals3/static/icons/c090.png
  20. BIN wals3/static/icons/c6f3.png
  21. BIN wals3/static/icons/c909.png
  22. BIN wals3/static/icons/c99f.png
  23. BIN wals3/static/icons/c9ff.png
  24. BIN wals3/static/icons/ca00.png
  25. BIN wals3/static/icons/cccc.png
  26. BIN wals3/static/icons/cd00.png
  27. BIN wals3/static/icons/cf40.png
  28. BIN wals3/static/icons/cf60.png
  29. BIN wals3/static/icons/cf6f.png
  30. BIN wals3/static/icons/cfc0.png
  31. BIN wals3/static/icons/cff0.png
  32. BIN wals3/static/icons/cffc.png
  33. BIN wals3/static/icons/cfff.png
  34. BIN wals3/static/icons/d000.png
  35. BIN wals3/static/icons/d00d.png
  36. BIN wals3/static/icons/d090.png
  37. BIN wals3/static/icons/d6f3.png
  38. BIN wals3/static/icons/d909.png
  39. BIN wals3/static/icons/d99f.png
  40. BIN wals3/static/icons/d9ff.png
  41. BIN wals3/static/icons/da00.png
  42. BIN wals3/static/icons/dccc.png
  43. BIN wals3/static/icons/dd00.png
  44. BIN wals3/static/icons/df40.png
  45. BIN wals3/static/icons/df60.png
  46. BIN wals3/static/icons/df6f.png
  47. BIN wals3/static/icons/dfc0.png
  48. BIN wals3/static/icons/dff0.png
  49. BIN wals3/static/icons/dffc.png
  50. BIN wals3/static/icons/dfff.png
  51. BIN wals3/static/icons/f000.png
  52. BIN wals3/static/icons/f00d.png
  53. BIN wals3/static/icons/f090.png
  54. BIN wals3/static/icons/f6f3.png
  55. BIN wals3/static/icons/f909.png
  56. BIN wals3/static/icons/f99f.png
  57. BIN wals3/static/icons/f9ff.png
  58. BIN wals3/static/icons/fa00.png
  59. BIN wals3/static/icons/fccc.png
  60. BIN wals3/static/icons/fd00.png
  61. BIN wals3/static/icons/ff40.png
  62. BIN wals3/static/icons/ff60.png
  63. BIN wals3/static/icons/ff6f.png
  64. BIN wals3/static/icons/ffc0.png
  65. BIN wals3/static/icons/fff0.png
  66. BIN wals3/static/icons/fffc.png
  67. BIN wals3/static/icons/ffff.png
  68. BIN wals3/static/icons/s000.png
  69. BIN wals3/static/icons/s00d.png
  70. BIN wals3/static/icons/s090.png
  71. BIN wals3/static/icons/s6f3.png
  72. BIN wals3/static/icons/s909.png
  73. BIN wals3/static/icons/s99f.png
  74. BIN wals3/static/icons/s9ff.png
  75. BIN wals3/static/icons/sa00.png
  76. BIN wals3/static/icons/sccc.png
  77. BIN wals3/static/icons/sd00.png
  78. BIN wals3/static/icons/sf40.png
  79. BIN wals3/static/icons/sf60.png
  80. BIN wals3/static/icons/sf6f.png
  81. BIN wals3/static/icons/sfc0.png
  82. BIN wals3/static/icons/sff0.png
  83. BIN wals3/static/icons/sffc.png
  84. BIN wals3/static/icons/sfff.png
  85. BIN wals3/static/icons/t000.png
  86. BIN wals3/static/icons/t00d.png
  87. BIN wals3/static/icons/t090.png
  88. BIN wals3/static/icons/t6f3.png
  89. BIN wals3/static/icons/t909.png
  90. BIN wals3/static/icons/t99f.png
  91. BIN wals3/static/icons/t9ff.png
  92. BIN wals3/static/icons/ta00.png
  93. BIN wals3/static/icons/tccc.png
  94. BIN wals3/static/icons/td00.png
  95. BIN wals3/static/icons/tf40.png
  96. BIN wals3/static/icons/tf60.png
  97. BIN wals3/static/icons/tf6f.png
  98. BIN wals3/static/icons/tfc0.png
  99. BIN wals3/static/icons/tff0.png
  100. BIN wals3/static/icons/tffc.png
  101. BIN wals3/static/icons/tfff.png
  102. BIN wals3/static/transparent.gif
  103. +929 −0 wals3/static/wals.css
  104. +13 −0 wals3/static/wals3.css
  105. +44 −0 wals3/static/wals3.js
  106. +336 −0 wals3/templates/home.mako
  107. +13 −0 wals3/templates/language/rdf.pt
  108. +1 −0 wals3/templates/language/snippet_html.mako
  109. +31 −0 wals3/templates/wals3.mako
  110. +32 −0 wals3/tests.py
  111. +9 −0 wals3/views.py
View
@@ -0,0 +1,4 @@
+0.0
+---
+
+- Initial version
View
@@ -0,0 +1,2 @@
+include *.txt *.ini *.cfg *.rst
+recursive-include wals3 *.ico *.png *.css *.gif *.jpg *.pt *.txt *.mak *.mako *.js *.html *.xml
View
@@ -0,0 +1,14 @@
+wals3 README
+==================
+
+Getting Started
+---------------
+
+- cd <directory containing this file>
+
+- $venv/bin/python setup.py develop
+
+- $venv/bin/initialize_wals3_db development.ini
+
+- $venv/bin/pserve development.ini
+
View
@@ -0,0 +1,72 @@
+###
+# app configuration
+# http://docs.pylonsproject.org/projects/pyramid/en/latest/narr/environment.html
+###
+
+[app:main]
+use = egg:wals3
+
+pyramid.reload_templates = true
+pyramid.debug_authorization = false
+pyramid.debug_notfound = false
+pyramid.debug_routematch = false
+pyramid.default_locale_name = en
+pyramid.includes =
+# pyramid_debugtoolbar
+ pyramid_tm
+
+#sqlalchemy.url = sqlite:///%(here)s/wals3.sqlite
+sqlalchemy.url = postgresql://robert@/wals3
+
+# By default, the toolbar only appears for clients from IP addresses
+# '127.0.0.1' and '::1'.
+# debugtoolbar.hosts = 127.0.0.1 ::1
+
+###
+# wsgi server configuration
+###
+
+[server:main]
+use = egg:waitress#main
+host = 0.0.0.0
+port = 6543
+
+###
+# logging configuration
+# http://docs.pylonsproject.org/projects/pyramid/en/latest/narr/logging.html
+###
+
+[loggers]
+keys = root, wals3, sqlalchemy
+
+[handlers]
+keys = console
+
+[formatters]
+keys = generic
+
+[logger_root]
+level = INFO
+handlers = console
+
+[logger_wals3]
+level = DEBUG
+handlers =
+qualname = wals3
+
+[logger_sqlalchemy]
+level = WARN
+handlers =
+qualname = sqlalchemy.engine
+# "level = INFO" logs SQL queries.
+# "level = DEBUG" logs SQL queries and results.
+# "level = WARN" logs neither. (Recommended for production systems.)
+
+[handler_console]
+class = StreamHandler
+args = (sys.stderr,)
+level = NOTSET
+formatter = generic
+
+[formatter_generic]
+format = %(asctime)s %(levelname)-5.5s [%(name)s][%(threadName)s] %(message)s
View
@@ -0,0 +1,27 @@
+[nosetests]
+match=^test
+nocapture=1
+cover-package=wals3
+with-coverage=1
+cover-erase=1
+
+[compile_catalog]
+directory = wals3/locale
+domain = clld
+statistics = true
+
+[extract_messages]
+add_comments = TRANSLATORS:
+output_file = wals3/locale/wals3.pot
+width = 80
+
+[init_catalog]
+domain = clld
+input_file = wals3/locale/wals3.pot
+output_dir = wals3/locale
+
+[update_catalog]
+domain = clld
+input_file = wals3/locale/wals3.pot
+output_dir = wals3/locale
+previous = true
View
@@ -0,0 +1,45 @@
+import os
+
+from setuptools import setup, find_packages
+
+here = os.path.abspath(os.path.dirname(__file__))
+README = open(os.path.join(here, 'README.txt')).read()
+CHANGES = open(os.path.join(here, 'CHANGES.txt')).read()
+
+requires = [
+ 'pyramid',
+ 'SQLAlchemy',
+ 'transaction',
+ 'pyramid_tm',
+ 'pyramid_debugtoolbar',
+ 'zope.sqlalchemy',
+ 'waitress',
+ ]
+
+setup(name='wals3',
+ version='0.0',
+ description='wals3',
+ long_description=README + '\n\n' + CHANGES,
+ classifiers=[
+ "Programming Language :: Python",
+ "Framework :: Pyramid",
+ "Topic :: Internet :: WWW/HTTP",
+ "Topic :: Internet :: WWW/HTTP :: WSGI :: Application",
+ ],
+ author='',
+ author_email='',
+ url='',
+ keywords='web wsgi bfg pylons pyramid',
+ packages=find_packages(),
+ include_package_data=True,
+ zip_safe=False,
+ test_suite='wals3',
+ install_requires=requires,
+ entry_points="""\
+ [paste.app_factory]
+ main = wals3:main
+ [console_scripts]
+ initialize_wals3_db = wals3.scripts.initializedb:main
+ """,
+ )
+
View
@@ -0,0 +1,77 @@
+from pyramid.config import Configurator
+from sqlalchemy import engine_from_config, desc
+from sqlalchemy.orm import joinedload
+from mako.template import Template
+from markupsafe import Markup
+
+from clld import interfaces
+from clld.web import datatables
+from clld.web.datatables.base import Col
+from clld.web.adapters import GeoJson
+
+from wals3.models import WalsLanguage, Genus, Family
+from wals3.adapters import GeoJsonFeature
+from wals3.maps import FeatureMap
+
+
+def _(s, *args, **kw):
+ return s
+
+_('Languages')
+
+
+class GenusCol(Col):
+ def order(self, direction):
+ return desc(Genus.name) if direction == 'desc' else Genus.name
+
+ def search(self, qs):
+ return Genus.name.contains(qs)
+
+ def format(self, item):
+ return item.genus.name
+
+
+class Languages(datatables.Languages):
+ def base_query(self, query):
+ return query.join(Genus).join(Family).options(joinedload(WalsLanguage.genus))
+
+ def col_defs(self):
+ cols = datatables.Languages.col_defs(self)
+ return cols[:2] + [GenusCol(self, 'genus')] + cols[2:]
+
+
+def main(global_config, **settings):
+ """ This function returns a Pyramid WSGI application.
+ """
+ settings['mako.directories'] = ['wals3:templates', 'clld:web/templates']
+ settings['clld.app_template'] = "wals3.mako"
+
+ config = Configurator(settings=settings)
+
+ #
+ # must add project specific translation dir first
+ #
+ config.add_translation_dirs('wals3:locale')
+
+ #
+ # then include clld, thereby adding the default translations
+ #
+ config.include('clld.web.app')
+
+ config.register_datatable('languages', Languages)
+ config.register_map('parameter', FeatureMap)
+
+ config.override_asset(
+ to_override='clld:web/templates/language/rdf.pt',
+ override_with='wals3:templates/language/rdf.pt')
+
+ config.register_adapter(
+ GeoJsonFeature,
+ interfaces.IParameter,
+ interfaces.IRepresentation,
+ GeoJson.mimetype)
+
+ config.add_static_view('static', 'static', cache_max_age=3600)
+ config.add_route('home', '/')
+ config.scan()
+ return config.make_wsgi_app()
View
@@ -0,0 +1,15 @@
+from clld.web.adapters import GeoJsonParameter
+
+
+class GeoJsonFeature(GeoJsonParameter):
+
+ def feature_properties(self, ctx, req, feature):
+ language, values = feature
+ val = list(values)[0]
+ if val.domainelement.id == req.params.get('domainelement'):
+ res = GeoJsonParameter.feature_properties(self, ctx, req, feature)
+ res['icon_type'] = val.domainelement.icon_id[:1]
+ res['icon_color'] = '#%s' % ''.join(2*c for c in val.domainelement.icon_id[1:])
+ res['value_numeric'] = val.domainelement.numeric
+ res['value_name'] = val.domainelement.name
+ return res
@@ -0,0 +1,23 @@
+# English translations for PROJECT.
+# Copyright (C) 2012 ORGANIZATION
+# This file is distributed under the same license as the PROJECT project.
+# FIRST AUTHOR <EMAIL@ADDRESS>, 2012.
+#
+msgid ""
+msgstr ""
+"Project-Id-Version: PROJECT VERSION\n"
+"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n"
+"POT-Creation-Date: 2012-11-11 17:31+0100\n"
+"PO-Revision-Date: 2012-11-11 17:30+0100\n"
+"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
+"Language-Team: en <LL@li.org>\n"
+"Plural-Forms: nplurals=2; plural=(n != 1)\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=utf-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+"Generated-By: Babel 1.0dev\n"
+
+#: wals3/__init__.py:13
+msgid "Languages"
+msgstr "WALS Languages"
+
View
@@ -0,0 +1,23 @@
+# Translations template for wals3.
+# Copyright (C) 2012 ORGANIZATION
+# This file is distributed under the same license as the wals3 project.
+# FIRST AUTHOR <EMAIL@ADDRESS>, 2012.
+#
+#, fuzzy
+msgid ""
+msgstr ""
+"Project-Id-Version: wals3 0.0\n"
+"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n"
+"POT-Creation-Date: 2012-11-11 17:31+0100\n"
+"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
+"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
+"Language-Team: LANGUAGE <LL@li.org>\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=utf-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+"Generated-By: Babel 1.0dev\n"
+
+#: wals3/__init__.py:13
+msgid "Languages"
+msgstr ""
+
View
@@ -0,0 +1,14 @@
+from clld.web.maps import ParameterMap, Map
+from clld.web.util.htmllib import HTML
+
+
+class FeatureMap(ParameterMap):
+ def get_layers(self):
+ res = []
+ for layer, de in zip(ParameterMap.get_layers(self), self.ctx.domain):
+ layer['marker'] = HTML.img(src=self.req.static_url('wals3:static/icons/' + de.icon_id + '.png'))
+ res.append(layer)
+ return res
+
+ def options(self):
+ return {'style_map': 'wals_feature'}
Oops, something went wrong.

0 comments on commit 065bfa8

Please sign in to comment.