Compare commits

..

No commits in common. "ccdae9cf84c646d7f8ec7dd9db0633e49a3b55b1" and "3feec1a252b9fbe7d8f97b00096260f0604903da" have entirely different histories.

4 changed files with 1 additions and 105 deletions

View File

@ -5,7 +5,6 @@
<meta charset="UTF-8"> <meta charset="UTF-8">
<link rel="icon" href="/favicon.ico"> <link rel="icon" href="/favicon.ico">
<link rel="stylesheet" href="blog.css"> <link rel="stylesheet" href="blog.css">
<link rel="alternative" type="application/rss+xml" href="blog.xml">
</head> </head>
<body> <body>
<table> <table>

View File

@ -1,19 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
<channel>
<title>tilde.town blog</title>
<description>web log of tilde town</description>
<link>https://tilde.town/blog.html</link>
<atom:link rel="self" type="application/rss+xml" href="https://tilde.town/blog.xml"/>
{{ range .News }}
<item>
<title>{{.Title}}</title>
<pubDate>{{.Pubdate}}</pubDate>
<description>
<![CDATA[{{.Content}}]]>
</description>
<guid isPermalink="false">{{.Pubdate}}-{{.Title}}</guid>
</item>
{{ end }}
</channel>
</rss>

View File

@ -6,6 +6,5 @@ set -e
cd /town/src/tilde.town cd /town/src/tilde.town
/usr/bin/go run genblog.go > blog.html /usr/bin/go run genblog.go > blog.html
/usr/bin/go run genfeed.go > blog.xml
/usr/bin/go run genusers.go > users.html /usr/bin/go run genusers.go > users.html
/bin/cp index.html blog.html blog.xml users.html blog.css style.css /var/www/tilde.town/ /bin/cp index.html blog.html users.html blog.css style.css /var/www/tilde.town/

View File

@ -1,83 +0,0 @@
package main
import (
"bytes"
_ "embed"
"encoding/json"
"fmt"
"os"
"os/exec"
"text/template"
)
const statsPath = "/usr/local/bin/stats"
//go:embed feed.tmpl.xml
var feedTmpl string
type newsEntry struct {
Title string // Title of entry
Pubdate string // Human readable date
Content string // HTML of entry
}
type tildeData struct {
News []newsEntry
}
func _main() error {
data, err := stats()
if err != nil {
return err
}
type tmplData struct {
News []newsEntry
}
td := &tmplData{
News: data.News,
}
t, err := template.New("feed").Parse(feedTmpl)
if err != nil {
return fmt.Errorf("failed to parse the feed template: %w", err)
}
out := bytes.Buffer{}
if err = t.Execute(&out, td); err != nil {
return fmt.Errorf("failed to render feed template: %w", err)
}
fmt.Println(out.String())
return nil
}
func stats() (*tildeData, error) {
sout := bytes.Buffer{}
cmd := exec.Command(statsPath)
cmd.Stdout = &sout
err := cmd.Run()
if err != nil {
return nil, err
}
var data tildeData
err = json.Unmarshal(sout.Bytes(), &data)
if err != nil {
return nil, err
}
return &data, nil
}
func main() {
err := _main()
if err != nil {
fmt.Fprintf(os.Stderr, "error: %s\n", err)
os.Exit(1)
}
}