Support even more obscure card types
This commit is contained in:
parent
77994e8246
commit
0c9c37e886
4 changed files with 16 additions and 7 deletions
|
@ -158,7 +158,7 @@ proc parseBroadcast(js: JsonNode): Card =
|
|||
proc parseCard(js: JsonNode; urls: JsonNode): Card =
|
||||
const imageTypes = ["summary_photo_image", "player_image", "promo_image",
|
||||
"photo_image_full_size", "thumbnail_image", "thumbnail",
|
||||
"event_thumbnail"]
|
||||
"event_thumbnail", "image"]
|
||||
let
|
||||
vals = ? js{"binding_values"}
|
||||
name = js{"name"}.getStr
|
||||
|
@ -176,7 +176,7 @@ proc parseCard(js: JsonNode; urls: JsonNode): Card =
|
|||
result.url = js{"url"}.getStr
|
||||
|
||||
case kind
|
||||
of promoVideo, promoVideoConvo, appPlayer:
|
||||
of promoVideo, promoVideoConvo, appPlayer, videoDirectMessage:
|
||||
result.video = some parsePromoVideo(vals)
|
||||
if kind == appPlayer:
|
||||
result.text = vals{"app_category"}.getStrVal(result.text)
|
||||
|
@ -202,8 +202,11 @@ proc parseCard(js: JsonNode; urls: JsonNode): Card =
|
|||
result.url = u{"expanded_url"}.getStr
|
||||
break
|
||||
|
||||
if kind in {promoImageConvo, promoImageApp} and result.url.len == 0 or
|
||||
result.url.startsWith("card://"):
|
||||
if kind in {videoDirectMessage, imageDirectMessage}:
|
||||
result.url.setLen 0
|
||||
|
||||
if kind in {promoImageConvo, promoImageApp, imageDirectMessage} and
|
||||
result.url.len == 0 or result.url.startsWith("card://"):
|
||||
result.url = getPicUrl(result.image)
|
||||
|
||||
proc parseTweet(js: JsonNode): Tweet =
|
||||
|
|
|
@ -82,8 +82,10 @@ proc getCardTitle*(js: JsonNode; kind: CardKind): string =
|
|||
result = js{"title"}.getStrVal
|
||||
if kind == promoVideoConvo:
|
||||
result = js{"thank_you_text"}.getStrVal(result)
|
||||
if kind == liveEvent:
|
||||
elif kind == liveEvent:
|
||||
result = js{"event_category"}.getStrVal
|
||||
elif kind in {videoDirectMessage, imageDirectMessage}:
|
||||
result = js{"cta1"}.getStrVal
|
||||
|
||||
proc getBanner*(js: JsonNode): string =
|
||||
let url = js{"profile_banner_url"}.getImageStr
|
||||
|
|
|
@ -119,6 +119,8 @@ type
|
|||
unified = "unified_card"
|
||||
moment = "moment"
|
||||
messageMe = "message_me"
|
||||
videoDirectMessage = "video_direct_message"
|
||||
imageDirectMessage = "image_direct_message"
|
||||
|
||||
Card* = object
|
||||
kind*: CardKind
|
||||
|
|
|
@ -150,8 +150,10 @@ proc renderCardImage(card: Card): VNode =
|
|||
proc renderCardContent(card: Card): VNode =
|
||||
buildHtml(tdiv(class="card-content")):
|
||||
h2(class="card-title"): text card.title
|
||||
p(class="card-description"): text card.text
|
||||
span(class="card-destination"): text card.dest
|
||||
if card.text.len > 0:
|
||||
p(class="card-description"): text card.text
|
||||
if card.dest.len > 0:
|
||||
span(class="card-destination"): text card.dest
|
||||
|
||||
proc renderCard(card: Card; prefs: Prefs; path: string): VNode =
|
||||
const smallCards = {app, player, summary, storeLink}
|
||||
|
|
Loading…
Reference in a new issue