]> git.plutz.net Git - shellwiki/blobdiff - themes/default.sh
bugfix editor help: display of original language page
[shellwiki] / themes / default.sh
index 3c803f455716d56ff6bba276a2586690945fb958..6c761a747aba50f42ae76a8d7e68caaafe0d650b 100755 (executable)
@@ -5,9 +5,9 @@
 theme_head(){
   local IFS="$BR"
   printf '
-  <meta name="viewport" content="width=device-width"/>
+  <meta name="viewport" content="width=device-width">
   '
-  for css in "$_BASE/[.]/cgilite/common.css" "$_BASE/[.]/themes/default.css" $PAGE_CSS; do
+  for css in "$_BASE/%5B.%5D/cgilite/common.css" "$_BASE/%5B.%5D/themes/default.css" $PAGE_CSS; do
     printf  '<link rel="stylesheet" type="text/css" href="%s">' \
             "$(HTML "${css##*//}")"
   done
@@ -27,27 +27,27 @@ theme_pagemenu(){
   if acl_write "$page"; then
     printf  '
     <ul class="pagemenu">
-      <li><a href="./[view]">View</a></li>
-      <li><a href="./[edit]">Edit</a></li>
-      <li><a href="./[attachment]">Attachments</a></li>
-      <li><a href="./[revision]">Revisions</a></li>
-      <li><a href="./[rename]">Rename</a></li>
-      <li><a href="./[move]">Move</a></li>
-      <li><a href="./[delete]">Delete</a></li>
+      <li><a href="./%%5Bview%%5D">View</a></li>
+      <li><a href="./%%5Bedit%%5D">Edit</a></li>
+      <li><a href="./%%5Battachment%%5D">Attachments</a></li>
+      <li><a href="./%%5Brevision%%5D">Revisions</a></li>
+      <li><a href="./%%5Brename%%5D">Rename</a></li>
+      <li><a href="./%%5Bmove%%5D">Move</a></li>
+      <li><a href="./%%5Bdelete%%5D">Delete</a></li>
     </ul>'
   fi
 }
 
 theme_page(){
   local page="$1" title="$2"
-  title="$(HTML "${title:-"${page}"}")"
+  title="$(HTML "${title:-"${PAGE_TITLE:-"${page}"}"}")"
 
   # Important! Web Server response including newline
   printf "%s\r\n" "Content-Type: text/html; charset=utf-8" ""
 
   cat <<-EOF
        <!DOCTYPE HTML>
-       <html><head>
+       <html${LANGUAGE:+ lang=\"${LANGUAGE}\"}><head>
          $(theme_head)
          <title>${title}</title>
        </head><body id="$(HTML "${PATH_INFO}")">
@@ -68,29 +68,53 @@ theme_page(){
 }
 
 theme_editor(){
-  local page="$1" template="$2" title
-  title="${page%/}"; title="${title##*/}"
+  local page="$1" template="$2" title file att
+  title="$(HTML "${PAGE_TITLE:-"${page}"}")"
 
   [ "$template" ] && acl_read "$template" || template="$page"
 
   theme_page - "Editor: $title" <<-EOF
-       <form method=POST action="$(HTML "${_BASE}${page%/}/[edit]")">
+       <input checked type=radio class=tab name=edithelp value=edtr id=editor><label for=editor>Editor</label>
+       <input         type=radio class=tab name=edithelp value=help id=syntax><label for=syntax>Syntax</label>
+       <input         type=radio class=tab name=edithelp value=att  id=attach><label for=attach>Attachments</label>
+       $([ "$LANGUAGE_DEFAULT" -a "$LANGUAGE_DEFAULT" != "$LANGUAGE" ] && printf '
+       <input         type=radio class=tab name=edithelp value=att  id=transl><label for=transl>%s</label>
+       ' "$LANGUAGE_DEFAULT"
+       )
+       <form class="tab editor" method=POST action="$(HTML "${_BASE}${page%/}/[edit]")">
          <input type=hidden name=session_key value="${SESSION_KEY}"/>
          <textarea name=pagetext>$({ wiki_text "$page" \
                                   || wiki_text "$template"; } |HTML)</textarea>
          <button type=submit name=action value=update>Update</button>
          <button type=submit name=action value=cancel>Cancel</button>
        </form>
+        <div class="tab syntax">$(wiki "/[wiki]/editorhelp/")</div>
+       <div class="tab attach">
+       $(for file in "$_EXEC/pages/${page%/:$LANGUAGE/}/#attachments"/* "$_DATA/pages/${page%/:$LANGUAGE/}/#attachments"/*; do
+         [ "$file" = "$_EXEC/pages/${page%/:$LANGUAGE/}/#attachments/${file##*/}" \
+               -a -f "$_DATA/pages/${page%/:$LANGUAGE/}/#attachments/${file##*/}" ] && continue
+         case ${file##*/} in
+           \*) continue;;
+           *.[pP][nN][gG]|*.[jJ][pP][gG]|*.[jJ][pP][eE][gG]|*.[gG][iI][fF])
+             [ "$page" != "${page%/:$LANGUAGE/}" ] && p=../ || p=''
+             att="$(HTML "${file##*/}")"
+             printf '<p class=aimg><img src="%s%s">![](%s)</p><ul class=aimg><li>[%s]([attachment]/%s)</li><li>[![%s](%s)]([attachment]/%s)</li></ul>' \
+                    "$p" "$att" "$att" "$att" "$att" "$att" "$att" "$att"
+             ;;
+           *)
+             att="$(HTML "${file##*/}")"
+             printf '<p class="adoc">[%s](%s)</p>' "$att" "$att"
+             ;;
+         esac
+       done)
+       </div>
+       $(if [ "$LANGUAGE_DEFAULT" -a "$LANGUAGE_DEFAULT" != "$LANGUAGE" ]; then
+         printf '<div class="tab transl">%s</div>' "$(LANGUAGE='' wiki_text "${page%/:$LANGUAGE/}" |HTML)"
+       fi)
        EOF
 }
 
-theme_revisions(){
-  local page="$1" title
-  title="${page%/}"; title="${title##*/}"
-
- "$_EXEC/macros/revisions" "$page" \
-  | theme_page - "Revisions: $title"
-}
+theme_revisions(){ theme_page "$@"; }
 
 theme_attachments(){
   local page="$1" title
@@ -129,7 +153,7 @@ theme_attachments(){
                    <span class=date>%s</span>
                  </li>' \
                 "$hfile" "$hfile" "$hfile" "$hfile" \
-                "$hfile" "$hfile" "$hfile" "$hfile" \
+                "$(slopecode "${file##*/}")" "$hfile" "$hfile" "$hfile" \
                 "$(size_human "$size")" "$(date -d @"$date" +"%F %T")"
        done)
            </ul>
@@ -171,7 +195,7 @@ theme_error(){
     500) printf "%s\r\n" "Status: 500 Internal Server Error";;
   esac
 
-  if [ "$(mdfile "/[wiki]/$errno/")" ]; then
+  if mdfile "/[wiki]/$errno/" >&-; then
     theme_page "/[wiki]/$errno/"
   else
     printf "Content-Length: 0\r\n\r\n"