diff --git a/humans.txt b/humans.txt new file mode 100644 index 0000000..b5d2951 --- /dev/null +++ b/humans.txt @@ -0,0 +1 @@ +Made by m*, the one this page is about \ No newline at end of file diff --git a/main.go b/main.go index b130ecb..53dcce2 100644 --- a/main.go +++ b/main.go @@ -1,12 +1,19 @@ package main import ( + "fmt" "html/template" "log" "net/http" "os" ) +func (a abc) Open(name string) (http.File, error) { + val, err := a.Open(name) + fmt.Println(err) + return val, err +} + func main() { port := os.Getenv("PORT") if port == "" { @@ -14,7 +21,18 @@ func main() { log.Printf("Defaulting to port %s \n", port) } + // Custom-ish paths. Includes templates http.HandleFunc("/", handleRoot) + + // static files in /static + http.Handle("/static/", http.StripPrefix("/static/", http.FileServer(http.Dir("./static")))) + + // .well-known from /well-known + http.Handle("/.well-known/", http.StripPrefix("/.well-known/", http.FileServer(http.Dir("./well-known")))) + + // Static files not in /static or /.well-known + http.HandleFunc("/robots.txt", buildHTTPFileReader("robots.txt")) + http.HandleFunc("/humans.txt", buildHTTPFileReader("humans.txt")) if err := http.ListenAndServe(":"+port, nil); err != nil { log.Fatal(err) } @@ -31,3 +49,14 @@ func handleRoot(w http.ResponseWriter, r *http.Request) { http.Error(w, "Failed to execute template", http.StatusInternalServerError) } } + +func buildHTTPFileReader(path string) func(w http.ResponseWriter, r *http.Request) { + return func(w http.ResponseWriter, r *http.Request) { + file, err := os.ReadFile(path) + if err != nil { + http.Error(w, "Failed to load file", http.StatusInternalServerError) + return + } + fmt.Fprintf(w, "%s", file) + } +} diff --git a/robots.txt b/robots.txt new file mode 100644 index 0000000..9cf63e4 --- /dev/null +++ b/robots.txt @@ -0,0 +1,17 @@ +User-agent: CCBot +Disallow: / + +User-agent: ChatGPT-User +Disallow: / + +User-agent: GPTBot +Disallow: / + +User-agent: Google-Extended +Disallow: / + +User-agent: Omgilibot +Disallow: / + +User-Agent: FacebookBot +Disallow: / \ No newline at end of file diff --git a/static/example.txt b/static/example.txt new file mode 100644 index 0000000..6be3b89 --- /dev/null +++ b/static/example.txt @@ -0,0 +1 @@ +paban \ No newline at end of file diff --git a/static/styles/index.css b/static/styles/index.css new file mode 100644 index 0000000..bab539d --- /dev/null +++ b/static/styles/index.css @@ -0,0 +1,30 @@ +@import url('https://fonts.googleapis.com/css2?family=Cantarell&display=swap'); +* { + /* Some global vars for colors*/ + --text: #0c0311; + --background: #fdfbfe; + --primary: #9b41d8; + --secondary: #d7b3ef; + --accent: #7924b2; + + font-family: Cantarell, serif; +} +body { + background: var(--background); +} +table { + border-collapse: collapse; +} + +td, th { + border: 1px solid var(--accent); + text-align: left; + padding: 8px; +} + +tr:nth-child(even) { + background-color: var(--secondary); +} +footer { + font-size: small; +} \ No newline at end of file diff --git a/templates/index.html b/templates/index.html index 3245791..d9cead2 100644 --- a/templates/index.html +++ b/templates/index.html @@ -2,36 +2,7 @@ - + m* @@ -89,6 +60,13 @@

And a fren: Erika


Todo: Add proper styling

-

Last updated: 18.09.2023: 11:33

+ \ No newline at end of file diff --git a/well-known/hosting-provider b/well-known/hosting-provider new file mode 100644 index 0000000..f16e445 --- /dev/null +++ b/well-known/hosting-provider @@ -0,0 +1 @@ +https://cloud.google.com \ No newline at end of file