From 7921cb00e173a76586c7fa7d739f8714d2922630 Mon Sep 17 00:00:00 2001 From: Ariya Hidayat Date: Sat, 22 Sep 2012 13:39:19 -0700 Subject: [PATCH 1/3] Remove non-working weather example. The example stops working since the request is blocked. It needs a rewrite to use a different service. http://code.google.com/p/phantomjs/issues/detail?id=794 --- examples/weather.coffee | 49 ---------------------------------- examples/weather.js | 58 ----------------------------------------- 2 files changed, 107 deletions(-) delete mode 100644 examples/weather.coffee delete mode 100644 examples/weather.js diff --git a/examples/weather.coffee b/examples/weather.coffee deleted file mode 100644 index 2b7fa785..00000000 --- a/examples/weather.coffee +++ /dev/null @@ -1,49 +0,0 @@ -# Get weather info for given address (or for the default one, "Mountain View") - -page = require('webpage').create() -system = require 'system' -address = 'Mountain View' #< default value - -# Route "console.log()" calls from within the Page context to the main Phantom context (i.e. current "this") -page.onConsoleMessage = (msg) -> - console.log msg - -# Print usage message, if no address is passed -if system.args.length < 2 - console.log 'Usage: weather.coffee [address]' -else - address = Array.prototype.slice.call(system.args, 1).join(' ') - -# Heading -console.log "*** Loading weather information for '#{address}' ***\n" - -# Open Google "secret" Weather API and, onPageLoad, do... -page.open encodeURI("http://www.google.com/ig/api?weather=#{address}"), (status) -> - # Check for page load success - if status isnt 'success' - console.log 'Unable to access network' - else - # Execute some DOM inspection within the page context - page.evaluate -> - if document.querySelectorAll('problem_cause').length > 0 - console.log "No data available for #{address}" - else - data = (s, e) -> - e = e or document - el = e.querySelector s - if el then el.attributes.data.value else undefined - - console.log """City: #{data 'weather > forecast_information > city'} - Current condition: #{data 'weather > current_conditions > condition'} - Temperature: #{data 'weather > current_conditions > temp_f'} F - #{data 'weather > current_conditions > humidity'} - #{data 'weather > current_conditions > wind_condition'}\n - """ - - forecasts = document.querySelectorAll 'weather > forecast_conditions' - for i in forecasts - console.log "#{ data 'day_of_week', i }: " + - "#{ data 'low', i }-" + - "#{ data 'high', i } F " + - "#{ data 'condition', i }" - phantom.exit() diff --git a/examples/weather.js b/examples/weather.js deleted file mode 100644 index 641e3a9b..00000000 --- a/examples/weather.js +++ /dev/null @@ -1,58 +0,0 @@ -// Get weather info for given address (or for the default one, "Mountain View") - -var page = require('webpage').create(), - system = require('system'), - address = "Mountain View"; //< default value - -// Route "console.log()" calls from within the Page context to the main Phantom context (i.e. current "this") -page.onConsoleMessage = function(msg) { - console.log(msg); -}; - -// Print usage message, if no address is passed -if (system.args.length < 2) { - console.log("Usage: weather.js [address]"); -} else { - address = Array.prototype.slice.call(system.args, 1).join(' '); -} - -// Heading -console.log("*** Loading weather information for '" + address + "' ***\n"); - -// Open Google "secret" Weather API and, onPageLoad, do... -page.open(encodeURI('http://www.google.com/ig/api?weather=' + address), function (status) { - // Check for page load success - if (status !== "success") { - console.log("Unable to access network"); - } else { - // Execute some DOM inspection within the page context - page.evaluate(function() { - if (document.querySelectorAll('problem_cause').length > 0) { - console.log('No data available for ' + address); - } else { - function data (s, e) { - var el; - e = e || document; - el = e.querySelector(s); - return el ? el.attributes.data.value : undefined; - }; - - console.log('City: ' + data('weather > forecast_information > city')); - console.log('Current condition: ' + data('weather > current_conditions > condition')); - console.log('Temperature: ' + data('weather > current_conditions > temp_f') + ' F'); - console.log(data('weather > current_conditions > humidity')); - console.log(data('weather > current_conditions > wind_condition')); - console.log(''); - - var forecasts = document.querySelectorAll('weather > forecast_conditions'); - for (var i = 0; i < forecasts.length; ++i) { - var f = forecasts[i]; - console.log(data('day_of_week', f) + ': ' + - data('low', f) + '-' + data('high', f) + ' F ' + - data('condition', f)); - } - } - }); - } - phantom.exit(); -}); From e5b040ed1a7c249421b0e4f17c1a05fc1bf6c587 Mon Sep 17 00:00:00 2001 From: Ariya Hidayat Date: Sat, 22 Sep 2012 19:58:04 -0700 Subject: [PATCH 2/3] Advertise the migrated wiki pages. --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 3e104421..dafc54de 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # [PhantomJS](http://phantomjs.org) - Scriptable Headless WebKit -PhantomJS ([www.phantomjs.org](http://phantomjs.org)) is a headless WebKit scriptable with JavaScript or CoffeeScript. It is used by hundreds of [developers](http://code.google.com/p/phantomjs/wiki/ExternalArticles) and dozens of [organizations](http://code.google.com/p/phantomjs/wiki/WhoUsesPhantomJS) for web-related development workflow. +PhantomJS ([www.phantomjs.org](http://phantomjs.org)) is a headless WebKit scriptable with JavaScript or CoffeeScript. It is used by hundreds of [developers](https://github.com/ariya/phantomjs/wiki/Buzz) and dozens of [organizations](https://github.com/ariya/phantomjs/wiki/Users) for web-related development workflow. The latest [stable release](http://code.google.com/p/phantomjs/wiki/ReleaseNotes) is version 1.6 (codenamed "Lavender"). Follow the official Twitter stream [@PhantomJS](http://twitter.com/PhantomJS) to get the frequent development updates. @@ -33,12 +33,12 @@ PhantomJS needs not be used only as a stand-alone tool. Check also some excellen - [GhostDriver](http://github.com/detro/ghostdriver/) complements Selenium tests with a PhantomJS WebDriver implementation. - [PhantomRobot](https://github.com/datakurre/phantomrobot) runs Robot Framework acceptance tests in the background via PhantomJS. -and many others [companion projects](http://code.google.com/p/phantomjs/wiki/WhoUsesPhantomJS). +and many others [related projects](https://github.com/ariya/phantomjs/wiki/Related-Projects). ## Questions? - Explore the complete [documentation](http://code.google.com/p/phantomjs/wiki/PhantomJS?tm=6). -- Read tons of [user articles](http://code.google.com/p/phantomjs/wiki/ExternalArticles) on using PhantomJS. +- Read tons of [user articles](https://github.com/ariya/phantomjs/wiki/Buzz) on using PhantomJS. - Join the [mailing-list](http://groups.google.com/group/phantomjs) and discuss with other PhantomJS fans. PhantomJS is free software/open source, and is distributed under the [BSD license](http://opensource.org/licenses/BSD-3-Clause). It contains third-party code, see the included `third-party.txt` file for the license information on third-party code. From b9e1ced36f31740ad38465a081323dc62d323f5f Mon Sep 17 00:00:00 2001 From: Ariya Hidayat Date: Sat, 22 Sep 2012 20:24:58 -0700 Subject: [PATCH 3/3] Bracing for "Blazing Star". http://code.google.com/p/phantomjs/issues/detail?id=764 --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index dafc54de..86b7fb1e 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ PhantomJS ([www.phantomjs.org](http://phantomjs.org)) is a headless WebKit scriptable with JavaScript or CoffeeScript. It is used by hundreds of [developers](https://github.com/ariya/phantomjs/wiki/Buzz) and dozens of [organizations](https://github.com/ariya/phantomjs/wiki/Users) for web-related development workflow. -The latest [stable release](http://code.google.com/p/phantomjs/wiki/ReleaseNotes) is version 1.6 (codenamed "Lavender"). Follow the official Twitter stream [@PhantomJS](http://twitter.com/PhantomJS) to get the frequent development updates. +The latest [stable release](http://phantomjs.org/release-1.7.html) is version 1.7 (codenamed "Blazing Star"). Follow the official Twitter stream [@PhantomJS](http://twitter.com/PhantomJS) to get the frequent development updates. **Note**: Please **do not** create a GitHub pull request **without** reading the [Contribution Guide](https://github.com/ariya/phantomjs/blob/master/CONTRIBUTING.md) first. Failure to do so may result in the rejection of the pull request.