Class: OKF::Server::App

Inherits:
Object
  • Object
show all
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) 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)

Instance Method Summary collapse

Constructor Details

#initialize(folder, title: nil, link: nil, layout: "cose") ⇒ App

Returns a new instance of App.



34
35
36
37
38
39
# File 'lib/okf/server/app.rb', line 34

def initialize(folder, title: nil, link: nil, layout: "cose")
  @folder = folder
  @title = title
  @link = link
  @layout = layout
end

Instance Method Details

#call(env) ⇒ Object



41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/okf/server/app.rb', line 41

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 node_meta(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