Cleanup
This commit is contained in:
parent
9d19d70558
commit
da7045ecca
10 changed files with 22 additions and 14 deletions
|
|
@ -1,4 +1,4 @@
|
||||||
import os, strutils
|
import os
|
||||||
|
|
||||||
import sass
|
import sass
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@ proc newMailer*(config: Config): Mailer =
|
||||||
proc rateCheck(mailer: Mailer, address: string): bool =
|
proc rateCheck(mailer: Mailer, address: string): bool =
|
||||||
## Returns true if we've emailed the address too much.
|
## Returns true if we've emailed the address too much.
|
||||||
let diff = getTime() - mailer.lastReset
|
let diff = getTime() - mailer.lastReset
|
||||||
if diff.hours >= 1:
|
if diff.inHours >= 1:
|
||||||
mailer.lastReset = getTime()
|
mailer.lastReset = getTime()
|
||||||
mailer.emailsSent.clear()
|
mailer.emailsSent.clear()
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -814,7 +814,6 @@ routes:
|
||||||
countQuery = sql"select count(*) from thread;"
|
countQuery = sql"select count(*) from thread;"
|
||||||
countArgs: seq[string] = @[]
|
countArgs: seq[string] = @[]
|
||||||
|
|
||||||
|
|
||||||
if categoryId != -1:
|
if categoryId != -1:
|
||||||
categorySection = "c.id == ? and "
|
categorySection = "c.id == ? and "
|
||||||
countQuery = sql"select count(*) from thread t, category c where category == c.id and c.id == ?;"
|
countQuery = sql"select count(*) from thread t, category c where category == c.id and c.id == ?;"
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,10 @@
|
||||||
import strformat, times, options, json, httpcore, sugar, strutils, uri
|
import options, json, httpcore
|
||||||
|
|
||||||
import category
|
import category
|
||||||
|
|
||||||
when defined(js):
|
when defined(js):
|
||||||
include karax/prelude
|
include karax/prelude
|
||||||
import karax / [vstyles, kajax, kdom]
|
import karax / [vstyles, kajax]
|
||||||
|
|
||||||
import karaxutils, error, user, mainbuttons
|
import karaxutils, error, user, mainbuttons
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -21,9 +21,6 @@ when defined(js):
|
||||||
onCategoryChange: proc (oldCategory: Category, newCategory: Category)
|
onCategoryChange: proc (oldCategory: Category, newCategory: Category)
|
||||||
onAddCategory: proc (category: Category)
|
onAddCategory: proc (category: Category)
|
||||||
|
|
||||||
proc slug(name: string): string =
|
|
||||||
name.strip().replace(" ", "-").toLowerAscii
|
|
||||||
|
|
||||||
proc onCategoryLoad(state: CategoryPicker): proc (httpStatus: int, response: kstring) =
|
proc onCategoryLoad(state: CategoryPicker): proc (httpStatus: int, response: kstring) =
|
||||||
return
|
return
|
||||||
proc (httpStatus: int, response: kstring) =
|
proc (httpStatus: int, response: kstring) =
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,11 @@
|
||||||
import options, httpcore
|
import httpcore
|
||||||
type
|
type
|
||||||
PostError* = object
|
PostError* = object
|
||||||
errorFields*: seq[string] ## IDs of the fields with an error.
|
errorFields*: seq[string] ## IDs of the fields with an error.
|
||||||
message*: string
|
message*: string
|
||||||
|
|
||||||
when defined(js):
|
when defined(js):
|
||||||
import json
|
import json, options
|
||||||
include karax/prelude
|
include karax/prelude
|
||||||
|
|
||||||
import karaxutils
|
import karaxutils
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
import options, times, httpcore, json, sugar
|
import options, httpcore
|
||||||
|
|
||||||
import user
|
import user
|
||||||
type
|
type
|
||||||
|
|
@ -7,6 +7,7 @@ type
|
||||||
recaptchaSiteKey*: Option[string]
|
recaptchaSiteKey*: Option[string]
|
||||||
|
|
||||||
when defined(js):
|
when defined(js):
|
||||||
|
import times, json, sugar
|
||||||
include karax/prelude
|
include karax/prelude
|
||||||
import karax / [kajax, kdom]
|
import karax / [kajax, kdom]
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,16 @@
|
||||||
import strutils, strformat, parseutils, tables
|
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.} =
|
proc parseIntSafe*(s: string, value: var int) {.noSideEffect.} =
|
||||||
## parses `s` into an integer in the range `validRange`. If successful,
|
## parses `s` into an integer in the range `validRange`. If successful,
|
||||||
## `value` is modified to contain the result. Otherwise no exception is
|
## `value` is modified to contain the result. Otherwise no exception is
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
import options
|
import options
|
||||||
|
|
||||||
import user, threadlist
|
import user
|
||||||
|
|
||||||
type
|
type
|
||||||
PostInfo* = object
|
PostInfo* = object
|
||||||
|
|
@ -58,7 +58,7 @@ type
|
||||||
email*: Option[string]
|
email*: Option[string]
|
||||||
|
|
||||||
when defined(js):
|
when defined(js):
|
||||||
import karaxutils
|
import karaxutils, threadlist
|
||||||
|
|
||||||
proc renderPostUrl*(post: Post, thread: Thread): string =
|
proc renderPostUrl*(post: Post, thread: Thread): string =
|
||||||
renderPostUrl(thread.id, post.id)
|
renderPostUrl(thread.id, post.id)
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
import strformat, times, options, json, httpcore
|
import strformat, times, options, json, httpcore, sugar
|
||||||
|
|
||||||
import category, user
|
import category, user
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue