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::Server::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)
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(folder, title: nil, link: nil, layout: "cose") ⇒ App
constructor
A new instance of App.
Constructor Details
#initialize(folder, title: nil, link: nil, layout: "cose") ⇒ App
Returns a new instance of App.
28 29 30 31 32 33 |
# File 'lib/okf/server/app.rb', line 28 def initialize(folder, title: nil, link: nil, layout: "cose") @folder = folder @title = title @link = link @layout = layout end |
Instance Method Details
#call(env) ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/okf/server/app.rb', line 35 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) else not_found end end |