Serval
Serval is a logical-functional framework for developing web applications. It is generic and largely independent of the bio-specific modules. However, both serval and the bio-specific modules depend upon the same utility module, so I have decided just to bundle serval with blip for now. If you are interested in a distribution that is independent on Blip, contact the developer
Overview
Most web applications are an unholy mix of HTML and application code. Templating systems (eg Template::Toolkit, JSP, ASP, PHP) make some attempt to seperate the HTML from the application code, but they invariably end up tainting each other.
Declarative languages such as lisp and prolog, which allow you to mix code and data make natural choices for developing web applications.
Prolog as a server application language
Prolog is a particularly good choice, because web applications are naturally viewed as state machines, with rules governing when transitions occur, and what changes to apply to the web-user's state on each transition
In addition, many web applications have a significant querying component. Prolog is a natural choice for querying data
However, Prolog's native I/O commands are a poor choice for writing HTML. Less naive approaches to exporting HTML do not suffer the same problems. Any XML document (and thus any well formed HTML document) can be represented using nested prolog compound terms (similar to lisp's S-Expressions). For example:
sdefun(hello_world,
html(head(title('hello world')),
body(h1('hello world')))).
That intepreter can also be extended to have both standard functional programming primitives and access to prolog. For example:
% data predicates
person(chaz).
person(baz).
person(gaz).
sdefun(hello_everyone,
html(head(title('hello people)),
body(ul(findall(li(['hello to ',Person]),
person(Person)))))).
This uses a serval builtin function "findall", which queries prolog for all successful calls to person/1 unifying the variable Person with the name, and constructing an HTML list with one entry per person
Combined with the ability for the application programmer to define their own modular parameterized xml generating functions, this makes for a simple and powerful way of rapidly developing web applications
Parameterized page functions
Consider the following example: a function for showing an html table containing a summary of a list of data entities (eg genes). the function takes one argument, a (prolog) list of IDs. the function makes use of a prolog predicate gene_name/2 which is presumably defined in the model/logic section.
sdefun(gene_table(IDs),
table(border=1,
tr(th('ID'),th('Name')),
findall(tr(td(ID),td(Name)),
(member(ID,IDs),gene_name(ID,Name))))).
Transitions
Transitions are specified as prolog rules using strans/4 and strans/5. A transition has certain preconditions which must be satisfied before the transition can take place. The preconditions are the current page/state, and a standard prolog list of predicates that must succeed.
a transition also contains actions: these modify the current session state. the session state cannot be modified in the views, only in the controller.
% transition to page 'gene_search_results' on user action
strans(gene_search_results,StateIn,
( % PRECONDITIONS:
% the 'submit' param must be 'search' and the
% value of the param 'data_class' must be 'gene'
submit_param(StateIn,search),
getparam(S,data_class,gene)),
( % ACTIONS:
% the database is searched for genes and the
% resulting ID set is added to the state
ngetparam(StateIn,search_text,Search),
% this predicate should be defined in the model/logic
% part of the application
gene_ids_by_search_text(Search,IDs)),
( % CHANGES:
add([[gene_ids,IDs]]))).
To find out more...
This is essentially what serval is. To find out more read the serval module documentation, or even better, the full blip distribution and have a look at some of the example applications (in "examples/") and the full-blown Amigo next generation ontology application (in "apps"). There may be an instance of this running; try Phenotype Ontology and Database, Open Bio Ontologies or, a demo running on a random fun/unusual ontology I found: Semantic Bible.