File tree Expand file tree Collapse file tree 1 file changed +8
-5
lines changed Expand file tree Collapse file tree 1 file changed +8
-5
lines changed Original file line number Diff line number Diff line change @@ -2,22 +2,25 @@ var system = require("system");
2
2
var page = require ( "webpage" ) . create ( ) ;
3
3
var url = system . args [ 1 ] ;
4
4
5
- function json ( o ) {
6
- console . log ( JSON . stringify ( o , null , 2 ) ) ;
5
+ /**
6
+ * Encode the passed object into JSON and output it to the standard output.
7
+ **/
8
+ function output ( payload ) {
9
+ console . log ( JSON . stringify ( payload , null , 2 ) ) ;
7
10
}
8
11
9
12
if ( ! url ) {
10
- json ( { error : "Missing url" } ) ;
13
+ output ( { error : "Missing url" } ) ;
11
14
phantom . exit ( ) ;
12
15
}
13
16
14
17
page . open ( url , function ( status ) {
15
18
if ( status !== "success" ) {
16
- json ( { error : "Unable to open " + url } ) ;
19
+ output ( { error : "Unable to open " + url } ) ;
17
20
return phantom . exit ( ) ;
18
21
}
19
22
page . injectJs ( "vendor/Readability.js" ) ;
20
- json ( page . evaluate ( function ( url ) {
23
+ output ( page . evaluate ( function ( url ) {
21
24
var location = document . location ;
22
25
var uri = {
23
26
spec : location . href ,
You can’t perform that action at this time.
0 commit comments