-
-
Notifications
You must be signed in to change notification settings - Fork 12
Creating Internal Pages
A web browser like Odysseus has essentially two jobs: to present webpages to you so you can easily navigate between them, and to help you find those pages (again). To reduce percieved complexity and to take advantage of the link-driven UX of the Web, the latter is presented like a serverside webapp. To help achieve that Odysseus has it's own builtin web framework that's not dissimilar to Django or Ruby on Rails.
This page documents the components of said webframework.
Prosody, which Odysseus uses like a nicer version of PHP, is the core of it's webframework. It helps us combine DSLs like URL lists, SQL, and HTML to benefit from their combined concision, by moving stuff into place between these DSLs. It also provides a much nicer syntax ontop of Vala objects, like GLib.Value, SQLite tuples, JSON-GLib, LibXML, and the concept of query parameters, that are already runtime dynamic either in terms of supported fields and/or their primitive type. And finally it implicitly escapes all data values so noone forgets this crucial step, which has been seen efficiently escaping an entire HTML file.
It is heavily based on Django's templating language. And given that a webframework is mostly about serializing/deserializing popular text-based formats, Prosody provides most of what we need from a web framework.
Database migrations is the weakest component of Odysseus's web framework. It doesn't have any built-in intelligence other than tracking what schema version the enduser's database is at, and the migrations script does not handle merge conflicts at all. That is while you can certainly resolve merge conflicts in Git, those won't be reflected to anyone's database and any problems that way must be manually resolved on each machine.
Very simply what Odysseus has for migrations is a Prosody template that generates a sequence of SQL data definition statements given an integral variable v
. Prosody tags are not allowed within an SQL statement that's being outputted by this template.
An odysseus:
URI fetches a file out of data/pages/
(which are compiled via GResource into the same executable binary), and hands the rendered HTML, etc to WebKit. It's worth noting that the transport used for this has no concept of HTTP error codes, so all errors must be communicated in the page or be let slide.
A icon:
URI, given a size and an icon name, responds with the corresponding PNG image from the installed freedesktop.org compatible icon theme. This effectively grants pages access to a superb icon theme (at least on elementary OS) the reader is already familiar with.
If you submit a form in a page served from the odysseus:
URI scheme with a (CSS hidden) text field by the name of $
, Odysseus will intercept it and evaluate an INSERT OR REPLACE
SQL query passing in all text inputs before reloading the page to view all changes or reporting an error putting the blame on that form. The $
input is not passed in as a table field, but rather names the table for the query to apply to.