notes-server/server/html.go

48 lines
924 B
Go
Executable File

package server
import (
"fmt"
"gitea.inhome.blapointe.com/local/notes-server/config"
"net/http"
)
func head(w http.ResponseWriter, r *http.Request) {
w.Write([]byte(config.Head + "\n"))
}
func foot(w http.ResponseWriter, r *http.Request) {
w.Write([]byte(config.Foot + "\n"))
}
func block(w http.ResponseWriter, content string) {
fmt.Fprintf(w, "\n<div>\n%s\n</div>\n", content)
}
func h1(content string) string {
return h("1", content)
}
func h2(content string, style ...string) string {
return h("2", content, style...)
}
func h3(content string) string {
return h("3", content)
}
func h4(content string) string {
return h("4", content)
}
func h5(content string) string {
return h("5", content)
}
func h(level, content string, style ...string) string {
s := ""
if len(style) > 0 {
s = fmt.Sprintf("style=%q", style[0])
}
return fmt.Sprintf("\n<h%s %s>\n%s\n</h%s>\n", level, s, content, level)
}