tangled
alpha
login
or
join now
moth11.net
/
88x31
0
fork
atom
tiny 88x31 lexicon for atproto
0
fork
atom
overview
issues
pulls
pipelines
add better docs
moth11.net
1 month ago
5de120cb
67504d33
+76
4 changed files
expand all
collapse all
unified
split
handler
handler.go
tmpl
lbreference.html
partial
apidoc.html
iframe.html
+34
handler/handler.go
···
37
var logoutT = template.Must(template.ParseFiles("./tmpl/base.html", "./tmpl/logout.html"))
38
var uploadT = template.Must(template.ParseFiles("./tmpl/base.html", "./tmpl/upload.html"))
39
var referenceT = template.Must(template.ParseFiles("./tmpl/base.html", "./tmpl/reference.html"))
0
40
var embedT = template.Must(template.ParseFiles("./tmpl/partial/embedbuttonpart.html", "./tmpl/embedbase.html", "./tmpl/embedcollection.html"))
41
42
func MakeHandler(db *db.Store, oauth *myoauth.Service) *Handler {
···
45
h := &Handler{db: db, router: mux, oauth: oauth, sessionStore: sessionStore}
46
mux.HandleFunc("GET /", h.oauthMiddleware(h.gethome))
47
mux.HandleFunc("GET /reference", h.oauthMiddleware(h.getreference))
0
48
mux.HandleFunc("GET /login", h.oauthMiddleware(getlogin))
49
mux.HandleFunc("POST /login", h.login)
50
mux.HandleFunc("GET /logout", h.oauthMiddleware(getlogout))
···
149
rd.Title = "reference"
150
151
err := referenceT.ExecuteTemplate(w, "base.html", rd)
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
152
if err != nil {
153
http.Error(w, err.Error(), http.StatusInternalServerError)
154
}
···
37
var logoutT = template.Must(template.ParseFiles("./tmpl/base.html", "./tmpl/logout.html"))
38
var uploadT = template.Must(template.ParseFiles("./tmpl/base.html", "./tmpl/upload.html"))
39
var referenceT = template.Must(template.ParseFiles("./tmpl/base.html", "./tmpl/reference.html"))
40
+
var lbreferenceT = template.Must(template.ParseFiles("./tmpl/partial/iframe.html", "./tmpl/partial/apidoc.html", "./tmpl/base.html", "./tmpl/lbreference.html"))
41
var embedT = template.Must(template.ParseFiles("./tmpl/partial/embedbuttonpart.html", "./tmpl/embedbase.html", "./tmpl/embedcollection.html"))
42
43
func MakeHandler(db *db.Store, oauth *myoauth.Service) *Handler {
···
46
h := &Handler{db: db, router: mux, oauth: oauth, sessionStore: sessionStore}
47
mux.HandleFunc("GET /", h.oauthMiddleware(h.gethome))
48
mux.HandleFunc("GET /reference", h.oauthMiddleware(h.getreference))
49
+
mux.HandleFunc("GET /embed/liked-by/reference", h.oauthMiddleware(h.getlbreference))
50
mux.HandleFunc("GET /login", h.oauthMiddleware(getlogin))
51
mux.HandleFunc("POST /login", h.login)
52
mux.HandleFunc("GET /logout", h.oauthMiddleware(getlogout))
···
151
rd.Title = "reference"
152
153
err := referenceT.ExecuteTemplate(w, "base.html", rd)
154
+
if err != nil {
155
+
http.Error(w, err.Error(), http.StatusInternalServerError)
156
+
}
157
+
}
158
+
159
+
func (h *Handler) getlbreference(cs *oauth.ClientSession, w http.ResponseWriter, r *http.Request) {
160
+
type Apidoc struct {
161
+
Fragment string
162
+
Accepts string
163
+
Notes string
164
+
HREF string
165
+
}
166
+
type ReferenceData struct {
167
+
DID *string
168
+
Title string
169
+
Docs []Apidoc
170
+
}
171
+
var rd ReferenceData
172
+
if cs != nil {
173
+
did := cs.Data.AccountDID.String()
174
+
rd.DID = &did
175
+
}
176
+
rd.Title = "reference"
177
+
rd.Docs = []Apidoc{
178
+
{"did=",
179
+
"atproto did as string",
180
+
"prefer to use atproto did! i don't locally store handle:did mappings, so if you use a handle, i have to resolve it on the fly, which adds latency",
181
+
"https://88x31.store/embed/liked-by?did=did:plc:25z6ogppprfvijcnqo2fsfce",
182
+
},
183
+
}
184
+
185
+
err := lbreferenceT.ExecuteTemplate(w, "base.html", rd)
186
if err != nil {
187
http.Error(w, err.Error(), http.StatusInternalServerError)
188
}
+8
tmpl/lbreference.html
···
0
0
0
0
0
0
0
0
···
1
+
{{define "content"}}
2
+
<h2>
3
+
/embed/liked-by reference
4
+
</h2>
5
+
{{range .Docs}}
6
+
{{apidoc .}}
7
+
{{end}}
8
+
{{end}}
+19
tmpl/partial/apidoc.html
···
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
···
1
+
{{define "apidoc"}}
2
+
<h3>
3
+
{{.Fragment}}
4
+
</h3>
5
+
<h4>
6
+
accepts
7
+
</h4>
8
+
<p>
9
+
{{.Accepts}}
10
+
</p>
11
+
<h4>
12
+
notes
13
+
</h4>
14
+
<p>
15
+
{{.Notes}}
16
+
</p>
17
+
{{iframe .}}
18
+
<hr>
19
+
{{end}}
+15
tmpl/partial/iframe.html
···
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
···
1
+
{{define "iframe"}}
2
+
<h4>
3
+
example HTML
4
+
</h4>
5
+
<div>
6
+
<code>
7
+
<iframe src="<a href="{{.HREF}}">{{.HREF}}</a>"></iframe>
8
+
</code>
9
+
</div>
10
+
<h4>
11
+
example output
12
+
</h4>
13
+
<iframe src="{{.HREF}}">
14
+
</iframe>
15
+
{{end}}