commit e9ab890a9115873d9bb85ab528929e30a737206c
parent 0cdb3037414e2b0c0394ca82ef8423fa68d3f30b
Author: Peter Kosyh <p.kosyh@gmail.com>
Date: Sun, 6 Sep 2020 17:52:30 +0300
not working rss draft
Diffstat:
3 files changed, 9 insertions(+), 2 deletions(-)
diff --git a/ii-node/main.go b/ii-node/main.go
@@ -50,10 +50,12 @@ var users_opt *string = flag.String("u", "points.txt", "Users database")
var db_opt *string = flag.String("db", "./db", "II database path (directory)")
var listen_opt *string = flag.String("L", ":8080", "Listen address")
var sysname_opt *string = flag.String("sys", "ii-go", "Node name")
+var host_opt *string = flag.String("host", "http://127.0.0.1:8080", "Node address")
var verbose_opt *bool = flag.Bool("v", false, "Verbose")
var echo_opt *string = flag.String("e", "list.txt", "Echoes list")
type WWW struct {
+ Host string;
tpl *template.Template
db *ii.DB
edb *ii.EDB
@@ -74,6 +76,7 @@ func main() {
db.Name = *sysname_opt
www.db = db
www.edb = edb
+ www.Host = *host_opt
WebInit(&www)
fs := http.FileServer(http.Dir("lib"))
diff --git a/ii-node/tpl/rss.tpl b/ii-node/tpl/rss.tpl
@@ -2,13 +2,13 @@
<channel>
<title>{{.Topic}}</title>
<description>RSS feed with last messages</description>
-<link>http://127.0.0.1:8080</link>
+<link>{{.BasePath}}</link>
{{ range .Msg }}
<item>
<title>{{.Subj}}</title>
<guid>{{.MsgId}}</guid>
- <link>http://127.0.0.1:8080/{{.MsgId}}#{{.MsgId}}</link>
+ <link>{{.BasePath}}/{{.MsgId}}#{{.MsgId}}</link>
<pubDate>{{.Date | fdate }}</pubDate>
<description>{{.Text}}</description>
<author>{{.From}}</author>
diff --git a/ii-node/web.go b/ii-node/web.go
@@ -187,6 +187,7 @@ func www_query(user *ii.User, www WWW, w http.ResponseWriter, r *http.Request, q
}
if rss {
ctx.Topic = db.Name + " :: " + req
+ ctx.BasePath = www.Host
/* yes, we should use text/template here, but it will be longer to do */
fmt.Fprintf(w, "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n")
return www.tpl.ExecuteTemplate(w, "rss.tpl", ctx)
@@ -597,6 +598,9 @@ func WebInit(www *WWW) {
"is_even": func(i int) bool {
return i%2 == 0
},
+ "unescape": func(s string) template.HTML {
+ return template.HTML(s)
+ },
}
www.tpl = template.Must(template.New("main").Funcs(funcMap).ParseGlob("tpl/*.tpl"))
}