Discussion:
libfossil www interface: looking for ideas
(too old to reply)
Stephan Beal
2014-02-17 17:33:33 UTC
Permalink
Hi, all,

over the weekend i put together some proof-of-concept code demonstrating
CGI pages created using libfossil, e.g.:

http://fossil.wanderinghorse.net/repos/libfossil/cgidemo/index.cgi/timeline?showSrc=1&limit=5

This post is about gathering input for, say, the top 5 things a fossil WWW
UI needs to provide, so that i can be sure to shape the code to be able to
do these things.

Some of the main features i have in mind include:

- it must be able to support various types of pages: HTML, plain text,
JSON, and those outputing raw data (e.g. for fetching images or PDFs out of
a repo).

- For HTML-based pages, the framework should take care of wrapping the main
content (the "app") in the site's preferred header/footer, and catching
exceptions thrown from the app so that they can be displayed inside the
normal page layout (as opposed to ending the page abruptly at the error
point). The framework supports multi-level output buffering (modeled on
PHP's ob_start() and friends) so, for example, it is possible for a page to
decide, halfway through rendering, that it will set a cookie (it's not
normally possible to set cookies after page output has started, but
buffering enables that) or even that it will simply discard all current
output, change the Content-Type, and output something completely different.

- it must be relatively extensible by the client. One of my goals is that
clients can add pages by dropping scripts into some specific directory (or
store them in a db table) and, after that, some CGI path, e.g.
/pages/mySpecialPage, will Do The Right Thing, wrapping the page/app up in
the main layout, or allowing the page to specify that it will generate all
output itself (e.g. JSON or raw binary output).

- rather than think in terms of pages i'd like to think in terms of "apps"
or "applets." There's no reason that a "page" should not be able to turn
around and embed 4 other smaller "pagelets." There's also no reason those
pagelets can't load JavaScript, fetch JSON data from the server, and be
completely interactive.

There are no compatibility constraints vis-a-vis the fossil we all know and
love. This is about creating alternate UIs for it.

Before asking some concrete questions, let me briefly explain current
caveats (due to current limits of libfossi):

- it's read-only: libfossil doesn't currently know anything about fossil's
authentication model. i.e. only public content can currently be rendered by
apps, and editing anything (while possible at the library level) won't be
on the UI's TODO list for the near-term.

- There is no ticket support for the time being. Fossil's tickets are
closely tied to th1, and i currently have no plans to integrate th1 into
libfossil (but may eventually do so via a higher-level optional API).


Now the questions...

what are the top 5 (or so) pages you all use in the Fossil WWW UI (the
fossil 'ui' command, or the page shown by a fossil server/CGI)?

Mine, in no particular order:

- /timeline
- browsing version diffs from the timeline
- /reports (i love these!)
- the wiki often in some repos, but not at all in others.
- occasionally /dir, but not too often


In your opinion, what page is missing from Fossil, which you would like to
see (keeping in mind the caveats mentioned above)?

:-?
--
----- stephan beal
http://wanderinghorse.net/home/stephan/
http://gplus.to/sgbeal
"Freedom is sloppy. But since tyranny's the only guaranteed byproduct of
those who insist on a perfect world, freedom will have to do." -- Bigby Wolf
Michai Ramakers
2014-02-17 19:16:42 UTC
Permalink
opinion polls are always fun, because everyone has one.
Post by Stephan Beal
what are the top 5 (or so) pages you all use in the Fossil WWW UI (the
fossil 'ui' command, or the page shown by a fossil server/CGI)?
in this order:

- /timeline
- /tree of trunk or particular checkin/tag
- /taglist
- /vdiff of sourcetree (glob) between 2 tags
- all the rest

(replace /tree with /dir if convenient)
Post by Stephan Beal
In your opinion, what page is missing from Fossil, which you would like to
see (keeping in mind the caveats mentioned above)?
Can't think of anything now; it's very complete for my use.

Michai
David Given
2014-02-17 21:59:01 UTC
Permalink
On 2/17/14, 5:33 PM, Stephan Beal wrote:
[...]
Post by Stephan Beal
- rather than think in terms of pages i'd like to think in terms of "apps"
or "applets." There's no reason that a "page" should not be able to turn
around and embed 4 other smaller "pagelets." There's also no reason those
pagelets can't load JavaScript, fetch JSON data from the server, and be
completely interactive.
This sounds very much as if what you're actually looking for is a web
servlet engine with libfossil bindings, rather than anything that's
actually specific to Fossil.

In which case I'd strongly urge that the best option here is to pick a
third party servlet engine based on its own criteria rather than
inventing yet another one --- they're harder than they look and there
are too many as it is! (Particularly if you want something
session-based; sessions are surprisingly hard to get right.)

[...]
Post by Stephan Beal
In your opinion, what page is missing from Fossil, which you would like to
see (keeping in mind the caveats mentioned above)?
I'd like a page that allows browsing the repository *by filename*. There
are many occasions when I want to be able to link directly to the tip
version of a particular file, and currently I can't do that --- I either
have to link to a file by artifact ID or force the file to be available
via doc/ somehow, which isn't always possible.
--
┌───  ───── http://www.cowlark.com ─────
│
│ "You cannot truly appreciate _Atlas Shrugged_ until you have read it
│ in the original Klingon." --- Sea Wasp on r.a.sf.w
Stephan Beal
2014-02-17 22:26:17 UTC
Permalink
Post by David Given
This sounds very much as if what you're actually looking for is a web
servlet engine with libfossil bindings, rather than anything that's
actually specific to Fossil.
Almost, except that i have no grand delusions about it being used for
everything. It's primarily:

a) a testing ground for the lib. Can it provide users the data they need
easily? Scriptability of a library is sort of a benchmark for me on its
usability/flexibility.

b) proof of concept. Until someone can actually "touch" libfossil, nobody
but me is going to be using it!

c) it's just fun to tinker with the script bindings.

i'm not looking to provide a universal solution to all WWW UI needs, just a
demo/proof-of-concept.

In which case I'd strongly urge that the best option here is to pick a
Post by David Given
third party servlet engine based on its own criteria rather than
inventing yet another one --- they're harder than they look and there
are too many as it is! (Particularly if you want something
session-based; sessions are surprisingly hard to get right.)
Can you recommend one in C? i'm self-imposed bound to C here. i "might" be
convinced to write it in C++.

i actually have sessions support implemented in C already[1], but it's not
used here because i really don't want to have sessions in the db. Once
libfossil gets fossil authentication support, i wouldn't mind storing
non-anonymous/guest-user sessions (as a JSON object) in the repo, because
that number is bounded (manx = one per registered user). That's a ways down
the road, but it's not far out of reach (just not high on the priority
list).

A new demo, just uploaded :

http://fossil.wanderinghorse.net/repos/libfossil/cgidemo/index.cgi/manifest?version=1
http://fossil.wanderinghorse.net/repos/libfossil/cgidemo/index.cgi/manifest?version=trunk&baseline=1
http://fossil.wanderinghorse.net/repos/libfossil/cgidemo/index.cgi/manifest?showSrc=1


Good night!

[1] = http://fossil.wanderinghorse.net/wikis/cson/?page=cson_session
--
----- stephan beal
http://wanderinghorse.net/home/stephan/
http://gplus.to/sgbeal
"Freedom is sloppy. But since tyranny's the only guaranteed byproduct of
those who insist on a perfect world, freedom will have to do." -- Bigby Wolf
David Given
2014-02-19 21:06:30 UTC
Permalink
On 2/17/14, 10:26 PM, Stephan Beal wrote:
[...]
Post by Stephan Beal
Can you recommend one in C? i'm self-imposed bound to C here. i "might" be
convinced to write it in C++.
Unfortunately, no --- it's not something I'd really want to do in C, as
C's strengths do not really match the kind of wholesale string shuffling
you need for a servlet engine. (Although using sqlite *just for string
manipulation* from C is surprisingly comfortable.)

In the past I've used an engine in Python (greenevents based? It's been
a while) which was okay, despite being in Python; also Lua's wsapi,
which is indifferently documented but tiny and flexible. But that
probably doesn't really help.
--
┌───  ───── http://www.cowlark.com ─────
│
│ "You cannot truly appreciate _Atlas Shrugged_ until you have read it
│ in the original Klingon." --- Sea Wasp on r.a.sf.w
Stephan Beal
2014-02-19 21:25:10 UTC
Permalink
Post by David Given
Unfortunately, no --- it's not something I'd really want to do in C, as
C's strengths do not really match the kind of wholesale string shuffling
you need for a servlet engine. (Although using sqlite *just for string
manipulation* from C is surprisingly comfortable.)
That's where the scripting engine comes in :).

In the past I've used an engine in Python (greenevents based? It's been
Post by David Given
a while) which was okay, despite being in Python;
+1, though i'll admit that my grounds are purely aesthetic, not technical.

also Lua's wsapi,
Post by David Given
which is indifferently documented but tiny and flexible. But that
probably doesn't really help.
So far my home-grown scripting engine (originally inspired by Fossil's th1)
has held up surprisingly nicely to libfossil's needs (so far only had to
fix one minor bug in the script engine :). Only the low-level bits of the
demo CGI pages are in C. All of the high-level shuffling and is done by the
scripts. This isn't an attempt to provide a "standard" scripting engine or
platform for (lib)Fossil, basically just to show that it can be done - that
libfossil is far enough along to do these things and that they can be bound
to script engines (a personal benchmark i use to help estimate a library
API's viability).

BTW: i've started documenting the script bindings and the related CGI bits
here:

https://docs.google.com/document/d/1YsVMBNJfuZC7tIxqhNgK21O7dQyV0mnsfQRn0GMpU5I/view

That "should" be readable by anyone, but have occasionally heard complaints
that those without a Google account can't see my GDocs.

[1] = a very basic binding example:
http://fossil.wanderinghorse.net/repos/libfossil/index.cgi/artifact/c6d9bc06fe2fa884?ln=882-893
--
----- stephan beal
http://wanderinghorse.net/home/stephan/
http://gplus.to/sgbeal
"Freedom is sloppy. But since tyranny's the only guaranteed byproduct of
those who insist on a perfect world, freedom will have to do." -- Bigby Wolf
Ron Wilson
2014-02-19 22:59:02 UTC
Permalink
Post by David Given
[...]
Post by Stephan Beal
Can you recommend one in C? i'm self-imposed bound to C here. i "might"
be
Post by Stephan Beal
convinced to write it in C++.
Unfortunately, no --- it's not something I'd really want to do in C, as
C's strengths do not really match the kind of wholesale string shuffling
you need for a servlet engine. (Although using sqlite *just for string
manipulation* from C is surprisingly comfortable.)
Years ago, I used an "AWK lib" to code complex string handling in C.
Unfortunately, I lost the sources for those projects and have had no luck
finding the library, again.

While I have seem some CGIs written in C, I've never seen a web app frame
work for C.
Nico Williams
2014-02-20 23:37:26 UTC
Permalink
Post by Stephan Beal
Post by David Given
In which case I'd strongly urge that the best option here is to pick a
third party servlet engine based on its own criteria rather than
inventing yet another one --- they're harder than they look and there
are too many as it is! (Particularly if you want something
session-based; sessions are surprisingly hard to get right.)
Can you recommend one in C? i'm self-imposed bound to C here. i "might" be
convinced to write it in C++.
If you look aroung in http://github.com/stedolan you'll find a minimal
http server, with much of the code you need for building something
like this.
Doug Currie
2014-02-21 00:28:37 UTC
Permalink
Post by Nico Williams
Post by Stephan Beal
Can you recommend one in C? i'm self-imposed bound to C here. i "might"
be
Post by Stephan Beal
convinced to write it in C++.
If you look aroung in http://github.com/stedolan you'll find a minimal
http server, with much of the code you need for building something
like this.
Or Mongoose: https://code.google.com/p/mongoose/

e

Continue reading on narkive:
Loading...