weblicate 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +1 -1
- data/bin/weblicate +22 -10
- data/lib/weblicate/har.rb +4 -1
- metadata +3 -3
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.4'
|
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
@@ -7,13 +7,25 @@ dest_domain = ARGV[1] || nil
|
|
7
7
|
|
8
8
|
a = Har.new harfile, :dest_domain => dest_domain
|
9
9
|
a.get_files
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
10
|
+
|
11
|
+
files_dir = a.har_title + '-files'
|
12
|
+
vhosts_file = a.har_title + '-vhosts'
|
13
|
+
hosts_file = a.har_title + '-hosts'
|
14
|
+
dns_script = a.har_title + '-dns'
|
15
|
+
|
16
|
+
File.open(vhosts_file, 'w') { |file| file.write(a.vhosts) }
|
17
|
+
File.open(hosts_file, 'w') { |file| file.write(a.hosts_file) }
|
18
|
+
File.open(dns_script, 'w') { |file| file.write(a.dns) }
|
19
|
+
|
20
|
+
puts <<-EOF
|
21
|
+
|
22
|
+
Now run these commands...
|
23
|
+
|
24
|
+
rsync -avz #{files_dir}/ #{a.dest_domain}:/var/www/weblicate/
|
25
|
+
scp #{vhosts_file} #{a.dest_domain}:/etc/apache2/sites-enabled/
|
26
|
+
cat #{hosts_file} >> /etc/hosts # For access from workstation
|
27
|
+
|
28
|
+
OPTIONAL - if you want access from the wider internet
|
29
|
+
sh #{dns_script} # Create domains on Slicehost
|
30
|
+
|
31
|
+
EOF
|
data/lib/weblicate/har.rb
CHANGED
@@ -9,6 +9,7 @@ require 'net/http'
|
|
9
9
|
class Har
|
10
10
|
|
11
11
|
attr_accessor :dest_domain
|
12
|
+
attr_reader :har_file, :har_title
|
12
13
|
|
13
14
|
def initialize(harfile, options={})
|
14
15
|
@dest_domain = options[:dest_domain] || 'localhost'
|
@@ -18,6 +19,8 @@ class Har
|
|
18
19
|
else
|
19
20
|
contents = harfile
|
20
21
|
end
|
22
|
+
@har_file = harfile
|
23
|
+
@har_title = File.basename(harfile, '.har')
|
21
24
|
@har = JSON.parse(contents)
|
22
25
|
end
|
23
26
|
|
@@ -52,7 +55,7 @@ class Har
|
|
52
55
|
|
53
56
|
def save_file(url, contents)
|
54
57
|
uri = URI.parse(url)
|
55
|
-
dest = File.join("
|
58
|
+
dest = File.join("#{@har_title}-files", uri.host+'.'+@dest_domain, uri.path)
|
56
59
|
dest << 'index.html' if dest[-1,1] == '/'
|
57
60
|
FileUtils.mkdir_p File.dirname dest
|
58
61
|
File.open(dest, "w") { |file| file.write contents }
|
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: 23
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 4
|
10
|
+
version: 0.0.4
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Mike Bailey
|