|
@@ -26,6 +26,9 @@ local NT = {}
|
|
-- All resource subjects.
|
|
-- All resource subjects.
|
|
local subjects
|
|
local subjects
|
|
|
|
|
|
|
|
+-- Extension for type-based icon files.
|
|
|
|
+local ICON_EXT = ".svg"
|
|
|
|
+
|
|
local asset_dir = pkar.config.htmlgen.out_dir
|
|
local asset_dir = pkar.config.htmlgen.out_dir
|
|
local index_path = path.join(asset_dir, "js", "fuse_index.json")
|
|
local index_path = path.join(asset_dir, "js", "fuse_index.json")
|
|
local keys_path = path.join(asset_dir, "js", "fuse_keys.json")
|
|
local keys_path = path.join(asset_dir, "js", "fuse_keys.json")
|
|
@@ -52,6 +55,7 @@ end
|
|
local M = {
|
|
local M = {
|
|
res_dir = path.join(pkar.config.htmlgen.out_dir, "res"),
|
|
res_dir = path.join(pkar.config.htmlgen.out_dir, "res"),
|
|
asset_dir = asset_dir,
|
|
asset_dir = asset_dir,
|
|
|
|
+ icon_dir = path.join(asset_dir, "icons"),
|
|
media_dir = path.join(pkar.config.htmlgen.out_dir, "media"),
|
|
media_dir = path.join(pkar.config.htmlgen.out_dir, "media"),
|
|
webroot = "", -- TODO switch depending on local FS or webserver generation.
|
|
webroot = "", -- TODO switch depending on local FS or webserver generation.
|
|
}
|
|
}
|
|
@@ -111,6 +115,17 @@ local function get_tn_url(s, ext) -- TODO caller needs to pass correct ext
|
|
end
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
+--[[ Find closest available type icon to the given type.
|
|
|
|
+--]]
|
|
|
|
+local function get_icon_url(lineage)
|
|
|
|
+ for i = #lineage, 1, -1 do
|
|
|
|
+ if path.isfile(path.join(M.icon_dir, lineage[i] .. ICON_EXT)) then
|
|
|
|
+ return M.webroot .. "/icons/" .. lineage[i] .. ICON_EXT
|
|
|
|
+ end
|
|
|
|
+ end
|
|
|
|
+end
|
|
|
|
+
|
|
|
|
+
|
|
local function generate_dres(s, mconf)
|
|
local function generate_dres(s, mconf)
|
|
local dmd = {}
|
|
local dmd = {}
|
|
local rel = {}
|
|
local rel = {}
|
|
@@ -151,7 +166,6 @@ local function generate_dres(s, mconf)
|
|
label = label,
|
|
label = label,
|
|
tn = get_tn_url(ref),
|
|
tn = get_tn_url(ref),
|
|
})
|
|
})
|
|
- logger:debug("Child label for ", ref.data, ": ", ll[#ll].label or "nil")
|
|
|
|
-- There can only be one "next"
|
|
-- There can only be one "next"
|
|
_, child_s = next(repo.gr:attr(child_s, pkar.NEXT_P))
|
|
_, child_s = next(repo.gr:attr(child_s, pkar.NEXT_P))
|
|
end
|
|
end
|
|
@@ -213,6 +227,7 @@ local function generate_dres(s, mconf)
|
|
rel = rel,
|
|
rel = rel,
|
|
children = children,
|
|
children = children,
|
|
ls_next = ls_next,
|
|
ls_next = ls_next,
|
|
|
|
+ icon_url = get_icon_url(mconf.lineage),
|
|
breadcrumbs = get_breadcrumbs(mconf),
|
|
breadcrumbs = get_breadcrumbs(mconf),
|
|
rdf_href = pkar.gen_pairtree("/res", s.data, ".ttl", true),
|
|
rdf_href = pkar.gen_pairtree("/res", s.data, ".ttl", true),
|
|
})
|
|
})
|
|
@@ -316,6 +331,7 @@ local function generate_ores(s, mconf)
|
|
techmd = techmd,
|
|
techmd = techmd,
|
|
rel = rel,
|
|
rel = rel,
|
|
ls_next = ls_next,
|
|
ls_next = ls_next,
|
|
|
|
+ icon_url = get_icon_url(mconf.lineage),
|
|
breadcrumbs = get_breadcrumbs(mconf),
|
|
breadcrumbs = get_breadcrumbs(mconf),
|
|
pres = pres,
|
|
pres = pres,
|
|
thumbnail = tn,
|
|
thumbnail = tn,
|