From cf0ff262754759228d242425d03c01823e358079 Mon Sep 17 00:00:00 2001 From: dgtlmoon Date: Fri, 12 Jul 2024 19:42:18 +0200 Subject: [PATCH 1/3] UI - Extract as title should work on all processors (#2490) --- .../processors/text_json_diff/processor.py | 6 ------ changedetectionio/update_worker.py | 10 ++++++++++ 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/changedetectionio/processors/text_json_diff/processor.py b/changedetectionio/processors/text_json_diff/processor.py index 1dc501a2..1de5bafb 100644 --- a/changedetectionio/processors/text_json_diff/processor.py +++ b/changedetectionio/processors/text_json_diff/processor.py @@ -338,12 +338,6 @@ class perform_site_check(difference_detection_processor): if blocked: changed_detected = False - # Extract title as title - if is_html: - if self.datastore.data['settings']['application'].get('extract_title_as_title') or watch['extract_title_as_title']: - if not watch['title'] or not len(watch['title']): - update_obj['title'] = html_tools.extract_element(find='title', html_content=self.fetcher.content) - logger.debug(f"Watch UUID {watch.get('uuid')} content check - Previous MD5: {watch.get('previous_md5')}, Fetched MD5 {fetched_md5}") if changed_detected: diff --git a/changedetectionio/update_worker.py b/changedetectionio/update_worker.py index a5af5c2b..fee09c5d 100644 --- a/changedetectionio/update_worker.py +++ b/changedetectionio/update_worker.py @@ -505,6 +505,16 @@ class update_worker(threading.Thread): if update_handler.xpath_data: watch.save_xpath_data(data=update_handler.xpath_data) + # Extract <title> as title if possible/requested. + if self.datastore.data['settings']['application'].get('extract_title_as_title') or watch['extract_title_as_title']: + if not watch['title'] or not len(watch['title']): + try: + update_obj['title'] = html_tools.extract_element(find='title', html_content=update_handler.fetcher.content) + logger.info(f"UUID: {uuid} Extract <title> updated title to '{update_obj['title']}") + except Exception as e: + logger.warning(f"UUID: {uuid} Extract <title> as watch title was enabled, but couldn't find a <title>.") + + # Now update after running everything try: self.datastore.update_watch(uuid=uuid, update_obj=update_obj) From bba9a218d40e9b39bfbf3705d95ac5dbc7a38d2d Mon Sep 17 00:00:00 2001 From: dgtlmoon <dgtlmoon@gmail.com> Date: Sat, 13 Jul 2024 11:57:36 +0200 Subject: [PATCH 2/3] Style fixes --- changedetectionio/static/styles/scss/styles.scss | 3 +++ changedetectionio/static/styles/styles.css | 3 +++ 2 files changed, 6 insertions(+) diff --git a/changedetectionio/static/styles/scss/styles.scss b/changedetectionio/static/styles/scss/styles.scss index aa805285..044ee0ac 100644 --- a/changedetectionio/static/styles/scss/styles.scss +++ b/changedetectionio/static/styles/scss/styles.scss @@ -1118,6 +1118,9 @@ ul { color: #fff; opacity: 0.7; } + svg { + vertical-align: middle; + } @extend .inline-tag; } diff --git a/changedetectionio/static/styles/styles.css b/changedetectionio/static/styles/styles.css index b9469fd0..7d3b6ba8 100644 --- a/changedetectionio/static/styles/styles.css +++ b/changedetectionio/static/styles/styles.css @@ -1194,6 +1194,9 @@ ul { color: #fff; opacity: 0.7; } +.restock-label svg { + vertical-align: middle; } + #chrome-extension-link { padding: 9px; border: 1px solid var(--color-grey-800); From e05796f81e29d30e35a89b8eb89f1036eadde714 Mon Sep 17 00:00:00 2001 From: dgtlmoon <dgtlmoon@gmail.com> Date: Sat, 13 Jul 2024 11:58:02 +0200 Subject: [PATCH 3/3] Form label improvements --- changedetectionio/processors/restock_diff/forms.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/changedetectionio/processors/restock_diff/forms.py b/changedetectionio/processors/restock_diff/forms.py index 1ab01e6e..181dc22d 100644 --- a/changedetectionio/processors/restock_diff/forms.py +++ b/changedetectionio/processors/restock_diff/forms.py @@ -13,7 +13,7 @@ class processor_settings_form(processor_text_json_diff_form): render_kw={"placeholder": "No limit", "size": "10"}) price_change_max = FloatField('Maximum amount to trigger notification', [validators.Optional()], render_kw={"placeholder": "No limit", "size": "10"}) - price_change_threshold_percent = FloatField('Threshold in % for price changes', validators=[ + price_change_threshold_percent = FloatField('Threshold in % for price changes since the original price', validators=[ validators.Optional(), validators.NumberRange(min=0, max=100, message="Should be between 0 and 100"), ], render_kw={"placeholder": "0%", "size": "5"}) @@ -37,12 +37,13 @@ class processor_settings_form(processor_text_json_diff_form): <div class="pure-control-group"> <fieldset class="pure-group"> {{ render_checkbox_field(form.in_stock_only) }} - <span class="pure-form-message-inline">Only trigger notifications when page changes from <strong>out of stock</strong> to <strong>back in stock</strong></span> + <span class="pure-form-message-inline">Only trigger re-stock notification when page changes from <strong>out of stock</strong> to <strong>back in stock</strong></span> </fieldset> <fieldset class="pure-group"> {{ render_checkbox_field(form.follow_price_changes) }} <span class="pure-form-message-inline">Changes in price should trigger a notification</span> - <span class="pure-form-message-inline">When OFF - only care about restock detection</span> + <br> + <span class="pure-form-message-inline">When OFF - Only care about restock detection</span> </fieldset> <fieldset class="pure-group price-change-minmax"> {{ render_field(form.price_change_min, placeholder=watch['restock']['price']) }} @@ -55,7 +56,8 @@ class processor_settings_form(processor_text_json_diff_form): <fieldset class="pure-group price-change-minmax"> {{ render_field(form.price_change_threshold_percent) }} <span class="pure-form-message-inline">Price must change more than this % to trigger a change.</span><br> - <span class="pure-form-message-inline">For example, If the product is $1,000 USD, <strong>2%</strong> would mean it has to change more than $20 since the first check.</span><br> + <span class="pure-form-message-inline">For example, If the product is $1,000 USD originally, <strong>2%</strong> would mean it has to change more than $20 since the first check.</span><br> + </fieldset> </div> </fieldset>""" \ No newline at end of file