8 <meta name="viewport" content="width=device-width"/>
10 for css in "$_BASE/[.]/cgilite/common.css" "$_BASE/[.]/themes/default.css" $PAGE_CSS; do
11 printf '<link rel="stylesheet" type="text/css" href="%s">' \
12 "$(HTML "${css##*//}")"
17 printf '<header>%s</header>' "$(wiki '[wiki]/header/')"
21 printf '<footer>%s</footer>' "$(wiki '[wiki]/footer/')"
27 if acl_write "$page"; then
30 <li><a href="./[view]">View</a></li>
31 <li><a href="./[edit]">Edit</a></li>
32 <li><a href="./[attachment]">Attachments</a></li>
33 <li><a href="./[revision]">Revisions</a></li>
34 <li><a href="./[rename]">Rename</a></li>
35 <li><a href="./[move]">Move</a></li>
36 <li><a href="./[delete]">Delete</a></li>
42 local page="$1" title="$2"
43 title="$(HTML "${title:-"${page}"}")"
45 # Important! Web Server response including newline
46 printf "%s\r\n" "Content-Type: text/html; charset=utf-8" ""
52 <title>${title}</title>
53 </head><body id="$(HTML "${PATH_INFO}")">
57 $(if [ "$page" = '-' ]; then
71 local page="$1" template="$2" title
72 title="${page%/}"; title="${title##*/}"
74 [ "$template" ] && acl_read "$template" || template="$page"
76 theme_page - "Editor: $title" <<-EOF
77 <form method=POST action="$(HTML "${_BASE}${page%/}/[edit]")">
78 <input type=hidden name=session_key value="${SESSION_KEY}"/>
79 <textarea name=pagetext>$({ wiki_text "$page" \
80 || wiki_text "$template"; } |HTML)</textarea>
81 <button type=submit name=action value=update>Update</button>
82 <button type=submit name=action value=cancel>Cancel</button>
89 title="${page%/}"; title="${title##*/}"
91 "$_EXEC/macros/revisions" "$page" \
92 | theme_page - "Revisions: $title"
97 title="${page%/}"; title="${title##*/}"
99 if acl_write "$page"; then
100 theme_page - "Attachments: $title" <<-EOF
101 <form class=upload method=POST enctype="multipart/form-data">
102 <input type=hidden name=session_id value="$SESSION_ID">
103 <input type=file name=file multiple>
104 <button type=submit name=action value=upload>Upload</button>
107 <form method=POST><ul class="attachment list">
108 <input type=hidden name=session_key value="$SESSION_KEY">
109 $(for file in "$_EXEC/pages/$page/#attachments"/* "$_DATA/pages/$page/#attachments"/*; do
110 [ "$file" = "$_EXEC/pages/$page/#attachments/${file##*/}" \
111 -a -f "$_DATA/pages/$page/#attachments/${file##*/}" ] && continue
112 stat="$(stat -c '%s %Y' -- "$file" 2>&-)" || continue
113 size="${stat% *}" date="${stat#* }"
114 hfile="$(HTML "${file##*/}")"
116 printf '<li><button type=submit name=delete value="%s">Delete</button><a class=name href="[attachment]/%s">%s</a>
117 <span class=size>%s</span><span class=date>%s</span></li>' \
118 "$hfile" "$hfile" "$hfile" "$(size_human "$size")" "$(date -d @"$date" +"%F %T")"
123 theme_page - "Attachments: $title" <<-EOF
124 <ul class="attachment list">
125 $(for file in "$_EXEC/pages/$page/#attachments"/* "$_DATA/pages/$page/#attachments"/*; do
126 [ "$file" = "$_EXEC/pages/$page/#attachments/${file##*/}" \
127 -a -f "$_DATA/pages/$page/#attachments/${file##*/}" ] && continue
128 stat="$(stat -c '%s %Y' -- "$file" 2>&-)" || continue
129 size="${stat% *}" date="${stat#* }"
130 hfile="$(HTML "${file##*/}")"
132 printf '<li><a class=name href="%s">%s</a>
133 <span class=size>%s</span><span class=date>%s</span></li>' \
134 "$hfile" "$hfile" "$(size_human "$size")" "$(date -d @"$date" +"%F %T")"
145 400) printf "%s\r\n" "Status: 400 Bad Request";;
146 403) printf "%s\r\n" "Status: 403 Forbidden";;
147 404) printf "%s\r\n" "Status: 404 Not Found";;
148 409) printf "%s\r\n" "Status: 409 Conflict";;
149 500) printf "%s\r\n" "Status: 500 Internal Server Error";;
152 if [ "$(mdfile "/[wiki]/$errno/")" ]; then
153 theme_page "/[wiki]/$errno/"
155 printf "Content-Length: 0\r\n\r\n"