2019-09-06 00:42:35 +00:00
|
|
|
import asyncdispatch
|
2019-07-31 00:15:43 +00:00
|
|
|
from net import Port
|
2019-06-20 14:16:20 +00:00
|
|
|
|
2019-09-06 00:42:35 +00:00
|
|
|
import jester
|
2019-06-24 21:25:21 +00:00
|
|
|
|
2019-09-06 00:42:35 +00:00
|
|
|
import types, config, prefs
|
2019-09-09 02:41:20 +00:00
|
|
|
import views/[general, about]
|
2019-09-06 00:42:35 +00:00
|
|
|
import routes/[preferences, timeline, media]
|
2019-06-20 14:16:20 +00:00
|
|
|
|
2019-07-31 00:15:43 +00:00
|
|
|
const configPath {.strdefine.} = "./nitter.conf"
|
|
|
|
let cfg = getConfig(configPath)
|
2019-06-23 00:46:46 +00:00
|
|
|
|
2019-09-06 00:42:35 +00:00
|
|
|
createPrefRouter(cfg)
|
|
|
|
createTimelineRouter(cfg)
|
|
|
|
createMediaRouter(cfg)
|
2019-07-31 00:15:43 +00:00
|
|
|
|
|
|
|
settings:
|
|
|
|
port = Port(cfg.port)
|
|
|
|
staticDir = cfg.staticDir
|
|
|
|
bindAddr = cfg.address
|
|
|
|
|
2019-06-20 14:16:20 +00:00
|
|
|
routes:
|
|
|
|
get "/":
|
2019-08-19 18:25:00 +00:00
|
|
|
resp renderMain(renderSearch(), Prefs(), cfg.title)
|
2019-06-20 14:16:20 +00:00
|
|
|
|
2019-09-09 02:41:20 +00:00
|
|
|
get "/about":
|
|
|
|
resp renderMain(renderAbout(), Prefs(), cfg.title)
|
|
|
|
|
2019-06-20 14:16:20 +00:00
|
|
|
post "/search":
|
|
|
|
if @"query".len == 0:
|
2019-08-15 21:17:13 +00:00
|
|
|
resp Http404, showError("Please enter a username.", cfg.title)
|
2019-06-20 14:16:20 +00:00
|
|
|
redirect("/" & @"query")
|
|
|
|
|
2019-09-06 00:42:35 +00:00
|
|
|
extend preferences, ""
|
|
|
|
extend timeline, ""
|
|
|
|
extend media, ""
|
2019-06-20 14:16:20 +00:00
|
|
|
|
|
|
|
runForever()
|