From 24109aa8d8d3c98ed793622f5b5af6907e2a9237 Mon Sep 17 00:00:00 2001 From: spatialfree Date: Tue, 27 Feb 2024 18:57:13 -0500 Subject: [PATCH] initial backend setup w/braille_xr page --- .gitattributes | 6 ++ .gitignore | 3 + data/data.go | 1 + go.mod | 5 ++ go.sum | 2 + readme.md | 22 ++++++ server.go | 61 +++++++++++++++++ src/router/router.go | 19 +++++ tem/html/biz copy.html | 49 +++++++++++++ tem/html/biz.html | 99 +++++++++++++++++++++++++++ tem/html/braille_xr.html | 34 +++++++++ tem/html/head.html | 8 +++ tem/html/mono.html | 99 +++++++++++++++++++++++++++ tem/tem.go | 67 ++++++++++++++++++ web/pages/braille_xr/braille_xr.go | 21 ++++++ web/pages/mono/mono.go | 50 ++++++++++++++ web/public/img/brailliant_bi_40x.webp | 3 + web/public/img/dofdev_logo.svg | 3 + web/public/img/hack.jpg | 3 + web/public/img/hack.webp | 3 + web/public/img/icons/art.svg | 3 + web/public/img/icons/com.svg | 3 + web/public/img/icons/degree.svg | 3 + web/public/img/icons/kofi.svg | 3 + web/public/img/icons/merch.svg | 3 + web/public/img/icons/net.svg | 3 + web/public/img/icons/northstar.svg | 3 + web/public/img/icons/org.svg | 3 + web/public/img/icons/patreon.svg | 3 + web/public/img/icons/scroll.svg | 3 + web/public/img/logo.svg | 3 + web/public/style.css | 94 +++++++++++++++++++++++++ 32 files changed, 685 insertions(+) create mode 100644 .gitattributes create mode 100644 .gitignore create mode 100644 data/data.go create mode 100644 go.mod create mode 100644 go.sum create mode 100644 readme.md create mode 100644 server.go create mode 100644 src/router/router.go create mode 100644 tem/html/biz copy.html create mode 100644 tem/html/biz.html create mode 100644 tem/html/braille_xr.html create mode 100644 tem/html/head.html create mode 100644 tem/html/mono.html create mode 100644 tem/tem.go create mode 100644 web/pages/braille_xr/braille_xr.go create mode 100644 web/pages/mono/mono.go create mode 100644 web/public/img/brailliant_bi_40x.webp create mode 100644 web/public/img/dofdev_logo.svg create mode 100644 web/public/img/hack.jpg create mode 100644 web/public/img/hack.webp create mode 100644 web/public/img/icons/art.svg create mode 100644 web/public/img/icons/com.svg create mode 100644 web/public/img/icons/degree.svg create mode 100644 web/public/img/icons/kofi.svg create mode 100644 web/public/img/icons/merch.svg create mode 100644 web/public/img/icons/net.svg create mode 100644 web/public/img/icons/northstar.svg create mode 100644 web/public/img/icons/org.svg create mode 100644 web/public/img/icons/patreon.svg create mode 100644 web/public/img/icons/scroll.svg create mode 100644 web/public/img/logo.svg create mode 100644 web/public/style.css diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..c9c7fb8 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,6 @@ +*.svg filter=lfs diff=lfs merge=lfs -text +*.jpg filter=lfs diff=lfs merge=lfs -text +*.webp filter=lfs diff=lfs merge=lfs -text +*.jpeg filter=lfs diff=lfs merge=lfs -text +*.png filter=lfs diff=lfs merge=lfs -text +*.webm filter=lfs diff=lfs merge=lfs -text diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..14fd545 --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +dofdev + +*.json \ No newline at end of file diff --git a/data/data.go b/data/data.go new file mode 100644 index 0000000..0ad59c2 --- /dev/null +++ b/data/data.go @@ -0,0 +1 @@ +package data diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..a65a9fb --- /dev/null +++ b/go.mod @@ -0,0 +1,5 @@ +module github.com/spatialfree/dofdev + +go 1.20 + +require github.com/gorilla/mux v1.8.1 // indirect diff --git a/go.sum b/go.sum new file mode 100644 index 0000000..7128337 --- /dev/null +++ b/go.sum @@ -0,0 +1,2 @@ +github.com/gorilla/mux v1.8.1 h1:TuBL49tXwgrFYWhqrNgrUNEY92u81SPhu7sTdzQEiWY= +github.com/gorilla/mux v1.8.1/go.mod h1:AKf9I4AEqPTmMytcMc0KkNouC66V3BtZ4qD5fmWSiMQ= diff --git a/readme.md b/readme.md new file mode 100644 index 0000000..cb65fd0 --- /dev/null +++ b/readme.md @@ -0,0 +1,22 @@ +```shell +# build and run +go build && ./dofdev + +#deploy +rsync -avz --progress ~/go/src/dofdev/ root@dofdev:/root/dofdev/ +``` +server starting at: http://localhost:3000 + + +i actually want to do this in a different way + +instead of a server that can be attacked +or taken down/compromised by me + +we instead have a distributed application that receives updates + +that way he has his copy and i have mine + +and they are on local secure devices + +it can just be console application for now \ No newline at end of file diff --git a/server.go b/server.go new file mode 100644 index 0000000..051c386 --- /dev/null +++ b/server.go @@ -0,0 +1,61 @@ +package main + +import ( + "fmt" + "log" + "net/http" + + "github.com/spatialfree/dofdev/src/router" + "github.com/spatialfree/dofdev/tem" +) + +func init() { + fmt.Println("init()") + tem.Load() +} + +func main() { + r := router.New() + + // Start the web server + log.Println("server starting on port 3000...") + addr := ":3210" + // addr := "192.168.0.21:3000" + if err := http.ListenAndServe(addr, r); err != nil { + log.Fatalf("error starting server: %v", err) + } + + // fs := http.FileServer(http.Dir("./res")) + // http.Handle("/res/", http.StripPrefix("/res/", fs)) + + // http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { + // fmt.Println("request: ", r.URL.Path) + // http.ServeFile(w, r, "./index.html") + // }) + + // http.HandleFunc("/pass", func(w http.ResponseWriter, r *http.Request) { + // fmt.Println("request: ", r.URL.Path) + // // fmt.Println("request: ", r.Header) + // fmt.Println("request: ", r.FormValue("pass")) + // fmt.Println("request: ", hash(r.FormValue("pass"))) + // if hash(r.FormValue("pass")) == 3556498 { + // http.ServeFile(w, r, "./biz.html") + // } else { + // http.Error(w, "Forbidden", http.StatusForbidden) + // } + // }) + + // fmt.Println("server starting @ http://localhost:3210 ...") + // if err := http.ListenAndServe(":3210", nil); err != nil { + // panic(err) + // } +} + +// hash function +func hash(s string) uint32 { + h := uint32(0) + for i := 0; i < len(s); i++ { + h = 31*h + uint32(s[i]) + } + return h +} diff --git a/src/router/router.go b/src/router/router.go new file mode 100644 index 0000000..368757b --- /dev/null +++ b/src/router/router.go @@ -0,0 +1,19 @@ +package router + +import ( + "net/http" + + "github.com/gorilla/mux" + braillexr "github.com/spatialfree/dofdev/web/pages/braille_xr" + "github.com/spatialfree/dofdev/web/pages/mono" +) + +func New() *mux.Router { + r := mux.NewRouter() // .StrictSlash(false) + + r.PathPrefix(("/public/")).Handler(http.StripPrefix("/public/", http.FileServer(http.Dir("web/public/")))) + r.HandleFunc("/", mono.Handler) + r.HandleFunc("/braille_xr", braillexr.Handler) + + return r +} diff --git a/tem/html/biz copy.html b/tem/html/biz copy.html new file mode 100644 index 0000000..512d0da --- /dev/null +++ b/tem/html/biz copy.html @@ -0,0 +1,49 @@ +

shared accounts:

+ + +
+ + + + \ No newline at end of file diff --git a/tem/html/biz.html b/tem/html/biz.html new file mode 100644 index 0000000..c0c1132 --- /dev/null +++ b/tem/html/biz.html @@ -0,0 +1,99 @@ +

shared accounts:

+ + +
+ + + + + + \ No newline at end of file diff --git a/tem/html/braille_xr.html b/tem/html/braille_xr.html new file mode 100644 index 0000000..00b1fca --- /dev/null +++ b/tem/html/braille_xr.html @@ -0,0 +1,34 @@ +{{ template "head.html" .}} + +
+ +

braille_xr

+ +

problem

+ + + +

solution

+ + +

progress

+ + + +
+ +
\ No newline at end of file diff --git a/tem/html/head.html b/tem/html/head.html new file mode 100644 index 0000000..2124e69 --- /dev/null +++ b/tem/html/head.html @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/tem/html/mono.html b/tem/html/mono.html new file mode 100644 index 0000000..6f4d557 --- /dev/null +++ b/tem/html/mono.html @@ -0,0 +1,99 @@ +{{ template "head.html" .}} + +
+ +

+ An effort to open higher degrees of
+ spatial interaction free
+ to the world. +

+ + +

degrees of freedom development

+ +
+
Ethan Merchant + @spatialfree +
+
Niko Ryan + @opendegree +
+
+ +
×
+ + + + + +
+ + + + +

projects

+

xr based interfaces

+ +braille_xr + +
+ +
+ + + + +
© 2018-2024 dofdev
+ + + \ No newline at end of file diff --git a/tem/tem.go b/tem/tem.go new file mode 100644 index 0000000..8d82dd2 --- /dev/null +++ b/tem/tem.go @@ -0,0 +1,67 @@ +package tem + +import ( + "fmt" + "html/template" + "net/http" +) + +var ( + Templates *template.Template +) + +func Load() { + Templates = template.Must(template.ParseGlob("tem/html/*.html")) + fmt.Println("templates loaded") +} + +func Render( + w http.ResponseWriter, + r *http.Request, + template string, + page string, + title string, + desc string, + page_data interface{}, +) { + w.WriteHeader(http.StatusOK) + + data := struct { + Host string + Page string + Title string + Desc string + Local bool + Root bool + Data interface{} + }{ + Host: r.Host, + Page: page, + Title: title, + Desc: desc, + Local: true, // (os.Getenv("LOCAL") == "true"), // toggle here for flag testing + Root: true, // (os.Getenv("HOST_IDEABRELLA") == strings.ReplaceAll(r.Host, ":3000", "")), + Data: page_data, + } + + err := Templates.ExecuteTemplate(w, template, data) + if err != nil { + fmt.Println(err) + } +} + +// for small refreshable templates within pages +// so no need for page things like title, desc, etc. +func RenderSub( + w http.ResponseWriter, + r *http.Request, + template string, + page_data interface{}, +) { + w.WriteHeader(http.StatusOK) + + err := Templates.ExecuteTemplate(w, template, page_data) + if err != nil { + fmt.Println(err) + } +} diff --git a/web/pages/braille_xr/braille_xr.go b/web/pages/braille_xr/braille_xr.go new file mode 100644 index 0000000..702f6c7 --- /dev/null +++ b/web/pages/braille_xr/braille_xr.go @@ -0,0 +1,21 @@ +package braillexr + +import ( + "net/http" + + "github.com/spatialfree/dofdev/tem" +) + +// func Handler(ctx *gin.Context) { +func Handler(w http.ResponseWriter, r *http.Request) { + data := struct { + }{} + tem.Render( + w, r, + "braille_xr.html", + "braille_xr", + "braille_xr", + "refreshable braille display for rendering and input with handtracking", + data, + ) +} diff --git a/web/pages/mono/mono.go b/web/pages/mono/mono.go new file mode 100644 index 0000000..6a932bd --- /dev/null +++ b/web/pages/mono/mono.go @@ -0,0 +1,50 @@ +package mono + +import ( + "net/http" + + "github.com/spatialfree/dofdev/tem" +) + +// func Handler(ctx *gin.Context) { +func Handler(w http.ResponseWriter, r *http.Request) { + data := struct { + Projects []Project + }{ + Projects, + } + tem.Render( + w, r, + "mono.html", + "", + "dofdev", + "an effort to open higher degrees of spatial interaction free to the world.", + data, + ) +} + +type Project struct { + ID int + Title string + Description string + Art string +} + +// This would ideally come from a database +var Projects = []Project{ + {ID: 1, + Title: "Prompt-Train", + Description: "PromptTrain, the PromptWriting Excellence Engine, is here to help you enhance your writing skills and unleash your creativity. Receive valuable feedback on your prompts, compete in creative challenges, connect with a supportive community, and embark on your journey towards writing excellence.", + Art: "/res/projects/prompt-train.png", + }, + {ID: 2, + Title: "Echo AI", + Description: "With EchoAI, creating AI personas is a breeze. Define your character's name, appearance, traits, speech patterns, emotional range, and background story. Submit website and training reference documents, and specify preferred topics and custom responses. EchoAI offers a user-friendly, step-by-step process to bring your Echo AI persona to life.", + Art: "/res/projects/echo-ai.png", + }, + {ID: 3, + Title: "PromptScript", + Description: "PromptScript is a web based ai prompting language that allows you to orchestrate complex systematic patterns with large language models.", + Art: "/res/projects/promptscript.png", + }, +} diff --git a/web/public/img/brailliant_bi_40x.webp b/web/public/img/brailliant_bi_40x.webp new file mode 100644 index 0000000..2c54b5c --- /dev/null +++ b/web/public/img/brailliant_bi_40x.webp @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:1b4f3e5ed69b298385072981e005b4b619faca569cad49f63b6e7298c695259f +size 43088 diff --git a/web/public/img/dofdev_logo.svg b/web/public/img/dofdev_logo.svg new file mode 100644 index 0000000..3b5d605 --- /dev/null +++ b/web/public/img/dofdev_logo.svg @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:fa7d41b8364d53d8faed160d5cc79af44486fa4f5cdd3476340f0208594f6120 +size 62425 diff --git a/web/public/img/hack.jpg b/web/public/img/hack.jpg new file mode 100644 index 0000000..c72db3a --- /dev/null +++ b/web/public/img/hack.jpg @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:7703a1a65e010616c7ff46998a9913132b21bf96339820db4f7c1c6d99092457 +size 1028731 diff --git a/web/public/img/hack.webp b/web/public/img/hack.webp new file mode 100644 index 0000000..a9bdc59 --- /dev/null +++ b/web/public/img/hack.webp @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:af61dc5402560365214b33b11aa4efbe2beb66af0758d67c800d5ce05ccaf115 +size 464182 diff --git a/web/public/img/icons/art.svg b/web/public/img/icons/art.svg new file mode 100644 index 0000000..57f04a4 --- /dev/null +++ b/web/public/img/icons/art.svg @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:e3d1158cb28163acf278b1ac71b1bc49292ffe4ac7c986501cf05199732669b0 +size 2558 diff --git a/web/public/img/icons/com.svg b/web/public/img/icons/com.svg new file mode 100644 index 0000000..82cdd66 --- /dev/null +++ b/web/public/img/icons/com.svg @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:d98538146feeeb7c3a1241c8d7da1da07b452229e8090d7399ccfa0f5531dbe0 +size 2849 diff --git a/web/public/img/icons/degree.svg b/web/public/img/icons/degree.svg new file mode 100644 index 0000000..1e146f5 --- /dev/null +++ b/web/public/img/icons/degree.svg @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:9e2b3a0819f148e2f6052954fc78918df40564dc1c5a55aebe77be232c95a1f7 +size 4827 diff --git a/web/public/img/icons/kofi.svg b/web/public/img/icons/kofi.svg new file mode 100644 index 0000000..8049de9 --- /dev/null +++ b/web/public/img/icons/kofi.svg @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:b4526468530adc462affd5b0fcc1501892fc16b6ee2bf067c99c3edebedad265 +size 3930 diff --git a/web/public/img/icons/merch.svg b/web/public/img/icons/merch.svg new file mode 100644 index 0000000..619f281 --- /dev/null +++ b/web/public/img/icons/merch.svg @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:8430e915d2af003764820ea8b3768d346490894c30fa3cc807ddd3e827ad0d0e +size 2434 diff --git a/web/public/img/icons/net.svg b/web/public/img/icons/net.svg new file mode 100644 index 0000000..b07f5c2 --- /dev/null +++ b/web/public/img/icons/net.svg @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:defdd8ddd90e2e20079f6628891b3ba0ff11e372b2ec976df761c3b844404d9a +size 6205 diff --git a/web/public/img/icons/northstar.svg b/web/public/img/icons/northstar.svg new file mode 100644 index 0000000..4ecb6ca --- /dev/null +++ b/web/public/img/icons/northstar.svg @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:260088c6d5d841f46cf3ed1e675248c0bd02887b4df18b47716abe3d0415f32b +size 10695 diff --git a/web/public/img/icons/org.svg b/web/public/img/icons/org.svg new file mode 100644 index 0000000..4363af6 --- /dev/null +++ b/web/public/img/icons/org.svg @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:6450c5f342e5e2dc2d3627c08d0ebb83365b622a6ac92c66a369fee841a0ddb3 +size 1992 diff --git a/web/public/img/icons/patreon.svg b/web/public/img/icons/patreon.svg new file mode 100644 index 0000000..0625dba --- /dev/null +++ b/web/public/img/icons/patreon.svg @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:ae03e97c37435f8527d378202e6bef72c0971a9de2983d6563f747bb293a3632 +size 2959 diff --git a/web/public/img/icons/scroll.svg b/web/public/img/icons/scroll.svg new file mode 100644 index 0000000..c6a6e3c --- /dev/null +++ b/web/public/img/icons/scroll.svg @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:6215862873bb3293610c1e5a74d6b4537ed0bca1b42392a2ffb267e6d0dc96bc +size 2582 diff --git a/web/public/img/logo.svg b/web/public/img/logo.svg new file mode 100644 index 0000000..dc152d8 --- /dev/null +++ b/web/public/img/logo.svg @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:69a3ded806dd9d1c53f2693d54c7966c3b941734546fa22eb0fe7d44a65ebe8c +size 21509 diff --git a/web/public/style.css b/web/public/style.css new file mode 100644 index 0000000..3155ddd --- /dev/null +++ b/web/public/style.css @@ -0,0 +1,94 @@ +@import url('https://fonts.googleapis.com/css2?family=Atkinson+Hyperlegible&display=swap'); +@import url('https://fonts.googleapis.com/css2?family=Courier+Prime&display=swap'); +@import url('https://fonts.googleapis.com/css2?family=Nanum+Myeongjo&display=swap'); +html { + height: 100dvh; + margin: 0 auto; + max-width: 600px; +} +* { + display: block; + box-sizing: border-box; + flex-shrink: 0; + + text-wrap: balance; + font-family: 'Atkinson Hyperlegible', sans-serif; + text-rendering: optimizeLegibility; +} +title, style, script { + display: none; +} +body { + height: 100dvh; + margin: 0 auto; padding: 0; + line-height: 1.5; + background-color: #808080; + color: #000; +} +main { + height: 100dvh; + margin: 0 auto; + /* padding-top: 64px; */ + display: flex; + flex-flow: column; + align-items: center; +} +h1, h2 { + letter-spacing: 2px; +} +h1 { + color: #fff; +} +a, b, i, code, span { + display: inline; + font-family: inherit; + font-size: inherit; + color: inherit; +} +a { + cursor: pointer; + text-decoration: underline; +} +a:focus { + filter: brightness(1.333); +} +b { font-weight: bold; } +i { font-style: italic; } +code { + font-family: 'DM Mono', monospace; + font-weight: 500; + color: #0000FF; +} +img, video, canvas { + overflow: hidden; +} + +img { + all: revert-layer; + display: block; + margin: 0 auto; + border-radius: 1px; +} +.t_symbol { + margin: 2rem auto; + font-family: "Nanum Myeongjo", serif; + text-align: center; + font-size: 64px; + /* font-weight: bold; */ + color: #666; +} +footer { + margin-top: 128px; + height: 64px; + line-height: 64px; + letter-spacing: 0.5px; + font-size: 0.75em; +} +input { + outline: none; + border: none; + padding: 8px 16px; + border-radius: 32px; + letter-spacing: 1px; + font-size: 16px; +} \ No newline at end of file