Fix issues compiling and testing

This commit is contained in:
Joey Payne 2019-01-24 20:37:03 -07:00
commit 41a1a36dbf
6 changed files with 37 additions and 15 deletions

View file

@ -63,6 +63,26 @@ test Runs tester
fasttest Runs tester without recompiling backend
```
To get up and running:
```bash
git clone https://github.com/nim-lang/nimforum
cd nimforum
git submodule update --init --recursive
nimble install
# Setup the db with user: admin, pass: admin and some other users
nimble devdb
# Run this again if frontend code changes
nimble frontend
# Will start a server at localhost:5000
nimble backend
```
Development typically involves running `nimble devdb` which sets up the
database for development and testing, then `nimble backend`
which compiles and runs the forum's backend, and `nimble frontend`

View file

@ -1,5 +1,5 @@
# Package
version = "2.0.1"
version = "2.1.0"
author = "Dominik Picheta"
description = "The Nim forum"
license = "MIT"
@ -13,13 +13,13 @@ skipExt = @["nim"]
# Dependencies
requires "nim >= 0.18.1"
requires "jester 0.4.0"
requires "jester#22f8240"
requires "bcrypt#head"
requires "hmac#9c61ebe2fd134cf97"
requires "recaptcha 1.0.2"
requires "sass#649e0701fa5c"
requires "karax#d8df257dd"
requires "karax#c8c7b13"
requires "webdriver#20f3c1b"

View file

@ -71,13 +71,13 @@ when isMainModule:
"test",
"$2a$08$bY85AhoD1e9u0IsD9sM7Ee6kFSLeXRLxJ6rMgfb1wDnU9liaymoTG",
1526908753,
"*B2a] IL\"~sh)q-GBd/i$^>.TL]PR~>1IX>Fp-:M3pCm^cFD\um"
"*B2a] IL\"~sh)q-GBd/i$^>.TL]PR~>1IX>Fp-:M3pCm^cFD\\um"
)
let ident2 = makeIdentHash(
"test",
"$2a$08$bY85AhoD1e9u0IsD9sM7Ee6kFSLeXRLxJ6rMgfb1wDnU9liaymoTG",
1526908753,
"*B2a] IL\"~sh)q-GBd/i$^>.TL]PR~>1IX>Fp-:M3pCm^cFD\um"
"*B2a] IL\"~sh)q-GBd/i$^>.TL]PR~>1IX>Fp-:M3pCm^cFD\\um"
)
doAssert ident == ident2
@ -85,6 +85,6 @@ when isMainModule:
"test",
"$2a$08$bY85AhoD1e9u0IsD9sM7Ee6kFSLeXRLxJ6rMgfb1wDnU9liaymoTG",
1526908754,
"*B2a] IL\"~sh)q-GBd/i$^>.TL]PR~>1IX>Fp-:M3pCm^cFD\um"
"*B2a] IL\"~sh)q-GBd/i$^>.TL]PR~>1IX>Fp-:M3pCm^cFD\\um"
)
doAssert ident != invalid
doAssert ident != invalid

View file

@ -8,7 +8,7 @@
import system except Thread
import
os, strutils, times, md5, strtabs, math, db_sqlite,
scgi, jester, asyncdispatch, asyncnet, sequtils,
jester, asyncdispatch, asyncnet, sequtils,
parseutils, random, rst, recaptcha, json, re, sugar,
strformat, logging
import cgi except setCookie
@ -76,7 +76,6 @@ proc getGravatarUrl(email: string, size = 80): string =
# -----------------------------------------------------------------------------
template `||`(x: untyped): untyped = (if not isNil(x): x else: "")
proc validateCaptcha(recaptchaResp, ip: string) {.async.} =
# captcha validation:
@ -133,9 +132,9 @@ proc checkLoggedIn(c: TForumData) =
let row = getRow(db,
sql"select name, email, status from person where id = ?", c.userid)
c.username = ||row[0]
c.email = ||row[1]
c.rank = parseEnum[Rank](||row[2])
c.username = row[0]
c.email = row[1]
c.rank = parseEnum[Rank](row[2])
# In order to handle the "last visit" line appropriately, i.e.
# it shouldn't disappear after a refresh, we need to manage a
@ -463,7 +462,7 @@ proc executeReply(c: TForumData, threadId: int, content: string,
crud(crCreate, "post", "author", "ip", "content", "thread", "replyingTo"),
c.userId, c.req.ip, content, $threadId,
if replyingTo.isSome(): $replyingTo.get()
else: nil
else: ""
)
discard tryExec(
db,

View file

@ -60,7 +60,7 @@ when defined(js):
if user.isNone(): return not thread.isModerated
let rank = user.get().rank
if rank < Moderator and thread.isModerated:
if rank < Rank.Moderator and thread.isModerated:
return thread.author == user.get()
return true

View file

@ -45,7 +45,7 @@ template withBackend(body: untyped): untyped =
import browsertests/[scenario1, threads, issue181, categories]
when isMainModule:
proc main() =
spawn runProcess("geckodriver -p 4444 --log config")
defer:
discard execCmd("killall geckodriver")
@ -71,3 +71,6 @@ when isMainModule:
except:
sleep(10000) # See if we can grab any more output.
raise
when isMainModule:
main()