Compare commits
3 Commits
80c1631bdd
...
7d48d2abba
Author | SHA1 | Date | |
---|---|---|---|
|
7d48d2abba | ||
|
8108d55c29 | ||
|
300a78ef48 |
@ -161,6 +161,18 @@ func indexMiddleware(h gemini.Handler) gemini.Handler {
|
||||
})
|
||||
}
|
||||
|
||||
func feedMiddleware(h gemini.Handler) gemini.Handler {
|
||||
|
||||
return gemini.HandlerFunc(func(
|
||||
ctx context.Context,
|
||||
rw gemini.ResponseWriter,
|
||||
r *gemini.Request,
|
||||
) {
|
||||
rw = forceResponseWriterMediaType(rw, "application/atom+xml")
|
||||
h.ServeGemini(ctx, rw, r)
|
||||
})
|
||||
}
|
||||
|
||||
func postsMiddleware(tplHandler gemini.Handler) gemini.Handler {
|
||||
|
||||
return gemini.HandlerFunc(func(
|
||||
@ -228,6 +240,7 @@ func (a *api) handler() (gemini.Handler, error) {
|
||||
mux := new(gemini.Mux)
|
||||
mux.Handle("/posts/", postsMiddleware(tplHandler))
|
||||
mux.Handle("/assets/", a.assetsMiddleware())
|
||||
mux.Handle("/feed.xml", feedMiddleware(tplHandler))
|
||||
mux.Handle("/", tplHandler)
|
||||
|
||||
var h gemini.Handler
|
||||
|
@ -5,4 +5,6 @@
|
||||
|
||||
{{ end -}}
|
||||
|
||||
=> https://code.betamike.com/mediocregopher/mediocre-blog Source
|
||||
|
||||
=> {{ BlogURL "wtfpl.txt" }} License for all content, if you must have one
|
||||
|
@ -3,8 +3,7 @@
|
||||
{{ $page := .GetQueryIntValue "page" 0 -}}
|
||||
|
||||
{{ if eq $page 0 -}}
|
||||
Here you'll find an archive of all published posts. The content varies almost as
|
||||
much as the quality!
|
||||
Here you'll find an archive of all published posts. The content varies almost as much as the quality!
|
||||
|
||||
{{ end -}}
|
||||
|
||||
|
@ -1,8 +1,7 @@
|
||||
{{ $post := .GetPostByID (.GetQueryValue "id" "") -}}
|
||||
|
||||
{{ if eq $post.Format "md" -}}
|
||||
This post has been translated from it's original markdown format, if it seems
|
||||
busted it might appear better over HTTP:
|
||||
This post has been translated from it's original markdown format, if it seems busted it might appear better over HTTP:
|
||||
|
||||
=> {{ PostHTTPURL $post.ID }}
|
||||
|
||||
|
17
src/gmi/util.go
Normal file
17
src/gmi/util.go
Normal file
@ -0,0 +1,17 @@
|
||||
package gmi
|
||||
|
||||
import "git.sr.ht/~adnano/go-gemini"
|
||||
|
||||
type rwSetMediaTypeNoop struct {
|
||||
gemini.ResponseWriter
|
||||
}
|
||||
|
||||
func (rwSetMediaTypeNoop) SetMediaType(string) {}
|
||||
|
||||
func forceResponseWriterMediaType(
|
||||
rw gemini.ResponseWriter, mediaType string,
|
||||
) gemini.ResponseWriter {
|
||||
|
||||
rw.SetMediaType(mediaType)
|
||||
return rwSetMediaTypeNoop{rw}
|
||||
}
|
@ -114,6 +114,8 @@
|
||||
/
|
||||
<a href="{{ BlogURL "feed.xml" }}">RSS</a>
|
||||
//
|
||||
<a href="https://code.betamike.com/mediocregopher/mediocre-blog">Source</a>
|
||||
/
|
||||
<a href="{{ StaticURL "wtfpl.txt" }}">License</a>
|
||||
</header>
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user