X-Git-Url: https://git.plutz.net/?a=blobdiff_plain;f=handlers%2F60_edit.sh;h=b55a3440bf91ba77e27ccca3aab0e7b9e28b2642;hb=fced9f31f3947c647eab57be43fc30c003c98ecb;hp=6d4e1eac12bd7c1359b7b1a95ad9bd19dcfa11b4;hpb=1addbd404bc8cd6f869e9e1df19cc83081fa7bc2;p=shellwiki diff --git a/handlers/60_edit.sh b/handlers/60_edit.sh index 6d4e1ea..b55a344 100755 --- a/handlers/60_edit.sh +++ b/handlers/60_edit.sh @@ -1,20 +1,20 @@ #!/bin/sh -. "${_EXEC}/session_lock.sh" - -wiki_text() { - # Print source text of a wiki page - # Get page from data or underlay dir - local page="$(PATH "$1")" +# Copyright 2022 - 2023 Paul Hänsch +# +# Permission to use, copy, modify, and/or distribute this software for any +# purpose with or without fee is hereby granted, provided that the above +# copyright notice and this permission notice appear in all copies. +# +# THE SOFTWARE IS PROVIDED “AS IS” AND THE AUTHOR DISCLAIMS ALL WARRANTIES +# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY +# SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR +# IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - if [ -f "$_DATA/pages/$page/#page.md" ]; then - cat -- "$_DATA/pages/$page/#page.md" - elif [ -f "$_EXEC/pages/$page/#page.md" ]; then - cat -- "$_EXEC/pages/$page/#page.md" - else - return 1 - fi -} +. "${_EXEC}/session_lock.sh" case $PATH_INFO in */\[edit\]) : ;; @@ -39,11 +39,11 @@ elif [ "$edit_action" = update ]; then POST pagetext >"$edit_file" S_RELEASE "$edit_file" else - export ERRMSG="ERR_NOLOCK" + export ERROR_MSG="Unable to lock page for editing" REDIRECT "${_BASE}${PATH_INFO%\[edit\]}/[edit]" fi - if [ "$(which git)" ]; then + if [ "$REV_PAGES" = true ]; then git -C "$_DATA" add \ -- "pages/$edit_page/#page.md" git -C "$_DATA" commit -qm \