diff options
| author | Omar Roth <omarroth@hotmail.com> | 2018-04-05 20:06:22 -0500 |
|---|---|---|
| committer | Omar Roth <omarroth@hotmail.com> | 2018-04-05 20:06:22 -0500 |
| commit | e2b5b7793a3604fae22dedd3a370ee2ab38a1234 (patch) | |
| tree | 06e9e07551656a66b306aa5c56a266458bd29045 | |
| parent | 815aeeb29c945d2f499f0cd1917d0e6b3072ca86 (diff) | |
| download | invidious-e2b5b7793a3604fae22dedd3a370ee2ab38a1234.tar.gz invidious-e2b5b7793a3604fae22dedd3a370ee2ab38a1234.tar.bz2 invidious-e2b5b7793a3604fae22dedd3a370ee2ab38a1234.zip | |
Use fill_links once instead of per comment
| -rw-r--r-- | src/helpers.cr | 8 | ||||
| -rw-r--r-- | src/invidious.cr | 1 |
2 files changed, 4 insertions, 5 deletions
diff --git a/src/helpers.cr b/src/helpers.cr index 6b05a016..f973fc6a 100644 --- a/src/helpers.cr +++ b/src/helpers.cr @@ -381,9 +381,6 @@ def template_comments(root) score = child["data"]["score"] body_html = HTML.unescape(child["data"]["body_html"].as_s) - # Replace local links wtih links back to Reddit - body_html = fill_links(body_html, "https", "www.reddit.com") - replies_html = "" if child["data"]["replies"] != "" replies_html = template_comments(child["data"]["replies"]["data"]["children"]) @@ -402,7 +399,8 @@ def template_comments(root) if child["data"]["depth"].as_i > 0 html += <<-END_HTML <div class="pure-g"> - <div class="pure-u-1-24"></div> + <div class="pure-u-1-24"> + </div> <div class="pure-u-23-24"> #{content} </div> @@ -483,7 +481,7 @@ def fill_links(html, scheme, host) html.xpath_nodes("//a").each do |match| url = URI.parse(match["href"]) # Reddit links don't have host - if !url.host + if !url.host && !match["href"].starts_with?("javascript") url.scheme = scheme url.host = host match["href"] = url diff --git a/src/invidious.cr b/src/invidious.cr index af070b6f..7307b255 100644 --- a/src/invidious.cr +++ b/src/invidious.cr @@ -296,6 +296,7 @@ get "/watch" do |env| reddit_comments, reddit_thread = get_reddit_comments(id, reddit_client, headers) reddit_html = template_comments(reddit_comments) + reddit_html = fill_links(reddit_html, "https", "www.reddit.com") reddit_html = add_alt_links(reddit_html) rescue ex reddit_thread = nil |
