Login
wikiByName.s2 at [6dca54dfde]
Login

File bindings/s2/require.d/plugins/fsl/wikiByName.s2 artifact 7160c97ec1 part of check-in 6dca54dfde


/**
   require() plugin which fetches a wiki page from the repo db,
   in the form of an Object which mimics the fsl_deck structure
   (see Fossil.Context.loadManifest()).

   It interprets its argument as a wiki page name and throws if not
   found.
*/
return requireS2(['fsl/context', 'fsl/db/repo'], proc(fsl, repo){
    return {
        isVirtual: true,
        _F: fsl,
        _sql: <<<_SQL
        SELECT x.rid FROM tag t, tagxref x
        WHERE x.tagid=t.tagid 
        AND t.tagname='wiki-%1$q'
        ORDER BY mtime DESC LIMIT 1 _SQL,
        load: function(name){
            return this._F.loadManifest(
                this._F.db.selectValue(this._sql.applyFormat(name))
                ||| throw "No wiki such wiki page: "+name
            );
        }
    };
});