used a drop down menu and rewrote checking code to fit GUI description

diff-proposed-for-bwees
bwees 3 years ago
parent 8ee42d2403
commit dc3fc6cfdf

@ -278,23 +278,18 @@ class perform_site_check():
logging.debug("check_unique_lines: UUID {} had unique content".format(uuid)) logging.debug("check_unique_lines: UUID {} had unique content".format(uuid))
if changed_detected: if changed_detected:
diff_filters = { if watch.get("trigger_type", "all") != "all": # if we are supposed to filter any diff types
"add": watch.get('trigger_on_add', True),
"del": watch.get('trigger_on_del', True),
}
if False in diff_filters.values(): # if we are supposed to filter any diff types
print("Diff Filters Active: " + str(diff_filters))
# get the diff types present in the watch # get the diff types present in the watch
diff_types = watch.get_diff_types(text_content_before_ignored_filter) diff_types = watch.get_diff_types(text_content_before_ignored_filter)
print("Diff components found: " + str(diff_types)) print("Diff components found: " + str(diff_types))
# for each diff type, if the filter setting is false, and the diff type is present, then set the changed_detected to false # Only Additions
for diff_type in diff_types: if watch["trigger_type"] == "add" and not diff_types["add"] and diff_types["del"]:
if not diff_filters[diff_type] and diff_types[diff_type]: changed_detected = False
changed_detected = False
break # we only need to check one diff type # Only Deletions
elif watch["trigger_type"] == "delete" and not diff_types["del"] and diff_types["add"]:
changed_detected = False
# Always record the new checksum and the new text # Always record the new checksum and the new text
update_obj["previous_md5"] = fetched_md5 update_obj["previous_md5"] = fetched_md5

@ -8,7 +8,6 @@ from wtforms import (
PasswordField, PasswordField,
RadioField, RadioField,
SelectField, SelectField,
SelectMultipleField,
StringField, StringField,
SubmitField, SubmitField,
TextAreaField, TextAreaField,
@ -344,8 +343,7 @@ class watchForm(commonSettingsForm):
check_unique_lines = BooleanField('Only trigger when new lines appear', default=False) check_unique_lines = BooleanField('Only trigger when new lines appear', default=False)
trigger_text = StringListField('Trigger/wait for text', [validators.Optional(), ValidateListRegex()]) trigger_text = StringListField('Trigger/wait for text', [validators.Optional(), ValidateListRegex()])
text_should_not_be_present = StringListField('Block change-detection if text matches', [validators.Optional(), ValidateListRegex()]) text_should_not_be_present = StringListField('Block change-detection if text matches', [validators.Optional(), ValidateListRegex()])
trigger_on_add = BooleanField('Additions', default=True) trigger_type = SelectField(u'Trigger On', choices=[("all", "Any Changes"), ("add", "Only Additions"), ("delete", "Only Deletions")], coerce=str, default="add")
trigger_on_del = BooleanField('Deletions', default=True)
webdriver_js_execute_code = TextAreaField('Execute JavaScript before change detection', render_kw={"rows": "5"}, validators=[validators.Optional()]) webdriver_js_execute_code = TextAreaField('Execute JavaScript before change detection', render_kw={"rows": "5"}, validators=[validators.Optional()])

@ -43,8 +43,7 @@ class model(dict):
'fetch_backend': None, 'fetch_backend': None,
'extract_title_as_title': False, 'extract_title_as_title': False,
'check_unique_lines': False, # On change-detected, compare against all history if its something new 'check_unique_lines': False, # On change-detected, compare against all history if its something new
'trigger_on_add': True, # Allow a trigger if there are additions from the last snapshot 'trigger_type': "all",
'trigger_on_del': True, # Allow a trigger if there are deletions from the last snapshot
'proxy': None, # Preferred proxy connection 'proxy': None, # Preferred proxy connection
# Re #110, so then if this is set to None, we know to use the default value instead # Re #110, so then if this is set to None, we know to use the default value instead
# Requires setting to None on submit if it's the same as the default # Requires setting to None on submit if it's the same as the default

@ -157,13 +157,11 @@ User-Agent: wonderbra 1.0") }}
</div> </div>
</fieldset> </fieldset>
<fieldset> <fieldset>
<div class="pure-control-group"> <div class="pure-control-group" id="request-method">
<label for="trigger-type">Trigger On</label> {{ render_field(form.trigger_type) }}
{{ render_checkbox_field(form.trigger_on_add, class="trigger-type") }}
{{ render_checkbox_field(form.trigger_on_del, class="trigger-type") }}
<span class="pure-form-message-inline"> <span class="pure-form-message-inline">
This filter only compares to the previous snapshot. This is different from the "Only trigger when new lines appear" setting which checks all previous snapshots. This filter only compares to the previous snapshot. This is different from the "Only trigger when new lines appear" setting which checks all previous snapshots.
This is good for filtering out notifications for only content being removed. This is good for filtering out notifications that only are showing deleted content. (i.e A notice being removed from a website)
</span> </span>
</div> </div>
</fieldset> </fieldset>

Loading…
Cancel
Save