Cleanup
This commit is contained in:
parent
fd20fcf3ee
commit
7639883c6a
|
@ -4,7 +4,8 @@ import strutils, json, xmltree, uri
|
||||||
import ".."/[types, parser, parserutils, query]
|
import ".."/[types, parser, parserutils, query]
|
||||||
import utils, consts, timeline
|
import utils, consts, timeline
|
||||||
|
|
||||||
proc getResult[T](json: JsonNode; query: Query; after: string): Result[T] =
|
proc getResult*[T](json: JsonNode; query: Query; after: string): Result[T] =
|
||||||
|
if json == nil: return Result[T](beginning: true, query: query)
|
||||||
Result[T](
|
Result[T](
|
||||||
hasMore: json["has_more_items"].to(bool),
|
hasMore: json["has_more_items"].to(bool),
|
||||||
maxId: json.getOrDefault("max_position").getStr(""),
|
maxId: json.getOrDefault("max_position").getStr(""),
|
||||||
|
@ -46,11 +47,11 @@ proc getSearch*[T](query: Query; after, agent: string): Future[Result[T]] {.asyn
|
||||||
|
|
||||||
result = getResult[T](json, query, after)
|
result = getResult[T](json, query, after)
|
||||||
if not json.hasKey("items_html"): return
|
if not json.hasKey("items_html"): return
|
||||||
let html = parseHtml(json["items_html"].to(string))
|
|
||||||
|
|
||||||
when T is Tweet:
|
when T is Tweet:
|
||||||
result = await finishTimeline(json, query, after, agent)
|
result = await finishTimeline(json, query, after, agent)
|
||||||
elif T is Profile:
|
elif T is Profile:
|
||||||
result.hasMore = json["items_html"].to(string) != "\n"
|
let html = json["items_html"].to(string)
|
||||||
for p in html.selectAll(".js-stream-item"):
|
result.hasMore = html != "\n"
|
||||||
|
for p in parseHtml(html).selectAll(".js-stream-item"):
|
||||||
result.content.add parsePopupProfile(p, ".ProfileCard")
|
result.content.add parsePopupProfile(p, ".ProfileCard")
|
||||||
|
|
|
@ -2,18 +2,11 @@ import httpclient, asyncdispatch, htmlparser
|
||||||
import sequtils, strutils, json, xmltree, uri
|
import sequtils, strutils, json, xmltree, uri
|
||||||
|
|
||||||
import ".."/[types, parser, parserutils, formatters, query]
|
import ".."/[types, parser, parserutils, formatters, query]
|
||||||
import utils, consts, media
|
import utils, consts, media, search
|
||||||
|
|
||||||
proc finishTimeline*(json: JsonNode; query: Query; after, agent: string): Future[Timeline] {.async.} =
|
proc finishTimeline*(json: JsonNode; query: Query; after, agent: string): Future[Timeline] {.async.} =
|
||||||
if json == nil: return Timeline(beginning: true, query: query)
|
result = getResult[Tweet](json, query, after)
|
||||||
|
if json == nil: return
|
||||||
result = Timeline(
|
|
||||||
hasMore: json["has_more_items"].to(bool),
|
|
||||||
maxId: json.getOrDefault("max_position").getStr(""),
|
|
||||||
minId: json.getOrDefault("min_position").getStr("").cleanPos(),
|
|
||||||
query: query,
|
|
||||||
beginning: after.len == 0
|
|
||||||
)
|
|
||||||
|
|
||||||
if json["new_latent_count"].to(int) == 0: return
|
if json["new_latent_count"].to(int) == 0: return
|
||||||
if not json.hasKey("items_html"): return
|
if not json.hasKey("items_html"): return
|
||||||
|
|
|
@ -3,12 +3,11 @@ import asyncfile, uri, strutils, httpclient, os
|
||||||
import jester, regex
|
import jester, regex
|
||||||
|
|
||||||
import router_utils
|
import router_utils
|
||||||
import ".."/[types, formatters, utils, prefs]
|
import ".."/[types, formatters, prefs]
|
||||||
import ../views/general
|
import ../views/general
|
||||||
|
|
||||||
export asyncfile, httpclient, os, strutils
|
export asyncfile, httpclient, os, strutils
|
||||||
export regex
|
export regex
|
||||||
export utils
|
|
||||||
|
|
||||||
proc createMediaRouter*(cfg: Config) =
|
proc createMediaRouter*(cfg: Config) =
|
||||||
router media:
|
router media:
|
||||||
|
|
|
@ -3,7 +3,7 @@ import strutils, uri
|
||||||
import jester
|
import jester
|
||||||
|
|
||||||
import router_utils
|
import router_utils
|
||||||
import ".."/[prefs, types, utils]
|
import ".."/[prefs, types]
|
||||||
import ../views/[general, preferences]
|
import ../views/[general, preferences]
|
||||||
|
|
||||||
export preferences
|
export preferences
|
||||||
|
|
|
@ -1,3 +1,6 @@
|
||||||
|
import ../utils
|
||||||
|
export utils
|
||||||
|
|
||||||
template cookiePrefs*(): untyped {.dirty.} =
|
template cookiePrefs*(): untyped {.dirty.} =
|
||||||
getPrefs(request.cookies.getOrDefault("preferences"))
|
getPrefs(request.cookies.getOrDefault("preferences"))
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@ import strutils, sequtils, uri
|
||||||
import jester
|
import jester
|
||||||
|
|
||||||
import router_utils
|
import router_utils
|
||||||
import ".."/[query, types, utils, api, agents, prefs]
|
import ".."/[query, types, api, agents, prefs]
|
||||||
import ../views/[general, search]
|
import ../views/[general, search]
|
||||||
|
|
||||||
export search
|
export search
|
||||||
|
|
|
@ -3,17 +3,15 @@ import asyncdispatch, strutils, sequtils, uri
|
||||||
import jester
|
import jester
|
||||||
|
|
||||||
import router_utils
|
import router_utils
|
||||||
import ".."/[api, prefs, types, utils, cache, formatters, agents, query]
|
import ".."/[api, prefs, types, formatters, agents]
|
||||||
import ../views/[general, profile, timeline, status, search]
|
import ../views/[general, status]
|
||||||
|
|
||||||
export uri, sequtils
|
export uri, sequtils
|
||||||
export router_utils
|
export router_utils
|
||||||
export api, cache, formatters, query, agents
|
export api, formatters, agents
|
||||||
export profile, status
|
export status
|
||||||
|
|
||||||
proc createStatusRouter*(cfg: Config) =
|
proc createStatusRouter*(cfg: Config) =
|
||||||
setProfileCacheTime(cfg.profileCacheTime)
|
|
||||||
|
|
||||||
router status:
|
router status:
|
||||||
get "/@name/status/@id":
|
get "/@name/status/@id":
|
||||||
cond '.' notin @"name"
|
cond '.' notin @"name"
|
||||||
|
|
|
@ -3,7 +3,7 @@ import asyncdispatch, strutils, sequtils, uri
|
||||||
import jester
|
import jester
|
||||||
|
|
||||||
import router_utils
|
import router_utils
|
||||||
import ".."/[api, prefs, types, utils, cache, formatters, agents, query]
|
import ".."/[api, prefs, types, cache, formatters, agents, query]
|
||||||
import ../views/[general, profile, timeline, status, search]
|
import ../views/[general, profile, timeline, status, search]
|
||||||
|
|
||||||
export uri, sequtils
|
export uri, sequtils
|
||||||
|
|
Loading…
Reference in New Issue