mirror of
https://github.com/aljazceru/njump.git
synced 2025-12-17 22:34:25 +01:00
initial broken draft of relays page.
This commit is contained in:
38
main.go
38
main.go
@@ -1,16 +1,50 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"embed"
|
||||
"html"
|
||||
"net/http"
|
||||
"os"
|
||||
"text/template"
|
||||
|
||||
"github.com/rs/zerolog"
|
||||
)
|
||||
|
||||
var log = zerolog.New(os.Stderr).Output(zerolog.ConsoleWriter{Out: os.Stdout}).
|
||||
With().Timestamp().Logger()
|
||||
//go:embed static/*
|
||||
var static embed.FS
|
||||
|
||||
//go:embed templates/*
|
||||
var templates embed.FS
|
||||
|
||||
var (
|
||||
tmpl *template.Template
|
||||
templateMapping = make(map[string]string)
|
||||
|
||||
log = zerolog.New(os.Stderr).Output(zerolog.ConsoleWriter{Out: os.Stdout}).With().Timestamp().Logger()
|
||||
)
|
||||
|
||||
func main() {
|
||||
// initialize templates
|
||||
// use a mapping to expressly link the templates and share them between more kinds/types
|
||||
templateMapping["profile"] = "profile.html"
|
||||
templateMapping["note"] = "note.html"
|
||||
templateMapping["address"] = "other.html"
|
||||
templateMapping["relay"] = "relay.html"
|
||||
|
||||
funcMap := template.FuncMap{
|
||||
"basicFormatting": basicFormatting,
|
||||
"mdToHTML": mdToHTML,
|
||||
"escapeString": html.EscapeString,
|
||||
"sanitizeXSS": sanitizeXSS,
|
||||
}
|
||||
|
||||
tmpl = template.Must(
|
||||
template.New("tmpl").
|
||||
Funcs(funcMap).
|
||||
ParseFS(templates, "templates/*"),
|
||||
)
|
||||
|
||||
// routes
|
||||
http.HandleFunc("/njump/image/", generate)
|
||||
http.HandleFunc("/njump/proxy/", proxy)
|
||||
http.Handle("/njump/static/", http.StripPrefix("/njump/", http.FileServer(http.FS(static))))
|
||||
|
||||
Reference in New Issue
Block a user