Move web templates and static assets to web/ dir alongside binary; update install.sh to deploy them
- Moved templates from src/web/templates/ to web/templates/ and static CSS from src/web/static/ to web/static/ - Updated handlers.go paths (src/web/ → web/) so the binary looks for templates at the correct deployment location - Updated install.sh to create web/templates/ and web/static/ directories and download the files from the repo - Removed old src/web/ directory (dead code) - Rebuilt inboxer binary with corrected template paths
This commit is contained in:
parent
78af7f7a6a
commit
a942afc52c
9 changed files with 16 additions and 3 deletions
BIN
bin/inboxer
BIN
bin/inboxer
Binary file not shown.
15
install.sh
15
install.sh
|
|
@ -85,8 +85,12 @@ else
|
|||
fi
|
||||
|
||||
# --- Create directory structure ----------------------------------------------
|
||||
WEB_DIR="${INSTALL_DIR}/web"
|
||||
TEMPLATES_DIR="${WEB_DIR}/templates"
|
||||
STATIC_DIR="${WEB_DIR}/static"
|
||||
|
||||
info "Creating directories under ${INSTALL_DIR}..."
|
||||
mkdir -p "${BIN_DIR}" "${DATA_DIR}" "${LOGS_DIR}"
|
||||
mkdir -p "${BIN_DIR}" "${DATA_DIR}" "${LOGS_DIR}" "${TEMPLATES_DIR}" "${STATIC_DIR}"
|
||||
|
||||
# --- Download helper ---------------------------------------------------------
|
||||
download() {
|
||||
|
|
@ -129,6 +133,15 @@ download "${REPO_BASE}/bin/inboxer" "${BIN_DIR}/inboxer" 755
|
|||
download "${REPO_BASE}/bin/config.yaml" "${BIN_DIR}/config.yaml" 644
|
||||
download "${REPO_BASE}/bin/prompt.txt" "${BIN_DIR}/prompt.txt" 644
|
||||
|
||||
# Web templates and static assets
|
||||
info "Downloading web templates and static assets..."
|
||||
download "${REPO_BASE}/web/templates/base.html" "${TEMPLATES_DIR}/base.html" 644
|
||||
download "${REPO_BASE}/web/templates/login.html" "${TEMPLATES_DIR}/login.html" 644
|
||||
download "${REPO_BASE}/web/templates/verify.html" "${TEMPLATES_DIR}/verify.html" 644
|
||||
download "${REPO_BASE}/web/templates/dashboard.html" "${TEMPLATES_DIR}/dashboard.html" 644
|
||||
download "${REPO_BASE}/web/templates/settings.html" "${TEMPLATES_DIR}/settings.html" 644
|
||||
download "${REPO_BASE}/web/static/style.css" "${STATIC_DIR}/style.css" 644
|
||||
|
||||
# Adjust config paths for /opt/inboxer deployment
|
||||
info "Adjusting configuration paths for deployment..."
|
||||
sed -i 's|path: "bin/db.sqlite"|path: "'"${DATA_DIR}"'/db.sqlite"|' "${BIN_DIR}/config.yaml"
|
||||
|
|
|
|||
|
|
@ -51,7 +51,7 @@ func parseTemplates() (map[string]*template.Template, error) {
|
|||
"currentYear": func() int { return time.Now().Year() },
|
||||
}
|
||||
|
||||
templateDir := "src/web/templates"
|
||||
templateDir := "web/templates"
|
||||
pages := []string{"login", "verify", "dashboard", "settings"}
|
||||
templates := make(map[string]*template.Template, len(pages))
|
||||
|
||||
|
|
@ -565,7 +565,7 @@ func parseInt(s string, defaultValue int) int {
|
|||
// RegisterRoutes registers all HTTP routes
|
||||
func (h *Handler) RegisterRoutes(router *mux.Router) {
|
||||
// Static files
|
||||
router.PathPrefix("/static/").Handler(http.StripPrefix("/static/", http.FileServer(http.Dir("src/web/static"))))
|
||||
router.PathPrefix("/static/").Handler(http.StripPrefix("/static/", http.FileServer(http.Dir("web/static"))))
|
||||
|
||||
// Public routes
|
||||
router.HandleFunc("/", h.LoginHandler).Methods("GET")
|
||||
|
|
|
|||
Loading…
Reference in a new issue