Minor cleanup, fix empty lines before card links
This commit is contained in:
parent
a3303d6bef
commit
4407651ed6
|
@ -16,6 +16,10 @@ const hostname {.strdefine.} = "nitter.net"
|
||||||
proc stripText*(text: string): string =
|
proc stripText*(text: string): string =
|
||||||
text.replace(nbsp, " ").strip()
|
text.replace(nbsp, " ").strip()
|
||||||
|
|
||||||
|
proc stripHtml*(text: string): string =
|
||||||
|
let html = parseHtml(text)
|
||||||
|
html.innerText()
|
||||||
|
|
||||||
proc shortLink*(text: string; length=28): string =
|
proc shortLink*(text: string; length=28): string =
|
||||||
result = text.replace(re"https?://(www.)?", "")
|
result = text.replace(re"https?://(www.)?", "")
|
||||||
if result.len > length:
|
if result.len > length:
|
||||||
|
@ -93,7 +97,3 @@ proc getTwitterLink*(path: string; params: Table[string, string]): string =
|
||||||
result = $(parseUri("https://twitter.com") / path ? p)
|
result = $(parseUri("https://twitter.com") / path ? p)
|
||||||
if username.len > 0:
|
if username.len > 0:
|
||||||
result = result.replace("/" & username, "")
|
result = result.replace("/" & username, "")
|
||||||
|
|
||||||
proc getTweetPreview*(text: string): string =
|
|
||||||
let html = parseHtml(text)
|
|
||||||
html.innerText()
|
|
||||||
|
|
|
@ -57,7 +57,8 @@ proc parseText*(text: XmlNode; skipLink=""): string =
|
||||||
if "data-expanded-url" in el.attrs:
|
if "data-expanded-url" in el.attrs:
|
||||||
let url = el.attr("data-expanded-url")
|
let url = el.attr("data-expanded-url")
|
||||||
if url == skipLink: continue
|
if url == skipLink: continue
|
||||||
elif "u-hidden" in class: result.add "\n"
|
if "u-hidden" in class and result.len > 0:
|
||||||
|
result.add "\n"
|
||||||
result.add a(shortLink(url), href=url)
|
result.add a(shortLink(url), href=url)
|
||||||
elif "ashtag" in class:
|
elif "ashtag" in class:
|
||||||
let hash = el.innerText()
|
let hash = el.innerText()
|
||||||
|
|
|
@ -57,7 +57,7 @@ proc renderMain*(body: VNode; req: Request; title="Nitter"; titleText=""; desc="
|
||||||
meta(name="viewport", content="width=device-width, initial-scale=1.0")
|
meta(name="viewport", content="width=device-width, initial-scale=1.0")
|
||||||
meta(property="og:type", content=`type`)
|
meta(property="og:type", content=`type`)
|
||||||
meta(property="og:title", content=titleText)
|
meta(property="og:title", content=titleText)
|
||||||
meta(property="og:description", content=getTweetPreview(desc))
|
meta(property="og:description", content=stripHtml(desc))
|
||||||
meta(property="og:site_name", content="Nitter")
|
meta(property="og:site_name", content="Nitter")
|
||||||
|
|
||||||
for url in images:
|
for url in images:
|
||||||
|
|
Loading…
Reference in New Issue