Compare commits
2 commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
66fbb7c44d | ||
|
|
85ea229f7f |
23 changed files with 58 additions and 55 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
|
@ -12,3 +12,5 @@ nimcache/
|
|||
forum
|
||||
createdb
|
||||
editdb
|
||||
|
||||
.vscode
|
||||
|
|
|
|||
|
|
@ -1,11 +1,11 @@
|
|||
when defined(js):
|
||||
import sugar, httpcore, options, json
|
||||
import sugar, httpcore
|
||||
import dom except Event
|
||||
|
||||
include karax/prelude
|
||||
import karax / [kajax, kdom]
|
||||
import karax / [kajax]
|
||||
|
||||
import error, replybox, threadlist, post
|
||||
import error
|
||||
import karaxutils
|
||||
|
||||
type
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ when defined(js):
|
|||
include karax/prelude
|
||||
import karax / [kajax, kdom]
|
||||
|
||||
import error, replybox, threadlist, post
|
||||
import error
|
||||
import karaxutils
|
||||
|
||||
type
|
||||
|
|
@ -13,17 +13,12 @@ when defined(js):
|
|||
loading: bool
|
||||
status: HttpCode
|
||||
error: Option[PostError]
|
||||
newPassword: kstring
|
||||
|
||||
proc newActivateEmail*(): ActivateEmail =
|
||||
ActivateEmail(
|
||||
status: Http200,
|
||||
newPassword: ""
|
||||
status: Http200
|
||||
)
|
||||
|
||||
proc onPassChange(e: Event, n: VNode, state: ActivateEmail) =
|
||||
state.newPassword = n.value
|
||||
|
||||
proc onPost(httpStatus: int, response: kstring, state: ActivateEmail) =
|
||||
postFinished:
|
||||
navigateTo(makeUri("/activateEmail/success"))
|
||||
|
|
|
|||
|
|
@ -14,9 +14,7 @@ proc cmpNames*(cat1: Category, cat2: Category): int =
|
|||
|
||||
when defined(js):
|
||||
include karax/prelude
|
||||
import karax / [vstyles, kajax, kdom]
|
||||
|
||||
import karaxutils
|
||||
import karax / [vstyles]
|
||||
|
||||
proc render*(category: Category): VNode =
|
||||
result = buildHtml():
|
||||
|
|
|
|||
|
|
@ -1,11 +1,12 @@
|
|||
when defined(js):
|
||||
import sugar, httpcore, options, json, strutils, algorithm
|
||||
import dom except Event
|
||||
import jsffi except `&`
|
||||
|
||||
include karax/prelude
|
||||
import karax / [kajax, kdom, vstyles, vdom]
|
||||
import karax / [kajax, kdom, vdom]
|
||||
|
||||
import error, replybox, threadlist, post, category, user
|
||||
import error, category, user
|
||||
import category, karaxutils
|
||||
|
||||
type
|
||||
|
|
@ -108,7 +109,7 @@ when defined(js):
|
|||
let form = dom.document.getElementById("add-category-form")
|
||||
let formData = newFormData(form)
|
||||
|
||||
ajaxPost(uri, @[], cast[cstring](formData),
|
||||
ajaxPost(uri, @[], formData.to(cstring),
|
||||
(s: int, r: kstring) => onAddCategoryPost(s, r, state))
|
||||
|
||||
proc onClose(ev: Event, n: VNode, state: CategoryPicker) =
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
when defined(js):
|
||||
import sugar, httpcore, options, json
|
||||
import dom except Event
|
||||
import jsffi except `&`
|
||||
|
||||
include karax/prelude
|
||||
import karax / [kajax, kdom]
|
||||
|
|
@ -59,7 +60,7 @@ when defined(js):
|
|||
formData.append("id", $state.post.id)
|
||||
of DeleteThread:
|
||||
formData.append("id", $state.thread.id)
|
||||
ajaxPost(uri, @[], cast[cstring](formData),
|
||||
ajaxPost(uri, @[], formData.to(cstring),
|
||||
(s: int, r: kstring) => onDeletePost(s, r, state))
|
||||
|
||||
proc onClose(ev: Event, n: VNode, state: DeleteModal) =
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
when defined(js):
|
||||
import httpcore, options, sugar, json
|
||||
import jsffi except `&`
|
||||
|
||||
include karax/prelude
|
||||
import karax/kajax
|
||||
|
|
@ -54,7 +55,7 @@ when defined(js):
|
|||
formData.append("postId", $state.post.id)
|
||||
# TODO: Subject
|
||||
let uri = makeUri("/updatePost")
|
||||
ajaxPost(uri, @[], cast[cstring](formData),
|
||||
ajaxPost(uri, @[], formData.to(cstring),
|
||||
(s: int, r: kstring) => onEditPost(s, r, state))
|
||||
|
||||
proc render*(state: EditBox, post: Post): VNode =
|
||||
|
|
|
|||
|
|
@ -7,7 +7,6 @@ type
|
|||
when defined(js):
|
||||
import json
|
||||
include karax/prelude
|
||||
import karax / [vstyles, kajax, kdom]
|
||||
|
||||
import karaxutils
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import strformat, times, options, json, tables, sugar, httpcore, uri
|
||||
import options, tables, sugar, httpcore
|
||||
from dom import window, Location, document, decodeURI
|
||||
|
||||
include karax/prelude
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import options, times, httpcore, json, sugar
|
||||
|
||||
import threadlist, user
|
||||
import user
|
||||
type
|
||||
UserStatus* = object
|
||||
user*: Option[User]
|
||||
|
|
@ -63,7 +63,7 @@ when defined(js):
|
|||
proc getStatus(logout: bool=false) =
|
||||
if state.loading: return
|
||||
let diff = getTime() - state.lastUpdate
|
||||
if diff.minutes < 5:
|
||||
if diff.inMinutes < 5:
|
||||
return
|
||||
|
||||
state.loading = true
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import strutils, options, strformat, parseutils, tables
|
||||
import strutils, strformat, parseutils, tables
|
||||
|
||||
proc parseIntSafe*(s: string, value: var int) {.noSideEffect.} =
|
||||
## parses `s` into an integer in the range `validRange`. If successful,
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
when defined(js):
|
||||
import sugar, httpcore, options, json
|
||||
import dom except Event, KeyboardEvent
|
||||
import jsffi except `&`
|
||||
|
||||
include karax/prelude
|
||||
import karax / [kajax, kdom]
|
||||
|
|
@ -30,7 +31,7 @@ when defined(js):
|
|||
let form = dom.document.getElementById("login-form")
|
||||
# TODO: This is a hack, karax should support this.
|
||||
let formData = newFormData(form)
|
||||
ajaxPost(uri, @[], cast[cstring](formData),
|
||||
ajaxPost(uri, @[], formData.to(cstring),
|
||||
(s: int, r: kstring) => onLogInPost(s, r, state))
|
||||
|
||||
proc onClose(ev: Event, n: VNode, state: LoginModal) =
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ when defined(js):
|
|||
include karax/prelude
|
||||
import karax / [kajax, kdom]
|
||||
|
||||
import error, replybox, threadlist, post, category, user
|
||||
import error, replybox, threadlist, post, user
|
||||
import karaxutils, categorypicker
|
||||
|
||||
type
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import strformat, options
|
||||
import options
|
||||
|
||||
import user, threadlist
|
||||
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ import options, httpcore, json, sugar, sequtils, strutils
|
|||
when defined(js):
|
||||
include karax/prelude
|
||||
import karax/[kajax, kdom]
|
||||
import jsffi except `&`
|
||||
|
||||
import error, karaxutils, post, user, threadlist
|
||||
|
||||
|
|
@ -116,7 +117,7 @@ when defined(js):
|
|||
makeUri("/unlike")
|
||||
else:
|
||||
makeUri("/like")
|
||||
ajaxPost(uri, @[], cast[cstring](formData),
|
||||
ajaxPost(uri, @[], formData.to(cstring),
|
||||
(s: int, r: kstring) =>
|
||||
onPost(s, r, state, post, currentUser.get()))
|
||||
|
||||
|
|
@ -172,7 +173,7 @@ when defined(js):
|
|||
makeUri("/unlock")
|
||||
else:
|
||||
makeUri("/lock")
|
||||
ajaxPost(uri, @[], cast[cstring](formData),
|
||||
ajaxPost(uri, @[], formData.to(cstring),
|
||||
(s: int, r: kstring) =>
|
||||
onPost(s, r, state, thread))
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
|
||||
import system except Thread
|
||||
import options, json, times, httpcore, strformat, sugar, math, strutils
|
||||
import options, json, times, httpcore, sugar, strutils
|
||||
import sequtils
|
||||
|
||||
import threadlist, category, post, user
|
||||
|
|
@ -18,7 +18,7 @@ when defined(js):
|
|||
import jsffi except `&`
|
||||
|
||||
include karax/prelude
|
||||
import karax / [vstyles, kajax, kdom]
|
||||
import karax / [kajax, kdom]
|
||||
|
||||
import karaxutils, error, replybox, editbox, postbutton, delete
|
||||
import categorypicker
|
||||
|
|
@ -326,12 +326,12 @@ when defined(js):
|
|||
]
|
||||
var diffStr = tmpl[0]
|
||||
let diff = latestTime - prevPost.info.creation.fromUnix()
|
||||
if diff.weeks > 48:
|
||||
let years = diff.weeks div 48
|
||||
if diff.inWeeks > 48:
|
||||
let years = diff.inWeeks div 48
|
||||
diffStr =
|
||||
(if years == 1: tmpl[1] else: tmpl[2]) % $years
|
||||
elif diff.weeks > 4:
|
||||
let months = diff.weeks div 4
|
||||
elif diff.inWeeks > 4:
|
||||
let months = diff.inWeeks div 4
|
||||
diffStr =
|
||||
(if months == 1: tmpl[3] else: tmpl[4]) % $months
|
||||
else:
|
||||
|
|
|
|||
|
|
@ -1,12 +1,12 @@
|
|||
import options, httpcore, json, sugar, times, strformat, strutils
|
||||
import options, httpcore, json, sugar, times, strutils
|
||||
|
||||
import threadlist, post, category, error, user
|
||||
import threadlist, post, error, user
|
||||
|
||||
when defined(js):
|
||||
from dom import document
|
||||
include karax/prelude
|
||||
import karax/[kajax, kdom]
|
||||
import karaxutils, postbutton, delete, profilesettings
|
||||
import karaxutils, profilesettings
|
||||
|
||||
type
|
||||
ProfileTab* = enum
|
||||
|
|
|
|||
|
|
@ -1,10 +1,11 @@
|
|||
when defined(js):
|
||||
import httpcore, options, sugar, json, strutils, strformat
|
||||
import jsffi except `&`
|
||||
|
||||
include karax/prelude
|
||||
import karax/[kajax, kdom]
|
||||
|
||||
import replybox, post, karaxutils, postbutton, error, delete, user
|
||||
import post, karaxutils, postbutton, error, delete, user
|
||||
|
||||
type
|
||||
ProfileSettings* = ref object
|
||||
|
|
@ -68,7 +69,7 @@ when defined(js):
|
|||
formData.append("rank", $state.rank)
|
||||
formData.append("username", $state.profile.user.name)
|
||||
let uri = makeUri("/saveProfile")
|
||||
ajaxPost(uri, @[], cast[cstring](formData),
|
||||
ajaxPost(uri, @[], formData.to(cstring),
|
||||
(s: int, r: kstring) => onProfilePost(s, r, state))
|
||||
|
||||
proc needsSave(state: ProfileSettings): bool =
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
when defined(js):
|
||||
import strformat, options, httpcore, json, sugar
|
||||
import jsffi except `&`
|
||||
|
||||
from dom import getElementById, scrollIntoView, setTimeout
|
||||
|
||||
|
|
@ -56,7 +57,7 @@ when defined(js):
|
|||
let formData = newFormData()
|
||||
formData.append("msg", state.text)
|
||||
let uri = makeUri("/preview")
|
||||
ajaxPost(uri, @[], cast[cstring](formData),
|
||||
ajaxPost(uri, @[], formData.to(cstring),
|
||||
(s: int, r: kstring) => onPreviewPost(s, r, state))
|
||||
|
||||
proc onMessageClick(e: Event, n: VNode, state: ReplyBox) =
|
||||
|
|
@ -80,7 +81,7 @@ when defined(js):
|
|||
if replyingTo.isSome:
|
||||
formData.append("replyingTo", $replyingTo.get().id)
|
||||
let uri = makeUri("/createPost")
|
||||
ajaxPost(uri, @[], cast[cstring](formData),
|
||||
ajaxPost(uri, @[], formData.to(cstring),
|
||||
(s: int, r: kstring) => onReplyPost(s, r, state))
|
||||
|
||||
proc onCancelClick(e: Event, n: VNode, state: ReplyBox) =
|
||||
|
|
|
|||
|
|
@ -1,11 +1,12 @@
|
|||
when defined(js):
|
||||
import sugar, httpcore, options, json
|
||||
import dom except Event, KeyboardEvent
|
||||
import jsffi except `&`
|
||||
|
||||
include karax/prelude
|
||||
import karax / [kajax, kdom]
|
||||
|
||||
import error, replybox, threadlist, post
|
||||
import error
|
||||
import karaxutils
|
||||
|
||||
type
|
||||
|
|
@ -86,7 +87,7 @@ when defined(js):
|
|||
let form = dom.document.getElementById("resetpassword-form")
|
||||
# TODO: This is a hack, karax should support this.
|
||||
let formData = newFormData(form)
|
||||
ajaxPost(uri, @[], cast[cstring](formData),
|
||||
ajaxPost(uri, @[], formData.to(cstring),
|
||||
(s: int, r: kstring) => onPost(s, r, state))
|
||||
|
||||
ev.preventDefault()
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ when defined(js):
|
|||
from dom import nil
|
||||
|
||||
include karax/prelude
|
||||
import karax / [vstyles, kajax, kdom]
|
||||
import karax / [kajax]
|
||||
|
||||
import karaxutils, error, threadlist, sugar
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
when defined(js):
|
||||
import sugar, httpcore, options, json
|
||||
import dom except Event
|
||||
import jsffi except `&`
|
||||
|
||||
include karax/prelude
|
||||
import karax / [kajax, kdom]
|
||||
|
|
@ -28,7 +29,7 @@ when defined(js):
|
|||
let form = dom.document.getElementById("signup-form")
|
||||
# TODO: This is a hack, karax should support this.
|
||||
let formData = newFormData(form)
|
||||
ajaxPost(uri, @[], cast[cstring](formData),
|
||||
ajaxPost(uri, @[], formData.to(cstring),
|
||||
(s: int, r: kstring) => onSignUpPost(s, r, state))
|
||||
|
||||
proc onClose(ev: Event, n: VNode, state: SignupModal) =
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import strformat, times, options, json, httpcore, sugar
|
||||
import strformat, times, options, json, httpcore
|
||||
|
||||
import category, user
|
||||
|
||||
|
|
@ -98,19 +98,19 @@ when defined(js):
|
|||
let duration = currentTime - activityTime
|
||||
if currentTime.local().year != activityTime.local().year:
|
||||
return activityTime.local().format("MMM yyyy")
|
||||
elif duration.days > 30 and duration.days < 300:
|
||||
elif duration.inDays > 30 and duration.inDays < 300:
|
||||
return activityTime.local().format("MMM dd")
|
||||
elif duration.days != 0:
|
||||
return $duration.days & "d"
|
||||
elif duration.hours != 0:
|
||||
return $duration.hours & "h"
|
||||
elif duration.minutes != 0:
|
||||
return $duration.minutes & "m"
|
||||
elif duration.inDays != 0:
|
||||
return $duration.inDays & "d"
|
||||
elif duration.inHours != 0:
|
||||
return $duration.inHours & "h"
|
||||
elif duration.inMinutes != 0:
|
||||
return $duration.inMinutes & "m"
|
||||
else:
|
||||
return $duration.seconds & "s"
|
||||
return $duration.inSeconds & "s"
|
||||
|
||||
proc genThread(thread: Thread, isNew: bool, noBorder: bool): VNode =
|
||||
let isOld = (getTime() - thread.creation.fromUnix).weeks > 2
|
||||
let isOld = (getTime() - thread.creation.fromUnix).inWeeks > 2
|
||||
let isBanned = thread.author.rank.isBanned()
|
||||
result = buildHtml():
|
||||
tr(class=class({"no-border": noBorder, "banned": isBanned})):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue