[NB: To run jar version of aama: In webapp dir: 'java -jar aama-webapp.jar' get response: 'Started server on port 3000'] In process of revision with prototype python app.
This is an experimental Clojure webapp demonstrating access to an Resource Description Framework (RDF) dataset of paradigmatic and other morphological data via a local RDF server, in our case Apache Jena Fuseki. The webapp is intended as a test bed for applying a wide variety of SPARQL queries about morphological data in a Clojure context.
We have chosen to write the application in the LISP dialect
Clojure in part because we find
its functional structure congenial and conducive
to insights into the problem at hand, and in part
because of the formidable and constantly growing set of libraries
created by its very involved community of users.
However, as we note in aama.github.io,
essentially the same basic functionality could be achieved
by any software framework which can provide a web interface for handling
SPARQL queries submitted to an RDF datastore.
The application uses "live" aama data. It assumes that, following the process described in aama.github.io:
- language data in Extensible Data Notation (edn) format has been downloaded from one or more of the aama language repositories,
- transformed into ttl/rdf-xml format
using the appropriate shell script in
aama/tools/bin, and - loaded into the Fuseki datastore;
- and that the Fuseki server has been launched (by default on
localhost:3030) by running the shell script:
aama $ tools/bin/fuseki.sh
Note that after Fuseki has been launched, the Apache Jena Fuseki interface
can be consulted directly on the browser at localhost:3030.
SPARQL queries, for example, those contained in the
tools/sparql/rq-ru/
directory, can be run directly against the datastore in the Fuseki Control Panel on the
localhost:3030/dataset.html
page (select the /aama/ dataset when prompted).
As can be seen from the dependencies in project.clj, aama-webappis,
like most Leiningen-managed Clojure web applications,
based on the Ring
web application library, complemented by the
Compojure routing library;
clj-http is its http client library.
Hiccup is used here to represent HTML directly in Clojure. However, although a similar direct representation of SPARQL queries in Clojure could be accomplished by libraries such as Matsu, we have preferred to handle these queries as a collection of SPARQL templates, using the library Stencil to instantiate the values referenced in the templates. This makes it easier for someone familiar with the querying of RDF datasets, but not necessariy with Clojure, to inspect the SPARQL query templates, and suggest and even effect extensions and modifications to them.
(Analogous considerations, e.g., obtaining input from someone familiar with webpage design but not with Clojure, may eventually motivate the replacement of Hiccup by a templating approach to HTML such as Enlive or Selmer.)
The organization of the application code itself follows a rather consistent
pattern. As usual in a Clojure application, each namespace is in a file
NS.clj, and all these files are placed in directories and subdirectories
under src/clj/webapp (where /clj vs /cljs distinguishes the Clojure
vs the ClojureScript files). And as usual in a Compojure-based web application,
the various parts are held together by a small set of functions in a
webapp.handler namespace file. The application background menu,
as well as the basic page layout and invocation of the various javascript
and css resources are taken care of in webapp.views.layout.
The very large number of help, utility, and information-requesting pages are
each represented by a webapp.routes.[NS] file. These information-requesting
files are of a very uniform structure, familiar to almost any database
application in whatever context: almost every one presents an HTML form, with
information (language, morphosyntactic categories, etc.) to be supplied by
selection-lists, check-boxes, and text-input areas. The requested information
is passed to a handler function, which uses it to formulate a SPARQL query
from one of the templates in webapp.models.sparql, submits the request to
the fuseki datastore via clj-http.client/get, and finally parses the
response, formats it, and displays both it, and, where feasible, the query,
as html output.
Cloning the aama/webapp repository, as per aama.github.io, will have downloaded both the source-code and a stand-alone jar file. Presuming that the Fuseki server has been launched (cfs. above) the application can be run in the webapp directory either:
-
From the downloaded sorce-code, using Leiningen:
Enter the following Leiningen command in a shell (terminal session) to launch the app in a local webserver:
aama/webapp $ lein ring server-headless[Note that at present use of Clojurescsript(cljs) is at best marginal in this application. However we are currently experimenting with the transfer of at least some js functionality to cljs, and to the extent that this happens, the user, in another shell, will want to run:
aama/webapp $ lein cljsbuild auto
which will compile the Clojurescript and reload code on edit. See lein cljsbuild for details.]
-
As a Java application from the jar file to be found in the webapp directory, with the command:
aama/webapp $ java -jar aama-webapp.jar
In either case, you can then open localhost:3000 in your browser,
and you will see the application's main menu. Go immediately to the
Help > Initialize Applicationmenu item to generate the application-specific lists and indices used in menus, queries, and displays (otherwise on most pages you will not see anything).
For the Clojure REPL see lein repl,
tools.nrepl, and
cider.
You do not have to use emacs. Many Clojure hackers do, but Lighttable has also become quite popular.
For the Clojurescript REPL, See
- [The REPL and Evaluation Environments] (https://github.com/clojure/clojurescript/wiki/ The-REPL-and-Evaluation-Environments)
- [REPL Support](https://github.com/emezeske/lein-cljsbuild/blob/1.0.3/doc/ REPL.md) for lein cljsbuild