Skip to content

Commit

Permalink
Added files.
Browse files Browse the repository at this point in the history
  • Loading branch information
chrzyki committed Jun 25, 2018
1 parent 669ac0e commit e78d452
Show file tree
Hide file tree
Showing 37 changed files with 569 additions and 0 deletions.
31 changes: 31 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
Contributing
------------

Install the development environment:

```sh
$ pip install virtualenv # might require sudo/admin privileges
$ git clone https://github.com/clld/clld.git # you may also clone a suitable fork
$ cd amsd
$ python -m virtualenv .venv
$ source .venv/bin/activate # Windows: .venv\Scripts\activate.bat
$ pip install -r requirements.txt # installs the cloned version with dev-tools in development mode
```

Then create a database:

```sh
$ su - postgres
$ createdb amsd
```

and initialize it, either
- loading a dump of the production DB, using the app's `load_db` task from the
`appconfig` package
- or by running `python amsd/scripts/initializedb.py development.ini` (may require access to the appropriate data repository).

Now you should be able to run the tests:

```sh
$ pytest
```
2 changes: 2 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
include *.txt *.ini *.cfg *.rst
recursive-include amsd *.ico *.png *.css *.gif *.jpg *.pt *.txt *.mak *.mako *.js *.html *.xml
47 changes: 47 additions & 0 deletions alembic.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
[alembic]
script_location = migrations

# set to 'true' to run the environment during
# the 'revision' command, regardless of autogenerate
# revision_environment = false

sqlalchemy.url = postgresql://postgres@/amsd

[production]
script_location = migrations
sqlalchemy.url = postgresql://amsd@/amsd

# Logging configuration
[loggers]
keys = root,sqlalchemy,alembic

[handlers]
keys = console

[formatters]
keys = generic

[logger_root]
level = WARN
handlers = console
qualname =

[logger_sqlalchemy]
level = WARN
handlers =
qualname = sqlalchemy.engine

[logger_alembic]
level = INFO
handlers =
qualname = alembic

[handler_console]
class = StreamHandler
args = (sys.stderr,)
level = NOTSET
formatter = generic

[formatter_generic]
format = %(levelname)-5.5s [%(name)s] %(message)s
datefmt = %H:%M:%S
12 changes: 12 additions & 0 deletions amsd/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
from pyramid.config import Configurator

# we must make sure custom models are known at database initialization!
from amsd import models


def main(global_config, **settings):
""" This function returns a Pyramid WSGI application.
"""
config = Configurator(settings=settings)
config.include('clldmpg')
return config.make_wsgi_app()
2 changes: 2 additions & 0 deletions amsd/adapters.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
def includeme(config):
pass
8 changes: 8 additions & 0 deletions amsd/appconf.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[clld]
menuitems_list = contributions parameters languages contributors sentences sources
app_template = amsd.mako
github_repos = clld/amsd
pacific_centered_maps = 0

[mako]
directories_list = amsd:templates clldmpg:templates clld:web/templates
10 changes: 10 additions & 0 deletions amsd/assets.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
from clld.web.assets import environment
from clldutils.path import Path

import amsd


environment.append_path(
Path(amsd.__file__).parent.joinpath('static').as_posix(),
url='/amsd:static/')
environment.load_path = list(reversed(environment.load_path))
2 changes: 2 additions & 0 deletions amsd/datatables.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
def includeme(config):
pass
Empty file added amsd/interfaces.py
Empty file.
2 changes: 2 additions & 0 deletions amsd/maps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
def includeme(config):
pass
25 changes: 25 additions & 0 deletions amsd/models.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
from zope.interface import implementer
from sqlalchemy import (
Column,
String,
Unicode,
Integer,
Boolean,
ForeignKey,
UniqueConstraint,
)
from sqlalchemy.orm import relationship, backref
from sqlalchemy.ext.declarative import declared_attr
from sqlalchemy.ext.hybrid import hybrid_property

from clld import interfaces
from clld.db.meta import Base, CustomModelMixin
#from clld.db.models.common import Language


#-----------------------------------------------------------------------------
# specialized common mapper classes
#-----------------------------------------------------------------------------
#@implementer(interfaces.ILanguage)
#class amsdLanguage(CustomModelMixin, Language):
# pk = Column(Integer, ForeignKey('language.pk'), primary_key=True)
1 change: 1 addition & 0 deletions amsd/scripts/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#
42 changes: 42 additions & 0 deletions amsd/scripts/initializedb.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
from __future__ import unicode_literals
import sys

from clld.scripts.util import initializedb, Data
from clld.db.meta import DBSession
from clld.db.models import common

import amsd
from amsd import models


def main(args):
data = Data()

dataset = common.Dataset(
id=amsd.__name__,
name="--TODO--",
publisher_name="Max Planck Institute for the Science of Human History",
publisher_place="Jena",
publisher_url="http://www.shh.mpg.de",
license="http://creativecommons.org/licenses/by/4.0/",
domain='amsd.clld.org',
jsondata={
'license_icon': 'cc-by.png',
'license_name': 'Creative Commons Attribution 4.0 International License'})

DBSession.add(dataset)

#
# TODO: add editors!
#

def prime_cache(args):
"""If data needs to be denormalized for lookup, do that here.
This procedure should be separate from the db initialization, because
it will have to be run periodically whenever data has been updated.
"""


if __name__ == '__main__': # pragma: no cover
initializedb(create=main, prime_cache=prime_cache)
sys.exit(0)
Binary file added amsd/static/1520350500.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added amsd/static/amsd_logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions amsd/static/project.css
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

1 change: 1 addition & 0 deletions amsd/static/project.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

7 changes: 7 additions & 0 deletions amsd/templates/amsd.mako
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<%inherit file="app.mako"/>

<%block name="brand">
<a href="${request.resource_url(request.dataset)}" class="brand">${request.dataset.name}</a>
</%block>

${next.body()}
68 changes: 68 additions & 0 deletions amsd/templates/dataset/detail_html.mako
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
<%inherit file="../home_comp.mako"/>

<h2>Welcome to the Australian Message Stick Database</h2>

<p class="lead">
Message sticks are carved graphic devices from Indigenous Australia, used to
facilitate long-distance communication. This database is a digital
repository of 1024 message sticks and associated metadata located in museums
across the world. It also stores photographs and sketches of messages that
are no longer extant. The database is searchable via 30 fields, including
linguistic area, semantic domain, motifs and source. The full dataset will
be migrated to this location soon. In the meantime click <a
href="https://cdhrsys.anu.edu.au/occams_v1c/index.php" target="_blank">here</a>
to visit the beta version and the Help link for access instructions.
</p>

<h2>Example</h2>
<img width="180" height="180"
src="${request.static_url('amsd:static/1520350500.png')}" class="image"/>

<p>
The Australian Message Stick Database contains data licensed under various
conditions depending on agreements with museums (see individual records for
details). No restricted or sacred items are included. It has been developed
by The Mint Research Group at The Max Planck Institute for the Science of
Human History.
</p>

<h3>How to access the Australian Message Sticks Database</h3>
<p>The beta version can be accessed from <a
href="https://cdhrsys.anu.edu.au/occams_v1c/index.php">https://cdhrsys.anu.edu.au/occams_v1c/index.php</a>.<br/>
Please contact Piers Kelly (kelly [AT] shh.mpg.de) for log-in credentials or
for a zipped copy of the database.
</p>

<div class="row-fluid">
<div class="span4 well well-small">
<h3>How to cite:</h3>
<p>
Kelly, Piers (ed.). 2018. The Australian Message Stick Database
(beta version)
</p>
</div>
<div class="span4" style="padding: 20px; text-align: center;">
<img width="200" height="200"
src="${request.static_url('amsd:static/amsd_logo.png')}"
class="image"/>
</div>
<div class="span4">
<table class="table table-nonfluid">
<tbody>
<tr>
<th>Artefacts</th>
<td class="right">1024</td>
</tr>
<tr>
<th>Linguistic areas</th>
<td class="right">54</td>
</tr>
<tr>
<th>Motifs</th>
<td class="right">37</td>
</tr>
</tbody>
</table>
</div>
</div>

4 changes: 4 additions & 0 deletions amsd/tests/conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
from amsd import models
import pytest

pytest_plugins = ['clld']
2 changes: 2 additions & 0 deletions amsd/tests/test_functional.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
def test_home(app):
app.get_html('/legal', status=200)
9 changes: 9 additions & 0 deletions amsd/tests/test_scripts.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# coding: utf8
from __future__ import unicode_literals, print_function, division

from amsd.scripts.initializedb import main, prime_cache


def test_dbinit(db):
main(None)
prime_cache(None)
7 changes: 7 additions & 0 deletions amsd/tests/test_selenium.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
from __future__ import unicode_literals
import time


def test_ui(selenium):
selenium.browser.get(selenium.url('/download'))
time.sleep(3)
7 changes: 7 additions & 0 deletions amsd/util.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
"""
This module will be available in templates as ``u``.
This module is also used to lookup custom template context providers, i.e. functions
following a special naming convention which are called to update the template context
before rendering resource's detail or index views.
"""
1 change: 1 addition & 0 deletions amsd/views.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#
3 changes: 3 additions & 0 deletions data/README.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Files in this directory can be conveniently accessed from scripts using

args.data_file('path', 'relative', 'to', 'here')
43 changes: 43 additions & 0 deletions development.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
[app:main]
use = egg:amsd

pyramid.reload_templates = true
pyramid.debug_authorization = false
pyramid.debug_notfound = false
pyramid.debug_routematch = false
pyramid.default_locale_name = en
pyramid.includes =
pyramid_tm
sqlalchemy.url = postgresql://chrzyki@/amsd

[server:main]
use = egg:waitress#main
host = 127.0.0.1
port = 6543

[loggers]
keys = root, amsd

[handlers]
keys = console

[formatters]
keys = generic

[logger_root]
level = INFO
handlers = console

[logger_amsd]
level = DEBUG
handlers =
qualname = amsd

[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
Loading

0 comments on commit e78d452

Please sign in to comment.