some bugfixes
This commit is contained in:
parent
4c05ca3352
commit
ecbd49d2a0
2 changed files with 60 additions and 38 deletions
78
forum.nim
78
forum.nim
|
|
@ -691,51 +691,53 @@ when not defined(writeStatusContent):
|
||||||
c.send("Status: " & status & "\r\L" & strHeaders & "\r\L")
|
c.send("Status: " & status & "\r\L" & strHeaders & "\r\L")
|
||||||
c.send(content)
|
c.send(content)
|
||||||
|
|
||||||
|
proc mainLoop() =
|
||||||
|
try:
|
||||||
|
db = Open(connection="nimforum.db", user="postgres", password="",
|
||||||
|
database="nimforum")
|
||||||
|
open(s, 9000.TPort)
|
||||||
|
while next(s):
|
||||||
|
var r: TRequest
|
||||||
|
r.vars = s.headers
|
||||||
|
r.ip = r.vars["REMOTE_ADDR"]
|
||||||
|
r.url = r.vars["DOCUMENT_URI"]
|
||||||
|
r.startTime = epochTime()
|
||||||
|
|
||||||
|
# the server software (nginx) seems to f*ck up SCGI + POST/GET, so I work
|
||||||
|
# around this issue here:
|
||||||
|
try:
|
||||||
|
for key, val in cgi.decodeData(r.vars["QUERY_STRING"]):
|
||||||
|
r.vars[key] = val
|
||||||
|
except ECgi:
|
||||||
|
nil
|
||||||
|
try:
|
||||||
|
for key, val in cgi.decodeData(s.input):
|
||||||
|
r.vars[key] = val
|
||||||
|
except ECgi:
|
||||||
|
nil
|
||||||
|
let fi = processFile(r)
|
||||||
|
|
||||||
|
if fi.isFile:
|
||||||
|
writeStatusOkTextContent(s.client, fi.contentType)
|
||||||
|
send(s.client, fi.content)
|
||||||
|
else:
|
||||||
|
let (status, resp, headers) = processRequest(r)
|
||||||
|
s.client.writeStatusContent(status, resp, headers)
|
||||||
|
s.client.close()
|
||||||
|
finally:
|
||||||
|
close(s)
|
||||||
|
close(db)
|
||||||
|
|
||||||
proc main() =
|
proc main() =
|
||||||
docConfig = rstgen.defaultConfig()
|
docConfig = rstgen.defaultConfig()
|
||||||
|
|
||||||
math.randomize()
|
math.randomize()
|
||||||
db = Open(connection="nimforum.db", user="postgres", password="",
|
|
||||||
database="nimforum")
|
|
||||||
|
|
||||||
open(s, 9000.TPort)
|
|
||||||
while next(s):
|
|
||||||
var r: TRequest
|
|
||||||
r.vars = s.headers
|
|
||||||
r.ip = r.vars["REMOTE_ADDR"]
|
|
||||||
r.url = r.vars["DOCUMENT_URI"]
|
|
||||||
r.startTime = epochTime()
|
|
||||||
|
|
||||||
# the server software (nginx) seems to f*ck up SCGI + POST/GET, so I work
|
|
||||||
# around this issue here:
|
|
||||||
try:
|
|
||||||
for key, val in cgi.decodeData(r.vars["QUERY_STRING"]):
|
|
||||||
r.vars[key] = val
|
|
||||||
except ECgi:
|
|
||||||
nil
|
|
||||||
try:
|
|
||||||
for key, val in cgi.decodeData(s.input):
|
|
||||||
r.vars[key] = val
|
|
||||||
except ECgi:
|
|
||||||
nil
|
|
||||||
let fi = processFile(r)
|
|
||||||
|
|
||||||
if fi.isFile:
|
|
||||||
writeStatusOkTextContent(s.client, fi.contentType)
|
|
||||||
send(s.client, fi.content)
|
|
||||||
else:
|
|
||||||
let (status, resp, headers) = processRequest(r)
|
|
||||||
s.client.writeStatusContent(status, resp, headers)
|
|
||||||
s.client.close()
|
|
||||||
close(s)
|
|
||||||
close(db)
|
|
||||||
|
|
||||||
proc mainWrapper() =
|
|
||||||
for i in 0..10:
|
for i in 0..10:
|
||||||
try:
|
try:
|
||||||
main()
|
mainLoop()
|
||||||
except:
|
except:
|
||||||
echo "FATAL: ", getCurrentExceptionMsg()
|
echo "FATAL: ", getCurrentExceptionMsg()
|
||||||
|
os.sleep(1000)
|
||||||
|
|
||||||
mainWrapper()
|
main()
|
||||||
|
|
||||||
|
|
|
||||||
20
rst.txt
20
rst.txt
|
|
@ -10,6 +10,7 @@ See also the
|
||||||
or the `quick reference <http://docutils.sourceforge.net/docs/user/rst/quickref.html>`_
|
or the `quick reference <http://docutils.sourceforge.net/docs/user/rst/quickref.html>`_
|
||||||
for further information.
|
for further information.
|
||||||
|
|
||||||
|
Elements of **markdown** are also supported.
|
||||||
|
|
||||||
|
|
||||||
Inline elements
|
Inline elements
|
||||||
|
|
@ -36,6 +37,10 @@ this::
|
||||||
|
|
||||||
`Nimrod <http://nimrod-code.org>`_
|
`Nimrod <http://nimrod-code.org>`_
|
||||||
|
|
||||||
|
Or like this::
|
||||||
|
|
||||||
|
`<http://nimrod-code.org>`_
|
||||||
|
|
||||||
|
|
||||||
Code blocks
|
Code blocks
|
||||||
===========
|
===========
|
||||||
|
|
@ -59,6 +64,21 @@ Is rendered as:
|
||||||
Except Nimrod, the programming languages C, C++, Java and C# have highlighting
|
Except Nimrod, the programming languages C, C++, Java and C# have highlighting
|
||||||
support.
|
support.
|
||||||
|
|
||||||
|
An alternative github-like syntax is also supported. This has the advantage
|
||||||
|
that no excessive indentation is needed::
|
||||||
|
|
||||||
|
```nimrod
|
||||||
|
if x == "abc":
|
||||||
|
echo "xyz"```
|
||||||
|
|
||||||
|
Is rendered as:
|
||||||
|
|
||||||
|
.. code-block:: nimrod
|
||||||
|
|
||||||
|
if x == "abc":
|
||||||
|
echo "xyz"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Literal blocks
|
Literal blocks
|
||||||
==============
|
==============
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue