|
@@ -81,25 +81,33 @@ end
|
|
|
its own, traverse the list of first children and use the first one found
|
|
|
with a thumbnail.
|
|
|
|
|
|
- @TODO This should actually use the `pas:hasRepresentation` property
|
|
|
- instead of the first child.
|
|
|
-
|
|
|
@param[in] s Subject (resource) URI.
|
|
|
|
|
|
@param[in] ext Optional extension to add, including the extension separator
|
|
|
(`.`). If not provided, `.jpg` is used.
|
|
|
--]]
|
|
|
local function get_tn_url(s, ext) -- TODO caller needs to pass correct ext
|
|
|
- if repo.gr:attr(s, pkar.RDF_TYPE)[pkar.FILE_T.hash] then
|
|
|
+ if repo.gr:contains(triple.new(s, pkar.RDF_TYPE, pkar.FILE_T)) 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))
|
|
|
+ if ref then return get_tn_url(ref, ext) end
|
|
|
+
|
|
|
-- Recurse through all first children until one with a thumbnail, or a
|
|
|
-- leaf without children, is found.
|
|
|
- local first_child
|
|
|
- _, first_child = next(repo.gr:attr(s, pkar.FIRST_P))
|
|
|
- if first_child then return get_tn_url(first_child, ext) end
|
|
|
+ local t
|
|
|
+ -- Look for preferred rep first.
|
|
|
+ _, 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
|
|
|
+ end
|
|
|
+ if t then return get_tn_url(t, ext) end
|
|
|
end
|
|
|
|
|
|
|
|
@@ -115,16 +123,8 @@ local function generate_dres(s, mconf)
|
|
|
logger:debug("DRES pname: " .. pname)
|
|
|
local pconf = ((mconf.properties or NT)[pname] or NT)
|
|
|
-- RDF types are shown in in breadcrumbs.
|
|
|
- if pname == pkar.RDF_TYPE.data then goto skip
|
|
|
- elseif ((mconf.properties or NT)[pname] or NT).type == "rel" then
|
|
|
- -- Relationship.
|
|
|
- rel[pname] = {
|
|
|
- label = pconf.label,
|
|
|
- description = pconf.description,
|
|
|
- uri = pconf.uri
|
|
|
- }
|
|
|
- for _, o in pairs(ots) do table.insert(dmd[pname], o.data) end
|
|
|
- elseif pname == "first" then
|
|
|
+ if pname == pkar.RDF_TYPE.data then goto skip end
|
|
|
+ if pname == "first" then
|
|
|
-- Build a linked list for every first found.
|
|
|
for _, o in pairs(ots) do
|
|
|
-- Loop through all first children.
|
|
@@ -144,13 +144,14 @@ 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))
|
|
|
+ --dbg()
|
|
|
table.insert(ll, {
|
|
|
- href = pkar.gen_pairtree(
|
|
|
- "/res", child_s.data, ".html", true),
|
|
|
+ href = pkar.gen_pairtree("/res", ref.data, ".html", true),
|
|
|
label = label,
|
|
|
- tn = get_tn_url(child_s),
|
|
|
+ tn = get_tn_url(ref),
|
|
|
})
|
|
|
- logger:debug("Child label for ", child_s.data, ": ", ll[#ll].label or "nil")
|
|
|
+ logger:debug("Child label for ", ref.data, ": ", ll[#ll].label or "nil")
|
|
|
-- There can only be one "next"
|
|
|
_, child_s = next(repo.gr:attr(child_s, pkar.NEXT_P))
|
|
|
end
|
|
@@ -159,6 +160,19 @@ local function generate_dres(s, mconf)
|
|
|
elseif pname == "next" then
|
|
|
-- Sibling.
|
|
|
for _, o in pairs(ots) do ls_next = o.data break end
|
|
|
+ elseif pconf.type == "resource" then
|
|
|
+ -- Relationship.
|
|
|
+ rel[pname] = {
|
|
|
+ label = pconf.label,
|
|
|
+ description = pconf.description,
|
|
|
+ uri = pconf.uri,
|
|
|
+ }
|
|
|
+ for _, o in pairs(ots) do
|
|
|
+ table.insert(rel[pname], {
|
|
|
+ href = pkar.gen_pairtree("/res", o.data, ".html", true),
|
|
|
+ label = nsm.denormalize_uri(o.data),
|
|
|
+ })
|
|
|
+ end
|
|
|
else
|
|
|
-- Descriptive metadata.
|
|
|
local attr = {
|
|
@@ -221,18 +235,23 @@ local function generate_ores(s, mconf)
|
|
|
local pname = model.uri_to_id[nsm.denormalize_uri(p.data)] or p.data
|
|
|
local pconf = ((mconf.properties or NT)[pname] or NT)
|
|
|
-- RDF types are shown in in breadcrumbs.
|
|
|
- if pname == pkar.RDF_TYPE.data then goto skip
|
|
|
- elseif pconf.type == "rel" then
|
|
|
+ if pname == pkar.RDF_TYPE.data then goto skip end
|
|
|
+ if pname == "next" then
|
|
|
+ -- Sibling.
|
|
|
+ for _, o in pairs(ots) do ls_next = o.data break end
|
|
|
+ elseif pconf.type == "resource" then
|
|
|
-- Relationship.
|
|
|
rel[pname] = {
|
|
|
label = pconf.label,
|
|
|
description = pconf.description,
|
|
|
- uri = pconf.uri
|
|
|
+ uri = pconf.uri,
|
|
|
}
|
|
|
- for _, o in pairs(ots) do table.insert(techmd[pname], o.data) end
|
|
|
- elseif pname == "next" then
|
|
|
- -- Sibling.
|
|
|
- for _, o in pairs(ots) do ls_next = o.data break end
|
|
|
+ for _, o in pairs(ots) do
|
|
|
+ table.insert(rel[pname], {
|
|
|
+ href = pkar.gen_pairtree("/res", o.data, ".html", true),
|
|
|
+ label = nsm.denormalize_uri(o.data),
|
|
|
+ })
|
|
|
+ end
|
|
|
else
|
|
|
-- Descriptive metadata.
|
|
|
techmd[pname] = {
|