sitemap2png 0.1.1 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/README.md +24 -0
- data/Rakefile +4 -0
- data/lib/sitemap2png/cli.rb +32 -21
- data/lib/sitemap2png/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
NmJkMzIwMTM4YTE3MWUzYzEzZjVhZjczZjE1NjA1M2U3MjYzOWU3OQ==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
YmZiNjhlZTAxNGU4NTMzYTY5NmEzOTdkZGMxYmNlZGJmMzA5ZjRkMg==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
NzI0ZTBhZjIzY2ZiZjgyOGYxMTZkNGU5OTY1ODRmNTllOTcxNWE2ZTI4ZjRi
|
10
|
+
NDI3ZTU5N2U4YWFkMWZmZmVkMWIzOTVjMTAzOWZmYWIyOTRkOTBhMjU0ODMw
|
11
|
+
ZmU4MWIwNjY3MjI2NTBjYjY3NWE3MDczMGEyNDI0NWJhODk3NGM=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
NDcyYjk1MGUwODcxMTRhZDljZjIyNzc0ODZhYzNjNmI4ODMyODZlY2I4OGIz
|
14
|
+
Y2I0ZjM4ZWE2YjlmZDI1MDY4MjUyMjFiMGQyNTdmMmU2NDk1MjE5Y2Q5Mjk1
|
15
|
+
YjE1ZGI5YjExYTQ0NTdlZDQ1ZDBhY2NhMGY4OWVmODdiMDBhNjA=
|
data/README.md
CHANGED
@@ -11,12 +11,36 @@
|
|
11
11
|
```
|
12
12
|
$ gem install sitemap2png
|
13
13
|
```
|
14
|
+
|
14
15
|
## Usage
|
15
16
|
|
16
17
|
The following tasks are available trough the command line.
|
17
18
|
|
18
19
|
```
|
19
20
|
Commands:
|
21
|
+
sitemap2png help [COMMAND] # Describe available commands or one specific command
|
22
|
+
sitemap2png load SITEMAP PATH WITH # Load sitemap.xml & save screenshots
|
23
|
+
```
|
24
|
+
|
25
|
+
## Commands
|
26
|
+
|
27
|
+
### load
|
28
|
+
|
29
|
+
```
|
30
|
+
Usage:
|
31
|
+
sitemap2png load SITEMAP PATH WITH
|
32
|
+
|
33
|
+
Options:
|
34
|
+
-w, [--with=N]
|
35
|
+
# Default: 1024
|
36
|
+
-d, [--delay=N]
|
37
|
+
# Default: 0
|
38
|
+
```
|
39
|
+
|
40
|
+
## Example Usage
|
41
|
+
|
42
|
+
```
|
43
|
+
$ sitemap2png load http://mysite.com/sitemap.xml /path/to/destination -w 1900
|
20
44
|
```
|
21
45
|
|
22
46
|
## Development
|
data/Rakefile
CHANGED
data/lib/sitemap2png/cli.rb
CHANGED
@@ -6,35 +6,46 @@ require 'fileutils'
|
|
6
6
|
module Sitemap2png
|
7
7
|
class Cli < Thor
|
8
8
|
|
9
|
-
desc "load SITEMAP
|
9
|
+
desc "load SITEMAP PATH WITH", "Load sitemap.xml & save screenshots"
|
10
|
+
method_option :with, :aliases => "-w", :type => :numeric, :default => 1024
|
10
11
|
method_option :delay, :aliases => "-d", :type => :numeric, :default => 0
|
11
|
-
def load(sitemap,
|
12
|
-
basedir = File.dirname(File.dirname(File.dirname(__FILE__)))
|
13
|
-
webkit2png = "#{basedir}/vendor/webkit2png"
|
12
|
+
def load(sitemap, path)
|
13
|
+
@basedir = File.dirname(File.dirname(File.dirname(__FILE__)))
|
14
|
+
@webkit2png = "#{@basedir}/vendor/webkit2png"
|
14
15
|
|
15
|
-
# validate
|
16
|
-
FileUtils.mkdir_p(
|
16
|
+
# validate path
|
17
|
+
FileUtils.mkdir_p(path) unless Dir.exists?(path)
|
17
18
|
|
19
|
+
load_sitemap(sitemap, path, options[:width], options[:delay])
|
18
20
|
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
21
|
+
end
|
22
|
+
|
23
|
+
no_tasks do
|
24
|
+
|
25
|
+
def load_sitemap(sitemap, path, width, delay)
|
26
|
+
begin
|
27
|
+
puts "Loading sitemap #{sitemap}"
|
28
|
+
xml = Net::HTTP.get_response(URI.parse(sitemap)).body
|
29
|
+
rescue Exception => error
|
30
|
+
raise Thor::Error, "Could not read sitemap!"
|
31
|
+
end
|
25
32
|
|
26
|
-
|
27
|
-
|
33
|
+
# validate data
|
34
|
+
doc = Nokogiri::XML(xml)
|
28
35
|
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
[640, 768, 1024, 1600].each do |width|
|
35
|
-
system "#{webkit2png} #{url} --thumb --dir=#{target} --width=#{width} --filename=#{name}-#{width} --delay=#{options[:delay]}"
|
36
|
+
doc.css('url > loc').each do |node|
|
37
|
+
url = node.text
|
38
|
+
name = File.basename(url, '.*')
|
39
|
+
puts "Taking shots from: #{url}"
|
40
|
+
system "#{@webkit2png} #{url} --thumb --dir=#{path} --width=#{width} --filename=#{name}-#{width} --delay=#{delay}"
|
36
41
|
end
|
42
|
+
|
43
|
+
doc.css('sitemap > loc').each do |node|
|
44
|
+
load_sitemap(node.text, path, width, delay)
|
45
|
+
end
|
46
|
+
|
37
47
|
end
|
48
|
+
|
38
49
|
end
|
39
50
|
|
40
51
|
end
|
data/lib/sitemap2png/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sitemap2png
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- franklin
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2014-01-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|