|
@@ -25,9 +25,6 @@ local dbg = require "debugger"
|
|
-- "nil" table - for missing key fallback in chaining.
|
|
-- "nil" table - for missing key fallback in chaining.
|
|
local NT = {}
|
|
local NT = {}
|
|
|
|
|
|
--- All resource subjects.
|
|
|
|
-local subjects
|
|
|
|
-
|
|
|
|
-- Extension for type-based icon files.
|
|
-- Extension for type-based icon files.
|
|
local ICON_EXT = ".svg"
|
|
local ICON_EXT = ".svg"
|
|
|
|
|
|
@@ -584,7 +581,7 @@ M.generate_resource = function(s)
|
|
local res_path = pkar.gen_pairtree(M.res_dir, s.data, ".ttl")
|
|
local res_path = pkar.gen_pairtree(M.res_dir, s.data, ".ttl")
|
|
dir.makepath(path.dirname(res_path))
|
|
dir.makepath(path.dirname(res_path))
|
|
local ofh = assert(io.open(res_path, "w"))
|
|
local ofh = assert(io.open(res_path, "w"))
|
|
- ofh:write(repo.serialize_rsrc(s, "ttl"))
|
|
|
|
|
|
+ for chunk in repo.serialize_rsrc(s, "ttl") do ofh:write(chunk) end
|
|
ofh:close()
|
|
ofh:close()
|
|
|
|
|
|
-- Generate HTML doc.
|
|
-- Generate HTML doc.
|
|
@@ -604,9 +601,19 @@ M.generate_resource = function(s)
|
|
end
|
|
end
|
|
|
|
|
|
|
|
|
|
-M.generate_resources = function()
|
|
|
|
- -- Look up if subjects are already populated.
|
|
|
|
- subjects = subjects or repo.gr:unique_terms(triple.POS_S)
|
|
|
|
|
|
+M.generate_resources = function(coll_id)
|
|
|
|
+ -- TODO It's more complicated than this. Each member in the collection
|
|
|
|
+ -- must be scanned recursively for outbound links and visited links must
|
|
|
|
+ -- be noted down to avoid loops.
|
|
|
|
+ --[[
|
|
|
|
+ if coll_id then
|
|
|
|
+ subject_ts = repo.gr:term_set(
|
|
|
|
+ term.new_iriref_ns("par:" .. coll_id), triple.POS_S,
|
|
|
|
+ model.id_to_uri.has_member, triple.POS_P
|
|
|
|
+ )
|
|
|
|
+ else subjects_ts = repo.gr:unique_terms(triple.POS_S) end
|
|
|
|
+ --]]
|
|
|
|
+ subjects_ts = repo.gr:unique_terms(triple.POS_S)
|
|
|
|
|
|
-- Initialize the JSON template with an opening brace.
|
|
-- Initialize the JSON template with an opening brace.
|
|
local ofh = assert(io.open(index_path, "w"))
|
|
local ofh = assert(io.open(index_path, "w"))
|
|
@@ -614,7 +621,7 @@ M.generate_resources = function()
|
|
ofh:close()
|
|
ofh:close()
|
|
|
|
|
|
-- TODO parallelize
|
|
-- TODO parallelize
|
|
- for s in subjects:iter() do assert(M.generate_resource(s)) end
|
|
|
|
|
|
+ for s in subjects_ts:iter() do assert(M.generate_resource(s)) end
|
|
|
|
|
|
-- Close the open list brace in the JSON template after all the resources
|
|
-- Close the open list brace in the JSON template after all the resources
|
|
-- have been added.
|
|
-- have been added.
|