From 5ccdcab06214bbefd68d9ad669e8b57dfa435f4f Mon Sep 17 00:00:00 2001 From: Sophist <3001893+Sophist-UK@users.noreply.github.com> Date: Fri, 14 Jul 2023 13:56:48 +0100 Subject: [PATCH 1/4] Tweak private_eye.recipe Small formatting improvements. --- recipes/private_eye.recipe | 29 ++++++++++++++++++++++++----- 1 file changed, 24 insertions(+), 5 deletions(-) diff --git a/recipes/private_eye.recipe b/recipes/private_eye.recipe index e635b928db..9573b50a12 100644 --- a/recipes/private_eye.recipe +++ b/recipes/private_eye.recipe @@ -8,9 +8,14 @@ from datetime import datetime, timedelta class PrivateEyeRecipe(BasicNewsRecipe): ## - # Last Edited: 2023-07-01 + # Last Edited: 2023-07-14 # - # Remark: Version 3.0 + # Remark: Version 3.1 2023-07-14 + # Show crossword on right so clues are continuous down left + # Crossword image scales with ebook reader width + # Link to crossword image removed + # Improve cartoons page layout + # Version 3.0 2023-07-01 # Rewrite (by Sophist-UK) to fit latest web pages, correctly identify pages to include # and improve formatting. # Edited to add: inclusion of About page, @@ -115,6 +120,20 @@ class PrivateEyeRecipe(BasicNewsRecipe): return [('Private Eye', articles)] + def preprocess_html(self, soup): + # Remove tag link to crossword image + for tag in soup.findAll('a', {'href': re.compile(r'/pictures/crossword/')}): + self.log("Removing link to crossword image...") + tag.unwrap() + + # Remove align tag in crossword image (so float right works) + for tag in soup.findAll('img', {'src': re.compile(r'/pictures/crossword/')}): + if "align" in tag.attrs: + self.log("Removing crossword image align attribute...") + del tag.attrs['align'] + + return soup + # We remove vast swathes of HTML which is not part of the articles. # Remove sibling content remove_tags_before = [ @@ -165,11 +184,11 @@ class PrivateEyeRecipe(BasicNewsRecipe): # However some is new css to tweak output when part of an ebook. extra_css = ' \n '.join([ '#content img {float: right;}', - '#content img.cartoon-left {float: left;}', - '#content img.cartoon-right {float: right;}', + '#content img.cartoon-left {float: left; margin-right: 15px; margin-bottom: 15px;}', + '#content img.cartoon-right {float: none; margin-bottom: 15px;}', '#content img:first-child {float: none;}', '#content #block-sections img {float: none;}', - '#content #block-sections img.crossword {float: none; width: 50%; margin-right: 20px;}', + '#content #block-sections img.crossword {float: right; width: 40%; margin-left: 15px; min-width: 350px;}', '#article-caption-box {float: right; background: #222222; display: block; width: 40%; max-width: 40%;}', '#caption-box {color: #ffffff; text-align: center; padding: 5px 20px 15px 20px;}', '#whatsapp {border-left: 5px #8aba60 solid; border-right: 5px #8aba60 solid; border-bottom: 5px #8aba60 solid; padding: 0 20px 20px 20px;}', From 316d994a37967c00f38d87b3870ad9012102e9a5 Mon Sep 17 00:00:00 2001 From: Sophist <3001893+Sophist-UK@users.noreply.github.com> Date: Fri, 14 Jul 2023 15:10:33 +0100 Subject: [PATCH 2/4] Additional tweaks to images --- recipes/private_eye.recipe | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/recipes/private_eye.recipe b/recipes/private_eye.recipe index 9573b50a12..936c675614 100644 --- a/recipes/private_eye.recipe +++ b/recipes/private_eye.recipe @@ -12,9 +12,8 @@ class PrivateEyeRecipe(BasicNewsRecipe): # # Remark: Version 3.1 2023-07-14 # Show crossword on right so clues are continuous down left - # Crossword image scales with ebook reader width # Link to crossword image removed - # Improve cartoons page layout + # Improve many image layouts # Version 3.0 2023-07-01 # Rewrite (by Sophist-UK) to fit latest web pages, correctly identify pages to include # and improve formatting. @@ -183,13 +182,22 @@ class PrivateEyeRecipe(BasicNewsRecipe): # ebook without duplicating it as extra css. # However some is new css to tweak output when part of an ebook. extra_css = ' \n '.join([ - '#content img {float: right;}', + '#content img {float: right; width: 45%; minimum-width:350px;}', '#content img.cartoon-left {float: left; margin-right: 15px; margin-bottom: 15px;}', '#content img.cartoon-right {float: none; margin-bottom: 15px;}', + '#content img.strip {float: none; width: 100%;}', '#content img:first-child {float: none;}', - '#content #block-sections img {float: none;}', + '#content img.gnitty-right {float: none; width: 160px;}', + '#content #story > div[align=right] > img:first-child {float: none; width: 15px;}', + '#content #story > img:first-child {float: none; height: 100px; width: none; minimum-width: none;}', + #'#content #block-sections img {float: none; width: 100%;}', + '#content #block-sections img {float: none; width: none;}', + '#content #block-sections img.photo-right {float: right; width: 25%; min-width:120px; margin-left: 15px;}', + '#content #block-sections > p:last-child > img:first-child {float: none; width: 120px;}', + '#content #block-sections > p:last-child > img:nth-child(2) {float: none; width: 120px;}', '#content #block-sections img.crossword {float: right; width: 40%; margin-left: 15px; min-width: 350px;}', - '#article-caption-box {float: right; background: #222222; display: block; width: 40%; max-width: 40%;}', + '#content #article-caption-box {float: right; background: #222222; display: block; width: 40%; min-width: 250px; font-size: 90%; margin-left: 15px;}', + '#content #article-caption-box img {float: none; width: 100%; max-width: none;}', '#caption-box {color: #ffffff; text-align: center; padding: 5px 20px 15px 20px;}', '#whatsapp {border-left: 5px #8aba60 solid; border-right: 5px #8aba60 solid; border-bottom: 5px #8aba60 solid; padding: 0 20px 20px 20px;}', '#whatsapp::after {clear:both;}', @@ -198,4 +206,5 @@ class PrivateEyeRecipe(BasicNewsRecipe): '.whatsapp-left {text-align: left; margin-right: 30%; background-color: #eeeeee;}', '.whatsapp-right {text-align: right; margin-left: 30%; background-color: #dce5ae;}', '#whatsapp .whatsapp-left img, #whatsapp .whatsapp-right img {width: 35px; margin: 0 10px; vertical-align: middle;}', + '#whatsapp .whatsapp-left img.emoji, #whatsapp .whatsapp-right img.emoji {max-width: 35px; margin: 0 5px; vertical-align: middle;}', ]) From cb2f3f224c3a9affc36875bb1ab3100a323df7e4 Mon Sep 17 00:00:00 2001 From: Sophist <3001893+Sophist-UK@users.noreply.github.com> Date: Fri, 14 Jul 2023 15:11:44 +0100 Subject: [PATCH 3/4] Remove obsolete commented code --- recipes/private_eye.recipe | 1 - 1 file changed, 1 deletion(-) diff --git a/recipes/private_eye.recipe b/recipes/private_eye.recipe index 936c675614..0a185435c8 100644 --- a/recipes/private_eye.recipe +++ b/recipes/private_eye.recipe @@ -190,7 +190,6 @@ class PrivateEyeRecipe(BasicNewsRecipe): '#content img.gnitty-right {float: none; width: 160px;}', '#content #story > div[align=right] > img:first-child {float: none; width: 15px;}', '#content #story > img:first-child {float: none; height: 100px; width: none; minimum-width: none;}', - #'#content #block-sections img {float: none; width: 100%;}', '#content #block-sections img {float: none; width: none;}', '#content #block-sections img.photo-right {float: right; width: 25%; min-width:120px; margin-left: 15px;}', '#content #block-sections > p:last-child > img:first-child {float: none; width: 120px;}', From 7cb2e217334a8139eefcda4305545d358251f61f Mon Sep 17 00:00:00 2001 From: Sophist <3001893+Sophist-UK@users.noreply.github.com> Date: Fri, 14 Jul 2023 15:29:53 +0100 Subject: [PATCH 4/4] Tweak PM's WhatsApp --- recipes/private_eye.recipe | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/recipes/private_eye.recipe b/recipes/private_eye.recipe index 0a185435c8..8ddda8392d 100644 --- a/recipes/private_eye.recipe +++ b/recipes/private_eye.recipe @@ -191,6 +191,7 @@ class PrivateEyeRecipe(BasicNewsRecipe): '#content #story > div[align=right] > img:first-child {float: none; width: 15px;}', '#content #story > img:first-child {float: none; height: 100px; width: none; minimum-width: none;}', '#content #block-sections img {float: none; width: none;}', + '#content #block-sections img.lookalike {float: none; width: 100%;}', '#content #block-sections img.photo-right {float: right; width: 25%; min-width:120px; margin-left: 15px;}', '#content #block-sections > p:last-child > img:first-child {float: none; width: 120px;}', '#content #block-sections > p:last-child > img:nth-child(2) {float: none; width: 120px;}', @@ -200,10 +201,10 @@ class PrivateEyeRecipe(BasicNewsRecipe): '#caption-box {color: #ffffff; text-align: center; padding: 5px 20px 15px 20px;}', '#whatsapp {border-left: 5px #8aba60 solid; border-right: 5px #8aba60 solid; border-bottom: 5px #8aba60 solid; padding: 0 20px 20px 20px;}', '#whatsapp::after {clear:both;}', - '.whatsapp-left, .whatsapp-right {margin: 20px 0px 0px 0px; padding: 15px; border-radius: 10px;}', - '.whatsapp-left, .whatsapp-right {font-family: Helvetica, Arial, "sans-serif"; font-weight: 300; font-size: 18px; line-height: 24px;}', - '.whatsapp-left {text-align: left; margin-right: 30%; background-color: #eeeeee;}', - '.whatsapp-right {text-align: right; margin-left: 30%; background-color: #dce5ae;}', + '#whatsapp .whatsapp-left, .whatsapp-right {margin: 0 0 20px 0; padding: 15px; border-radius: 10px;}', + '#whatsapp .whatsapp-left, .whatsapp-right {font-family: Helvetica, Arial, "sans-serif"; font-weight: 300; font-size: 18px; line-height: 24px;}', + '#whatsapp .whatsapp-left {text-align: left; margin-right: 30%; background-color: #eeeeee;}', + '#whatsapp .whatsapp-right {text-align: right; margin-left: 30%; background-color: #dce5ae;}', '#whatsapp .whatsapp-left img, #whatsapp .whatsapp-right img {width: 35px; margin: 0 10px; vertical-align: middle;}', '#whatsapp .whatsapp-left img.emoji, #whatsapp .whatsapp-right img.emoji {max-width: 35px; margin: 0 5px; vertical-align: middle;}', ])