feat(hexojs): Publish command auto-sets Hexo root for subdirectory

- Calculate web root from portal path (e.g., /www/blog → /blog/)
- Update _config.yml root setting before regenerating
- Run hexo clean && generate to apply new root
- Bumped release to r4

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
CyberMind-FR 2026-01-24 14:29:37 +01:00
parent 549e189059
commit 21105f1ef1
2 changed files with 33 additions and 3 deletions

View File

@ -8,7 +8,7 @@ include $(TOPDIR)/rules.mk
PKG_NAME:=secubox-app-hexojs
PKG_VERSION:=1.0.0
PKG_RELEASE:=3
PKG_RELEASE:=4
PKG_ARCH:=all
PKG_MAINTAINER:=CyberMind Studio <contact@cybermind.fr>

View File

@ -819,13 +819,43 @@ cmd_publish() {
local public_dir="$data_path/site/public"
local portal_path="/www/blog"
local config_file="$data_path/site/_config.yml"
# Allow custom portal path from config
local custom_path=$(uci_get portal.path)
[ -n "$custom_path" ] && portal_path="$custom_path"
# Calculate web root from portal path (strip /www prefix)
local web_root="${portal_path#/www}"
[ -z "$web_root" ] && web_root="/"
# Ensure trailing slash
[ "${web_root%/}" = "$web_root" ] && web_root="$web_root/"
if ! lxc_running; then
log_error "Container not running"
return 1
fi
if [ ! -f "$config_file" ]; then
log_error "No Hexo config found at $config_file"
return 1
fi
log_info "Setting Hexo root to: $web_root"
# Update root in _config.yml (use sed to replace existing root line)
if grep -q "^root:" "$config_file"; then
sed -i "s|^root:.*|root: $web_root|" "$config_file"
else
# Add root config if not present
echo "root: $web_root" >> "$config_file"
fi
log_info "Regenerating static files for $web_root..."
lxc_exec sh -c "cd /opt/hexojs/site && hexo clean && hexo generate"
if [ ! -d "$public_dir" ]; then
log_error "No public directory found. Run: hexoctl build"
log_error "Build failed - no public directory"
return 1
fi
@ -838,7 +868,7 @@ cmd_publish() {
rsync -av --delete "$public_dir/" "$portal_path/"
log_info "Published $(find "$portal_path" -type f | wc -l) files to $portal_path"
log_info "Access at: http://$(uci -q get network.lan.ipaddr || echo 'router')/blog/"
log_info "Access at: http://$(uci -q get network.lan.ipaddr || echo 'router')$web_root"
}
cmd_logs() {