order="$(REF o)"
if tempfile="$(SLOCK "$cardfile" "$locktimeout")"; then
- REDIRECT "/cards/?o=${order}&f=${filter}&e=${card}"
+ REDIRECT "${_BASE}/cards/?o=${order}&f=${filter}&e=${card}"
elif [ -f "$tempfile" ]; then
SET_COOKIE session message="SESSLOCK"
- REDIRECT "/cards/?o=${order}&f=${filter}#${card}"
+ REDIRECT "${_BASE}/cards/?o=${order}&f=${filter}#${card}"
else
SET_COOKIE session message="EDITLOCK"
- REDIRECT "/cards/?o=${order}&f=${filter}#${card}"
+ REDIRECT "${_BASE}/cards/?o=${order}&f=${filter}#${card}"
fi
case $(POST choice) in
filter)
- REDIRECT "/cards/?o=$(POST order)&f=${filter}"
+ REDIRECT "${_BASE}/cards/?o=$(POST order)&f=${filter}"
;;
new_filter)
- REDIRECT "/cards/?o=$(POST order)&f=${filter}&newfilter=yes"
+ REDIRECT "${_BASE}/cards/?o=$(POST order)&f=${filter}&newfilter=yes"
;;
export_csv)
- REDIRECT "/cards/export_csv.sh?o=$(POST order)&f=${filter}"
+ REDIRECT "${_BASE}/cards/export_csv.sh?o=$(POST order)&f=${filter}"
;;
*)
- REDIRECT '/cards/'
+ REDIRECT "${_BASE}/cards/"
;;
esac
{ w_filter_diag
printf '
- [form class="newcard" action="/cards/new_card.sh" method="POST"
+ [form class="newcard" action="%s/cards/new_card.sh" method="POST"
[button type="submit" %s]
[input name="seed" placeholder="%s"]
- ]' "$(l10n newcard)" "$(l10n vcf_seed_label)"
+ ]' "${_BASE}" "$(l10n newcard)" "$(l10n vcf_seed_label)"
[ "$edit" ] && edit_card "$edit"
list_cards
} | yield_page cards #/cards/cards.css
else
card="$(pdi_load "$tempfile")"
cat <<-EOF
- [form .card #${cardfile##*/} action="/cards/update_card.sh" method="POST"
+ [form .card #${cardfile##*/} action="${_BASE}/cards/update_card.sh" method="POST"
[input type="hidden" name="tid" value="$(transid ${tempfile})"]
[div .section .basic $(
edit_item "$card" N GENDER
[div .section .note . $(card_item "$card" NOTE)]
[div .section .attendance [h3 $(l10n course_attendance) ] [ul
$(grep -F " ${cardfile##*/}" "$_DATA/mappings/attendance" |while read each discard; do
- printf '[li [a .item .attendance href="/courses#%s" . %s]]' \
- "$each" \
+ printf '[li [a .item .attendance href="%s/courses#%s" . %s]]' \
+ "${_BASE}" "$each" \
"$(pdi_value "$(pdi_load "$_DATA/ical/$each")" SUMMARY || l10n "(unnamed course)" |unescape |HTML)"
done |sort -k7)]
$(card_item "$card" CATEGORIES)
]
[div .control
- [a .button .item href="/cards/edit_card.sh?card=${cardfile##*/}" $(l10n edit)]
- [a .button .item href="/cards/export_card.sh?card=${cardfile##*/}" $(l10n vcf_export)]
+ [a .button .item href="${_BASE}/cards/edit_card.sh?card=${cardfile##*/}" $(l10n edit)]
+ [a .button .item href="${_BASE}/cards/export_card.sh?card=${cardfile##*/}" $(l10n vcf_export)]
]
]
EOF
UID:${uid}
END:VCARD
EOF
- REDIRECT "/cards/?o=${order}&f=${filter}&e=${card}"
+ REDIRECT "${_BASE}/cards/?o=${order}&f=${filter}&e=${card}"
else
SET_COOKIE session message="EDITLOCK"
- REDIRECT "/cards/?o=${order}&f=${filter}"
+ REDIRECT "${_BASE}/cards/?o=${order}&f=${filter}"
fi
if ! tempfile=$(CHECK_SLOCK "$cardfile"); then
SET_COOKIE 0 message="NO VALID FILE LOCK"
- REDIRECT "/cards/?o=${order}&f=${filter}&e=${card}"
+ REDIRECT "${_BASE}/cards/?o=${order}&f=${filter}&e=${card}"
exit 0
elif [ "$(POST tid)" != "$(transid "$tempfile")" ]; then
SET_COOKIE 0 message="INVALID TRANSACTION ID"
- REDIRECT "/cards/?o=${order}&f=${filter}&e=${card}"
+ REDIRECT "${_BASE}/cards/?o=${order}&f=${filter}&e=${card}"
exit 0
fi
case "$action" in
addfield)
- REDIRECT "/cards/?o=${order}&f=${filter}&e=${card}"
+ REDIRECT "${_BASE}/cards/?o=${order}&f=${filter}&e=${card}"
;;
update)
if LOCK "$attfile"; then
cp "$tempfile" "$cardfile"
RELEASE_SLOCK "$cardfile"
- REDIRECT "/cards/?o=${order}&f=${filter}#${card}"
+ REDIRECT "${_BASE}/cards/?o=${order}&f=${filter}#${card}"
;;
cancel)
RELEASE_SLOCK "$cardfile"
[ -f "$cardfile" ] \
- && REDIRECT "/cards/?o=${order}&f=${filter}#${card}" \
- || REDIRECT "/cards/?o=${order}&f=${filter}"
+ && REDIRECT "${_BASE}/cards/?o=${order}&f=${filter}#${card}" \
+ || REDIRECT "${_BASE}/cards/?o=${order}&f=${filter}"
;;
delete)
rm "$cardfile"
else
SET_COOKIE 0 message="COULD NOT UPDATE COURSE MAPPINGS"
fi
- REDIRECT "/cards/?o=${order}&f=${filter}"
+ REDIRECT "${_BASE}/cards/?o=${order}&f=${filter}"
;;
esac
"$(printf %s "$cat" |grep -qxEe "$2" && printf checked )" \
"$(HTML "$cat")"
done)
- [a href="/categories/" $(l10n edit_categories)]
+ [a href="${_BASE}/categories/" $(l10n edit_categories)]
]
[fieldset .tab .courses
$(list_courses | while IFS=/ read course coursename; do
w_filter_diag(){
cat <<EOF
- [form .filter action="/cards/filter_card.sh" method="POST"
+ [form .filter action="${_BASE}/cards/filter_card.sh" method="POST"
[h1 $(l10n filter_label)]
[input type="hidden" name="page" value="cards"]
sed -E -i '/^'"${remove}"'$/d' "$catfile"
fi
-REDIRECT "/categories/"
+REDIRECT "${_BASE}/categories/"
fi
done
-REDIRECT /categories/
+REDIRECT "${_BASE}/categories/"
coursefile="$_DATA/ical/${course##*/}"
if tempfile="$(SLOCK "$coursefile" "$locktimeout")"; then
- REDIRECT "/courses/?e=${course}"
+ REDIRECT "${_BASE}/courses/?e=${course}"
elif [ -f "$tempfile" ]; then
SET_COOKIE session message="SESSLOCK"
- REDIRECT "/courses/#${course}"
+ REDIRECT "${_BASE}/courses/#${course}"
else
SET_COOKIE session message="EDITLOCK"
- REDIRECT "/courses/#${course}"
+ REDIRECT "${_BASE}/courses/#${course}"
fi
if [ ! -r "$coursefile" ]; then
SET_COOKIE 0 message="Cannot read course file"
- REDIRECT /courses/
+ REDIRECT "${_BASE}/courses/"
return 0
elif ! mkdir -p "$_DATA/export"; then
SET_COOKIE 0 message="Cannot create export directory"
- REDIRECT /courses/
+ REDIRECT "${_BASE}/courses/"
return 0
fi
]]
EOF
-export HOME="$_DATA"
+export HOME="$_DATA/"
export XDG_CONFIG_HOME="$_DATA/xdg_config"
export XDG_CACHE_HOME="$_DATA/xdg_cache"
export XDG_DATA_HOME="$_DATA/xdg_local"
lowriter --convert-to pdf --outdir "$_DATA/export/" "$htmlfile" >/dev/null
-REDIRECT "$(URL "/export/${pdffile##*/}")"
+REDIRECT "$(URL "${_BASE}/export/${pdffile##*/}")"
{ w_sort_courses
printf '
- [form .newcourses action="/courses/new_course.sh" method="POST"
+ [form .newcourses action="%s/courses/new_course.sh" method="POST"
[button type="submit" %s]
- ]' "$(l10n newcourse)"
+ ]' "${_BASE}" "$(l10n newcourse)"
[ "$edit" ] && edit_course "$edit"
printf '[div .courselist\n'
else
course="$(pdi_load "$tempfile")"
cat <<-EOF
- [form .course #${coursefile##*/} action="/courses/update_course.sh" method="POST"
+ [form .course #${coursefile##*/} action="${_BASE}/courses/update_course.sh" method="POST"
[input type="hidden" name="course" value="${coursefile##*/}"]
[input type="hidden" name="tid" value="$(transid ${tempfile})"]
[div .section .basic . $(
[div .section .COMMENT . $(cal_item "$course" COMMENT)]
[div .section .attendance [h3 $(l10n course_attendance) ] [ul .
$(grep -F "${coursefile##*/} " "$_DATA/mappings/attendance" |while read discard each; do
- printf '[li [a .item .attendance href="/cards/#%s" . %s]]\n' \
- "$each" \
+ printf '[li [a .item .attendance href="%s/cards/#%s" . %s]]\n' \
+ "${_BASE}" "$each" \
"$(pdi_value "$(pdi_load "$_DATA/vcard/$each")" FN |unescape |HTML)"
done |sort -k7)]
]
[div .control
- [a .button .item href="/courses/edit_course.sh?course=${coursefile##*/}" $(l10n edit)]
- [a .button .item href="/courses/export_pdf.sh?course=${coursefile##*/}" target="blank" $(l10n courselist)]
- [a .button .item href="/courses/export_ical.sh?course=${coursefile##*/}" $(l10n ics_export)]
+ [a .button .item href="${_BASE}/courses/edit_course.sh?course=${coursefile##*/}" $(l10n edit)]
+ [a .button .item href="${_BASE}/courses/export_pdf.sh?course=${coursefile##*/}" target="blank" $(l10n courselist)]
+ [a .button .item href="${_BASE}/courses/export_ical.sh?course=${coursefile##*/}" $(l10n ics_export)]
[a .button .item href="mailto:zack@vuesch.org?bcc=$(course_mail "${coursefile##*/}" |HTML)" $(l10n course_mail)]
]
]
END:VEVENT
END:VCARD
EOF
- REDIRECT "/courses/?e=${course}"
+ REDIRECT "${_BASE}/courses/?e=${course}"
else
SET_COOKIE session message="EDITLOCK"
- REDIRECT "/courses/"
+ REDIRECT "${_BASE}/courses/"
fi
if ! tempfile="$(CHECK_SLOCK "$coursefile")"; then
SET_COOKIE 0 message="NO VALID FILE LOCK"
- REDIRECT "/courses/?e=${course}"
+ REDIRECT "${_BASE}/courses/?e=${course}"
exit 0
elif [ "$(POST tid)" != "$(transid "$tempfile")" ]; then
SET_COOKIE 0 message="INVALID TRANSACTION ID"
- REDIRECT "/courses/?e=${course}"
+ REDIRECT "${_BASE}/courses/?e=${course}"
exit 0
fi
newfield="$(POST newfield |grep -m 1 -xE '[A-Z][A-Z0-9-]*')"
ics="$(pdi_update_value "$ics" "$newfield" $(( $(pdi_count "$ics" "$newfield") + 1 )) '')"
printf '%s' "$ics" |grep -vx '' >"$tempfile"
- REDIRECT "/courses/?e=${course}"
+ REDIRECT "${_BASE}/courses/?e=${course}"
;;
addfield\ [A-Z]*)
newfield="$(POST action |sed -nE '1s;^addfield ([A-Z][A-Z0-9-]*)$;\1;p')"
ics="$(pdi_update_value "$ics" "$newfield" $(( $(pdi_count "$ics" "$newfield") + 1 )) '')"
printf '%s' "$ics" |grep -vx '' >"$tempfile"
- REDIRECT "/courses/?e=${course}"
+ REDIRECT "${_BASE}/courses/?e=${course}"
;;
update)
if LOCK "$attfile"; then
printf '%s' "$ics" |grep -vx '' >"${tempfile}.cp"
mv "${tempfile}.cp" "$coursefile"
RELEASE_SLOCK "$coursefile"
- REDIRECT "/courses/#${course}"
+ REDIRECT "${_BASE}/courses/#${course}"
;;
cancel)
RELEASE_SLOCK "$coursefile"
[ -f "$coursefile" ] \
- && REDIRECT "/courses/#${course}" \
- || REDIRECT "/courses/"
+ && REDIRECT "${_BASE}/courses/#${course}" \
+ || REDIRECT "${_BASE}/courses/"
;;
delete)
rm "$coursefile"
RELEASE_SLOCK "$coursefile"
- REDIRECT "/courses/"
+ REDIRECT "${_BASE}/courses/"
;;
*)
printf '%s' "$ics" |grep -vx '' >"$tempfile"
- REDIRECT "/courses/?e=${course}"
+ REDIRECT "${_BASE}/courses/?e=${course}"
;;
esac
for n in "$@"; do case ${n%%=*} in
data) _DATA="${n#data=}";;
exec) _EXEC="${n#exec=}";;
+ base) _BASE="${n#base=}";;
debug) DEBUG="${n#debug=}";;
esac; done
[ ! "${_EXEC%/}" ] && _EXEC="$(realpath "${0%/*}")" || _EXEC="${_EXEC%/}"
-[ ! "${_DATA%/}" ] && _DATA=. || _DATA="${_DATA%/}"
+[ ! "${_DATA%/}" ] && _DATA="${PWD%/}" || _DATA="${_DATA%/}"
+_BASE="${_BASE%/}"
[ "$DEBUG" ] && exec 2>>"$DEBUG"
mkdir -p "${_DATA}/cache" "${_DATA}/mappings" "${_DATA}/export" "${_DATA}/lock" "${_DATA}/ical" "${_DATA}/vcard"
. "$_EXEC/l10n.sh"
_PATH="$(PATH "/${PATH_INFO}")"
+_PATH="${_PATH#${_BASE}}"
ACTION="$(GET a)"
message="$(COOKIE message)"
[html [head
[title Confetti]
[meta name="viewport" content="width=device-width"]
- [link rel="stylesheet" type="text/css" href="/cgilite/common.css"]
- [link rel="stylesheet" type="text/css" href="/style.css"]
- '
+ [link rel="stylesheet" type="text/css" href="%s/cgilite/common.css"]
+ [link rel="stylesheet" type="text/css" href="%s/style.css"]
+ ' "${_BASE}" "${_BASE}"
[ -n "$style" ] && printf '
[link rel="stylesheet" type="text/css" href="%s"]
' "$style"
printf '
] [body #top class="%s"
' "$class"
- printf '[ul .menu [li [a "/cards/" . %s]][li [a "/courses/" . %s]]]' "$(l10n cards)" "$(l10n courses)"
+ printf '[ul .menu [li [a "%s/cards/" . %s]][li [a "%s/courses/" . %s]]]' "${_BASE}" "$(l10n cards)" "${_BASE}" "$(l10n courses)"
[ "$message" ] && printf '[p #message\n%s\n]' "$(l10n "$message")"
cat
printf '] ]'
topdir="/${topdir%%/*}"
case ${_PATH} in
- /) REDIRECT /cards/
+ "/") REDIRECT "${_BASE}/cards/"
;;
- /export/*.pdf) . "$_EXEC/cgilite/file.sh"
+ "/export"/*.pdf) . "$_EXEC/cgilite/file.sh"
FILE "${_DATA}/${_PATH}" "application/pdf"
;;
- /export/*) . "$_EXEC/cgilite/file.sh"
+ "/export"/*) . "$_EXEC/cgilite/file.sh"
FILE "${_DATA}/${_PATH}"
;;
*)
padding: .5em 3em;
box-shadow: inset 0 0 .5em #000;
}
-body.cards > .menu a[href="/cards/"],
-body.courses > .menu a[href="/courses/"] {
+body.cards > .menu a[href$="/cards/"],
+body.courses > .menu a[href$="/courses/"] {
color: #000;
background-color: #FFF;
box-shadow: none;