Compare commits
No commits in common. "9129820cb02a57213a1f7a32456436f1922edbbb" and "f5fadca631d8437536d48349be4e6783e5c6cca1" have entirely different histories.
9129820cb0
...
f5fadca631
7 changed files with 6 additions and 87 deletions
|
@ -466,14 +466,6 @@ proc parseGraphTweet(js: JsonNode; isLegacy=false): Tweet =
|
||||||
if result.quote.isSome:
|
if result.quote.isSome:
|
||||||
result.quote = some(parseGraphTweet(js{"quoted_status_result", "result"}, isLegacy))
|
result.quote = some(parseGraphTweet(js{"quoted_status_result", "result"}, isLegacy))
|
||||||
|
|
||||||
with communityNote, js{"birdwatch_pivot"}:
|
|
||||||
let note = BirdwatchNote(
|
|
||||||
id: communityNote{"note", "rest_id"}.getId,
|
|
||||||
title: communityNote{"title"}.getStr,
|
|
||||||
)
|
|
||||||
note.expandBirdwatchEntities(communityNote{"subtitle"})
|
|
||||||
result.birdwatch = some(note)
|
|
||||||
|
|
||||||
proc parseGraphThread(js: JsonNode): tuple[thread: Chain; self: bool] =
|
proc parseGraphThread(js: JsonNode): tuple[thread: Chain; self: bool] =
|
||||||
for t in js{"content", "items"}:
|
for t in js{"content", "items"}:
|
||||||
let entryId = t{"entryId"}.getStr
|
let entryId = t{"entryId"}.getStr
|
||||||
|
|
|
@ -319,28 +319,3 @@ proc expandNoteTweetEntities*(tweet: Tweet; js: JsonNode) =
|
||||||
tweet.expandTextEntities(entities, text, textSlice)
|
tweet.expandTextEntities(entities, text, textSlice)
|
||||||
|
|
||||||
tweet.text = tweet.text.multiReplace((unicodeOpen, xmlOpen), (unicodeClose, xmlClose))
|
tweet.text = tweet.text.multiReplace((unicodeOpen, xmlOpen), (unicodeClose, xmlClose))
|
||||||
|
|
||||||
proc expandBirdwatchEntities*(note: BirdwatchNote; js: JsonNode) =
|
|
||||||
let
|
|
||||||
entities = ? js{"entities"}
|
|
||||||
text = js{"text"}.getStr
|
|
||||||
runes = text.toRunes
|
|
||||||
|
|
||||||
var replacements = newSeq[ReplaceSlice]()
|
|
||||||
|
|
||||||
for ent in entities:
|
|
||||||
let
|
|
||||||
# twitter devs in their infinite wisdom making these entities of all others 1 indexed
|
|
||||||
slice = (ent{"fromIndex"}.getInt - 1) .. (ent{"toIndex"}.getInt - 1)
|
|
||||||
refType = ent{"ref", "type"}.getStr
|
|
||||||
|
|
||||||
case refType
|
|
||||||
of "TimelineUrl":
|
|
||||||
let
|
|
||||||
url = ent{"ref", "url"}.getStr
|
|
||||||
display = $runes[slice]
|
|
||||||
|
|
||||||
replacements.add ReplaceSlice(kind: rkUrl, slice: slice, url: url, display: display)
|
|
||||||
|
|
||||||
note.text = runes.replacedWith(replacements, 0 .. runes.len)
|
|
||||||
|
|
||||||
|
|
|
@ -86,12 +86,12 @@ proc createStatusRouter*(cfg: Config) =
|
||||||
let gif = get(conv.tweet.gif)
|
let gif = get(conv.tweet.gif)
|
||||||
images = @[gif.thumb]
|
images = @[gif.thumb]
|
||||||
video = getPicUrl(gif.url)
|
video = getPicUrl(gif.url)
|
||||||
#elif conv.tweet.card.isSome():
|
elif conv.tweet.card.isSome():
|
||||||
# let card = conv.tweet.card.get()
|
let card = conv.tweet.card.get()
|
||||||
# if card.image.len > 0:
|
if card.image.len > 0:
|
||||||
# images = @[card.image]
|
images = @[card.image]
|
||||||
# elif card.video.isSome():
|
elif card.video.isSome():
|
||||||
# images = @[card.video.get().thumb]
|
images = @[card.video.get().thumb]
|
||||||
|
|
||||||
let html = renderConversation(conv, prefs, getPath() & "#m")
|
let html = renderConversation(conv, prefs, getPath() & "#m")
|
||||||
resp renderMain(html, request, cfg, prefs, title, desc, ogTitle,
|
resp renderMain(html, request, cfg, prefs, title, desc, ogTitle,
|
||||||
|
|
|
@ -7,7 +7,6 @@
|
||||||
@import 'card';
|
@import 'card';
|
||||||
@import 'poll';
|
@import 'poll';
|
||||||
@import 'quote';
|
@import 'quote';
|
||||||
@import 'community_note';
|
|
||||||
|
|
||||||
.tweet-body {
|
.tweet-body {
|
||||||
flex: 1;
|
flex: 1;
|
||||||
|
|
|
@ -1,30 +0,0 @@
|
||||||
@import '_variables';
|
|
||||||
|
|
||||||
.community-note {
|
|
||||||
margin-top: 10px;
|
|
||||||
border: solid 1px var(--dark_grey);
|
|
||||||
border-radius: 10px;
|
|
||||||
background-color: var(--bg_elements);
|
|
||||||
overflow: hidden;
|
|
||||||
pointer-events: all;
|
|
||||||
position: relative;
|
|
||||||
width: 100%;
|
|
||||||
|
|
||||||
&:hover {
|
|
||||||
border-color: var(--grey);
|
|
||||||
}
|
|
||||||
|
|
||||||
.community-note-title {
|
|
||||||
font-weight: bold;
|
|
||||||
background-color: var(--bg_overlays);
|
|
||||||
padding: 6px 8px;
|
|
||||||
margin-top: 1px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.community-note-text {
|
|
||||||
overflow: hidden;
|
|
||||||
white-space: pre-wrap;
|
|
||||||
word-wrap: break-word;
|
|
||||||
padding: 8px;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -198,11 +198,6 @@ type
|
||||||
likes*: int
|
likes*: int
|
||||||
quotes*: int
|
quotes*: int
|
||||||
|
|
||||||
BirdwatchNote* = ref object
|
|
||||||
id*: int64
|
|
||||||
title*: string
|
|
||||||
text*: string
|
|
||||||
|
|
||||||
Tweet* = ref object
|
Tweet* = ref object
|
||||||
id*: int64
|
id*: int64
|
||||||
threadId*: int64
|
threadId*: int64
|
||||||
|
@ -228,7 +223,6 @@ type
|
||||||
gif*: Option[Gif]
|
gif*: Option[Gif]
|
||||||
video*: Option[Video]
|
video*: Option[Video]
|
||||||
photos*: seq[string]
|
photos*: seq[string]
|
||||||
birdwatch*: Option[BirdwatchNote]
|
|
||||||
|
|
||||||
Tweets* = seq[Tweet]
|
Tweets* = seq[Tweet]
|
||||||
|
|
||||||
|
|
|
@ -263,14 +263,6 @@ proc renderQuote(quote: Tweet; prefs: Prefs; path: string): VNode =
|
||||||
if quote.photos.len > 0 or quote.video.isSome or quote.gif.isSome:
|
if quote.photos.len > 0 or quote.video.isSome or quote.gif.isSome:
|
||||||
renderQuoteMedia(quote, prefs, path)
|
renderQuoteMedia(quote, prefs, path)
|
||||||
|
|
||||||
proc renderCommunityNote(note: BirdwatchNote; prefs: Prefs): VNode =
|
|
||||||
buildHtml(tdiv(class="community-note")):
|
|
||||||
tdiv(class="community-note-title"):
|
|
||||||
text note.title
|
|
||||||
|
|
||||||
tdiv(class="community-note-text", dir="auto"):
|
|
||||||
verbatim replaceUrls(note.text, prefs)
|
|
||||||
|
|
||||||
proc renderLocation*(tweet: Tweet): string =
|
proc renderLocation*(tweet: Tweet): string =
|
||||||
let (place, url) = tweet.getLocation()
|
let (place, url) = tweet.getLocation()
|
||||||
if place.len == 0: return
|
if place.len == 0: return
|
||||||
|
@ -351,9 +343,6 @@ proc renderTweet*(tweet: Tweet; prefs: Prefs; path: string; class=""; index=0;
|
||||||
if tweet.quote.isSome:
|
if tweet.quote.isSome:
|
||||||
renderQuote(tweet.quote.get(), prefs, path)
|
renderQuote(tweet.quote.get(), prefs, path)
|
||||||
|
|
||||||
if mainTweet and tweet.birdwatch.isSome:
|
|
||||||
renderCommunityNote(tweet.birdwatch.get(), prefs)
|
|
||||||
|
|
||||||
if mainTweet:
|
if mainTweet:
|
||||||
p(class="tweet-published"): text &"{getTime(tweet)}"
|
p(class="tweet-published"): text &"{getTime(tweet)}"
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue