Bläddra i källkod

WIP bricks: add ordered members from LL structure.

scossu 2 veckor sedan
förälder
incheckning
5b97065b48
1 ändrade filer med 11 tillägg och 17 borttagningar
  1. 11 17
      src/submission.lua

+ 11 - 17
src/submission.lua

@@ -121,27 +121,21 @@ M.generate_sip = function(path)
     for i, v in ipairs(sip) do
         local rmod = model.types[v.content_type]
         --dbg.assert(rmod)
-        if rmod.properties.next then
-            for j = i + 1, #sip do
-                if not v.next and
-                        sip[j].source_path:match("(.*/)") ==
-                                v.source_path:match("(.*/)") then
-                    v.next = sip[j].id
-                end
-            end
-        end
-        if rmod.properties.first then
-            for j = i + 1, #sip do
-                if not v.first and
-                    sip[j].source_path:match(
-                            "^" .. pkar.escape_pattern(v.source_path)
-                ) then
-                    v.first = sip[j].id
+        v.has_member = v.has_member or {}
+        for j = i + 1, #sip do
+            if sip[j].source_path:match(
+                    "^" .. pkar.escape_pattern(v.source_path))
+            then
+                local rel_path = sip[j].source_path:sub(#v.source_path + 2)
+                logger:debug("rel_path: " .. rel_path)
+                if not rel_path:match("/") then
+                    logger:debug(("Adding member %s to %s"):format(
+                            rel_path, v.source_path))
+                    table.insert(v.has_member, sip[j].id)
                 end
             end
         end
     end
-    --require "debugger"()
 
     return sip
 end