This commit is contained in:
Joey Yakimowich-Payne 2020-02-17 19:43:13 -07:00 • committed by Andreas Rumpf
commit da7045ecca
10 changed files with 22 additions and 14 deletions

View file

@ -1,4 +1,4 @@
import os, strutils
import os
import sass

View file

@ -20,7 +20,7 @@ proc newMailer*(config: Config): Mailer =
proc rateCheck(mailer: Mailer, address: string): bool =
## Returns true if we've emailed the address too much.
let diff = getTime() - mailer.lastReset
if diff.hours >= 1:
if diff.inHours >= 1:
mailer.lastReset = getTime()
mailer.emailsSent.clear()

View file

@ -814,7 +814,6 @@ routes:
countQuery = sql"select count(*) from thread;"
countArgs: seq[string] = @[]
if categoryId != -1:
categorySection = "c.id == ? and "
countQuery = sql"select count(*) from thread t, category c where category == c.id and c.id == ?;"

View file

@ -1,10 +1,10 @@
import strformat, times, options, json, httpcore, sugar, strutils, uri
import options, json, httpcore
import category
when defined(js):
include karax/prelude
import karax / [vstyles, kajax, kdom]
import karax / [vstyles, kajax]
import karaxutils, error, user, mainbuttons

View file

@ -21,9 +21,6 @@ when defined(js):
onCategoryChange: proc (oldCategory: Category, newCategory: Category)
onAddCategory: proc (category: Category)
proc slug(name: string): string =
name.strip().replace(" ", "-").toLowerAscii
proc onCategoryLoad(state: CategoryPicker): proc (httpStatus: int, response: kstring) =
return
proc (httpStatus: int, response: kstring) =

View file

@ -1,11 +1,11 @@
import options, httpcore
import httpcore
type
PostError* = object
errorFields*: seq[string] ## IDs of the fields with an error.
message*: string
when defined(js):
import json
import json, options
include karax/prelude
import karaxutils

View file

@ -1,4 +1,4 @@
import options, times, httpcore, json, sugar
import options, httpcore
import user
type
@ -7,6 +7,7 @@ type
recaptchaSiteKey*: Option[string]
when defined(js):
import times, json, sugar
include karax/prelude
import karax / [kajax, kdom]

View file

@ -1,5 +1,16 @@
import strutils, strformat, parseutils, tables
proc limit*(str: string, n: int): string =
## Limit the number of characters in a string. Ends with a elipsis
if str.len > n:
return str[0..<n-3] & "..."
else:
return str
proc slug*(name: string): string =
## Transforms text into a url slug
name.strip().replace(" ", "-").toLowerAscii
proc parseIntSafe*(s: string, value: var int) {.noSideEffect.} =
## parses `s` into an integer in the range `validRange`. If successful,
## `value` is modified to contain the result. Otherwise no exception is

View file

@ -1,6 +1,6 @@
import options
import user, threadlist
import user
type
PostInfo* = object
@ -58,7 +58,7 @@ type
email*: Option[string]
when defined(js):
import karaxutils
import karaxutils, threadlist
proc renderPostUrl*(post: Post, thread: Thread): string =
renderPostUrl(thread.id, post.id)

View file

@ -1,4 +1,4 @@
import strformat, times, options, json, httpcore
import strformat, times, options, json, httpcore, sugar
import category, user