2017-07-12 06:43:11 +00:00
|
|
|
package yatwiki
|
2017-07-11 07:08:22 +00:00
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"html/template"
|
|
|
|
"net/http"
|
|
|
|
"net/url"
|
|
|
|
"time"
|
|
|
|
)
|
|
|
|
|
|
|
|
func (this *WikiServer) routeRecentChangesRSS(w http.ResponseWriter, r *http.Request) {
|
|
|
|
recents, err := this.db.GetRecentChanges(0, this.opts.RecentChangesRSS)
|
|
|
|
if err != nil {
|
|
|
|
this.serveInternalError(w, r, err)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
content := `<?xml version="1.0" encoding="UTF-8" ?>
|
|
|
|
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
|
|
|
|
<channel>
|
|
|
|
<title>` + template.HTMLEscapeString(this.opts.PageTitle) + `</title>
|
|
|
|
<link>` + template.HTMLEscapeString(this.opts.ExternalBaseURL) + `</link>
|
|
|
|
<description>` + template.HTMLEscapeString(this.opts.PageTitle) + `</description>
|
|
|
|
<language>` + template.HTMLEscapeString(this.opts.DeclareRSSLanguage) + `</language>
|
|
|
|
<atom:link href="` + template.HTMLEscapeString(this.opts.ExternalBaseURL+`rss/changes`) + `" rel="self" type="application/rss+xml" />
|
|
|
|
`
|
|
|
|
for _, a := range recents {
|
|
|
|
content += `
|
|
|
|
<item>
|
2018-04-02 05:41:47 +00:00
|
|
|
<title>` + template.HTMLEscapeString(a.Title+` (r`+fmt.Sprintf("%d", a.ArticleID)+`)`) + `</title>
|
|
|
|
<link>` + template.HTMLEscapeString(this.opts.ExternalBaseURL+`archive/`+fmt.Sprintf("%d", a.ArticleID)) + `</link>
|
|
|
|
<guid>` + template.HTMLEscapeString(this.opts.ExternalBaseURL+`archive/`+fmt.Sprintf("%d", a.ArticleID)) + `</guid>
|
2017-07-11 07:08:22 +00:00
|
|
|
<author>` + template.HTMLEscapeString(this.opts.DeclareRSSEmail+` (`+this.opts.PageTitle+` `+a.Author+`)`) + `</author>
|
|
|
|
<pubDate>` + template.HTMLEscapeString(time.Unix(a.Modified, 0).In(this.loc).Format(time.RFC1123Z)) + `</pubDate>
|
|
|
|
<description>` + template.HTMLEscapeString(`
|
2017-08-13 05:51:44 +00:00
|
|
|
<a href="`+template.HTMLEscapeString(this.opts.ExternalBaseURL+`view/`+url.PathEscape(a.Title))+`">latest version</a>
|
2017-07-11 07:08:22 +00:00
|
|
|
|
|
2018-04-02 05:41:47 +00:00
|
|
|
<a href="`+template.HTMLEscapeString(this.opts.ExternalBaseURL+`archive/`+fmt.Sprintf("%d", a.ArticleID))+`">revision `+fmt.Sprintf("%d", a.ArticleID)+`</a>
|
2017-07-11 07:08:22 +00:00
|
|
|
|
|
2018-04-02 05:41:47 +00:00
|
|
|
<a href="`+template.HTMLEscapeString(this.opts.ExternalBaseURL+`diff/parent/`+fmt.Sprintf("%d", a.ArticleID))+`">diff to previous</a>
|
2017-07-11 07:08:22 +00:00
|
|
|
`) + `</description>
|
|
|
|
</item>
|
|
|
|
`
|
|
|
|
}
|
|
|
|
content += `
|
|
|
|
</channel>
|
|
|
|
</rss>`
|
|
|
|
|
|
|
|
w.Header().Set(`Content-Type`, `application/rss+xml`)
|
|
|
|
w.Write([]byte(content))
|
|
|
|
}
|