aboutsummaryrefslogtreecommitdiff
path: root/cmd
diff options
context:
space:
mode:
authorXe Iaso <me@xeiaso.net>2024-05-10 15:12:49 -0400
committerXe Iaso <me@xeiaso.net>2024-05-10 15:12:49 -0400
commit690f3d0ac6e0e41e8667e0c14b700187899774f9 (patch)
tree40a8c6129b065d8080b0f7b19174c21cb43ce8d3 /cmd
parent1a1c4141f34a39703172214de3dd197f67f3d70e (diff)
downloadxesite-690f3d0ac6e0e41e8667e0c14b700187899774f9.tar.xz
xesite-690f3d0ac6e0e41e8667e0c14b700187899774f9.zip
bring back the IRC announcer
Signed-off-by: Xe Iaso <me@xeiaso.net>
Diffstat (limited to 'cmd')
-rw-r--r--cmd/xesite/api.go69
-rw-r--r--cmd/xesite/main.go18
2 files changed, 11 insertions, 76 deletions
diff --git a/cmd/xesite/api.go b/cmd/xesite/api.go
index 3a4eadb..6a79ad9 100644
--- a/cmd/xesite/api.go
+++ b/cmd/xesite/api.go
@@ -2,8 +2,6 @@ package main
import (
"context"
- "encoding/json"
- "io/fs"
"os"
"os/exec"
"runtime"
@@ -12,7 +10,6 @@ import (
"github.com/twitchtv/twirp"
"google.golang.org/protobuf/types/known/emptypb"
"google.golang.org/protobuf/types/known/timestamppb"
- "xeiaso.net/v4/internal/jsonfeed"
"xeiaso.net/v4/internal/lume"
"xeiaso.net/v4/pb"
"xeiaso.net/v4/pb/external/protofeed"
@@ -60,69 +57,5 @@ type FeedServer struct {
}
func (f *FeedServer) Get(ctx context.Context, _ *emptypb.Empty) (*protofeed.Feed, error) {
- data, err := fs.ReadFile(f.fs, "blog.json")
- if err != nil {
- return nil, twirp.InternalErrorf("can't read blog.json: %w", err)
- }
-
- var feed jsonfeed.Feed
-
- if err := json.Unmarshal(data, &feed); err != nil {
- return nil, twirp.InternalErrorf("can't unmarshal blog.json: %w", err)
- }
-
- var result protofeed.Feed
-
- result.Title = feed.Title
- result.HomePageUrl = feed.HomePageURL
- result.FeedUrl = feed.FeedURL
- result.Description = feed.Description
- result.UserComment = feed.UserComment
- result.Icon = feed.Icon
- result.Favicon = feed.Favicon
- result.Expired = feed.Expired
- result.Language = feed.Language
- result.Items = make([]*protofeed.Item, len(feed.Items))
- result.Authors = make([]*protofeed.Author, len(feed.Authors))
-
- for i, item := range feed.Items {
- var atts []*protofeed.Attachment
- for _, att := range item.Attachments {
- atts = append(atts, &protofeed.Attachment{
- Url: att.URL,
- MimeType: att.MIMEType,
- Title: att.Title,
- SizeInBytes: att.SizeInBytes,
- DurationInSeconds: att.DurationInSeconds,
- })
- }
-
- var authors []*protofeed.Author
- for _, author := range item.Authors {
- authors = append(authors, &protofeed.Author{
- Name: author.Name,
- Url: author.URL,
- Avatar: author.Avatar,
- })
- }
-
- result.Items[i] = &protofeed.Item{
- Id: item.ID,
- Url: item.URL,
- ExternalUrl: item.ExternalURL,
- Title: item.Title,
- ContentHtml: item.ContentHTML,
- ContentText: item.ContentText,
- Summary: item.Summary,
- Image: item.Image,
- BannerImage: item.BannerImage,
- DatePublished: timestamppb.New(item.DatePublished),
- DateModified: timestamppb.New(item.DateModified),
- Tags: item.Tags,
- Authors: authors,
- Attachments: atts,
- }
- }
-
- return &result, nil
+ return f.fs.LoadProtoFeed()
}
diff --git a/cmd/xesite/main.go b/cmd/xesite/main.go
index bf9c9de..4df8d11 100644
--- a/cmd/xesite/main.go
+++ b/cmd/xesite/main.go
@@ -27,6 +27,7 @@ var (
gitRepo = flag.String("git-repo", "https://github.com/Xe/site", "Git repository to clone")
githubSecret = flag.String("github-secret", "", "GitHub secret to use for webhooks")
internalAPIBind = flag.String("internal-api-bind", ":3001", "Port to listen on for the internal API")
+ mimiAnnounceURL = flag.String("mimi-announce-url", "", "URL to use for the mimi announce service")
miToken = flag.String("mi-token", "", "Token to use for the mi API")
patreonSaasProxyURL = flag.String("patreon-saasproxy-url", "http://xesite-patreon-saasproxy.flycast", "URL to use for the patreon saasproxy")
siteURL = flag.String("site-url", "https://xeiaso.net/", "URL to use for the site")
@@ -53,14 +54,15 @@ func main() {
}
fs, err := lume.New(ctx, &lume.Options{
- Branch: *gitBranch,
- Repo: *gitRepo,
- StaticSiteDir: "lume",
- URL: *siteURL,
- Development: *devel,
- PatreonClient: pc,
- DataDir: *dataDir,
- MiToken: *miToken,
+ Branch: *gitBranch,
+ Repo: *gitRepo,
+ StaticSiteDir: "lume",
+ URL: *siteURL,
+ Development: *devel,
+ PatreonClient: pc,
+ DataDir: *dataDir,
+ MiToken: *miToken,
+ MimiAnnounceURL: *mimiAnnounceURL,
})
if err != nil {
log.Fatal(err)