Compare commits
3 Commits
9664dbb256
...
30bb9e3bbd
| Author | SHA1 | Date | |
|---|---|---|---|
| 30bb9e3bbd | |||
| 68f678c2df | |||
| 43b1cc2efd |
93
deploy.sh
Executable file
93
deploy.sh
Executable file
@@ -0,0 +1,93 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
# Deploy this luxtools plugin checkout into a mounted DokuWiki plugins dir.
|
||||||
|
# Default target is the user's mount path.
|
||||||
|
#
|
||||||
|
# Usage:
|
||||||
|
# ./deploy.sh # deploy to /thebe/Web/lib/plugins/luxtools/
|
||||||
|
# ./deploy.sh --dry-run # show what would change
|
||||||
|
# ./deploy.sh /path/to/luxtools
|
||||||
|
# ./deploy.sh --no-delete # don't delete extraneous files at target
|
||||||
|
|
||||||
|
TARGET="/thebe/Web/lib/plugins/luxtools"
|
||||||
|
DRY_RUN=0
|
||||||
|
DELETE=1
|
||||||
|
|
||||||
|
while (($#)); do
|
||||||
|
case "$1" in
|
||||||
|
--dry-run|-n)
|
||||||
|
DRY_RUN=1
|
||||||
|
shift
|
||||||
|
;;
|
||||||
|
--no-delete)
|
||||||
|
DELETE=0
|
||||||
|
shift
|
||||||
|
;;
|
||||||
|
-h|--help)
|
||||||
|
sed -n '1,80p' "$0"
|
||||||
|
exit 0
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
TARGET="$1"
|
||||||
|
shift
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
if ! command -v rsync >/dev/null 2>&1; then
|
||||||
|
echo "Error: rsync is required." >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
SRC_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||||
|
|
||||||
|
# Safety checks: make sure source looks like luxtools plugin
|
||||||
|
if [[ ! -f "$SRC_DIR/plugin.info.txt" ]]; then
|
||||||
|
echo "Error: '$SRC_DIR' doesn't look like luxtools (missing plugin.info.txt)." >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Ensure target dir exists
|
||||||
|
mkdir -p "$TARGET"
|
||||||
|
|
||||||
|
# Safety check: refuse to deploy to an obviously wrong directory.
|
||||||
|
# Allow empty dir (fresh install) OR existing luxtools plugin dir.
|
||||||
|
if [[ -e "$TARGET/plugin.info.txt" ]]; then
|
||||||
|
if ! grep -qi "^base\s\+luxtools" "$TARGET/plugin.info.txt" 2>/dev/null; then
|
||||||
|
echo "Error: target '$TARGET' has a plugin.info.txt, but it doesn't look like luxtools." >&2
|
||||||
|
echo "Refusing to deploy." >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
RSYNC_ARGS=(
|
||||||
|
-a
|
||||||
|
--human-readable
|
||||||
|
--itemize-changes
|
||||||
|
--chmod=Du=rwx,Dgo=rx,Fu=rw,Fgo=r
|
||||||
|
--exclude=deploy.sh
|
||||||
|
--exclude=.git/
|
||||||
|
--exclude=.github/
|
||||||
|
--exclude=.vscode/
|
||||||
|
--exclude=_test/
|
||||||
|
--exclude=deleted.files
|
||||||
|
--exclude=*.swp
|
||||||
|
--exclude=*.swo
|
||||||
|
--exclude=.DS_Store
|
||||||
|
)
|
||||||
|
|
||||||
|
if ((DRY_RUN)); then
|
||||||
|
RSYNC_ARGS+=(--dry-run)
|
||||||
|
fi
|
||||||
|
|
||||||
|
if ((DELETE)); then
|
||||||
|
RSYNC_ARGS+=(--delete)
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Deploying luxtools from: $SRC_DIR/"
|
||||||
|
echo "Deploying luxtools to: $TARGET/"
|
||||||
|
|
||||||
|
rsync "${RSYNC_ARGS[@]}" "$SRC_DIR/" "$TARGET/"
|
||||||
|
|
||||||
|
echo "Done."
|
||||||
@@ -10,6 +10,7 @@ use dokuwiki\plugin\luxtools\Path;
|
|||||||
*
|
*
|
||||||
* Provides shared functionality for directory, files, and images syntax.
|
* Provides shared functionality for directory, files, and images syntax.
|
||||||
*/
|
*/
|
||||||
|
if (!class_exists('syntax_plugin_luxtools_abstract', false)) {
|
||||||
abstract class syntax_plugin_luxtools_abstract extends SyntaxPlugin
|
abstract class syntax_plugin_luxtools_abstract extends SyntaxPlugin
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
@@ -103,15 +104,47 @@ abstract class syntax_plugin_luxtools_abstract extends SyntaxPlugin
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// DokuWiki caches the $data returned by handle(). When the shape changes
|
||||||
|
// between plugin versions, old cached instructions can feed unexpected
|
||||||
|
// structures (or even null) into render(). Be defensive to avoid fatals.
|
||||||
|
if (!is_array($data)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if ($format !== 'xhtml' && $format !== 'odt') {
|
if ($format !== 'xhtml' && $format !== 'odt') {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$pathData = $data['pathData'];
|
// New format: ['pathData' => array, 'params' => array]
|
||||||
$params = $data['params'];
|
// Back-compat: numeric list or older associative keys.
|
||||||
|
$pathData = $data['pathData'] ?? ($data[0] ?? null);
|
||||||
|
$params = $data['params'] ?? ($data[1] ?? null);
|
||||||
|
|
||||||
|
// Some older cached instructions may pass the raw path as string.
|
||||||
|
if (is_string($pathData)) {
|
||||||
|
$pathData = $this->processPath($pathData);
|
||||||
|
}
|
||||||
|
|
||||||
|
// If params are missing (older cache), fall back to defaults.
|
||||||
|
if (!is_array($params)) {
|
||||||
|
$params = $this->parseFlags('');
|
||||||
|
}
|
||||||
|
|
||||||
|
// If pathData was inlined (e.g. ['base'=>..,'pattern'=>..,'params'=>..]), extract it.
|
||||||
|
if (!is_array($pathData)) {
|
||||||
|
$candidate = $data;
|
||||||
|
unset($candidate['params']);
|
||||||
|
if (isset($candidate['base']) || isset($candidate['pattern']) || isset($candidate['path'])) {
|
||||||
|
$pathData = $candidate;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!is_array($pathData)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
// Disable caching if requested
|
// Disable caching if requested
|
||||||
if ($params['cache'] === 0) {
|
if (($params['cache'] ?? 0) == 0) {
|
||||||
$renderer->nocache();
|
$renderer->nocache();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -218,3 +251,5 @@ abstract class syntax_plugin_luxtools_abstract extends SyntaxPlugin
|
|||||||
return [$base, $pattern];
|
return [$base, $pattern];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user