|
@@ -91,18 +91,19 @@ end
|
|
|
(`.`). If not provided, `.jpg` is used.
|
|
|
--]]
|
|
|
local function get_tn_url(s, ext) -- TODO caller needs to pass correct ext
|
|
|
- if repo.gr:contains(triple.new(s, pkar.RDF_TYPE, pkar.FILE_T)) then
|
|
|
+ if repo.gr:contains(triple.new(s, pkar.RDF_TYPE, model.id_to_uri.file))
|
|
|
+ then
|
|
|
-- The subject is a file.
|
|
|
return pkar.gen_pairtree(TN_WEB_PATH, s.data, ext or ".jpg", true)
|
|
|
end
|
|
|
|
|
|
-- If it's a brick, look for its ref.
|
|
|
local ref
|
|
|
- _, ref = next(repo.gr:attr(s, pkar.REF_P))
|
|
|
+ _, ref = next(repo.gr:attr(s, model.id_to_uri.ref))
|
|
|
if ref then return get_tn_url(ref, ext) end
|
|
|
|
|
|
local pref_rep
|
|
|
- _, pref_rep = next(repo.gr:attr(s, pkar.PREF_REP_P))
|
|
|
+ _, pref_rep = next(repo.gr:attr(s, model.id_to_uri.pref_rep))
|
|
|
if pref_rep then return get_tn_url(pref_rep, ext) end
|
|
|
|
|
|
-- Recurse through all first children until one with a thumbnail, or a
|
|
@@ -112,8 +113,8 @@ local function get_tn_url(s, ext) -- TODO caller needs to pass correct ext
|
|
|
_, t = next(repo.gr:attr(s, model.id_to_uri["pref_rep"]))
|
|
|
if not t then
|
|
|
-- If not found, look for reference of first child.
|
|
|
- _, t = next(repo.gr:attr(s, pkar.FIRST_P))
|
|
|
- if t then _, t = next(repo.gr:attr(t, pkar.REF_P)) end
|
|
|
+ _, t = next(repo.gr:attr(s, model.id_to_uri.first))
|
|
|
+ if t then _, t = next(repo.gr:attr(t, model.id_to_uri.ref)) end
|
|
|
end
|
|
|
if t then return get_tn_url(t, ext) end
|
|
|
end
|
|
@@ -170,7 +171,7 @@ local function generate_dres(s, mconf)
|
|
|
|
|
|
while child_s do
|
|
|
-- Loop trough all next nodes for each first child.
|
|
|
- local _, ref = next(repo.gr:attr(child_s, pkar.REF_P))
|
|
|
+ local _, ref = next(repo.gr:attr(child_s, model.id_to_uri.ref))
|
|
|
--dbg()
|
|
|
table.insert(ll, {
|
|
|
href = pkar.gen_pairtree("/res", ref.data, ".html", true),
|
|
@@ -178,7 +179,8 @@ local function generate_dres(s, mconf)
|
|
|
tn = get_tn_url(ref),
|
|
|
})
|
|
|
-- 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, model.id_to_uri.next))
|
|
|
end
|
|
|
table.insert(children, ll)
|
|
|
end
|
|
@@ -208,7 +210,7 @@ local function generate_dres(s, mconf)
|
|
|
-- TODO differentiate term types
|
|
|
for _, o in pairs(ots) do table.insert(attr, o.data) end
|
|
|
table.sort(attr)
|
|
|
- if p == pkar.DC_TITLE_P then title = attr[1] end
|
|
|
+ if p == model.id_to_uri.label then title = attr[1] end
|
|
|
table.insert(dmd, attr)
|
|
|
end
|
|
|
::skip::
|
|
@@ -227,7 +229,7 @@ local function generate_dres(s, mconf)
|
|
|
logger:debug("Breadcrumbs:", pp.write(get_breadcrumbs(mconf)))
|
|
|
|
|
|
local pref_rep, pref_rep_url
|
|
|
- _, pref_rep = next(repo.gr:attr(s, pkar.PREF_REP_P))
|
|
|
+ _, pref_rep = next(repo.gr:attr(s, model.id_to_uri.pref_rep))
|
|
|
if pref_rep then
|
|
|
pref_rep_url = pkar.gen_pairtree("/res", pref_rep.data, ".html", true)
|
|
|
end
|
|
@@ -316,7 +318,7 @@ local function generate_ores(s, mconf)
|
|
|
local pres_conf = txconf.pres or {fn = "copy"}
|
|
|
-- Set file name to resource ID + source extension.
|
|
|
dest_fname = (
|
|
|
- s.data:gsub(pkar.PAR_NS, "") ..
|
|
|
+ s.data:gsub(nsm.get_ns("par"), "") ..
|
|
|
(pres_conf.ext or path.extension(res_path[1])))
|
|
|
dest_dir = path.join(
|
|
|
M.media_dir, dest_fname:sub(1, 2), dest_fname:sub(3, 4))
|
|
@@ -391,8 +393,8 @@ M.generate_search_idx = function(s, mconf)
|
|
|
|
|
|
for p, ots in pairs(attrs) do
|
|
|
local pname
|
|
|
- if p == pkar.CONTENT_TYPE_P then goto skip end
|
|
|
- if p == pkar.PATH_P then
|
|
|
+ if p == model.id_to_uri.content_type then goto skip end
|
|
|
+ if p == model.id_to_uri.source_path then
|
|
|
if mconf.types.file then
|
|
|
_, fpath = next(ots)
|
|
|
rrep.fname = path.basename(fpath.data)
|
|
@@ -453,7 +455,7 @@ end
|
|
|
|
|
|
M.generate_resource = function(s)
|
|
|
local res_type
|
|
|
- _, res_type = next(repo.gr:attr(s, pkar.CONTENT_TYPE_P))
|
|
|
+ _, res_type = next(repo.gr:attr(s, model.id_to_uri.content_type))
|
|
|
local mconf = model.from_uri(res_type)
|
|
|
|
|
|
-- Generate RDF/Turtle doc.
|
|
@@ -519,8 +521,8 @@ M.generate_homepage = function()
|
|
|
for _, s in pairs(s_ts) do
|
|
|
if i > (pkar.config.htmlgen.max_homepage_items or 10) then break end
|
|
|
local title, submitted
|
|
|
- _, title = next(repo.gr:attr(s, pkar.DC_TITLE_P))
|
|
|
- _, submitted = next(repo.gr:attr(s, pkar.SUBMITTED_P))
|
|
|
+ _, title = next(repo.gr:attr(s, model.id_to_uri.label))
|
|
|
+ _, submitted = next(repo.gr:attr(s, model.id_to_uri.submitted))
|
|
|
|
|
|
local obj = {
|
|
|
href = pkar.gen_pairtree("/res", s.data, ".html", true),
|
|
@@ -542,8 +544,8 @@ M.generate_homepage = function()
|
|
|
)
|
|
|
for _, s in pairs(s_ts) do
|
|
|
local title, submitted
|
|
|
- _, title = next(repo.gr:attr(s, pkar.DC_TITLE_P))
|
|
|
- _, submitted = next(repo.gr:attr(s, pkar.SUBMITTED_P))
|
|
|
+ _, title = next(repo.gr:attr(s, model.id_to_uri.label))
|
|
|
+ _, submitted = next(repo.gr:attr(s, model.id_to_uri.submitted))
|
|
|
|
|
|
local coll = {
|
|
|
href = pkar.gen_pairtree("/res", s.data, ".html", true),
|