]> git.plutz.net Git - serve0/commitdiff
ordering for manual groups
authorPaul Hänsch <paul@plutz.net>
Tue, 21 Dec 2021 23:08:44 +0000 (00:08 +0100)
committerPaul Hänsch <paul@plutz.net>
Tue, 21 Dec 2021 23:08:44 +0000 (00:08 +0100)
db_meta.sh
view.sh

index e3a5c5fc797b3cb7194c3c47420b6a4fb95d6240..9dfbe4c2460a422a23ac1a956a1d0839b4ce3579 100755 (executable)
@@ -166,25 +166,41 @@ list_meta(){
 
 dbmeta_autogroup(){
   sed -E '
+    h;  # save original dataset
+
+    # strip common suffixes of web video sites
+    s;-([0-9a-zA-Z_-]{11}|ph[0-9a-f]{13}|xh[0-9a-zA-Z]{5}|[0-9]{6,})\r;-\r;;
+
+    # clear branching status
+    tBRANCH; :BRANCH
+
     # perform auto grouping if group id is missing or empty
     /\r$/bAUTOGROUP; s;\r      \\$;\r;; tAUTOGROUP;
   
-    # skip auto grouping if manual group id is present
-    /\r        .+$/b;
+    # only perform ordering if manual group id is present
+    /\r        .+$/bAUTOORDER;
+
+    b;
+
+    :AUTOORDER
+    # strip all fields but the name
+    s;^([^\t]+ [^\t]+  [^\t]+  [^\t]+  [^\t]+  )([^\r]+)\r     (.+)$;\2;
+
+    # reduce to numerals
+    s;[^0-9]+;;g;
+
+    # append ordering field to dataset
+    H; g; s;\n;\t;;
+    b;
   
     :AUTOGROUP
-    # save original dataset
-    h;
-  
     # strip all fields but the name
     s;^[^\t]+  [^\t]+  [^\t]+  [^\t]+  [^\t]+  ;;
-    # strip common suffixes of web video sites
-    s;-([0-9a-zA-Z_-]{11}|ph[0-9a-f]{13}|[0-9]{6,})\r$;-\r;;
   
     # replace all numeric parts and append numerals to an ordering field
     # the group id will be made up of only the non-numeric character frame
     # the ordering field will hold all numbers from the name
-    :X s;^([^\r0-9]*)([0-9]+)([^\r0-9]*)\r\t?([0-9]*)$;\1\r\3\r        \4\2;; tX;
+    :X s;^([^0-9]*)([0-9]+)([^\r]*)\r\t?([0-9]*)$;\1\r\3\r     \4\2;; tX;
   
     # append group id and ordering field to dataset
     H; g; s;\n;\t;;
diff --git a/view.sh b/view.sh
index 1566a82f208644a2fda1766311069eed721d10a7..c7f030e23cf41f27b120f16e89329b0dfd5b3167 100755 (executable)
--- a/view.sh
+++ b/view.sh
@@ -41,6 +41,7 @@ printf 'Content-Type: text/html;charset=utf-8\r\n\r\n'
     printf '[div .itemlist'
     list_meta "$_DATA/${ITEM%/*}/.index/meta" \
     | grep -F "${CR}   ${META_GROUP}" \
+    | sort -n -k8 -k6,6 \
     | while read_meta; do
       file="$(printf %s\\n "$_DATA/${META_NAME}".*)"
       [ "/${file#${_DATA}/}" = "$ITEM" ] && continue