scossu 2 týždňov pred
rodič
commit
5950a1d541

+ 9 - 5
README.md

@@ -237,8 +237,9 @@ functional and available for use by the intended audience.
   - ✓ Generate RDF (single resource)
 - ⚒ Front end
   - ✓ JS search engine
-  - ⎊ Basic styling
-      - ⎊ Default type icons
+  - ⚒ Add collections to index page
+  - ⚒ Basic styling
+      - ⚒ Default type icons
 - ⎊ QA
   - ⎊ ~50 resource data set
 
@@ -246,9 +247,8 @@ functional and available for use by the intended audience.
 
 - Multilingual support
 - Management UI & API
-  - Deposit
-    - S3 source pointer
-    - Single tar or zip file submission
+  - Deposit via S3 source pointer
+  - Deposit via single tar or zip file submission
   - Dump & restore (whole archive & individual resources)
 - Content model
   - Local overrides
@@ -262,3 +262,7 @@ functional and available for use by the intended audience.
 - Front end
   - Enhanced styling and access
 - Testing
+
+#### Post-MVP
+
+- Incremental build

+ 17 - 1
src/generator.lua

@@ -26,6 +26,9 @@ local NT = {}
 -- All resource subjects.
 local subjects
 
+-- Extension for type-based icon files.
+local ICON_EXT = ".svg"
+
 local asset_dir = pkar.config.htmlgen.out_dir
 local index_path = path.join(asset_dir, "js", "fuse_index.json")
 local keys_path = path.join(asset_dir, "js", "fuse_keys.json")
@@ -52,6 +55,7 @@ end
 local M = {
     res_dir = path.join(pkar.config.htmlgen.out_dir, "res"),
     asset_dir = asset_dir,
+    icon_dir = path.join(asset_dir, "icons"),
     media_dir = path.join(pkar.config.htmlgen.out_dir, "media"),
     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
 
 
+--[[ 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 dmd = {}
     local rel = {}
@@ -151,7 +166,6 @@ local function generate_dres(s, mconf)
                         label = label,
                         tn = get_tn_url(ref),
                     })
-                    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
@@ -213,6 +227,7 @@ local function generate_dres(s, mconf)
         rel = rel,
         children = children,
         ls_next = ls_next,
+        icon_url = get_icon_url(mconf.lineage),
         breadcrumbs = get_breadcrumbs(mconf),
         rdf_href = pkar.gen_pairtree("/res", s.data, ".ttl", true),
     })
@@ -316,6 +331,7 @@ local function generate_ores(s, mconf)
         techmd = techmd,
         rel = rel,
         ls_next = ls_next,
+        icon_url = get_icon_url(mconf.lineage),
         breadcrumbs = get_breadcrumbs(mconf),
         pres = pres,
         thumbnail = tn,

+ 5 - 0
templates/assets/css/pkar.css

@@ -18,3 +18,8 @@
     font-style: normal;
     font-weight: bold;
 }
+
+.title_icon {
+    width: 3rem;
+    margin: 0.5rem;
+}

+ 1 - 0
templates/assets/icons/anything.svg

@@ -0,0 +1 @@
+<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width='1em' height='1em'><path fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.5" d="m21 7.5l-9-5.25L3 7.5m18 0l-9 5.25m9-5.25v9l-9 5.25M3 7.5l9 5.25M3 7.5v9l9 5.25m0-9v9"/></svg>

+ 1 - 0
templates/assets/icons/artifact.svg

@@ -0,0 +1 @@
+<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512" width='1em' height='1em'><path fill="currentColor" d="M304 30c-32 64-22.35 180.063 0 208c42.406 53.007 80 80 80 128c0 32-16 80-48 112v16H176v-16c-32.002-31.995-48-80-48-112c0-48 37.594-74.993 80-128c22.35-27.937 32-144 0-208c48-16 48-16 96 0"/></svg>

+ 1 - 0
templates/assets/icons/book.svg

@@ -0,0 +1 @@
+<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width='1em' height='1em'><path fill="currentColor" d="M21 5c-1.11-.35-2.33-.5-3.5-.5c-1.95 0-4.05.4-5.5 1.5c-1.45-1.1-3.55-1.5-5.5-1.5S2.45 4.9 1 6v14.65c0 .25.25.5.5.5c.1 0 .15-.05.25-.05C3.1 20.45 5.05 20 6.5 20c1.95 0 4.05.4 5.5 1.5c1.35-.85 3.8-1.5 5.5-1.5c1.65 0 3.35.3 4.75 1.05c.1.05.15.05.25.05c.25 0 .5-.25.5-.5V6c-.6-.45-1.25-.75-2-1m0 13.5c-1.1-.35-2.3-.5-3.5-.5c-1.7 0-4.15.65-5.5 1.5V8c1.35-.85 3.8-1.5 5.5-1.5c1.2 0 2.4.15 3.5.5z"/><path fill="currentColor" d="M17.5 10.5c.88 0 1.73.09 2.5.26V9.24c-.79-.15-1.64-.24-2.5-.24c-1.7 0-3.24.29-4.5.83v1.66c1.13-.64 2.7-.99 4.5-.99M13 12.49v1.66c1.13-.64 2.7-.99 4.5-.99c.88 0 1.73.09 2.5.26V11.9c-.79-.15-1.64-.24-2.5-.24c-1.7 0-3.24.3-4.5.83m4.5 1.84c-1.7 0-3.24.29-4.5.83v1.66c1.13-.64 2.7-.99 4.5-.99c.88 0 1.73.09 2.5.26v-1.52c-.79-.16-1.64-.24-2.5-.24"/></svg>

+ 1 - 0
templates/assets/icons/collection.svg

@@ -0,0 +1 @@
+<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 21 21" width='1em' height='1em'><g fill="none" fill-rule="evenodd" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round"><path d="m10.5 15.429l3.548 1.837a1 1 0 0 0 .907.006l2.992-1.496a1 1 0 0 0 .553-.894v-2.764a1 1 0 0 0-.553-.894L14.5 9.5l-3.46 1.792a1 1 0 0 0-.54.888z"/><path d="m3.04 15.708l3.008 1.558a1 1 0 0 0 .907.006L10.5 15.5v-3.382a1 1 0 0 0-.553-.894L6.5 9.5l-3.46 1.792a1 1 0 0 0-.54.888v2.64a1 1 0 0 0 .54.888M6.5 9.429l3.548 1.837a1 1 0 0 0 .907.006L14.5 9.5V6.118a1 1 0 0 0-.553-.894l-2.992-1.496a1 1 0 0 0-.907.006L7.04 5.292a1 1 0 0 0-.54.888z"/><path d="m6.846 5.673l3.207 1.603a1 1 0 0 0 .894 0L14.12 5.69h0m-3.274 5.983l3.207 1.603a1 1 0 0 0 .894 0l3.172-1.586h0m-15.273-.017l3.207 1.603a1 1 0 0 0 .894 0l3.172-1.586h0M10.5 7.5v4m4 2V17m-8-3.5V17"/></g></svg>

+ 1 - 0
templates/assets/icons/document.svg

@@ -0,0 +1 @@
+<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width='1em' height='1em'><path d="M5 3h14a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2zm2 4v2h10V7H7zm0 4v2h10v-2H7zm0 4v2h7v-2H7z" fill="currentColor"/></svg>

+ 1 - 0
templates/assets/icons/info.txt

@@ -0,0 +1 @@
+Icons from https://opensourcesvgicons.com/

+ 1 - 0
templates/assets/icons/postcard.svg

@@ -0,0 +1 @@
+<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width='1em' height='1em'><path fill="currentColor" fill-rule="evenodd" d="M2 2a2 2 0 0 0-2 2v8a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V4a2 2 0 0 0-2-2zM1 4a1 1 0 0 1 1-1h12a1 1 0 0 1 1 1v8a1 1 0 0 1-1 1H2a1 1 0 0 1-1-1zm7.5.5a.5.5 0 0 0-1 0v7a.5.5 0 0 0 1 0zM2 5.5a.5.5 0 0 1 .5-.5H6a.5.5 0 0 1 0 1H2.5a.5.5 0 0 1-.5-.5m0 2a.5.5 0 0 1 .5-.5H6a.5.5 0 0 1 0 1H2.5a.5.5 0 0 1-.5-.5m0 2a.5.5 0 0 1 .5-.5H6a.5.5 0 0 1 0 1H2.5a.5.5 0 0 1-.5-.5M10.5 5a.5.5 0 0 0-.5.5v3a.5.5 0 0 0 .5.5h3a.5.5 0 0 0 .5-.5v-3a.5.5 0 0 0-.5-.5zM13 8h-2V6h2z"/></svg>

+ 1 - 0
templates/assets/icons/still_image.svg

@@ -0,0 +1 @@
+<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width='1em' height='1em'><path d="M8.5 13.498l2.5 3.006l3.5-4.506l4.5 6H5m16 1v-14a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2z" fill="currentColor"/></svg>

+ 1 - 0
templates/assets/icons/still_image_file.svg

@@ -0,0 +1 @@
+<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width='1em' height='1em'><path fill="currentColor" d="M13 9h5.5L13 3.5zM6 2h8l6 6v12a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V4c0-1.11.89-2 2-2m0 18h12v-8l-4 4l-2-2zM8 9a2 2 0 0 0-2 2a2 2 0 0 0 2 2a2 2 0 0 0 2-2a2 2 0 0 0-2-2"/></svg>

+ 1 - 0
templates/assets/icons/text_file.svg

@@ -0,0 +1 @@
+<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width='1em' height='1em'><path fill="currentColor" d="M13 9h5.5L13 3.5zM6 2h8l6 6v12a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V4c0-1.11.89-2 2-2m9 16v-2H6v2zm3-4v-2H6v2z"/></svg>

+ 1 - 0
templates/assets/icons/video.svg

@@ -0,0 +1 @@
+<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width='1em' height='1em'><path fill="currentColor" d="M17 10.5V7a1 1 0 0 0-1-1H4a1 1 0 0 0-1 1v10a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-3.5l4 4v-11z"/></svg>

+ 1 - 0
templates/assets/icons/video_file.svg

@@ -0,0 +1 @@
+<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width='1em' height='1em'><path fill="currentColor" d="M13 9h5.5L13 3.5zM6 2h8l6 6v12a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V4c0-1.11.89-2 2-2m11 17v-6l-3 2.2V13H7v6h7v-2.2z"/></svg>

+ 4 - 1
templates/dres.html

@@ -6,7 +6,10 @@
     <body>
         <%- header_tpl({site_title = site_title}) %>
         <main>
-            <h1><%= breadcrumbs[#breadcrumbs][2] %>:&ensp;<%= title %></h1>
+            <h1>
+                <img class="title_icon" src="<%= icon_url %>" />
+                <%= breadcrumbs[#breadcrumbs][2] -%>:&ensp;<%= title %>
+            </h1>
             <section id="res_lineage">
                 <h2>Classification</h2>
                 <p>

+ 4 - 1
templates/ores.html

@@ -6,7 +6,10 @@
     <body>
         <%- header_tpl({site_title = site_title}) %>
         <main>
-            <h1><%= breadcrumbs[#breadcrumbs][2] -%>:&ensp;<%= fname %></h1>
+            <h1>
+                <img class="title_icon" src="<%= icon_url %>" />
+                <%= breadcrumbs[#breadcrumbs][2] -%>:&ensp;<%= fname %>
+            </h1>
             <section id="res_lineage">
                 <h2>Classification</h2>
                 <p>