From 282996453015aca6181ba96c19eac4060e136010 Mon Sep 17 00:00:00 2001 From: Sam Ireland Date: Sun, 3 Jan 2021 20:56:15 +0000 Subject: [PATCH] Style blockquote --- html/main.js | 30 +++++++++++++++--------------- html/saved.html | 2 +- html/style.css | 15 +++++++++++++++ utilities.py | 15 ++++++++++----- 4 files changed, 41 insertions(+), 21 deletions(-) diff --git a/html/main.js b/html/main.js index 707509a..8ff82e7 100644 --- a/html/main.js +++ b/html/main.js @@ -17,20 +17,20 @@ const toggleMedia = e => { } window.addEventListener("load", function() { -const postsSection = document.querySelector(".posts-section"); -const commentsSection = document.querySelector(".comments-section"); -if (commentsSection) { - commentsSection.style.display = "none"; - const toggleButton = document.createElement("button"); - toggleButton.innerText = "toggle"; - toggleButton.addEventListener("click", toggleView); - document.body.insertBefore(toggleButton, postsSection); -} + const postsSection = document.querySelector(".posts-section"); + const commentsSection = document.querySelector(".comments-section"); + if (commentsSection) { + commentsSection.style.display = "none"; + const toggleButton = document.createElement("button"); + toggleButton.innerText = "toggle"; + toggleButton.addEventListener("click", toggleView); + document.body.insertBefore(toggleButton, postsSection); + } -for (let preview of document.querySelectorAll(".preview")) { - const media = preview.querySelector("img") || preview.querySelector("video"); - if (media) { - media.addEventListener("click", toggleMedia); - } -} + for (let preview of document.querySelectorAll(".preview")) { + const media = preview.querySelector("img") || preview.querySelector("video"); + if (media) { + media.addEventListener("click", toggleMedia); + } + } }) \ No newline at end of file diff --git a/html/saved.html b/html/saved.html index cdd8177..fea7a01 100644 --- a/html/saved.html +++ b/html/saved.html @@ -12,7 +12,7 @@

Saved Comments

-
+ \ No newline at end of file diff --git a/html/style.css b/html/style.css index 27cc38a..8df43cb 100644 --- a/html/style.css +++ b/html/style.css @@ -46,6 +46,21 @@ code { white-space: pre; } +blockquote { + font-style: italic; + padding-left: 8px; + position: relative; +} + +blockquote:before { + position: absolute; + left: 0; + width: 4px; + content: ""; + height: 100%; + background-color: #16a085; +} + a:hover { text-decoration: underline; } diff --git a/utilities.py b/utilities.py index d7e5746..f495c39 100644 --- a/utilities.py +++ b/utilities.py @@ -101,11 +101,16 @@ def save_media(post, location): if domain == "redd.it": downloader = Downloader(max_q=True, log=False) downloader.url = url - name = downloader.download() - extension = name.split(".")[-1] - filename = f"{readable_name}_{post.id}.{extension}" - os.rename(name, os.path.join(location, "media", filename)) - return filename + current = os.getcwd() + try: + name = downloader.download() + extension = name.split(".")[-1] + filename = f"{readable_name}_{post.id}.{extension}" + os.rename(name, os.path.join(location, "media", filename)) + return filename + except: + os.chdir(current) + return None # Is it a gfycat link that redirects? Update the URL if possible if domain == "gfycat.com":