start signer

This commit is contained in:
idk
2022-12-11 02:17:24 +00:00
parent f809bf01c8
commit 64f61570d3
3 changed files with 22 additions and 4 deletions

View File

@ -8,10 +8,11 @@ import (
)
type Feed struct {
HeaderTitle string
ArticlesSet []string
EntriesHTMLPath string
doc soup.Root
HeaderTitle string
ArticlesSet []string
EntriesHTMLPath string
BaseEntriesHTMLPath string
doc soup.Root
}
func (f *Feed) LoadHTML() error {
@ -25,6 +26,18 @@ func (f *Feed) LoadHTML() error {
for _, article := range articles {
f.ArticlesSet = append(f.ArticlesSet, article.HTML())
}
if f.BaseEntriesHTMLPath != "" {
data, err := ioutil.ReadFile(f.BaseEntriesHTMLPath)
if err != nil {
return fmt.Errorf("LoadHTML: error", err)
}
f.doc = soup.HTMLParse(string(data))
f.HeaderTitle = f.doc.Find("header").FullText()
articles := f.doc.FindAll("article")
for _, article := range articles {
f.ArticlesSet = append(f.ArticlesSet, article.HTML())
}
}
return nil
}

View File

@ -159,6 +159,10 @@ func Build(newsFile string) {
news.BACKUPFEED = *backupurl
news.SUBTITLE = *subtitle
news.URNID = *urn
base := filepath.Join(*newsfile, "entries.html")
if newsFile != base {
news.Feed.BaseEntriesHTMLPath = base
}
if feed, err := news.Build(); err != nil {
log.Printf("Build error: %s", err)
} else {

1
signer/signer.go Normal file
View File

@ -0,0 +1 @@
package newssigner