Add some metadata (robots.txt, humans.txt, .well-known) as well as /static

This commit is contained in:
Samantha Becker 2023-09-30 18:42:33 +02:00
parent f4103cccec
commit a0b66db4ed
7 changed files with 88 additions and 31 deletions

1
humans.txt Normal file
View file

@ -0,0 +1 @@
Made by m*, the one this page is about

29
main.go
View file

@ -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)
}
}

17
robots.txt Normal file
View file

@ -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: /

1
static/example.txt Normal file
View file

@ -0,0 +1 @@
paban

30
static/styles/index.css Normal file
View file

@ -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;
}

View file

@ -2,36 +2,7 @@
<html lang="en">
<head>
<script src="https://unpkg.com/htmx.org@1.9.5"></script>
<style>
@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);
}
</style>
<link rel="stylesheet" href="/static/styles/index.css">
<meta charset="UTF-8">
<title>m*</title>
</head>
@ -89,6 +60,13 @@
<p>And a fren: <a href="https://foxgirls.love/web">Erika</a></p>
<hr>
<p>Todo: Add proper styling</p>
<p>Last updated: 18.09.2023: 11:33</p>
<footer>
<p>Last updated: 30.09.2023: 18:37</p>
<p>
Privacy notice: This webpage uses Google Cloud Run for hosting.
If any tracking beyond generic request counting happens, I am not aware of it.
The server itself does not perform any tracking. I wouldn't even know how to start with that even if I wanted
</p>
</footer>
</body>
</html>

View file

@ -0,0 +1 @@
https://cloud.google.com