fromgit-url2mhtml 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/ChangeLog +7 -0
- data/README +50 -0
- data/Rakefile +114 -0
- data/bin/url2mhtml +7 -0
- data/doc/classes/Url2mhtml.html +260 -0
- data/doc/classes/Url2mhtml.src/M000001.html +21 -0
- data/doc/classes/Url2mhtml.src/M000002.html +25 -0
- data/doc/classes/Url2mhtml.src/M000003.html +23 -0
- data/doc/classes/Url2mhtml.src/M000004.html +41 -0
- data/doc/classes/Url2mhtml.src/M000005.html +18 -0
- data/doc/classes/Url2mhtml.src/M000006.html +30 -0
- data/doc/classes/Url2mhtml.src/M000007.html +30 -0
- data/doc/classes/Url2mhtml.src/M000008.html +22 -0
- data/doc/classes/Url2mhtmlTest.html +167 -0
- data/doc/classes/Url2mhtmlTest.src/M000009.html +17 -0
- data/doc/classes/Url2mhtmlTest.src/M000010.html +17 -0
- data/doc/classes/Url2mhtmlTest.src/M000011.html +19 -0
- data/doc/created.rid +1 -0
- data/doc/files/lib/url2mhtml_rb.html +110 -0
- data/doc/files/test/test_helper_rb.html +108 -0
- data/doc/files/test/url2mhtml_test_rb.html +108 -0
- data/doc/fr_class_index.html +28 -0
- data/doc/fr_file_index.html +29 -0
- data/doc/fr_method_index.html +37 -0
- data/doc/index.html +24 -0
- data/doc/rdoc-style.css +208 -0
- data/lib/url2mhtml.rb +106 -0
- data/test/test_helper.rb +3 -0
- data/test/url2mhtml_test.rb +16 -0
- metadata +105 -0
data/ChangeLog
ADDED
data/README
ADDED
@@ -0,0 +1,50 @@
|
|
1
|
+
|
2
|
+
= url2mhtml
|
3
|
+
|
4
|
+
|
5
|
+
== Description
|
6
|
+
|
7
|
+
|
8
|
+
== Installation
|
9
|
+
|
10
|
+
=== Archive Installation
|
11
|
+
|
12
|
+
rake install
|
13
|
+
|
14
|
+
=== Gem Installation
|
15
|
+
|
16
|
+
gem sources -a http://gems.github.com
|
17
|
+
gem install fromgit-url2mhtml
|
18
|
+
|
19
|
+
|
20
|
+
== Features/Problems
|
21
|
+
|
22
|
+
|
23
|
+
== Synopsis
|
24
|
+
|
25
|
+
|
26
|
+
== Copyright
|
27
|
+
|
28
|
+
Author:: forgithubid <forgithubid@gmail.com>
|
29
|
+
Copyright:: Copyright (c) 2008 forgithubid
|
30
|
+
License:: The MIT License
|
31
|
+
|
32
|
+
Copyright (c) 2008 forgithubid
|
33
|
+
|
34
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
35
|
+
of this software and associated documentation files (the "Software"), to deal
|
36
|
+
in the Software without restriction, including without limitation the rights
|
37
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
38
|
+
copies of the Software, and to permit persons to whom the Software is
|
39
|
+
furnished to do so, subject to the following conditions:
|
40
|
+
|
41
|
+
The above copyright notice and this permission notice shall be included in
|
42
|
+
all copies or substantial portions of the Software.
|
43
|
+
|
44
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
45
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
46
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
47
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
48
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
49
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
50
|
+
THE SOFTWARE.
|
data/Rakefile
ADDED
@@ -0,0 +1,114 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake'
|
3
|
+
require 'rake/clean'
|
4
|
+
require 'rake/testtask'
|
5
|
+
require 'rake/packagetask'
|
6
|
+
require 'rake/gempackagetask'
|
7
|
+
require 'rake/rdoctask'
|
8
|
+
require 'rake/contrib/rubyforgepublisher'
|
9
|
+
require 'rake/contrib/sshpublisher'
|
10
|
+
require 'fileutils'
|
11
|
+
require 'lib/url2mhtml'
|
12
|
+
include FileUtils
|
13
|
+
|
14
|
+
NAME = "url2mhtml"
|
15
|
+
AUTHOR = "forgithubid"
|
16
|
+
EMAIL = "forgithubid@gmail.com"
|
17
|
+
DESCRIPTION = "generate to MHTML from URL."
|
18
|
+
#RUBYFORGE_PROJECT = "url2mhtml"
|
19
|
+
HOMEPATH = "http://github.com/fromgit/url2mhtml/tree/master"
|
20
|
+
BIN_FILES = %w( url2mhtml )
|
21
|
+
|
22
|
+
VERS = Url2mhtml::VERSION
|
23
|
+
REV = File.read(".svn/entries")[/committed-rev="(d+)"/, 1] rescue nil
|
24
|
+
CLEAN.include ['**/.*.sw?', '*.gem', '.config']
|
25
|
+
RDOC_OPTS = [
|
26
|
+
'--title', "#{NAME} documentation",
|
27
|
+
"--charset", "utf-8",
|
28
|
+
"--opname", "index.html",
|
29
|
+
"--line-numbers",
|
30
|
+
"--main", "README",
|
31
|
+
"--inline-source",
|
32
|
+
]
|
33
|
+
|
34
|
+
task :default => [:test]
|
35
|
+
task :package => [:clean]
|
36
|
+
|
37
|
+
Rake::TestTask.new("test") do |t|
|
38
|
+
t.libs << "test"
|
39
|
+
t.pattern = "test/**/*_test.rb"
|
40
|
+
t.verbose = true
|
41
|
+
end
|
42
|
+
|
43
|
+
spec = Gem::Specification.new do |s|
|
44
|
+
s.name = NAME
|
45
|
+
s.version = VERS
|
46
|
+
s.platform = Gem::Platform::RUBY
|
47
|
+
s.has_rdoc = true
|
48
|
+
s.extra_rdoc_files = ["README", "ChangeLog"]
|
49
|
+
s.rdoc_options += RDOC_OPTS + ['--exclude', '^(examples|extras)/']
|
50
|
+
s.summary = DESCRIPTION
|
51
|
+
s.description = DESCRIPTION
|
52
|
+
s.author = AUTHOR
|
53
|
+
s.email = EMAIL
|
54
|
+
s.homepage = HOMEPATH
|
55
|
+
s.executables = BIN_FILES
|
56
|
+
# s.rubyforge_project = RUBYFORGE_PROJECT
|
57
|
+
s.bindir = "bin"
|
58
|
+
s.require_path = "lib"
|
59
|
+
#s.autorequire = ""
|
60
|
+
s.test_files = Dir["test/*_test.rb"]
|
61
|
+
|
62
|
+
s.add_dependency('mechanize', '>=0.7.8')
|
63
|
+
s.add_dependency('tmail', '>=1.2.3.1')
|
64
|
+
|
65
|
+
s.files = %w(README ChangeLog Rakefile) +
|
66
|
+
Dir.glob("{bin,doc,test,lib,templates,generator,extras,website,script}/**/*") +
|
67
|
+
Dir.glob("ext/**/*.{h,c,rb}") +
|
68
|
+
Dir.glob("examples/**/*.rb") +
|
69
|
+
Dir.glob("tools/*.rb") +
|
70
|
+
Dir.glob("rails/*.rb")
|
71
|
+
|
72
|
+
s.extensions = FileList["ext/**/extconf.rb"].to_a
|
73
|
+
end
|
74
|
+
|
75
|
+
Rake::GemPackageTask.new(spec) do |p|
|
76
|
+
p.need_tar = true
|
77
|
+
p.gem_spec = spec
|
78
|
+
end
|
79
|
+
|
80
|
+
task :install do
|
81
|
+
name = "#{NAME}-#{VERS}.gem"
|
82
|
+
sh %{rake package}
|
83
|
+
sh %{sudo gem install pkg/#{name}}
|
84
|
+
end
|
85
|
+
|
86
|
+
task :uninstall => [:clean] do
|
87
|
+
sh %{sudo gem uninstall #{NAME}}
|
88
|
+
end
|
89
|
+
|
90
|
+
|
91
|
+
Rake::RDocTask.new do |rdoc|
|
92
|
+
rdoc.rdoc_dir = 'html'
|
93
|
+
rdoc.options += RDOC_OPTS
|
94
|
+
rdoc.template = "resh"
|
95
|
+
#rdoc.template = "#{ENV['template']}.rb" if ENV['template']
|
96
|
+
if ENV['DOC_FILES']
|
97
|
+
rdoc.rdoc_files.include(ENV['DOC_FILES'].split(/,\s*/))
|
98
|
+
else
|
99
|
+
rdoc.rdoc_files.include('README', 'ChangeLog')
|
100
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
101
|
+
rdoc.rdoc_files.include('ext/**/*.c')
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
105
|
+
|
106
|
+
desc 'Show information about the gem.'
|
107
|
+
task :debug_gem do
|
108
|
+
puts spec.to_ruby
|
109
|
+
end
|
110
|
+
|
111
|
+
desc 'Update gem spec'
|
112
|
+
task :gemspec do
|
113
|
+
open("#{NAME}.gemspec", 'w').write spec.to_ruby
|
114
|
+
end
|
data/bin/url2mhtml
ADDED
@@ -0,0 +1,260 @@
|
|
1
|
+
<?xml version="1.0" encoding="iso-8859-1"?>
|
2
|
+
<!DOCTYPE html
|
3
|
+
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
4
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
5
|
+
|
6
|
+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
7
|
+
<head>
|
8
|
+
<title>Class: Url2mhtml</title>
|
9
|
+
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
10
|
+
<meta http-equiv="Content-Script-Type" content="text/javascript" />
|
11
|
+
<link rel="stylesheet" href=".././rdoc-style.css" type="text/css" media="screen" />
|
12
|
+
<script type="text/javascript">
|
13
|
+
// <![CDATA[
|
14
|
+
|
15
|
+
function popupCode( url ) {
|
16
|
+
window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
|
17
|
+
}
|
18
|
+
|
19
|
+
function toggleCode( id ) {
|
20
|
+
if ( document.getElementById )
|
21
|
+
elem = document.getElementById( id );
|
22
|
+
else if ( document.all )
|
23
|
+
elem = eval( "document.all." + id );
|
24
|
+
else
|
25
|
+
return false;
|
26
|
+
|
27
|
+
elemStyle = elem.style;
|
28
|
+
|
29
|
+
if ( elemStyle.display != "block" ) {
|
30
|
+
elemStyle.display = "block"
|
31
|
+
} else {
|
32
|
+
elemStyle.display = "none"
|
33
|
+
}
|
34
|
+
|
35
|
+
return true;
|
36
|
+
}
|
37
|
+
|
38
|
+
// Make codeblocks hidden by default
|
39
|
+
document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
|
40
|
+
|
41
|
+
// ]]>
|
42
|
+
</script>
|
43
|
+
|
44
|
+
</head>
|
45
|
+
<body>
|
46
|
+
|
47
|
+
|
48
|
+
|
49
|
+
<div id="classHeader">
|
50
|
+
<table class="header-table">
|
51
|
+
<tr class="top-aligned-row">
|
52
|
+
<td><strong>Class</strong></td>
|
53
|
+
<td class="class-name-in-header">Url2mhtml</td>
|
54
|
+
</tr>
|
55
|
+
<tr class="top-aligned-row">
|
56
|
+
<td><strong>In:</strong></td>
|
57
|
+
<td>
|
58
|
+
<a href="../files/lib/url2mhtml_rb.html">
|
59
|
+
lib/url2mhtml.rb
|
60
|
+
</a>
|
61
|
+
<br />
|
62
|
+
</td>
|
63
|
+
</tr>
|
64
|
+
|
65
|
+
<tr class="top-aligned-row">
|
66
|
+
<td><strong>Parent:</strong></td>
|
67
|
+
<td>
|
68
|
+
Object
|
69
|
+
</td>
|
70
|
+
</tr>
|
71
|
+
</table>
|
72
|
+
</div>
|
73
|
+
<!-- banner header -->
|
74
|
+
|
75
|
+
<div id="bodyContent">
|
76
|
+
|
77
|
+
|
78
|
+
|
79
|
+
<div id="contextContent">
|
80
|
+
|
81
|
+
|
82
|
+
|
83
|
+
</div>
|
84
|
+
|
85
|
+
<div id="method-list">
|
86
|
+
<h3 class="section-bar">Methods</h3>
|
87
|
+
|
88
|
+
<div class="name-list">
|
89
|
+
<a href="#M000004">append_relative_contents</a>
|
90
|
+
<a href="#M000008">capture</a>
|
91
|
+
<a href="#M000007">create_mail</a>
|
92
|
+
<a href="#M000006">create_mail_part</a>
|
93
|
+
<a href="#M000001">get_agent</a>
|
94
|
+
<a href="#M000002">get_content</a>
|
95
|
+
<a href="#M000003">get_contents</a>
|
96
|
+
<a href="#M000005">resolve_relative_uri</a>
|
97
|
+
</div>
|
98
|
+
</div>
|
99
|
+
|
100
|
+
</div>
|
101
|
+
|
102
|
+
|
103
|
+
<!-- if includes -->
|
104
|
+
|
105
|
+
<div id="section">
|
106
|
+
|
107
|
+
|
108
|
+
<div id="constants-list">
|
109
|
+
<h3 class="section-bar">Constants</h3>
|
110
|
+
|
111
|
+
<div class="name-list">
|
112
|
+
<table summary="Constants">
|
113
|
+
<tr class="top-aligned-row context-row">
|
114
|
+
<td class="context-item-name">VERSION</td>
|
115
|
+
<td>=</td>
|
116
|
+
<td class="context-item-value">'0.0.2'</td>
|
117
|
+
</tr>
|
118
|
+
<tr class="top-aligned-row context-row">
|
119
|
+
<td class="context-item-name">ContentInfo</td>
|
120
|
+
<td>=</td>
|
121
|
+
<td class="context-item-value">Struct.new(:uri,:type,:body,:is_root,:title)</td>
|
122
|
+
</tr>
|
123
|
+
</table>
|
124
|
+
</div>
|
125
|
+
</div>
|
126
|
+
|
127
|
+
|
128
|
+
|
129
|
+
|
130
|
+
|
131
|
+
|
132
|
+
<!-- if method_list -->
|
133
|
+
<div id="methods">
|
134
|
+
<h3 class="section-bar">Public Class methods</h3>
|
135
|
+
|
136
|
+
<div id="method-M000004" class="method-detail">
|
137
|
+
<a name="M000004"></a>
|
138
|
+
|
139
|
+
<div class="method-heading">
|
140
|
+
<a href="Url2mhtml.src/M000004.html" target="Code" class="method-signature"
|
141
|
+
onclick="popupCode('Url2mhtml.src/M000004.html');return false;">
|
142
|
+
<span class="method-name">append_relative_contents</span><span class="method-args">(page,content_info_list)</span>
|
143
|
+
</a>
|
144
|
+
</div>
|
145
|
+
|
146
|
+
<div class="method-description">
|
147
|
+
</div>
|
148
|
+
</div>
|
149
|
+
|
150
|
+
<div id="method-M000008" class="method-detail">
|
151
|
+
<a name="M000008"></a>
|
152
|
+
|
153
|
+
<div class="method-heading">
|
154
|
+
<a href="Url2mhtml.src/M000008.html" target="Code" class="method-signature"
|
155
|
+
onclick="popupCode('Url2mhtml.src/M000008.html');return false;">
|
156
|
+
<span class="method-name">capture</span><span class="method-args">(uri)</span>
|
157
|
+
</a>
|
158
|
+
</div>
|
159
|
+
|
160
|
+
<div class="method-description">
|
161
|
+
</div>
|
162
|
+
</div>
|
163
|
+
|
164
|
+
<div id="method-M000007" class="method-detail">
|
165
|
+
<a name="M000007"></a>
|
166
|
+
|
167
|
+
<div class="method-heading">
|
168
|
+
<a href="Url2mhtml.src/M000007.html" target="Code" class="method-signature"
|
169
|
+
onclick="popupCode('Url2mhtml.src/M000007.html');return false;">
|
170
|
+
<span class="method-name">create_mail</span><span class="method-args">(title,parts)</span>
|
171
|
+
</a>
|
172
|
+
</div>
|
173
|
+
|
174
|
+
<div class="method-description">
|
175
|
+
</div>
|
176
|
+
</div>
|
177
|
+
|
178
|
+
<div id="method-M000006" class="method-detail">
|
179
|
+
<a name="M000006"></a>
|
180
|
+
|
181
|
+
<div class="method-heading">
|
182
|
+
<a href="Url2mhtml.src/M000006.html" target="Code" class="method-signature"
|
183
|
+
onclick="popupCode('Url2mhtml.src/M000006.html');return false;">
|
184
|
+
<span class="method-name">create_mail_part</span><span class="method-args">(content)</span>
|
185
|
+
</a>
|
186
|
+
</div>
|
187
|
+
|
188
|
+
<div class="method-description">
|
189
|
+
</div>
|
190
|
+
</div>
|
191
|
+
|
192
|
+
<div id="method-M000001" class="method-detail">
|
193
|
+
<a name="M000001"></a>
|
194
|
+
|
195
|
+
<div class="method-heading">
|
196
|
+
<a href="Url2mhtml.src/M000001.html" target="Code" class="method-signature"
|
197
|
+
onclick="popupCode('Url2mhtml.src/M000001.html');return false;">
|
198
|
+
<span class="method-name">get_agent</span><span class="method-args">()</span>
|
199
|
+
</a>
|
200
|
+
</div>
|
201
|
+
|
202
|
+
<div class="method-description">
|
203
|
+
</div>
|
204
|
+
</div>
|
205
|
+
|
206
|
+
<div id="method-M000002" class="method-detail">
|
207
|
+
<a name="M000002"></a>
|
208
|
+
|
209
|
+
<div class="method-heading">
|
210
|
+
<a href="Url2mhtml.src/M000002.html" target="Code" class="method-signature"
|
211
|
+
onclick="popupCode('Url2mhtml.src/M000002.html');return false;">
|
212
|
+
<span class="method-name">get_content</span><span class="method-args">(uri,is_root)</span>
|
213
|
+
</a>
|
214
|
+
</div>
|
215
|
+
|
216
|
+
<div class="method-description">
|
217
|
+
</div>
|
218
|
+
</div>
|
219
|
+
|
220
|
+
<div id="method-M000003" class="method-detail">
|
221
|
+
<a name="M000003"></a>
|
222
|
+
|
223
|
+
<div class="method-heading">
|
224
|
+
<a href="Url2mhtml.src/M000003.html" target="Code" class="method-signature"
|
225
|
+
onclick="popupCode('Url2mhtml.src/M000003.html');return false;">
|
226
|
+
<span class="method-name">get_contents</span><span class="method-args">(uri,is_root,content_info_list)</span>
|
227
|
+
</a>
|
228
|
+
</div>
|
229
|
+
|
230
|
+
<div class="method-description">
|
231
|
+
</div>
|
232
|
+
</div>
|
233
|
+
|
234
|
+
<div id="method-M000005" class="method-detail">
|
235
|
+
<a name="M000005"></a>
|
236
|
+
|
237
|
+
<div class="method-heading">
|
238
|
+
<a href="Url2mhtml.src/M000005.html" target="Code" class="method-signature"
|
239
|
+
onclick="popupCode('Url2mhtml.src/M000005.html');return false;">
|
240
|
+
<span class="method-name">resolve_relative_uri</span><span class="method-args">(base_uri,target_uri)</span>
|
241
|
+
</a>
|
242
|
+
</div>
|
243
|
+
|
244
|
+
<div class="method-description">
|
245
|
+
</div>
|
246
|
+
</div>
|
247
|
+
|
248
|
+
|
249
|
+
</div>
|
250
|
+
|
251
|
+
|
252
|
+
</div>
|
253
|
+
|
254
|
+
|
255
|
+
<div id="validator-badges">
|
256
|
+
<p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
|
257
|
+
</div>
|
258
|
+
|
259
|
+
</body>
|
260
|
+
</html>
|
@@ -0,0 +1,21 @@
|
|
1
|
+
<?xml version="1.0" encoding="iso-8859-1"?>
|
2
|
+
<!DOCTYPE html
|
3
|
+
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
4
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
5
|
+
|
6
|
+
<html>
|
7
|
+
<head>
|
8
|
+
<title>get_agent (Url2mhtml)</title>
|
9
|
+
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
10
|
+
<link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
|
11
|
+
</head>
|
12
|
+
<body class="standalone-code">
|
13
|
+
<pre><span class="ruby-comment cmt"># File lib/url2mhtml.rb, line 9</span>
|
14
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">get_agent</span>
|
15
|
+
<span class="ruby-identifier">user_agent_alias</span> =<span class="ruby-value str">'Windows IE 6'</span>
|
16
|
+
<span class="ruby-identifier">agent</span> = <span class="ruby-constant">WWW</span><span class="ruby-operator">::</span><span class="ruby-constant">Mechanize</span>.<span class="ruby-identifier">new</span>
|
17
|
+
<span class="ruby-identifier">agent</span>.<span class="ruby-identifier">user_agent_alias</span> =<span class="ruby-identifier">user_agent_alias</span>
|
18
|
+
<span class="ruby-identifier">agent</span>
|
19
|
+
<span class="ruby-keyword kw">end</span></pre>
|
20
|
+
</body>
|
21
|
+
</html>
|
@@ -0,0 +1,25 @@
|
|
1
|
+
<?xml version="1.0" encoding="iso-8859-1"?>
|
2
|
+
<!DOCTYPE html
|
3
|
+
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
4
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
5
|
+
|
6
|
+
<html>
|
7
|
+
<head>
|
8
|
+
<title>get_content (Url2mhtml)</title>
|
9
|
+
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
10
|
+
<link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
|
11
|
+
</head>
|
12
|
+
<body class="standalone-code">
|
13
|
+
<pre><span class="ruby-comment cmt"># File lib/url2mhtml.rb, line 16</span>
|
14
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">get_content</span>(<span class="ruby-identifier">uri</span>,<span class="ruby-identifier">is_root</span>)
|
15
|
+
<span class="ruby-identifier">got_content</span> = <span class="ruby-identifier">get_agent</span>.<span class="ruby-identifier">get</span>(<span class="ruby-identifier">uri</span>)
|
16
|
+
<span class="ruby-identifier">type</span>=<span class="ruby-identifier">got_content</span>.<span class="ruby-identifier">response</span>[<span class="ruby-value str">'content-type'</span>]
|
17
|
+
<span class="ruby-identifier">body</span>=<span class="ruby-identifier">got_content</span>.<span class="ruby-identifier">body</span>
|
18
|
+
|
19
|
+
<span class="ruby-identifier">title</span>= ( <span class="ruby-identifier">is_root</span> <span class="ruby-operator">&&</span> <span class="ruby-regexp re">/html/</span>.<span class="ruby-identifier">match</span>(<span class="ruby-identifier">type</span>) ) <span class="ruby-operator">?</span> <span class="ruby-identifier">got_content</span>.<span class="ruby-identifier">title</span> <span class="ruby-operator">:</span> <span class="ruby-value str">'no title'</span>
|
20
|
+
|
21
|
+
<span class="ruby-identifier">content_info</span>=<span class="ruby-constant">ContentInfo</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">uri</span>,<span class="ruby-identifier">type</span>,<span class="ruby-identifier">body</span>,<span class="ruby-identifier">is_root</span>,<span class="ruby-identifier">title</span>)
|
22
|
+
<span class="ruby-keyword kw">return</span> <span class="ruby-identifier">content_info</span>,<span class="ruby-identifier">got_content</span>
|
23
|
+
<span class="ruby-keyword kw">end</span></pre>
|
24
|
+
</body>
|
25
|
+
</html>
|
@@ -0,0 +1,23 @@
|
|
1
|
+
<?xml version="1.0" encoding="iso-8859-1"?>
|
2
|
+
<!DOCTYPE html
|
3
|
+
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
4
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
5
|
+
|
6
|
+
<html>
|
7
|
+
<head>
|
8
|
+
<title>get_contents (Url2mhtml)</title>
|
9
|
+
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
10
|
+
<link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
|
11
|
+
</head>
|
12
|
+
<body class="standalone-code">
|
13
|
+
<pre><span class="ruby-comment cmt"># File lib/url2mhtml.rb, line 27</span>
|
14
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">get_contents</span>(<span class="ruby-identifier">uri</span>,<span class="ruby-identifier">is_root</span>,<span class="ruby-identifier">content_info_list</span>)
|
15
|
+
|
16
|
+
<span class="ruby-identifier">content_info</span>,<span class="ruby-identifier">got_content</span>=<span class="ruby-identifier">get_content</span>(<span class="ruby-identifier">uri</span>,<span class="ruby-identifier">is_root</span>)
|
17
|
+
<span class="ruby-identifier">content_info_list</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">content_info</span>
|
18
|
+
|
19
|
+
<span class="ruby-identifier">append_relative_contents</span>(<span class="ruby-identifier">got_content</span>,<span class="ruby-identifier">content_info_list</span>) <span class="ruby-keyword kw">if</span> <span class="ruby-regexp re">/html/</span>.<span class="ruby-identifier">match</span>(<span class="ruby-identifier">content_info</span>.<span class="ruby-identifier">type</span>)
|
20
|
+
<span class="ruby-identifier">content_info_list</span>
|
21
|
+
<span class="ruby-keyword kw">end</span></pre>
|
22
|
+
</body>
|
23
|
+
</html>
|
@@ -0,0 +1,41 @@
|
|
1
|
+
<?xml version="1.0" encoding="iso-8859-1"?>
|
2
|
+
<!DOCTYPE html
|
3
|
+
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
4
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
5
|
+
|
6
|
+
<html>
|
7
|
+
<head>
|
8
|
+
<title>append_relative_contents (Url2mhtml)</title>
|
9
|
+
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
10
|
+
<link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
|
11
|
+
</head>
|
12
|
+
<body class="standalone-code">
|
13
|
+
<pre><span class="ruby-comment cmt"># File lib/url2mhtml.rb, line 36</span>
|
14
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">append_relative_contents</span>(<span class="ruby-identifier">page</span>,<span class="ruby-identifier">content_info_list</span>)
|
15
|
+
<span class="ruby-identifier">base_uri</span>=<span class="ruby-identifier">page</span>.<span class="ruby-identifier">uri</span>
|
16
|
+
<span class="ruby-identifier">raw_image_uris</span>=<span class="ruby-identifier">page</span>.<span class="ruby-identifier">search</span>(<span class="ruby-value str">'//img'</span>).<span class="ruby-identifier">map</span>{<span class="ruby-operator">|</span><span class="ruby-identifier">i</span><span class="ruby-operator">|</span> <span class="ruby-identifier">i</span>[<span class="ruby-value str">'src'</span>]}
|
17
|
+
<span class="ruby-identifier">raw_image_uris</span>.<span class="ruby-identifier">push</span>(<span class="ruby-operator">*</span>(<span class="ruby-identifier">page</span>.<span class="ruby-identifier">search</span>(<span class="ruby-value str">'//body'</span>).<span class="ruby-identifier">find_all</span>{<span class="ruby-operator">|</span><span class="ruby-identifier">i</span><span class="ruby-operator">|</span> <span class="ruby-identifier">i</span>[<span class="ruby-value str">'background'</span>]}.<span class="ruby-identifier">map</span>{<span class="ruby-operator">|</span><span class="ruby-identifier">i</span><span class="ruby-operator">|</span> <span class="ruby-identifier">i</span>[<span class="ruby-value str">'background'</span>]}))
|
18
|
+
<span class="ruby-identifier">raw_image_uris</span>.<span class="ruby-identifier">push</span>(<span class="ruby-operator">*</span>(<span class="ruby-identifier">page</span>.<span class="ruby-identifier">search</span>(<span class="ruby-value str">'//th'</span>).<span class="ruby-identifier">find_all</span>{<span class="ruby-operator">|</span><span class="ruby-identifier">i</span><span class="ruby-operator">|</span> <span class="ruby-identifier">i</span>[<span class="ruby-value str">'background'</span>]}.<span class="ruby-identifier">map</span>{<span class="ruby-operator">|</span><span class="ruby-identifier">i</span><span class="ruby-operator">|</span> <span class="ruby-identifier">i</span>[<span class="ruby-value str">'background'</span>]}))
|
19
|
+
<span class="ruby-identifier">raw_image_uris</span>.<span class="ruby-identifier">push</span>(<span class="ruby-operator">*</span>(<span class="ruby-identifier">page</span>.<span class="ruby-identifier">search</span>(<span class="ruby-value str">'//td'</span>).<span class="ruby-identifier">find_all</span>{<span class="ruby-operator">|</span><span class="ruby-identifier">i</span><span class="ruby-operator">|</span> <span class="ruby-identifier">i</span>[<span class="ruby-value str">'background'</span>]}.<span class="ruby-identifier">map</span>{<span class="ruby-operator">|</span><span class="ruby-identifier">i</span><span class="ruby-operator">|</span> <span class="ruby-identifier">i</span>[<span class="ruby-value str">'background'</span>]}))
|
20
|
+
<span class="ruby-identifier">image_uris</span>=<span class="ruby-identifier">raw_image_uris</span>.<span class="ruby-identifier">map</span>{<span class="ruby-operator">|</span><span class="ruby-identifier">i</span><span class="ruby-operator">|</span> <span class="ruby-identifier">resolve_relative_uri</span>(<span class="ruby-identifier">base_uri</span>,<span class="ruby-identifier">i</span>)}.<span class="ruby-identifier">grep</span>(<span class="ruby-regexp re">/^(http|ftp)/</span>)
|
21
|
+
|
22
|
+
<span class="ruby-identifier">raw_frame_uris</span>=<span class="ruby-identifier">page</span>.<span class="ruby-identifier">frames</span>.<span class="ruby-identifier">map</span>{<span class="ruby-operator">|</span><span class="ruby-identifier">f</span><span class="ruby-operator">|</span> <span class="ruby-identifier">f</span>.<span class="ruby-identifier">uri</span>}
|
23
|
+
<span class="ruby-identifier">frame_uris</span>=<span class="ruby-identifier">raw_frame_uris</span>.<span class="ruby-identifier">map</span>{<span class="ruby-operator">|</span><span class="ruby-identifier">i</span><span class="ruby-operator">|</span> <span class="ruby-identifier">resolve_relative_uri</span>(<span class="ruby-identifier">base_uri</span>,<span class="ruby-identifier">i</span>)}.<span class="ruby-identifier">grep</span>(<span class="ruby-regexp re">/^(http|ftp)/</span>)
|
24
|
+
|
25
|
+
<span class="ruby-identifier">raw_iframe_uris</span>=<span class="ruby-identifier">page</span>.<span class="ruby-identifier">iframes</span>.<span class="ruby-identifier">map</span>{<span class="ruby-operator">|</span><span class="ruby-identifier">f</span><span class="ruby-operator">|</span> <span class="ruby-identifier">f</span>.<span class="ruby-identifier">uri</span>}
|
26
|
+
<span class="ruby-identifier">iframe_uris</span>=<span class="ruby-identifier">raw_iframe_uris</span>.<span class="ruby-identifier">map</span>{<span class="ruby-operator">|</span><span class="ruby-identifier">i</span><span class="ruby-operator">|</span> <span class="ruby-identifier">resolve_relative_uri</span>(<span class="ruby-identifier">base_uri</span>,<span class="ruby-identifier">i</span>)}.<span class="ruby-identifier">grep</span>(<span class="ruby-regexp re">/^(http|ftp)/</span>)
|
27
|
+
|
28
|
+
<span class="ruby-identifier">raw_css_uris</span>=<span class="ruby-identifier">page</span>.<span class="ruby-identifier">search</span>(<span class="ruby-value str">'link[@rel="stylesheet"]'</span>).<span class="ruby-identifier">map</span>{<span class="ruby-operator">|</span><span class="ruby-identifier">l</span><span class="ruby-operator">|</span> <span class="ruby-identifier">l</span>[<span class="ruby-value str">'href'</span>]}
|
29
|
+
<span class="ruby-identifier">css_uris</span>=<span class="ruby-identifier">raw_css_uris</span>.<span class="ruby-identifier">map</span>{<span class="ruby-operator">|</span><span class="ruby-identifier">i</span><span class="ruby-operator">|</span> <span class="ruby-identifier">resolve_relative_uri</span>(<span class="ruby-identifier">base_uri</span>,<span class="ruby-identifier">i</span>)}.<span class="ruby-identifier">grep</span>(<span class="ruby-regexp re">/^(http|ftp)/</span>)
|
30
|
+
|
31
|
+
<span class="ruby-identifier">raw_script_uris</span>=<span class="ruby-identifier">page</span>.<span class="ruby-identifier">search</span>(<span class="ruby-value str">'script'</span>).<span class="ruby-identifier">find_all</span>{<span class="ruby-operator">|</span><span class="ruby-identifier">s</span><span class="ruby-operator">|</span> <span class="ruby-identifier">s</span>[<span class="ruby-value str">'src'</span>]}.<span class="ruby-identifier">map</span>{<span class="ruby-operator">|</span><span class="ruby-identifier">s</span><span class="ruby-operator">|</span> <span class="ruby-identifier">s</span>[<span class="ruby-value str">'src'</span>]}
|
32
|
+
<span class="ruby-identifier">script_uris</span>=<span class="ruby-identifier">raw_script_uris</span>.<span class="ruby-identifier">map</span>{<span class="ruby-operator">|</span><span class="ruby-identifier">i</span><span class="ruby-operator">|</span> <span class="ruby-identifier">resolve_relative_uri</span>(<span class="ruby-identifier">base_uri</span>,<span class="ruby-identifier">i</span>)}.<span class="ruby-identifier">grep</span>(<span class="ruby-regexp re">/^(http|ftp)/</span>)
|
33
|
+
|
34
|
+
|
35
|
+
<span class="ruby-identifier">raw_urls</span> = ( <span class="ruby-identifier">image_uris</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">frame_uris</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">iframe_uris</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">css_uris</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">script_uris</span> )
|
36
|
+
<span class="ruby-identifier">target_content_urls</span> = <span class="ruby-identifier">raw_urls</span>.<span class="ruby-identifier">map</span>{<span class="ruby-operator">|</span><span class="ruby-identifier">u</span><span class="ruby-operator">|</span> <span class="ruby-identifier">u</span>.<span class="ruby-identifier">gsub</span>(<span class="ruby-regexp re">/#.*/</span>,<span class="ruby-value str">''</span>)}.<span class="ruby-identifier">uniq</span>.<span class="ruby-identifier">find_all</span>{<span class="ruby-operator">|</span><span class="ruby-identifier">u</span><span class="ruby-operator">|</span> <span class="ruby-identifier">content_info_list</span>.<span class="ruby-identifier">any?</span>{<span class="ruby-operator">|</span><span class="ruby-identifier">content</span><span class="ruby-operator">|</span> <span class="ruby-identifier">u</span> <span class="ruby-operator">!=</span> <span class="ruby-identifier">content</span>.<span class="ruby-identifier">uri</span>}}
|
37
|
+
|
38
|
+
<span class="ruby-identifier">target_content_urls</span>.<span class="ruby-identifier">each</span>{<span class="ruby-operator">|</span><span class="ruby-identifier">uri</span><span class="ruby-operator">|</span> <span class="ruby-identifier">get_contents</span>(<span class="ruby-identifier">uri</span>,<span class="ruby-keyword kw">false</span>,<span class="ruby-identifier">content_info_list</span>)}
|
39
|
+
<span class="ruby-keyword kw">end</span></pre>
|
40
|
+
</body>
|
41
|
+
</html>
|
@@ -0,0 +1,18 @@
|
|
1
|
+
<?xml version="1.0" encoding="iso-8859-1"?>
|
2
|
+
<!DOCTYPE html
|
3
|
+
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
4
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
5
|
+
|
6
|
+
<html>
|
7
|
+
<head>
|
8
|
+
<title>resolve_relative_uri (Url2mhtml)</title>
|
9
|
+
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
10
|
+
<link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
|
11
|
+
</head>
|
12
|
+
<body class="standalone-code">
|
13
|
+
<pre><span class="ruby-comment cmt"># File lib/url2mhtml.rb, line 63</span>
|
14
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">resolve_relative_uri</span>(<span class="ruby-identifier">base_uri</span>,<span class="ruby-identifier">target_uri</span>)
|
15
|
+
<span class="ruby-constant">URI</span>.<span class="ruby-identifier">join</span>(<span class="ruby-identifier">base_uri</span>.<span class="ruby-identifier">to_s</span>,<span class="ruby-identifier">target_uri</span>).<span class="ruby-identifier">to_s</span>
|
16
|
+
<span class="ruby-keyword kw">end</span></pre>
|
17
|
+
</body>
|
18
|
+
</html>
|
@@ -0,0 +1,30 @@
|
|
1
|
+
<?xml version="1.0" encoding="iso-8859-1"?>
|
2
|
+
<!DOCTYPE html
|
3
|
+
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
4
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
5
|
+
|
6
|
+
<html>
|
7
|
+
<head>
|
8
|
+
<title>create_mail_part (Url2mhtml)</title>
|
9
|
+
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
10
|
+
<link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
|
11
|
+
</head>
|
12
|
+
<body class="standalone-code">
|
13
|
+
<pre><span class="ruby-comment cmt"># File lib/url2mhtml.rb, line 67</span>
|
14
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">create_mail_part</span>(<span class="ruby-identifier">content</span>)
|
15
|
+
<span class="ruby-identifier">part</span>=<span class="ruby-constant">TMail</span><span class="ruby-operator">::</span><span class="ruby-constant">Mail</span>.<span class="ruby-identifier">new</span>
|
16
|
+
|
17
|
+
<span class="ruby-identifier">part</span>[<span class="ruby-value str">'content-location'</span>]=<span class="ruby-identifier">content</span>.<span class="ruby-identifier">uri</span>
|
18
|
+
<span class="ruby-identifier">part</span>.<span class="ruby-identifier">content_type</span> = <span class="ruby-identifier">content</span>.<span class="ruby-identifier">type</span>
|
19
|
+
<span class="ruby-keyword kw">if</span> <span class="ruby-regexp re">/html/</span>.<span class="ruby-identifier">match</span>(<span class="ruby-identifier">content</span>.<span class="ruby-identifier">type</span>)
|
20
|
+
<span class="ruby-identifier">part</span>.<span class="ruby-identifier">transfer_encoding</span> = <span class="ruby-value str">'8bit'</span>
|
21
|
+
<span class="ruby-identifier">part</span>.<span class="ruby-identifier">body</span> = <span class="ruby-identifier">content</span>.<span class="ruby-identifier">body</span>
|
22
|
+
<span class="ruby-keyword kw">else</span>
|
23
|
+
<span class="ruby-identifier">part</span>.<span class="ruby-identifier">transfer_encoding</span> = <span class="ruby-value str">'base64'</span>
|
24
|
+
<span class="ruby-identifier">b64encoded_body</span> = [<span class="ruby-identifier">content</span>.<span class="ruby-identifier">body</span>].<span class="ruby-identifier">pack</span>(<span class="ruby-value str">'m'</span>).<span class="ruby-identifier">chomp</span>.<span class="ruby-identifier">gsub</span>(<span class="ruby-regexp re">/.{76}/</span>, <span class="ruby-value str">"\\1\n"</span>)
|
25
|
+
<span class="ruby-identifier">part</span>.<span class="ruby-identifier">body</span> = <span class="ruby-identifier">b64encoded_body</span>
|
26
|
+
<span class="ruby-keyword kw">end</span>
|
27
|
+
<span class="ruby-identifier">part</span>
|
28
|
+
<span class="ruby-keyword kw">end</span></pre>
|
29
|
+
</body>
|
30
|
+
</html>
|