From da7045ecca6bc9121aac0c97422d46ba2618d2f3 Mon Sep 17 00:00:00 2001 From: Joey Yakimowich-Payne Date: Mon, 17 Feb 2020 19:43:13 -0700 Subject: [PATCH] Cleanup --- src/buildcss.nim | 2 +- src/email.nim | 2 +- src/forum.nim | 1 - src/frontend/categorylist.nim | 4 ++-- src/frontend/categorypicker.nim | 3 --- src/frontend/error.nim | 4 ++-- src/frontend/header.nim | 3 ++- src/frontend/karaxutils.nim | 11 +++++++++++ src/frontend/post.nim | 4 ++-- src/frontend/threadlist.nim | 2 +- 10 files changed, 22 insertions(+), 14 deletions(-) diff --git a/src/buildcss.nim b/src/buildcss.nim index 551956a..129bb64 100644 --- a/src/buildcss.nim +++ b/src/buildcss.nim @@ -1,4 +1,4 @@ -import os, strutils +import os import sass diff --git a/src/email.nim b/src/email.nim index 8cf7b36..d26f4ad 100644 --- a/src/email.nim +++ b/src/email.nim @@ -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() diff --git a/src/forum.nim b/src/forum.nim index fc9a17b..13c095e 100644 --- a/src/forum.nim +++ b/src/forum.nim @@ -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 == ?;" diff --git a/src/frontend/categorylist.nim b/src/frontend/categorylist.nim index 231d697..37659c4 100644 --- a/src/frontend/categorylist.nim +++ b/src/frontend/categorylist.nim @@ -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 diff --git a/src/frontend/categorypicker.nim b/src/frontend/categorypicker.nim index 32a107b..1224282 100644 --- a/src/frontend/categorypicker.nim +++ b/src/frontend/categorypicker.nim @@ -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) = diff --git a/src/frontend/error.nim b/src/frontend/error.nim index 27f1e7c..0b67f5d 100644 --- a/src/frontend/error.nim +++ b/src/frontend/error.nim @@ -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 diff --git a/src/frontend/header.nim b/src/frontend/header.nim index edd1ade..aa6e786 100644 --- a/src/frontend/header.nim +++ b/src/frontend/header.nim @@ -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] diff --git a/src/frontend/karaxutils.nim b/src/frontend/karaxutils.nim index 8b2fe8f..f70ec5d 100644 --- a/src/frontend/karaxutils.nim +++ b/src/frontend/karaxutils.nim @@ -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..