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