tiny 88x31 lexicon for atproto

add reference

+57
+19
handler/handler.go
··· 35 35 var loginT = template.Must(template.ParseFiles("./tmpl/base.html", "./tmpl/login.html")) 36 36 var logoutT = template.Must(template.ParseFiles("./tmpl/base.html", "./tmpl/logout.html")) 37 37 var uploadT = template.Must(template.ParseFiles("./tmpl/base.html", "./tmpl/upload.html")) 38 + var referenceT = template.Must(template.ParseFiles("./tmpl/base.html", "./tmpl/reference.html")) 38 39 var embedT = template.Must(template.ParseFiles("./tmpl/partial/embedbuttonpart.html", "./tmpl/embedbase.html", "./tmpl/embedcollection.html")) 39 40 40 41 func MakeHandler(db *db.Store, oauth *myoauth.Service) *Handler { ··· 42 43 sessionStore := sessions.NewCookieStore([]byte(os.Getenv("SESSION_KEY"))) 43 44 h := &Handler{db: db, router: mux, oauth: oauth, sessionStore: sessionStore} 44 45 mux.HandleFunc("GET /", h.oauthMiddleware(h.gethome)) 46 + mux.HandleFunc("GET /reference", h.oauthMiddleware(h.getreference)) 45 47 mux.HandleFunc("GET /login", h.oauthMiddleware(getlogin)) 46 48 mux.HandleFunc("POST /login", h.login) 47 49 mux.HandleFunc("GET /logout", h.oauthMiddleware(getlogout)) ··· 128 130 hd.Buttons = btnView 129 131 130 132 err = homeT.ExecuteTemplate(w, "base.html", hd) 133 + if err != nil { 134 + http.Error(w, err.Error(), http.StatusInternalServerError) 135 + } 136 + } 137 + func (h *Handler) getreference(cs *oauth.ClientSession, w http.ResponseWriter, r *http.Request) { 138 + type ReferenceData struct { 139 + DID *string 140 + Title string 141 + } 142 + var rd ReferenceData 143 + if cs != nil { 144 + did := cs.Data.AccountDID.String() 145 + rd.DID = &did 146 + } 147 + rd.Title = "reference" 148 + 149 + err := referenceT.ExecuteTemplate(w, "base.html", rd) 131 150 if err != nil { 132 151 http.Error(w, err.Error(), http.StatusInternalServerError) 133 152 }
+3
tmpl/embedbase.html
··· 5 5 <meta name="viewport" content="width=device-width, initial-scale=1.0"> 6 6 <title>88x31s</title> 7 7 <style> 8 + body { 9 + padding: 0; 10 + } 8 11 .special { 9 12 background: linear-gradient(88deg, #f00, #ff0, #0f0, #0ff, #00f, #f0f); 10 13 }
+5
tmpl/home.html
··· 11 11 no buttons yet, <a href="/upload">post the first!</a> 12 12 {{end}} 13 13 </div> 14 + <div> 14 15 <a href="/upload">upload a button!</a> 16 + </div> 17 + <div> 18 + <a href="/reference">reference</a> 19 + </div> 15 20 {{end}}
+30
tmpl/reference.html
··· 1 + {{define "content"}} 2 + <p> 3 + the most convenient api for <a href="/">88x31.store</a> is <code>/embed/liked-by?did=</code> 4 + </p> 5 + <p> 6 + this returns neat server-side-rendered html for use esp. in an iframe, like so: 7 + <code> 8 + &lt;iframe src="<a href="https://88x31.store/embed/liked-by?did=did:plc:25z6ogppprfvijcnqo2fsfce">https://88x31.store/embed/liked-by?did=did:plc:25z6ogppprfvijcnqo2fsfce</a>"&gt;&lt;/iframe&gt; 9 + </code> 10 + which renders as 11 + </p> 12 + <iframe src="https://88x31.store/embed/liked-by?did=did:plc:25z6ogppprfvijcnqo2fsfce"></iframe> 13 + <p> 14 + of course this hotlinks the buttons. if you don't know what's what this is perfectly fine! 15 + </p> 16 + <p> 17 + if you expect a **lot** of traffic it's still ok, but please pay me in exposure or something lol 18 + </p> 19 + <p> 20 + you can also get and host the buttons yourself, either once from me using the getButton lexicon, or directly from the PDS 21 + </p> 22 + <p> 23 + if you're into atproto or want more flexibility with layout, you can also use the getLikedButtons lexicon to get JSON for a user's likes, like so: 24 + <code> 25 + &lt;iframe src="<a href="https://88x31.store/xrpc/store.88x31.getLikedButtons?did=did:plc:25z6ogppprfvijcnqo2fsfce">https://88x31.store/xrpc/store.88x31.getLikedButtons?did=did:plc:25z6ogppprfvijcnqo2fsfce</a>"&gt;&lt;/iframe&gt; 26 + </code> 27 + which renders as 28 + </p> 29 + <iframe src="https://88x31.store/xrpc/store.88x31.getLikedButtons?did=did:plc:25z6ogppprfvijcnqo2fsfce"></iframe> 30 + {{end}}