Compare commits

...

3 Commits

Author SHA1 Message Date
Brian Picciano
7d48d2abba Fix mediaType for feed.xml over gemini 2023-02-13 17:52:17 +01:00
Brian Picciano
8108d55c29 Fix some line wraps in gemini copy 2023-02-13 17:24:09 +01:00
Brian Picciano
300a78ef48 Include link to source 2023-02-13 17:15:48 +01:00
6 changed files with 36 additions and 4 deletions

View File

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

View File

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

View File

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

View File

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

View File

@ -114,6 +114,8 @@
 / 
<a href="{{ BlogURL "feed.xml" }}">RSS</a>
&nbsp;//&nbsp;
<a href="https://code.betamike.com/mediocregopher/mediocre-blog">Source</a>
&nbsp;/&nbsp;
<a href="{{ StaticURL "wtfpl.txt" }}">License</a>
</header>