Get rid of RSS completely
This commit is contained in:
parent
07e1983fcc
commit
f86f2ba146
@ -22,13 +22,13 @@ func GenerateAtomFeed(c *Config, db *DB) (*string, error) {
|
|||||||
|
|
||||||
articles, err := db.GetCertainArticles("published", true)
|
articles, err := db.GetCertainArticles("published", true)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("error getting published articles for RSS feed: %v", err)
|
return nil, fmt.Errorf("error getting published articles for Atom feed: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, article := range articles {
|
for _, article := range articles {
|
||||||
articleTitle, err := ConvertToPlain(article.Title)
|
articleTitle, err := ConvertToPlain(article.Title)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("error converting title to plain text for RSS feed: %v", err)
|
return nil, fmt.Errorf("error converting title to plain text for Atom feed: %v", err)
|
||||||
}
|
}
|
||||||
entry := atom.NewEntry(articleTitle)
|
entry := atom.NewEntry(articleTitle)
|
||||||
entry.ID = atom.NewID(fmt.Sprint("urn:entry:", article.ID))
|
entry.ID = atom.NewID(fmt.Sprint("urn:entry:", article.ID))
|
||||||
@ -41,13 +41,13 @@ func GenerateAtomFeed(c *Config, db *DB) (*string, error) {
|
|||||||
|
|
||||||
user, err := db.GetUser(c, article.AuthorID)
|
user, err := db.GetUser(c, article.AuthorID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("error getting user user info for RSS feed: %v", err)
|
return nil, fmt.Errorf("error getting user user info for Atom feed: %v", err)
|
||||||
}
|
}
|
||||||
entry.AddAuthor(atom.NewPerson(user.FirstName + " " + user.LastName))
|
entry.AddAuthor(atom.NewPerson(user.FirstName + " " + user.LastName))
|
||||||
|
|
||||||
articleSummary, err := ConvertToPlain(article.Summary)
|
articleSummary, err := ConvertToPlain(article.Summary)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("error converting description to plain text for RSS feed: %v", err)
|
return nil, fmt.Errorf("error converting description to plain text for Atom feed: %v", err)
|
||||||
}
|
}
|
||||||
if article.AutoGenerated {
|
if article.AutoGenerated {
|
||||||
articleSummary = "auto generated"
|
articleSummary = "auto generated"
|
||||||
@ -56,7 +56,7 @@ func GenerateAtomFeed(c *Config, db *DB) (*string, error) {
|
|||||||
|
|
||||||
tags, err := db.GetArticleTags(article.ID)
|
tags, err := db.GetArticleTags(article.ID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("error getting tags for articles for RSS feed: %v", err)
|
return nil, fmt.Errorf("error getting tags for articles for Atom feed: %v", err)
|
||||||
}
|
}
|
||||||
for _, tag := range tags {
|
for _, tag := range tags {
|
||||||
entry.AddCategory(atom.NewCategory(tag.Name))
|
entry.AddCategory(atom.NewCategory(tag.Name))
|
||||||
@ -79,7 +79,7 @@ func GenerateAtomFeed(c *Config, db *DB) (*string, error) {
|
|||||||
|
|
||||||
atom, err := feed.ToXML("UTF-8")
|
atom, err := feed.ToXML("UTF-8")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("error converting RSS feed to XML: %v", err)
|
return nil, fmt.Errorf("error converting Atom feed to XML: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
return &atom, nil
|
return &atom, nil
|
||||||
|
@ -1,103 +0,0 @@
|
|||||||
package backend
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
"io"
|
|
||||||
"os"
|
|
||||||
"time"
|
|
||||||
|
|
||||||
"git.streifling.com/jason/rss"
|
|
||||||
)
|
|
||||||
|
|
||||||
func GenerateRSS(c *Config, db *DB) (*string, error) {
|
|
||||||
channel := &rss.Channel{
|
|
||||||
Title: c.Title,
|
|
||||||
Link: c.Link,
|
|
||||||
Description: c.Description,
|
|
||||||
Items: make([]*rss.Item, 0),
|
|
||||||
}
|
|
||||||
|
|
||||||
articles, err := db.GetCertainArticles("published", true)
|
|
||||||
if err != nil {
|
|
||||||
return nil, fmt.Errorf("error getting published articles for RSS feed: %v", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
for _, article := range articles {
|
|
||||||
tags, err := db.GetArticleTags(article.ID)
|
|
||||||
if err != nil {
|
|
||||||
return nil, fmt.Errorf("error getting tags for articles for RSS feed: %v", err)
|
|
||||||
}
|
|
||||||
tagNames := make([]string, 0)
|
|
||||||
for _, tag := range tags {
|
|
||||||
tagNames = append(tagNames, tag.Name)
|
|
||||||
}
|
|
||||||
|
|
||||||
if article.IsInIssue || article.AutoGenerated {
|
|
||||||
tagNames = append(tagNames, fmt.Sprint("Orient Express ", article.IssueID))
|
|
||||||
}
|
|
||||||
if article.AutoGenerated {
|
|
||||||
tagNames = append(tagNames, "autogenerated")
|
|
||||||
}
|
|
||||||
|
|
||||||
user, err := db.GetUser(c, article.AuthorID)
|
|
||||||
if err != nil {
|
|
||||||
return nil, fmt.Errorf("error getting user user info for RSS feed: %v", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
articleTitle, err := ConvertToPlain(article.Title)
|
|
||||||
if err != nil {
|
|
||||||
return nil, fmt.Errorf("error converting title to plain text for RSS feed: %v", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
articleDescription, err := ConvertToPlain(article.Summary)
|
|
||||||
if err != nil {
|
|
||||||
return nil, fmt.Errorf("error converting description to plain text for RSS feed: %v", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
item := &rss.Item{
|
|
||||||
Author: user.FirstName + " " + user.LastName,
|
|
||||||
Categories: tagNames,
|
|
||||||
Description: articleDescription,
|
|
||||||
Guid: string(article.ID),
|
|
||||||
Link: article.ContentLink,
|
|
||||||
PubDate: article.Created.Format(time.RFC1123Z),
|
|
||||||
Title: articleTitle,
|
|
||||||
}
|
|
||||||
|
|
||||||
// if article.AutoGenerated {
|
|
||||||
// item.Enclosure = &rss.Enclosure{
|
|
||||||
// Url: article.EncURL,
|
|
||||||
// Lenght: article.EncLength,
|
|
||||||
// Type: article.EncType,
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
channel.Items = append(channel.Items, item)
|
|
||||||
}
|
|
||||||
|
|
||||||
feed := rss.NewFeed()
|
|
||||||
feed.Channels = append(feed.Channels, channel)
|
|
||||||
rss, err := feed.ToXML("UTF-8")
|
|
||||||
if err != nil {
|
|
||||||
return nil, fmt.Errorf("error converting RSS feed to XML: %v", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
return &rss, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func SaveRSS(filename string, feed *string) error {
|
|
||||||
file, err := os.Create(filename)
|
|
||||||
if err != nil {
|
|
||||||
return fmt.Errorf("error creating file for RSS feed: %v", err)
|
|
||||||
}
|
|
||||||
defer file.Close()
|
|
||||||
if err = file.Chmod(0644); err != nil {
|
|
||||||
return fmt.Errorf("error setting permissions for RSS file: %v", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
if _, err = io.WriteString(file, *feed); err != nil {
|
|
||||||
return fmt.Errorf("error writing to RSS file: %v", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
|
1
go.mod
1
go.mod
@ -5,7 +5,6 @@ go 1.23.2
|
|||||||
require (
|
require (
|
||||||
firebase.google.com/go/v4 v4.14.1
|
firebase.google.com/go/v4 v4.14.1
|
||||||
git.streifling.com/jason/atom v1.0.0
|
git.streifling.com/jason/atom v1.0.0
|
||||||
git.streifling.com/jason/rss v0.1.3
|
|
||||||
github.com/BurntSushi/toml v1.4.0
|
github.com/BurntSushi/toml v1.4.0
|
||||||
github.com/chai2010/webp v1.1.1
|
github.com/chai2010/webp v1.1.1
|
||||||
github.com/disintegration/imaging v1.6.2
|
github.com/disintegration/imaging v1.6.2
|
||||||
|
2
go.sum
2
go.sum
@ -29,8 +29,6 @@ firebase.google.com/go/v4 v4.14.1 h1:4qiUETaFRWoFGE1XP5VbcEdtPX93Qs+8B/7KvP2825g
|
|||||||
firebase.google.com/go/v4 v4.14.1/go.mod h1:fgk2XshgNDEKaioKco+AouiegSI9oTWVqRaBdTTGBoM=
|
firebase.google.com/go/v4 v4.14.1/go.mod h1:fgk2XshgNDEKaioKco+AouiegSI9oTWVqRaBdTTGBoM=
|
||||||
git.streifling.com/jason/atom v1.0.0 h1:E88z4S7JeT6T+WuAaJWnGwCWTx+vzSJ6giUL51MdptI=
|
git.streifling.com/jason/atom v1.0.0 h1:E88z4S7JeT6T+WuAaJWnGwCWTx+vzSJ6giUL51MdptI=
|
||||||
git.streifling.com/jason/atom v1.0.0/go.mod h1:FNTYJfatYaIOQn4OKy8y+Mtohqm3MeyEGZUu4bMtZ9E=
|
git.streifling.com/jason/atom v1.0.0/go.mod h1:FNTYJfatYaIOQn4OKy8y+Mtohqm3MeyEGZUu4bMtZ9E=
|
||||||
git.streifling.com/jason/rss v0.1.3 h1:fd3j4ZtcLehapcmmroo3AP3X34gRHC4xzpfV6bDV1ZU=
|
|
||||||
git.streifling.com/jason/rss v0.1.3/go.mod h1:gpZF0nZbQSstMpyHD9DTAvlQEG7v4pjO5c7aIMWM4Jg=
|
|
||||||
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
|
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
|
||||||
github.com/BurntSushi/toml v1.4.0 h1:kuoIxZQy2WRRk1pttg9asf+WVv6tWQuBNVmK8+nqPr0=
|
github.com/BurntSushi/toml v1.4.0 h1:kuoIxZQy2WRRk1pttg9asf+WVv6tWQuBNVmK8+nqPr0=
|
||||||
github.com/BurntSushi/toml v1.4.0/go.mod h1:ukJfTF/6rtPPRCnwkur4qwRxa8vTRFBF0uk2lLoLwho=
|
github.com/BurntSushi/toml v1.4.0/go.mod h1:ukJfTF/6rtPPRCnwkur4qwRxa8vTRFBF0uk2lLoLwho=
|
||||||
|
Loading…
x
Reference in New Issue
Block a user