From edf0a3a50dce03a81192fb3e09a904728b2c9be3 Mon Sep 17 00:00:00 2001 From: Noah Levitt Date: Tue, 20 Dec 2016 17:34:29 -0800 Subject: [PATCH] convert mouseovers and simpleclicks to jinja2 --- brozzler/behaviors.yaml | 7 +++++++ brozzler/js-templates/mouseovers.js.j2 | 7 ++----- brozzler/js-templates/simpleclicks.js.j2 | 7 ++----- setup.py | 2 +- 4 files changed, 12 insertions(+), 11 deletions(-) diff --git a/brozzler/behaviors.yaml b/brozzler/behaviors.yaml index 34c6334..1130bcc 100644 --- a/brozzler/behaviors.yaml +++ b/brozzler/behaviors.yaml @@ -42,36 +42,42 @@ behavior_js_template: simpleclicks.js.j2 default_parameters: click_css_selector: img.img-responsive + click_until_hard_timeout: False request_idle_timeout_sec: 10 - # acalog https://webarchive.jira.com/browse/ARI-3775 url_regex: '^https?://.*[?&]catoid=[^?]*$' behavior_js_template: simpleclicks.js.j2 default_parameters: click_css_selector: a[onclick] + click_until_hard_timeout: False request_idle_timeout_sec: 10 - # https://webarchive.jira.com/browse/ARI-3956 url_regex: '^https?://(?:www\.)?usask.ca/.*$' behavior_js_template: simpleclicks.js.j2 default_parameters: click_css_selector: a[id='feature-next'] + click_until_hard_timeout: False request_idle_timeout_sec: 10 - # https://webarchive.jira.com/browse/AITFIVE-451 url_regex: '^https?://(?:www\.)?soundcloud.com/.*$' behavior_js_template: simpleclicks.js.j2 default_parameters: click_css_selector: button.sc-button-play, button.playButton + click_until_hard_timeout: False request_idle_timeout_sec: 10 - # https://webarchive.jira.com/browse/AITFIVE-463 url_regex: '^https?://(?:www\.)?christophercerrone.com/.*$' behavior_js_template: simpleclicks.js.j2 default_parameters: click_css_selector: button.playButton.medium + click_until_hard_timeout: False request_idle_timeout_sec: 10 - # https://webarchive.jira.com/browse/ARI-4690 url_regex: '^https?://(?:www\.)?youtube.com/.*$' behavior_js_template: simpleclicks.js.j2 default_parameters: click_css_selector: span.load-more-text + click_until_hard_timeout: False request_idle_timeout_sec: 10 - # https://webarchive.jira.com/browse/ARI-4725 url_regex: '^https?://(?:www\.)?moma.org/.*$' @@ -88,6 +94,7 @@ behavior_js_template: mouseovers.js.j2 default_parameters: mouseover_css_selector: .menu-item a + mouseover_until_hard_timeout: False request_idle_timeout_sec: 10 - # default fallback behavior url_regex: '^.*$' diff --git a/brozzler/js-templates/mouseovers.js.j2 b/brozzler/js-templates/mouseovers.js.j2 index f4d6173..8521387 100644 --- a/brozzler/js-templates/mouseovers.js.j2 +++ b/brozzler/js-templates/mouseovers.js.j2 @@ -26,11 +26,8 @@ var umbraBehavior = { var mouseoveredSomething = false; var somethingLeftBelow = false; var somethingLeftAbove = false; - var cssSelector = "${mouseover_css_selector}"; - var mouseoverUntilTimeout = "${mouseover_until_hard_timeout}"; - - //handle Python to JavaScript boolean conversion - mouseoverUntilTimeout == "True" ? mouseoverUntilTimeout = true : mouseoverUntilTimeout = false; + var cssSelector = {{mouseover_css_selector|json}}; + var mouseoverUntilTimeout = {{mouseover_until_hard_timeout|json}}; var iframes = document.querySelectorAll("iframe"); var documents = Array(iframes.length + 1); diff --git a/brozzler/js-templates/simpleclicks.js.j2 b/brozzler/js-templates/simpleclicks.js.j2 index 282c096..95f0008 100644 --- a/brozzler/js-templates/simpleclicks.js.j2 +++ b/brozzler/js-templates/simpleclicks.js.j2 @@ -26,11 +26,8 @@ var umbraBehavior = { var clickedSomething = false; var somethingLeftBelow = false; var somethingLeftAbove = false; - var cssSelector = "${click_css_selector}"; - var clickUntilTimeout = "${click_until_hard_timeout}"; - - //handle Python to JavaScript boolean conversion - clickUntilTimeout == "True" ? clickUntilTimeout = true : clickUntilTimeout = false; + var cssSelector = {{click_css_selector|json}}; + var clickUntilTimeout = {{click_until_hard_timeout|json}}; var iframes = document.querySelectorAll("iframe"); var documents = Array(iframes.length + 1); diff --git a/setup.py b/setup.py index 3ac8a06..54681de 100644 --- a/setup.py +++ b/setup.py @@ -32,7 +32,7 @@ def find_package_data(package): setuptools.setup( name='brozzler', - version='1.1b9.dev150', + version='1.1b9.dev151', description='Distributed web crawling with browsers', url='https://github.com/internetarchive/brozzler', author='Noah Levitt',