# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
# IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+[ "$SEARCH_INDEX" != true ] && return 1
[ "${PATH_INFO%\[search\]}" = "$PATH_INFO" ] && return 1
. "$_EXEC/cgilite/storage.sh"
while read date doc freq num total; do
P="$_DATA/pages$(UNSTRING "$doc")"
- d="$(stat -c %Y -- "$P/#index.flag")"
- [ "$d" -gt "$date" ] && continue
+ d="$(stat -c %Y -- "$P/#index.flag" 2>&-)"
+ [ "$d" -le "$date" ] 2>&- || continue
printf '%s %f\n' "$doc" "$freq"
done <"$I/$w"
done \
| awk '
- { cnt[$1]++; weight[$1] = weight[$1] ? weight[$1] * $2 : $2; }
+ { cnt[$1]++; weight[$1] = weight[$1] ? weight[$1] + $2 : $2; }
END { m = 0; for (d in cnt) m = ( m < cnt[d] ) ? cnt[d] : m;
for (d in cnt) if ( cnt[d] == m ) printf "%f %s\n", weight[d], d;
}
printf 'Refresh: %i\r\n' 4
theme_error 403
return 0
- elif [ "$REV_PAGES" = true ]; then
+ fi
+ if [ "$REV_PAGES" = true ]; then
git -C "$_DATA" mv "pages/$oldname" "pages/$newname"
git -C "$_DATA" commit -m 'Page # '"$oldname"' # renamed to # '"$newname"' # by user @ '"$USER_NAME"' @' \
-- "pages/$oldname" "pages/$newname"
- REDIRECT "$_BASE${newname}"
else
mv -- "$_DATA/pages/$oldname" "$_DATA/pages/$newname"
- REDIRECT "$_BASE${newname}"
fi
+ if [ "$SEARCH_INDEX" = true ]; then
+ find "$_DATA/pages/$newname" -name "#index.flag" -delete
+ ( "$_EXEC/searchindex.sh" index --location "$newname" & ) &
+ fi
+ REDIRECT "$_BASE${newname}"
+
elif [ "$action" = move -a "$newlocation" ]; then
oldname="${PATH_INFO%\[*\]}"
newlocation="$(PATH "$newlocation")"
printf 'Refresh: %i\r\n' 4
theme_error 403
return 0
- elif [ "$REV_PAGES" = true ]; then
+ fi
+ if [ "$REV_PAGES" = true ]; then
git -C "$_DATA" mv "pages/${oldname}" "pages/${newname}"
git -C "$_DATA" commit -m 'Page # '"$oldname"' # moved to # '"$newname"' # by user @ '"$USER_NAME"' @' \
-- "pages/${oldname}" "pages/${newname}"
- REDIRECT "$_BASE${newname}"
else
mv -- "$_DATA/pages/$oldname" "$_DATA/pages/$newname"
- REDIRECT "$_BASE${newname}"
fi
+ if [ "$SEARCH_INDEX" = true ]; then
+ find "$_DATA/pages/$newname" -name "#index.flag" -delete
+ ( "$_EXEC/searchindex.sh" index --location "$newname" & ) &
+ fi
+ REDIRECT "$_BASE${newname}"
+
elif [ "$action" = delete ]; then
oldname="${PATH_INFO%\[*\]}"
if ! acl_write "$oldname"; then
export REV_PAGES=${REV_PAGES:-true}
export REV_ATTACHMENTS=${REV_ATTACHMENTS:-false}
export WIKI_THEME="${WIKI_THEME:-default}"
+export SEARCH_INDEX="${SEARCH_INDEX:-true}"
which git >/dev/null || REV_PAGES=false
[ "$REV_PAGES" != true ] && REV_ATTACHMENTS=false
cat >"$_DATA/.gitignore" <<-EOF
users.db
serverkey
+ tags/
+ index/
**/#cache/
- **/#page.lock
+ **/#page.md.lock
**/#page.*.cache
**/#page.*.cache.*
**/#page:*.*.cache
**/#page:*.*.cache.*
+ **/#index.flag
EOF
[ "$REV_ATTACHMENTS" != true ] \
&& printf '**/#attachments/\n' >>"$_DATA/.gitignore"
DOC="${PATH_INFO%/}/" P="$_DATA/pages${DOC}" I="$_DATA/index/"
-if [ -f "$P/#index.flag" -a ! "$P/#page.md" -nt "$P/#index.flag" ] || [ ! -d "$P" ]; then
+if [ "$SEARCH_INDEX" != true ] || [ ! -d "$P" ] || \
+ [ -f "$P/#index.flag" -a ! "$P/#page.md" -nt "$P/#index.flag" ]
+then
cat
exit 0
fi
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
# IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
-export _EXEC="${0%/*}/" _DATA="."
+export _EXEC="${_EXEC:-${0%/*}/}" _DATA="${_DATA:-.}"
verb="" v=0 cmd="" force="" location=""
help() {
Options:
--exec INSTALL_DIR
- Point to the location of your shellwiki installation. This will
- default to the path at which the script is called, if it can be
- determined.
+ Point to the location of your shellwiki installation. Without
+ this optin, the location will be read from the environments
+ variable "\$_EXEC", or will default to the path at which the
+ script is called, if it can be determined.
--data SITE_DIR
Point to the location of your site installation. I.e. the directory
- containing your "pages/" and "index/" dir. Defaults to working
- directory.
+ containing your "pages/" and "index/" dir. Defaults to the
+ environment variable "\$_DATA" or the working directory.
--force
Add pages to index even if they seem to be indexed already.