trackchange 0.4.0 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.md +33 -4
- data/lib/trackchange/dependencies.rb +0 -1
- data/lib/trackchange/exec.rb +1 -1
- data/lib/trackchange/probe.rb +9 -1
- data/lib/trackchange/query.coffee +23 -0
- data/lib/trackchange/version.rb +1 -1
- metadata +5 -4
data/README.md
CHANGED
@@ -57,13 +57,15 @@ substituted by the requested site url.
|
|
57
57
|
|
58
58
|
The default command is
|
59
59
|
|
60
|
-
lynx -dump '%url%' | uniq
|
60
|
+
lynx -nolist -dump '%url%' | uniq
|
61
61
|
|
62
62
|
Here are some alternatives you might want to experiment
|
63
63
|
with. (Unfortunately pandoc only works with http, not with https and
|
64
64
|
does not follow redirects, hence the version with curl.)
|
65
65
|
|
66
66
|
lynx -dump '%url%' | uniq | sed -e "/References/,/\s+[0-9]+\. h/d"
|
67
|
+
|
68
|
+
lynx -nolist -dump '%url%' | uniq
|
67
69
|
|
68
70
|
pandoc '%url%' -t markdown
|
69
71
|
|
@@ -71,18 +73,45 @@ does not follow redirects, hence the version with curl.)
|
|
71
73
|
|
72
74
|
curl -sL '%url%' | pandoc -t plain
|
73
75
|
|
74
|
-
|
76
|
+
phantomjs %queryscript% '%url%' '%selector%'
|
77
|
+
|
78
|
+
|
79
|
+
### rss_path (optional)
|
75
80
|
|
76
81
|
...
|
77
82
|
|
78
|
-
### feed_size
|
83
|
+
### feed_size (optional)
|
79
84
|
|
80
85
|
...
|
81
86
|
|
82
|
-
### log_level
|
87
|
+
### log_level (optional)
|
83
88
|
|
84
89
|
...
|
85
90
|
|
91
|
+
### sites (mandatory)
|
92
|
+
|
93
|
+
A list of sites, with the following properites.
|
94
|
+
|
95
|
+
#### url (mandatory)
|
96
|
+
|
97
|
+
The url of the site to be tracked.
|
98
|
+
|
99
|
+
#### threshold (optional)
|
100
|
+
|
101
|
+
If a threshold is given, no notification will be sent if the number of
|
102
|
+
changed lines is below or equal the given vaule.
|
103
|
+
|
104
|
+
#### selector (optional)
|
105
|
+
|
106
|
+
If a selector is given, it will be used as a CSS3 selector to reduce
|
107
|
+
the output to. The selector feature is only available if trackchange
|
108
|
+
is configured to use phantomjs to fetch the content, i.e.
|
109
|
+
|
110
|
+
fetch: phantomjs %queryscript% '%url%' '%selector%'
|
111
|
+
|
112
|
+
The query script will return plain text. If no selector is given, the
|
113
|
+
query script will select the body tag by default.
|
114
|
+
|
86
115
|
|
87
116
|
## Contributing
|
88
117
|
|
data/lib/trackchange/exec.rb
CHANGED
@@ -98,7 +98,7 @@ module Trackchange
|
|
98
98
|
# upgrade from 0.3.0 to 0.4.0
|
99
99
|
if v(data[:version]) < v('0.4.0')
|
100
100
|
data[:version ] = '0.4.0'
|
101
|
-
data[:fetch] = "lynx -dump '%url%' | uniq"
|
101
|
+
data[:fetch] = "lynx -nolist -dump '%url%' | uniq"
|
102
102
|
data[:feed_size] = 20
|
103
103
|
@config = OpenStruct.new(data)
|
104
104
|
store_config!
|
data/lib/trackchange/probe.rb
CHANGED
@@ -20,7 +20,15 @@ module Trackchange
|
|
20
20
|
url = site[:url]
|
21
21
|
fname = url.sub(%r{https?://}, '').tr_s('/?&', '...')
|
22
22
|
site_path = File.expand_path(fname, '~/.trackchange')
|
23
|
-
|
23
|
+
|
24
|
+
# build cmd
|
25
|
+
cmd = config.fetch + "> #{site_path}.new"
|
26
|
+
substitutions = {
|
27
|
+
url: url,
|
28
|
+
queryscript: File.expand_path('../query.coffee', __FILE__),
|
29
|
+
selector: site[:selector]
|
30
|
+
}
|
31
|
+
substitutions.each { |key, value| cmd = cmd.gsub("%#{key}%", value.to_s) }
|
24
32
|
logger.debug "% #{cmd}"
|
25
33
|
system cmd
|
26
34
|
|
@@ -0,0 +1,23 @@
|
|
1
|
+
page = require('webpage').create()
|
2
|
+
sys = require('system')
|
3
|
+
|
4
|
+
if (sys.args.length < 2 || sys.args.length > 3)
|
5
|
+
console.log 'Usage: select.coffee URL [selector]'
|
6
|
+
phantom.exit
|
7
|
+
|
8
|
+
address = sys.args[1]
|
9
|
+
selector = sys.args[2] || 'body'
|
10
|
+
|
11
|
+
query = (selector) ->
|
12
|
+
document.querySelector(selector).innerText
|
13
|
+
|
14
|
+
storePageAndExit = ->
|
15
|
+
result = page.evaluate query, selector
|
16
|
+
console.log result
|
17
|
+
phantom.exit()
|
18
|
+
|
19
|
+
page.open address, (status) ->
|
20
|
+
if status != 'success'
|
21
|
+
console.log 'Unable to load the address!'
|
22
|
+
phantom.exit 1
|
23
|
+
window.setTimeout storePageAndExit, 200
|
data/lib/trackchange/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: trackchange
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2015-
|
12
|
+
date: 2015-02-19 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: cronedit
|
@@ -77,6 +77,7 @@ files:
|
|
77
77
|
- lib/trackchange/dependencies.rb
|
78
78
|
- lib/trackchange/exec.rb
|
79
79
|
- lib/trackchange/probe.rb
|
80
|
+
- lib/trackchange/query.coffee
|
80
81
|
- lib/trackchange/version.rb
|
81
82
|
- trackchange.gemspec
|
82
83
|
homepage: ''
|
@@ -94,7 +95,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
94
95
|
version: '0'
|
95
96
|
segments:
|
96
97
|
- 0
|
97
|
-
hash:
|
98
|
+
hash: 1290840265357501692
|
98
99
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
99
100
|
none: false
|
100
101
|
requirements:
|
@@ -103,7 +104,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
103
104
|
version: '0'
|
104
105
|
segments:
|
105
106
|
- 0
|
106
|
-
hash:
|
107
|
+
hash: 1290840265357501692
|
107
108
|
requirements: []
|
108
109
|
rubyforge_project:
|
109
110
|
rubygems_version: 1.8.23
|