Implements rss for thread activity.
This commit is contained in:
parent
d1d9c69489
commit
eab0673409
2 changed files with 65 additions and 6 deletions
10
forum.nim
10
forum.nim
|
|
@ -645,7 +645,13 @@ get "/":
|
||||||
createTFD()
|
createTFD()
|
||||||
c.isThreadsList = true
|
c.isThreadsList = true
|
||||||
var count = 0
|
var count = 0
|
||||||
resp genMain(c, genThreadsList(c, count))
|
resp genMain(c, genThreadsList(c, count), genRSSHeaders(c))
|
||||||
|
|
||||||
|
get "/threadActivity.xml":
|
||||||
|
createTFD()
|
||||||
|
c.isThreadsList = true
|
||||||
|
var count = 0
|
||||||
|
resp genRSS(c), "application/atom+xml"
|
||||||
|
|
||||||
get "/t/@threadid/?@page?/?":
|
get "/t/@threadid/?@page?/?":
|
||||||
createTFD()
|
createTFD()
|
||||||
|
|
@ -691,7 +697,7 @@ get "/page/@page/?":
|
||||||
let list = genThreadsList(c, count)
|
let list = genThreadsList(c, count)
|
||||||
if count == 0:
|
if count == 0:
|
||||||
pass()
|
pass()
|
||||||
resp genMain(c, list)
|
resp genMain(c, list, genRSSHeaders(c))
|
||||||
|
|
||||||
get "/profile/@nick/?":
|
get "/profile/@nick/?":
|
||||||
createTFD()
|
createTFD()
|
||||||
|
|
|
||||||
61
main.tmpl
61
main.tmpl
|
|
@ -1,5 +1,6 @@
|
||||||
#! stdtmpl
|
#! stdtmpl
|
||||||
#proc genMain(c: var TForumData, content: string): string =
|
#proc genMain(c: var TForumData, content: string,
|
||||||
|
# additional_headers = ""): string =
|
||||||
# result = ""
|
# result = ""
|
||||||
# var stats: TForumStats
|
# var stats: TForumStats
|
||||||
# if c.isThreadsList: stats = c.getStats(false)
|
# if c.isThreadsList: stats = c.getStats(false)
|
||||||
|
|
@ -11,7 +12,7 @@
|
||||||
<head>
|
<head>
|
||||||
<title>Nimrod Forum</title>
|
<title>Nimrod Forum</title>
|
||||||
<link rel="stylesheet" href="${c.req.makeUri("css/normalize.css", absolute = false)}">
|
<link rel="stylesheet" href="${c.req.makeUri("css/normalize.css", absolute = false)}">
|
||||||
<link rel="stylesheet" href="${c.req.makeUri("css/style.css", absolute = false)}">
|
<link rel="stylesheet" href="${c.req.makeUri("css/style.css", absolute = false)}">${additional_headers}
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
|
@ -32,11 +33,11 @@
|
||||||
<a href="${frontQuery}login" class="right">Login</a>
|
<a href="${frontQuery}login" class="right">Login</a>
|
||||||
#end if
|
#end if
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id="topbar">
|
<div id="topbar">
|
||||||
${c.genActionMenu}
|
${c.genActionMenu}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id="content">
|
<div id="content">
|
||||||
$content
|
$content
|
||||||
<span style="color:red">$c.errorMsg</span>
|
<span style="color:red">$c.errorMsg</span>
|
||||||
|
|
@ -60,3 +61,55 @@
|
||||||
</div>
|
</div>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
#end proc
|
||||||
|
#
|
||||||
|
#proc genRSSHeaders(c: var TForumData): string =
|
||||||
|
# result = ""
|
||||||
|
<link href="${c.req.makeUri("threadActivity.xml")}" title="Thread activity"
|
||||||
|
type="application/atom+xml" rel="alternate">
|
||||||
|
#end proc
|
||||||
|
#
|
||||||
|
#proc genRSS(c: var TForumData): string =
|
||||||
|
# result = ""
|
||||||
|
# var stats: TForumStats
|
||||||
|
# let frontQuery = c.req.makeUri("/")
|
||||||
|
# if c.isThreadsList: stats = c.getStats(false)
|
||||||
|
# else:
|
||||||
|
# stats = c.getStats(true)
|
||||||
|
# end if
|
||||||
|
# const query = sql"""SELECT A.id, A.name,
|
||||||
|
# strftime('%Y-%m-%dT%H:%M:%S', (A.modified)),
|
||||||
|
# COUNT(B.id), C.name, B.content
|
||||||
|
# FROM thread AS A, post AS B, person AS C
|
||||||
|
# WHERE A.id = b.thread AND B.author = C.id
|
||||||
|
# GROUP BY B.thread
|
||||||
|
# ORDER BY modified DESC LIMIT ?"""
|
||||||
|
# const threadId = 0
|
||||||
|
# const name = 1
|
||||||
|
# const threadDate = 2
|
||||||
|
# const postCount = 3
|
||||||
|
# const postAuthor = 4
|
||||||
|
# const postContent = 5
|
||||||
|
# let recent = GetValue(db, sql"""SELECT
|
||||||
|
# strftime('%Y-%m-%dT%H:%M:%S', (modified)) FROM thread
|
||||||
|
# ORDER BY modified DESC LIMIT 1""")
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<feed xmlns="http://www.w3.org/2005/Atom">
|
||||||
|
<title>Nimrod forum thread activity</title>
|
||||||
|
<link href="${c.req.makeUri("/threadActivity.xml")}" rel="self" />
|
||||||
|
<link href="${frontQuery}" rel="self" />
|
||||||
|
<id>${frontQuery}</id>
|
||||||
|
<updated>${recent}</updated>
|
||||||
|
# for row in Rows(db, query, 10):
|
||||||
|
<entry>
|
||||||
|
<title>${XMLencode(%name)}</title>
|
||||||
|
<id>urn:entry:${%threadid}</id>
|
||||||
|
<link rel="alternate" type="text/html"
|
||||||
|
href="${c.req.makeUri(c.genThreadUrl(threadid = %threadid))}"/>
|
||||||
|
<updated>${%threadDate}</updated>
|
||||||
|
<content type="text"
|
||||||
|
>Posts ${postCount}, ${XMLEncode(%postAuthor)} said: ${XMLEncode(%postContent)}</content>
|
||||||
|
</entry>
|
||||||
|
# end for
|
||||||
|
</feed>
|
||||||
|
#end proc
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue