some bugfixes

This commit is contained in:
Araq 2012-05-09 23:49:59 +02:00
commit ecbd49d2a0
2 changed files with 60 additions and 38 deletions

View file

@ -691,51 +691,53 @@ when not defined(writeStatusContent):
c.send("Status: " & status & "\r\L" & strHeaders & "\r\L")
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() =
docConfig = rstgen.defaultConfig()
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:
try:
main()
mainLoop()
except:
echo "FATAL: ", getCurrentExceptionMsg()
os.sleep(1000)
mainWrapper()
main()

20
rst.txt
View file

@ -10,6 +10,7 @@ See also the
or the `quick reference <http://docutils.sourceforge.net/docs/user/rst/quickref.html>`_
for further information.
Elements of **markdown** are also supported.
Inline elements
@ -35,6 +36,10 @@ Links are either direct URLs like ``http://nimrod-code.org`` or written like
this::
`Nimrod <http://nimrod-code.org>`_
Or like this::
`<http://nimrod-code.org>`_
Code blocks
@ -59,6 +64,21 @@ Is rendered as:
Except Nimrod, the programming languages C, C++, Java and C# have highlighting
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
==============