weblicate 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +13 -6
- data/Rakefile +1 -1
- data/bin/weblicate +5 -5
- data/lib/weblicate/har.rb +10 -8
- metadata +3 -3
data/README.rdoc
CHANGED
@@ -6,6 +6,8 @@ Weblicate creates a copy of a web page, complete with third party assets, to be
|
|
6
6
|
When given a HAR file, weblicate writes all assets to local disk. It appends a domain to the end of all
|
7
7
|
URLs so you can simulate external requests from sites like doubleclick and google.
|
8
8
|
|
9
|
+
HAR, (or HTTP Archive) files are a great way to pass around information about web pages. Firebug lets you export them.
|
10
|
+
|
9
11
|
== Installation
|
10
12
|
|
11
13
|
You need Ruby and RubyGems installed
|
@@ -16,17 +18,22 @@ You need Ruby and RubyGems installed
|
|
16
18
|
|
17
19
|
Running the following command:
|
18
20
|
|
19
|
-
weblicate www.cnn.com.har
|
21
|
+
weblicate www.cnn.com.har
|
20
22
|
|
21
23
|
generates the following output:
|
22
24
|
|
23
|
-
|
24
|
-
|
25
|
-
|
25
|
+
www.cnn.com-files # All files and assets for the page
|
26
|
+
www.cnn.com-hosts # Entries that can be added to your local hosts file
|
27
|
+
www.cnn.com-vhosts # Apache vhosts entries for all domains
|
28
|
+
|
29
|
+
By default, weblicate appends '.localhost' to all domains. You can over ride
|
30
|
+
this if you want you weblicant to be accessible to the greater internet.
|
31
|
+
|
32
|
+
weblicate www.cnn.com.har yourdomain.com
|
26
33
|
|
27
|
-
|
34
|
+
Weblicate generates a script that creates the domains. It Works For Me.
|
28
35
|
|
29
|
-
|
36
|
+
www.cnn.com-dns # A script to create DNS entries (on Slicehost.com)
|
30
37
|
|
31
38
|
== Copyright
|
32
39
|
|
data/Rakefile
CHANGED
@@ -5,7 +5,7 @@ begin
|
|
5
5
|
require 'jeweler'
|
6
6
|
Jeweler::Tasks.new do |gem|
|
7
7
|
gem.name = "weblicate"
|
8
|
-
gem.version = '0.0.
|
8
|
+
gem.version = '0.0.5'
|
9
9
|
gem.summary = %Q{Replicate a website}
|
10
10
|
gem.description = %Q{Replicate a website based on a HAR file}
|
11
11
|
gem.email = "mike@bailey.net.au"
|
data/bin/weblicate
CHANGED
@@ -8,10 +8,10 @@ dest_domain = ARGV[1] || nil
|
|
8
8
|
a = Har.new harfile, :dest_domain => dest_domain
|
9
9
|
a.get_files
|
10
10
|
|
11
|
-
files_dir = a.
|
12
|
-
vhosts_file = a.
|
13
|
-
hosts_file = a.
|
14
|
-
dns_script = a.
|
11
|
+
files_dir = a.name + '-files'
|
12
|
+
vhosts_file = a.name + '-vhosts'
|
13
|
+
hosts_file = a.name + '-hosts'
|
14
|
+
dns_script = a.name + '-dns'
|
15
15
|
|
16
16
|
File.open(vhosts_file, 'w') { |file| file.write(a.vhosts) }
|
17
17
|
File.open(hosts_file, 'w') { |file| file.write(a.hosts_file) }
|
@@ -21,7 +21,7 @@ puts <<-EOF
|
|
21
21
|
|
22
22
|
Now run these commands...
|
23
23
|
|
24
|
-
rsync -avz #{files_dir}/ #{a.dest_domain}:/var/www/weblicate/
|
24
|
+
rsync -avz #{files_dir}/ #{a.dest_domain}:/var/www/weblicate/#{a.name}/
|
25
25
|
scp #{vhosts_file} #{a.dest_domain}:/etc/apache2/sites-enabled/
|
26
26
|
cat #{hosts_file} >> /etc/hosts # For access from workstation
|
27
27
|
|
data/lib/weblicate/har.rb
CHANGED
@@ -8,8 +8,7 @@ require 'net/http'
|
|
8
8
|
|
9
9
|
class Har
|
10
10
|
|
11
|
-
attr_accessor :dest_domain
|
12
|
-
attr_reader :har_file, :har_title
|
11
|
+
attr_accessor :dest_domain, :name
|
13
12
|
|
14
13
|
def initialize(harfile, options={})
|
15
14
|
@dest_domain = options[:dest_domain] || 'localhost'
|
@@ -19,8 +18,7 @@ class Har
|
|
19
18
|
else
|
20
19
|
contents = harfile
|
21
20
|
end
|
22
|
-
@
|
23
|
-
@har_title = File.basename(harfile, '.har')
|
21
|
+
@name = File.basename(harfile, '.har')
|
24
22
|
@har = JSON.parse(contents)
|
25
23
|
end
|
26
24
|
|
@@ -55,9 +53,13 @@ class Har
|
|
55
53
|
|
56
54
|
def save_file(url, contents)
|
57
55
|
uri = URI.parse(url)
|
58
|
-
dest = File.join("#{@
|
56
|
+
dest = File.join("#{@name}-files", uri.host+'.'+@dest_domain, uri.path)
|
59
57
|
dest << 'index.html' if dest[-1,1] == '/'
|
60
|
-
|
58
|
+
begin
|
59
|
+
FileUtils.mkdir_p File.dirname dest
|
60
|
+
rescue
|
61
|
+
puts "Error! Could not create #{File.dirname dest}"
|
62
|
+
end
|
61
63
|
File.open(dest, "w") { |file| file.write contents }
|
62
64
|
rescue
|
63
65
|
puts "Failed to parse url (#{url})"
|
@@ -68,8 +70,8 @@ class Har
|
|
68
70
|
<<-EOF
|
69
71
|
<VirtualHost *:80>
|
70
72
|
ServerName #{host}.#{@dest_domain}
|
71
|
-
DocumentRoot /var/www/weblicate/#{host}.#{@dest_domain}
|
72
|
-
<Directory /var/www/weblicate/#{host}.#{@dest_domain}>
|
73
|
+
DocumentRoot /var/www/weblicate/#{@name}/#{host}.#{@dest_domain}
|
74
|
+
<Directory /var/www/weblicate/#{@name}/#{host}.#{@dest_domain}>
|
73
75
|
Order allow,deny
|
74
76
|
Allow from all
|
75
77
|
</Directory>
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: weblicate
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 21
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 5
|
10
|
+
version: 0.0.5
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Mike Bailey
|