Class: OKF::Server::App
- Inherits:
-
Object
- Object
- OKF::Server::App
- Defined in:
- lib/okf/server/app.rb
Overview
HTTP access to a bundle's knowledge graph — a Rack app, so it runs under any
Rack server (WEBrick, via okf server) and can be mounted in a Rails app:
mount OKF::Server::App.new(folder) => "/knowledge"
The page (OKF::Render::Graph) boots from a minimal graph (id + title + edges
-
type/tag indexes) and pulls each concept's markdown body and description from here on demand, so the initial payload stays small and bodies are read live from disk (edits show without a restart). Part of the shell — it does I/O.
GET / the interactive graph page (text/html) GET /node?id=… the concept's raw markdown body (text/markdown) GET /node/meta?id=… its description, as an escaped HTML fragment GET /catalog rich per-concept metadata for the catalog/files/stats views: { concepts: [ title, type, description, tags, timestamp, status, area, dir, links_* ] } (JSON) GET /tags the tag index { tag => [id, …] } (JSON) GET /types the type index { type => [id, …] } (JSON) GET /index the §6 progressive-disclosure map for the Index panel: { directories: [ …okf-index rows… ] } (JSON, from the boot snapshot — authored maps are structure) GET /log the §7 history for the Log panel: { logs: [ dir, content ] } (JSON; content read live from disk, like a body — the log is the file that changes most)
Class Method Summary collapse
-
.not_found ⇒ Object
The 404 both this app and the Hub answer with, so the two cannot drift.
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(folder, title: nil, link: nil, layout: "cose", siblings: nil, self_slug: nil, hub_path: nil, search_endpoint: nil, manage_root: nil, manage_token: nil) ⇒ App
constructor
+siblings+/+self_slug+/+hub_path+ are set only when this app is hosted under a hub (OKF::Server::Hub): the other bundles the in-page switcher offers, this bundle's own mount slug, the hub root, and the hub's cross-bundle search route.
Constructor Details
#initialize(folder, title: nil, link: nil, layout: "cose", siblings: nil, self_slug: nil, hub_path: nil, search_endpoint: nil, manage_root: nil, manage_token: nil) ⇒ App
+siblings+/+self_slug+/+hub_path+ are set only when this app is hosted under
a hub (OKF::Server::Hub): the other bundles the in-page switcher offers, this
bundle's own mount slug, the hub root, and the hub's cross-bundle search
route. They stay nil for a standalone server and for okf render, so a
static file never advertises a switcher or a search it cannot answer.
39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/okf/server/app.rb', line 39 def initialize(folder, title: nil, link: nil, layout: "cose", siblings: nil, self_slug: nil, hub_path: nil, search_endpoint: nil, manage_root: nil, manage_token: nil) @folder = folder @title = title @link = link @layout = layout @siblings = siblings @self_slug = self_slug @hub_path = hub_path @search_endpoint = search_endpoint @manage_root = manage_root @manage_token = manage_token end |
Class Method Details
.not_found ⇒ Object
The 404 both this app and the Hub answer with, so the two cannot drift.
71 72 73 |
# File 'lib/okf/server/app.rb', line 71 def self.not_found [ 404, { "content-type" => "text/plain; charset=utf-8" }, [ "not found\n" ] ] end |
Instance Method Details
#call(env) ⇒ Object
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/okf/server/app.rb', line 53 def call(env) request = Rack::Request.new(env) return not_found unless request.get? case request.path_info when "", "/" then respond("text/html; charset=utf-8", page) when "/node" then node_body(request.params["id"]) when "/node/meta" then (request.params["id"]) when "/catalog" then respond_json(catalog) when "/tags" then respond_json(graph.tag_index) when "/types" then respond_json(graph.type_index) when "/index" then respond_json(directory_index) when "/log" then respond_json(logs) else not_found end end |