Преглед на файлове

Layout improvements for collection and dres.

scossu преди 4 дни
родител
ревизия
54ab3e10df
променени са 3 файла, в които са добавени 43 реда и са изтрити 26 реда
  1. 22 8
      src/generator.lua
  2. 9 8
      templates/coll.html
  3. 12 10
      templates/dres.html

+ 22 - 8
src/generator.lua

@@ -145,11 +145,6 @@ end
 local function generate_coll(s, mconf)
     local pref_rep, pref_rep_url
     _, 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)
-        -- Collection page uses full size image, shrunk to size if necessary.
-        pref_rep_file = get_tn_url(pref_rep):gsub(TN_WEB_PATH, MEDIA_WEB_PATH)
-    end
 
     local members = {}
     local child_s
@@ -163,6 +158,16 @@ local function generate_coll(s, mconf)
         )
     end
     --]]
+
+    -- First child is the alternative pref representation.
+    if not pref_rep then pref_rep = child_s end
+
+    if pref_rep then
+        pref_rep_url = pkar.gen_pairtree("/res", pref_rep.data, ".html", true)
+        -- Collection page uses full size image, shrunk to size if necessary.
+        pref_rep_file = get_tn_url(pref_rep):gsub(TN_WEB_PATH, MEDIA_WEB_PATH)
+    end
+
     local child_ref, child_label, child_mconf
     while child_s do
         _, child_ref = next(repo.gr:attr(child_s, model.id_to_uri.ref))
@@ -177,6 +182,7 @@ local function generate_coll(s, mconf)
             tn = get_tn_url(child_s),
             href = pkar.gen_pairtree("/res", child_ref.data, ".html", true),
             label = child_label.data,
+            ctype_label = child_mconf.label,
         })
         _, child_s = next(repo.gr:attr(child_s, model.id_to_uri.next))
     end
@@ -221,6 +227,10 @@ local function generate_dres(s, mconf)
     local title
     -- Metadata
     local attrs = repo.gr:connections(s, term.LINK_OUTBOUND)
+
+    local pref_rep, pref_rep_url
+    _, pref_rep = next(repo.gr:attr(s, model.id_to_uri.pref_rep))
+
     for p, ots in pairs(attrs) do
         local pname = model.uri_to_id[nsm.denormalize_uri(p.data)] or p.data
         logger:debug("DRES pname: " .. pname)
@@ -232,6 +242,8 @@ local function generate_dres(s, mconf)
             for _, o in pairs(ots) do
                 -- Loop through all first children.
                 local child_s = o
+                if not pref_rep then pref_rep = child_s end
+
                 logger:debug("local child_s: ", child_s.data)
                 local ll = {}
 
@@ -312,10 +324,9 @@ local function generate_dres(s, mconf)
     logger:debug("Children:", pp.write(children))
     logger:debug("Breadcrumbs:", pp.write(get_breadcrumbs(mconf)))
 
-    local pref_rep, pref_rep_url
-    _, 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)
+        pref_rep_file = get_tn_url(pref_rep):gsub(TN_WEB_PATH, MEDIA_WEB_PATH)
     end
 
     out_html = templates.dres.data({
@@ -331,7 +342,10 @@ local function generate_dres(s, mconf)
         children = children,
         ls_next = ls_next,
         tn_url = get_tn_url(s),
-        pref_rep = pref_rep_url,
+        pref_rep = {
+            url = pref_rep_url,
+            file = pref_rep_file,
+        },
         icon_url = get_icon_url(mconf.lineage),
         breadcrumbs = get_breadcrumbs(mconf),
         rdf_href = pkar.gen_pairtree("/res", s.data, ".ttl", true),

+ 9 - 8
templates/coll.html

@@ -12,11 +12,9 @@
             </h1>
             <div class="row">
                 <section id="head_img" class="column column-66">
-                    <% if pref_rep then %>
-                        <a href="<%= pref_rep.url %>">
-                            <img src="<%= pref_rep.file %>" alt="[TODO]"/>
-                       </a>
-                   <% end %>
+                <% if pref_rep then %>
+                    <img src="<%= pref_rep.file %>" alt="<%= title %>"/>
+                <% end %>
                 </section>
                 <section class="column column-30 toolbox">
                     <h4>Tools</h4>
@@ -25,16 +23,19 @@
                 </section>
             </div>
             <% if #members > 0 then %>
-            <section id="res_children">
+            <section id="res_mwmbers">
                 <h2>Members</h2>
-                <ul>
+                <ul class="slideshow">
                 <% for _, el in ipairs(members) do %>
                     <li>
                         <a href="<%= el.href %>">
                         <% if el.tn then %>
                             <img src="<%= el.tn %>" alt="<%= el.label %>" />
                         <% end %>
-                            <img class="text_icon" href="<%= el.icon %>" />
+                            <br/>
+                            <img
+                                class="body_icon" src="<%= el.icon %>"
+                                alt="<%= el.ctype_label %>"/>
                             <%= el.label %>
                         </a>
                     </li>

+ 12 - 10
templates/dres.html

@@ -12,18 +12,20 @@
                     alt="<%= breadcrumbs[#breadcrumbs][2] -%>" />
                 <%= title %>
             </h1>
-            <section class="toolbox">
-                <h4>Tools</h4>
-                <p><a href="<%= rdf_href %>">Download RDF document</a></p>
-                <p><a href="#">Download Laundry List [TODO]</a></p>
-            </section>
-            <section id="res_thumbnail">
+            <div class="row">
+                <section id="head_img" class="column column-66">
                 <% if pref_rep then %>
-                    <a href="<%= pref_rep %>">
-                        <img src="<%= tn_url %>" alt="Link to image file"/>
+                    <a href="<%= pref_rep.url %>">
+                        <img src="<%= pref_rep.file %>" alt="<%= title %>"/>
                    </a>
-               <% end %>
-            </section>
+                <% end %>
+                </section>
+                <section class="column column-30 toolbox">
+                    <h4>Tools</h4>
+                    <p><a href="<%= rdf_href %>">Download RDF document</a></p>
+                    <p><a href="#">Download Laundry List [TODO]</a></p>
+                </section>
+            </div>
             <section id="res_lineage">
                 <h2>Classification</h2>
                 <p>