This commit is contained in:
blank X 2021-08-11 20:22:30 +07:00
parent 301edec262
commit 6926e9f3e4
Signed by: blankie
GPG Key ID: CC15FC822C7F61F5
4 changed files with 25 additions and 24 deletions

28
main.go
View File

@ -1,18 +1,18 @@
package main
import (
"os"
"fmt"
"log"
"sort"
"time"
"errors"
"context"
"strings"
"net/url"
"crypto/x509"
"encoding/xml"
"errors"
"fmt"
"log"
"net/url"
"os"
"path/filepath"
"sort"
"strings"
"time"
"git.sr.ht/~adnano/go-gemini"
"git.sr.ht/~adnano/go-gemini/tofu"
@ -98,7 +98,7 @@ func do(client gemini.Client, ctx context.Context, req *gemini.Request, via []*g
}
if resp.Status.Class() == gemini.StatusPermanentFailure {
perrors[req.URL.String()] = PError{
Code: resp.Status,
Code: resp.Status,
Message: resp.Meta,
}
err = savePErrors()
@ -170,7 +170,7 @@ func main() {
Link: FeedLink{
Href: req.URL.String(),
},
Id: req.URL.String(),
Id: req.URL.String(),
Entries: nil,
}
if aw.Title == "" {
@ -181,10 +181,10 @@ func main() {
if len(aw.Items) == 0 {
feed.Updated = time.Now().Format(time.RFC3339)
} else {
feed.Updated = aw.Items[len(aw.Items) - 1].Date.Format(time.RFC3339)
feed.Updated = aw.Items[len(aw.Items)-1].Date.Format(time.RFC3339)
}
for i := len(aw.Items); i != 0; i-- {
item := aw.Items[i - 1]
item := aw.Items[i-1]
link, err := req.URL.Parse(item.Link)
if err != nil {
log.Fatal(err)
@ -193,9 +193,9 @@ func main() {
Title: item.Title,
Link: EntryLink{
Href: link.String(),
Rel: "alternate",
Rel: "alternate",
},
Id: link.String(),
Id: link.String(),
Updated: item.Date.Format(time.RFC3339),
})
}

View File

@ -1,9 +1,9 @@
package main
import (
"time"
"strings"
"encoding/xml"
"strings"
"time"
"git.sr.ht/~adnano/go-gemini"
)
@ -41,6 +41,7 @@ type FeedItem struct {
}
type ByTime []FeedItem
func (a ByTime) Len() int {
return len(a)
}
@ -63,9 +64,9 @@ func (a *AtomWriter) Handle(line gemini.Line) {
t, err := time.Parse("2006-01-02", string(runes[:10]))
if err == nil {
a.Items = append(a.Items, FeedItem{
Date: t,
Date: t,
Title: strings.TrimSpace(strings.TrimLeft(strings.TrimSpace(string(runes[10:])), ":-")),
Link: string(line.URL),
Link: string(line.URL),
})
}
case gemini.LineHeading1:

View File

@ -1,12 +1,12 @@
package main
import (
"os"
"bufio"
"net/url"
"os"
"path/filepath"
"strconv"
"strings"
"net/url"
"path/filepath"
"git.sr.ht/~adnano/go-gemini"
)
@ -44,7 +44,7 @@ func populatePErrors() error {
continue
}
perrors[url.String()] = PError{
Code: gemini.Status(code),
Code: gemini.Status(code),
Message: unescaper.Replace(values[2]),
}
}

View File

@ -1,11 +1,11 @@
package main
import (
"os"
"bufio"
"strings"
"net/url"
"os"
"path/filepath"
"strings"
)
var predirs map[string]*url.URL