use new docutils package
This commit is contained in:
parent
690e66e6ba
commit
4c05ca3352
3 changed files with 19 additions and 18 deletions
10
forms.tmpl
10
forms.tmpl
|
|
@ -61,8 +61,8 @@
|
||||||
</td>
|
</td>
|
||||||
<td class="content">
|
<td class="content">
|
||||||
#try:
|
#try:
|
||||||
${content.rstToHtml({roSupportSmilies})}
|
${content.rstToHtml}
|
||||||
#except ERecoverableError, EParseError:
|
#except EParseError:
|
||||||
# c.errorMsg = getCurrentExceptionMsg()
|
# c.errorMsg = getCurrentExceptionMsg()
|
||||||
#end
|
#end
|
||||||
</td>
|
</td>
|
||||||
|
|
@ -102,7 +102,11 @@
|
||||||
#end if
|
#end if
|
||||||
</td>
|
</td>
|
||||||
<td class="content">
|
<td class="content">
|
||||||
${(%postContent).rstToHtml({roSupportSmilies})}
|
#try:
|
||||||
|
${(%postContent).rstToHtml}
|
||||||
|
#except EParseError:
|
||||||
|
# c.errorMsg = getCurrentExceptionMsg()
|
||||||
|
#end
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
|
|
|
||||||
16
forum.nim
16
forum.nim
|
|
@ -8,7 +8,7 @@
|
||||||
|
|
||||||
import
|
import
|
||||||
os, strutils, times, md5, strtabs, cgi, math, db_sqlite, matchers,
|
os, strutils, times, md5, strtabs, cgi, math, db_sqlite, matchers,
|
||||||
rst, docgen, msgs, captchas, sockets, scgi, cookies
|
rst, rstgen, captchas, sockets, scgi, cookies
|
||||||
|
|
||||||
const
|
const
|
||||||
unselectedThread = -1
|
unselectedThread = -1
|
||||||
|
|
@ -64,6 +64,7 @@ type
|
||||||
|
|
||||||
var
|
var
|
||||||
db: TDbConn
|
db: TDbConn
|
||||||
|
docConfig: PStringTable
|
||||||
|
|
||||||
proc init(c: var TForumData) =
|
proc init(c: var TForumData) =
|
||||||
c.userPass = ""
|
c.userPass = ""
|
||||||
|
|
@ -135,7 +136,6 @@ proc UrlButton(c: var TForumData, text: string,
|
||||||
c.genQuery(nextAction, target), text]
|
c.genQuery(nextAction, target), text]
|
||||||
|
|
||||||
proc genButtons(c: var TForumData, btns: seq[TStyledButton]): string =
|
proc genButtons(c: var TForumData, btns: seq[TStyledButton]): string =
|
||||||
result = ""
|
|
||||||
if btns.len == 1:
|
if btns.len == 1:
|
||||||
var anchor = ""
|
var anchor = ""
|
||||||
if btns[0].action == actionReplyForm:
|
if btns[0].action == actionReplyForm:
|
||||||
|
|
@ -144,6 +144,7 @@ proc genButtons(c: var TForumData, btns: seq[TStyledButton]): string =
|
||||||
result = ("""<a class="active button" href="$1$3">$2</a>""") % [
|
result = ("""<a class="active button" href="$1$3">$2</a>""") % [
|
||||||
c.genQuery(btns[0].action, btns[0].tid), btns[0].text, anchor]
|
c.genQuery(btns[0].action, btns[0].tid), btns[0].text, anchor]
|
||||||
else:
|
else:
|
||||||
|
result = ""
|
||||||
for i, btn in pairs(btns):
|
for i, btn in pairs(btns):
|
||||||
var anchor = ""
|
var anchor = ""
|
||||||
if btns[i].action == actionReplyForm:
|
if btns[i].action == actionReplyForm:
|
||||||
|
|
@ -311,11 +312,15 @@ proc isPreview(c: TForumData): bool =
|
||||||
proc isDelete(c: TForumData): bool =
|
proc isDelete(c: TForumData): bool =
|
||||||
result = c.cgiData["delete"].len > 0
|
result = c.cgiData["delete"].len > 0
|
||||||
|
|
||||||
|
proc rstToHtml(content: string): string =
|
||||||
|
result = rstgen.rstToHtml(content, {roSupportSmilies, roSupportMarkdown},
|
||||||
|
docConfig)
|
||||||
|
|
||||||
proc validateRst(c: var TForumData, content: string): bool =
|
proc validateRst(c: var TForumData, content: string): bool =
|
||||||
result = true
|
result = true
|
||||||
try:
|
try:
|
||||||
discard content.rstToHtml({roSupportSmilies})
|
discard rstToHtml(content)
|
||||||
except ERecoverableError, EParseError:
|
except EParseError:
|
||||||
result = setError(c, "", getCurrentExceptionMsg())
|
result = setError(c, "", getCurrentExceptionMsg())
|
||||||
|
|
||||||
proc crud(c: TCrud, table: string, data: openArray[string]): TSqlQuery =
|
proc crud(c: TCrud, table: string, data: openArray[string]): TSqlQuery =
|
||||||
|
|
@ -687,7 +692,8 @@ when not defined(writeStatusContent):
|
||||||
c.send(content)
|
c.send(content)
|
||||||
|
|
||||||
proc main() =
|
proc main() =
|
||||||
docgen.setupConfig()
|
docConfig = rstgen.defaultConfig()
|
||||||
|
|
||||||
math.randomize()
|
math.randomize()
|
||||||
db = Open(connection="nimforum.db", user="postgres", password="",
|
db = Open(connection="nimforum.db", user="postgres", password="",
|
||||||
database="nimforum")
|
database="nimforum")
|
||||||
|
|
|
||||||
11
nimrod.cfg
11
nimrod.cfg
|
|
@ -1,14 +1,5 @@
|
||||||
|
|
||||||
# we need the documentation generator of the compiler:
|
# we need the documentation generator of the compiler:
|
||||||
|
|
||||||
--path:"/home/nimrod/Nimrod"
|
|
||||||
--path:"/home/nimrod/Nimrod/compiler"
|
|
||||||
|
|
||||||
--path:"/home/dominik/code/outside/git/Nimrod"
|
|
||||||
--path:"/home/dominik/code/outside/git/Nimrod/compiler"
|
|
||||||
|
|
||||||
--path:"../nimrod"
|
|
||||||
--path:"../nimrod/compiler"
|
|
||||||
|
|
||||||
--path:"$nimrod/packages/docutils"
|
--path:"$nimrod/packages/docutils"
|
||||||
|
|
||||||
|
--path:"$nimrod"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue