]> git.plutz.net Git - shellwiki/commitdiff
body id is always PATH_INFO, bugfix in attachment links
authorPaul Hänsch <paul@plutz.net>
Mon, 23 May 2022 17:34:17 +0000 (19:34 +0200)
committerPaul Hänsch <paul@plutz.net>
Mon, 23 May 2022 17:34:17 +0000 (19:34 +0200)
themes/default.sh

index 1f8d285d4eb9a241601dde074f0fbd80fcb66800..001dd3caa85d1ca95825359afa8d69f47b0d3600 100755 (executable)
@@ -33,9 +33,8 @@ theme_pagemenu(){
 }
 
 theme_page(){
-  local page="$1" title="$2" id="$3"
+  local page="$1" title="$2"
   title="$(HTML "${title:-"${page}"}")"
-  id="$(HTML "${id:-"${page}"}")"
 
   # Important! Web Server response including newline
   printf "%s\r\n" "Content-Type: text/html; charset=utf-8" ""
@@ -45,7 +44,7 @@ theme_page(){
        <html><head>
          $(theme_head)
          <title>${title}</title>
-       </head><body id="$id">
+       </head><body id="$(HTML "${PATH_INFO}")">
          $(theme_header)
          <main>
            $(theme_pagemenu)
@@ -68,7 +67,7 @@ theme_editor(){
 
   [ "$template" ] && acl_read "$template" || template="$page"
 
-  theme_page - "Editor: $title" "${page}[edit]" <<-EOF
+  theme_page - "Editor: $title" <<-EOF
        <form method=POST action="$(HTML "${page%/}/[edit]")">
          <input type=hidden name=session_key value="${SESSION_KEY}"/>
          <textarea name=pagetext>$({ wiki_text "$page" \
@@ -84,7 +83,7 @@ theme_revisions(){
   title="${page%/}"; title="${title##*/}"
 
  "$_EXEC/macros/revisions" "$page" \
-  | theme_page - "Revisions: $title" "${page}[revision]"
+  | theme_page - "Revisions: $title"
 }
 
 theme_attachments(){
@@ -92,7 +91,7 @@ theme_attachments(){
   title="${page%/}"; title="${title##*/}"
 
   if acl_write "$page"; then
-    theme_page - "Attachments: $title" "${page}[attachment]" <<-EOF
+    theme_page - "Attachments: $title" <<-EOF
        <form class=upload method=POST enctype="multipart/form-data">
          <input type=hidden name=session_id value="$SESSION_ID">
          <input type=file name=file multiple>
@@ -106,26 +105,27 @@ theme_attachments(){
                -a -f "$_DATA/pages/$page/#attachments/${file##*/}" ] && continue
          stat="$(stat -c '%s %Y' -- "$file" 2>&-)" || continue
          size="${stat% *}" date="${stat#* }"
+          hfile="$(HTML "${file##*/}")"
        
-         printf '<li><button type=submit name=delete value="%s">Delete</button><a class=name href="%s">%s</a>
+         printf '<li><button type=submit name=delete value="%s">Delete</button><a class=name href="[attachment]/%s">%s</a>
                  <span class=size>%s</span><span class=date>%s</span></li>' \
-           "$(HTML "${file##*/}")" "$(HTML "${file##*/}")" "$(HTML "${file##*/}")" \
-           "$(size_human "$size")" "$(date -d @"$date" +"%F %T")"
+                "$hfile" "$hfile" "$hfile" "$(size_human "$size")" "$(date -d @"$date" +"%F %T")"
        done)
        </ul></form>
        EOF
   else
-    theme_page - "Attachments: $title" "${page}[attachment]" <<-EOF
+    theme_page - "Attachments: $title" <<-EOF
        <ul class="attachment list">
        $(for file in "$_EXEC/pages/$page/#attachments"/* "$_DATA/pages/$page/#attachments"/*; do
          [ "$file" = "$_EXEC/pages/$page/#attachments/${file##*/}" \
                -a -f "$_DATA/pages/$page/#attachments/${file##*/}" ] && continue
          stat="$(stat -c '%s %Y' -- "$file" 2>&-)" || continue
          size="${stat% *}" date="${stat#* }"
+          hfile="$(HTML "${file##*/}")"
        
          printf '<li><a class=name href="%s">%s</a>
                  <span class=size>%s</span><span class=date>%s</span></li>' \
-           "$(HTML "${file##*/}")" "$(HTML "${file##*/}")" "$(size_human "$size")" "$(date -d @"$date" +"%F %T")"
+                "$hfile" "$hfile" "$(size_human "$size")" "$(date -d @"$date" +"%F %T")"
        done)
        </ul>
        EOF