Features: - URL shortener with QR codes, click tracking, deduplication, rate limiting - Pastebin with Markdown rendering, access tokens, raw view - Admin dashboard: dark theme, stats bar, Quick Links tiles with favicons, card-based layout, format/token badges, empty states - CSRF protection, bcrypt auth, in-memory sessions, security headers - Pure-Go SQLite (no CGo), single self-contained binary Deploy: - deploy/install.sh: auto-detects systemd vs SysV init - deploy/urlshort.service: hardened systemd unit - deploy/urlshort.init: SysV init script for older Ubuntu Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
24 lines
407 B
Go
24 lines
407 B
Go
package server
|
|
|
|
import (
|
|
"embed"
|
|
"html/template"
|
|
"io"
|
|
)
|
|
|
|
//go:embed all:templates
|
|
var templateFS embed.FS
|
|
|
|
//go:embed all:static
|
|
var staticFS embed.FS
|
|
|
|
var templates *template.Template
|
|
|
|
func initTemplates() {
|
|
templates = template.Must(template.ParseFS(templateFS, "templates/*.html"))
|
|
}
|
|
|
|
func renderTemplate(w io.Writer, name string, data any) error {
|
|
return templates.ExecuteTemplate(w, name, data)
|
|
}
|