mirror of
https://github.com/zedeus/nitter.git
synced 2024-12-23 09:55:30 +00:00
Implement link previews
This commit is contained in:
parent
afdbb6ad9e
commit
ec5f67123a
|
@ -27,7 +27,6 @@ is on implementing missing features.
|
||||||
|
|
||||||
- Search (images/videos, hashtags, etc.)
|
- Search (images/videos, hashtags, etc.)
|
||||||
- Custom timeline filter
|
- Custom timeline filter
|
||||||
- Nitter link previews
|
|
||||||
- More caching (waiting for [moigagoo/norm#19](https://github.com/moigagoo/norm/pull/19))
|
- More caching (waiting for [moigagoo/norm#19](https://github.com/moigagoo/norm/pull/19))
|
||||||
- Simple account system with customizable feed
|
- Simple account system with customizable feed
|
||||||
- Video support with hls.js
|
- Video support with hls.js
|
||||||
|
|
|
@ -140,7 +140,7 @@ a:hover {
|
||||||
|
|
||||||
.replying-to {
|
.replying-to {
|
||||||
color: hsla(240,1%,73%,.9);
|
color: hsla(240,1%,73%,.9);
|
||||||
margin: -4px 0 4px 0;
|
margin: -2px 0 4px 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
.status-el .status-content {
|
.status-el .status-content {
|
||||||
|
|
|
@ -68,9 +68,15 @@ proc getUserpic*(userpic: string; style=""): string =
|
||||||
proc getUserpic*(profile: Profile; style=""): string =
|
proc getUserpic*(profile: Profile; style=""): string =
|
||||||
getUserPic(profile.userpic, style)
|
getUserPic(profile.userpic, style)
|
||||||
|
|
||||||
|
proc getVideoEmbed*(video: Video): string =
|
||||||
|
&"https://twitter.com/i/videos/{video.videoId}?embed_source=facebook"
|
||||||
|
|
||||||
proc pageTitle*(profile: Profile): string =
|
proc pageTitle*(profile: Profile): string =
|
||||||
&"{profile.fullname} (@{profile.username})"
|
&"{profile.fullname} (@{profile.username})"
|
||||||
|
|
||||||
|
proc pageDesc*(profile: Profile): string =
|
||||||
|
"The latest tweets from " & profile.fullname
|
||||||
|
|
||||||
proc getTime*(tweet: Tweet): string =
|
proc getTime*(tweet: Tweet): string =
|
||||||
tweet.time.format("d/M/yyyy', ' HH:mm:ss")
|
tweet.time.format("d/M/yyyy', ' HH:mm:ss")
|
||||||
|
|
||||||
|
|
|
@ -24,7 +24,7 @@ proc showSingleTimeline(name, after, agent: string; query: Option[Query]): Futur
|
||||||
return ""
|
return ""
|
||||||
|
|
||||||
let profileHtml = renderProfile(profile, await timelineFut, await railFut)
|
let profileHtml = renderProfile(profile, await timelineFut, await railFut)
|
||||||
return renderMain(profileHtml, title=cfg.title, titleText=pageTitle(profile))
|
return renderMain(profileHtml, title=cfg.title, titleText=pageTitle(profile), desc=pageDesc(profile))
|
||||||
|
|
||||||
proc showMultiTimeline(names: seq[string]; after, agent: string; query: Option[Query]): Future[string] {.async.} =
|
proc showMultiTimeline(names: seq[string]; after, agent: string; query: Option[Query]): Future[string] {.async.} =
|
||||||
var q = query
|
var q = query
|
||||||
|
@ -91,7 +91,17 @@ routes:
|
||||||
resp Http404, showError("Tweet not found", cfg.title)
|
resp Http404, showError("Tweet not found", cfg.title)
|
||||||
|
|
||||||
let title = pageTitle(conversation.tweet.profile)
|
let title = pageTitle(conversation.tweet.profile)
|
||||||
resp renderMain(renderConversation(conversation), title=cfg.title, titleText=title)
|
let desc = conversation.tweet.text
|
||||||
|
let html = renderConversation(conversation)
|
||||||
|
|
||||||
|
if conversation.tweet.video.isSome():
|
||||||
|
let thumb = get(conversation.tweet.video).thumb
|
||||||
|
let vidUrl = getVideoEmbed(get(conversation.tweet.video))
|
||||||
|
resp renderMain(html, title=cfg.title, titleText=title, desc=desc,
|
||||||
|
images = @[thumb], `type`="video", video=vidUrl)
|
||||||
|
else:
|
||||||
|
resp renderMain(html, title=cfg.title, titleText=title,
|
||||||
|
desc=desc, images=conversation.tweet.photos)
|
||||||
|
|
||||||
get "/pic/@sig/@url":
|
get "/pic/@sig/@url":
|
||||||
cond "http" in @"url"
|
cond "http" in @"url"
|
||||||
|
|
|
@ -1,16 +1,36 @@
|
||||||
import karax/[karaxdsl, vdom]
|
import karax/[karaxdsl, vdom]
|
||||||
|
|
||||||
|
import ../utils
|
||||||
|
|
||||||
const doctype = "<!DOCTYPE html>\n"
|
const doctype = "<!DOCTYPE html>\n"
|
||||||
|
|
||||||
proc renderMain*(body: VNode; title="Nitter"; titleText=""): string =
|
proc renderMain*(body: VNode; title="Nitter"; titleText=""; desc="";
|
||||||
|
`type`="article"; video=""; images: seq[string] = @[]): string =
|
||||||
let node = buildHtml(html(lang="en")):
|
let node = buildHtml(html(lang="en")):
|
||||||
head:
|
head:
|
||||||
if titleText.len > 0:
|
|
||||||
title: text titleText & " | " & title
|
|
||||||
else:
|
|
||||||
title: text title
|
|
||||||
link(rel="stylesheet", `type`="text/css", href="/style.css")
|
link(rel="stylesheet", `type`="text/css", href="/style.css")
|
||||||
|
|
||||||
|
title:
|
||||||
|
if titleText.len > 0:
|
||||||
|
text titleText & " | " & title
|
||||||
|
else:
|
||||||
|
text title
|
||||||
|
|
||||||
|
meta(name="og:type", content=`type`)
|
||||||
|
meta(name="og:title", content=titleText)
|
||||||
|
meta(name="og:description", content=desc)
|
||||||
|
meta(name="og:site_name", content="Twitter")
|
||||||
|
|
||||||
|
for url in images:
|
||||||
|
meta(name="og:image", content=getSigUrl(url, "pic"))
|
||||||
|
|
||||||
|
if video.len > 0:
|
||||||
|
meta(name="og:video:url", content=video)
|
||||||
|
meta(name="og:video:secure_url", content=video)
|
||||||
|
meta(name="og:video:type", content="text/html")
|
||||||
|
meta(name="og:video:width", content="1200")
|
||||||
|
meta(name="og:video:height", content="675")
|
||||||
|
|
||||||
body:
|
body:
|
||||||
nav(id="nav", class="nav-bar container"):
|
nav(id="nav", class="nav-bar container"):
|
||||||
tdiv(class="inner-nav"):
|
tdiv(class="inner-nav"):
|
||||||
|
|
Loading…
Reference in a new issue