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-10-17 22:45:54 +00:00
|
|
|
import types, config, prefs, formatters
|
2019-09-09 02:41:20 +00:00
|
|
|
import views/[general, about]
|
2019-09-23 14:12:20 +00:00
|
|
|
import routes/[
|
|
|
|
preferences, timeline, status, media, search, rss, list, unsupported]
|
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-23 14:12:20 +00:00
|
|
|
createUnsupportedRouter(cfg)
|
2019-09-06 00:42:35 +00:00
|
|
|
createPrefRouter(cfg)
|
|
|
|
createTimelineRouter(cfg)
|
2019-09-20 23:08:30 +00:00
|
|
|
createListRouter(cfg)
|
2019-09-20 12:10:10 +00:00
|
|
|
createStatusRouter(cfg)
|
2019-09-13 20:24:58 +00:00
|
|
|
createSearchRouter(cfg)
|
2019-09-06 00:42:35 +00:00
|
|
|
createMediaRouter(cfg)
|
2019-09-15 10:10:43 +00:00
|
|
|
createRssRouter(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-09-20 23:08:30 +00:00
|
|
|
resp renderMain(renderSearch(), request, cfg.title)
|
2019-06-20 14:16:20 +00:00
|
|
|
|
2019-09-09 02:41:20 +00:00
|
|
|
get "/about":
|
2019-09-20 23:08:30 +00:00
|
|
|
resp renderMain(renderAbout(), request, cfg.title)
|
2019-09-09 02:41:20 +00:00
|
|
|
|
2019-09-23 14:12:20 +00:00
|
|
|
get "/explore":
|
|
|
|
redirect("/about")
|
2019-09-22 23:55:02 +00:00
|
|
|
|
2019-09-23 14:12:20 +00:00
|
|
|
get "/help":
|
|
|
|
redirect("/about")
|
|
|
|
|
2019-10-17 22:45:54 +00:00
|
|
|
get "/i/redirect":
|
|
|
|
let url = decodeUrl(@"url")
|
|
|
|
if url.len == 0: halt Http404
|
|
|
|
redirect(replaceUrl(url, cookiePrefs()))
|
|
|
|
|
2019-10-07 14:47:53 +00:00
|
|
|
error Http404:
|
|
|
|
resp showError("Page not found", cfg.title)
|
|
|
|
|
2019-09-23 14:12:20 +00:00
|
|
|
extend unsupported, ""
|
2019-09-06 00:42:35 +00:00
|
|
|
extend preferences, ""
|
2019-09-15 10:10:43 +00:00
|
|
|
extend rss, ""
|
2019-09-13 20:24:58 +00:00
|
|
|
extend search, ""
|
2019-09-06 00:42:35 +00:00
|
|
|
extend timeline, ""
|
2019-09-20 23:08:30 +00:00
|
|
|
extend list, ""
|
2019-09-20 12:10:10 +00:00
|
|
|
extend status, ""
|
2019-09-06 00:42:35 +00:00
|
|
|
extend media, ""
|
2019-06-20 14:16:20 +00:00
|
|
|
|
|
|
|
runForever()
|