texmailer 0.1
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/LICENSE +339 -0
- data/README +24 -0
- data/bin/texmailer +70 -0
- data/lib/texmailer/ca-bundle.crt +4599 -0
- data/lib/texmailer/config.rb +75 -0
- data/lib/texmailer/drafts.rb +172 -0
- data/lib/texmailer/rhtml/blankprev.html +4 -0
- data/lib/texmailer/rhtml/drafts.html +82 -0
- data/lib/texmailer/rhtml/header.html +24 -0
- data/lib/texmailer/rhtml/index.html +125 -0
- data/lib/texmailer/rhtml/send.html +50 -0
- data/lib/texmailer/rhtml/settings.html +62 -0
- data/lib/texmailer/send.rb +150 -0
- data/lib/texmailer/wapp.rb +38 -0
- metadata +104 -0
@@ -0,0 +1,50 @@
|
|
1
|
+
<%
|
2
|
+
if ! req["mailid"] || ! req.post? then
|
3
|
+
message = "Internal Error!"
|
4
|
+
status = true
|
5
|
+
else
|
6
|
+
mailid = req["mailid"]
|
7
|
+
savedraft(mailid,req)
|
8
|
+
if ! preview(mailid,req)
|
9
|
+
message = "Error in TeX source!"
|
10
|
+
status = false
|
11
|
+
else
|
12
|
+
status,message = sendmail(mailid,req)
|
13
|
+
status,message = msmtp(req,message) if status
|
14
|
+
discarddraft(mailid) if status
|
15
|
+
if /command not found/m.match(message) then
|
16
|
+
message = "Please install the msmtp program and ensure it is in your path."
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
%>
|
21
|
+
<html>
|
22
|
+
<head>
|
23
|
+
<title>TeXMailer</title>
|
24
|
+
</head>
|
25
|
+
<body style="background-color:#dedede">
|
26
|
+
<%= File.read($basedir+"/rhtml/header.html")%>
|
27
|
+
<br> <br>
|
28
|
+
<center>
|
29
|
+
<table style="border:2px solid; font-size:15px; text-align:center; background-color: #badaba; padding:10px; border-color:1aaa1a">
|
30
|
+
<tr>
|
31
|
+
<% if status then %>
|
32
|
+
<td style="text-align:center">
|
33
|
+
<br>
|
34
|
+
<span style="font-size:18pt"> <%= message %> </span>
|
35
|
+
<br> <br>
|
36
|
+
</td>
|
37
|
+
<% else %>
|
38
|
+
<td style="text-align:left">
|
39
|
+
<span style="font-size:18pt">
|
40
|
+
Error Sending Mail: <a href="index.html?mailid=<%= mailid %>" class="toplink">Return</a>
|
41
|
+
</span>
|
42
|
+
<br> <br>
|
43
|
+
<pre style="font-size:10pt">
|
44
|
+
<%= message %>
|
45
|
+
</pre>
|
46
|
+
<% end %>
|
47
|
+
</table>
|
48
|
+
</center>
|
49
|
+
</body>
|
50
|
+
</html>
|
@@ -0,0 +1,62 @@
|
|
1
|
+
<%
|
2
|
+
saveparams req if req.post?
|
3
|
+
p = loadparams
|
4
|
+
%>
|
5
|
+
<html>
|
6
|
+
<head>
|
7
|
+
<title>TeXMailer</title>
|
8
|
+
</head>
|
9
|
+
<body style="background-color:#dedede">
|
10
|
+
<%= File.read($basedir+"/rhtml/header.html")%>
|
11
|
+
<br> <br>
|
12
|
+
<center>
|
13
|
+
<% if req.post? then %>
|
14
|
+
<span style="font-size:18px">Settings Saved</span>
|
15
|
+
<br>
|
16
|
+
<% end %>
|
17
|
+
<table style="border:2px solid; font-size:15px; text-align:center; background-color: #badaba; padding:10px; border-color:1aaa1a">
|
18
|
+
<form name="setform" method="POST" action="settings.html" autocomplete="off">
|
19
|
+
<tr><td><b>SMTP Settings</b><br> </td></tr>
|
20
|
+
<tr><td style="width:100%">
|
21
|
+
|
22
|
+
<table style="border:0px; width:100%; font-size:15px">
|
23
|
+
<%
|
24
|
+
[['From Name','from',0],
|
25
|
+
['From Address','mailfrom',0],
|
26
|
+
['SMTP Host','host',0],
|
27
|
+
['Port','port',0],
|
28
|
+
['Use SSL','ssl',2],
|
29
|
+
['Ignore Certificate','igcert',2],
|
30
|
+
['Authenticate','auth',2],
|
31
|
+
['Username','user',0],
|
32
|
+
['Password','pass',1]].each do |x|
|
33
|
+
%>
|
34
|
+
<tr>
|
35
|
+
<td style="text-align:right"><%= x[0] %>: </td>
|
36
|
+
<td>
|
37
|
+
<% if x[2] == 0 then %>
|
38
|
+
<input name="<%= x[1] %>" value="<%= p[x[1]] %>" size=30>
|
39
|
+
<% elsif x[2] == 1 then %>
|
40
|
+
<input name="<%= x[1] %>" size=30 value="<%= p[x[1]] %>" type="password">
|
41
|
+
<% else %>
|
42
|
+
<input name="<%= x[1] %>" type="checkbox" <%= "checked" if p[x[1]] == 'true' %>>
|
43
|
+
<% end %>
|
44
|
+
</td>
|
45
|
+
|
46
|
+
</tr>
|
47
|
+
<%
|
48
|
+
end
|
49
|
+
%>
|
50
|
+
</table>
|
51
|
+
</tr></td>
|
52
|
+
<tr><td>
|
53
|
+
<br>
|
54
|
+
<input type="submit" value="Save">
|
55
|
+
<input type="reset" value="Reset">
|
56
|
+
</td></tr>
|
57
|
+
</form>
|
58
|
+
</table>
|
59
|
+
</center>
|
60
|
+
|
61
|
+
</body>
|
62
|
+
</html>
|
@@ -0,0 +1,150 @@
|
|
1
|
+
require 'net/smtp'
|
2
|
+
|
3
|
+
module Texmailer
|
4
|
+
|
5
|
+
def stripcss(html)
|
6
|
+
css = nil
|
7
|
+
r = /\<link[^\>]*href="(.*\.css)"[\>]*\>/m
|
8
|
+
html.gsub!(r) { |g|
|
9
|
+
m = Regexp.last_match
|
10
|
+
if ! File.readable? m[1]
|
11
|
+
rep = ""
|
12
|
+
else
|
13
|
+
css = File.read(m[1])
|
14
|
+
rep = <<SCPT
|
15
|
+
<style type="text/css">
|
16
|
+
#{css}
|
17
|
+
</style>
|
18
|
+
SCPT
|
19
|
+
end
|
20
|
+
rep
|
21
|
+
}
|
22
|
+
|
23
|
+
return html if ! css
|
24
|
+
|
25
|
+
r = /\/\*.*?\*\//m
|
26
|
+
css.gsub!(r,'')
|
27
|
+
|
28
|
+
styles = Array.new
|
29
|
+
r = /(.*?)\{(.*?)\}/
|
30
|
+
while m = r.match(css)
|
31
|
+
cls = m[1].strip
|
32
|
+
|
33
|
+
stlf = ''
|
34
|
+
s = m[2]
|
35
|
+
r2 = /font.*?\:.*?\;/
|
36
|
+
while m2 = r2.match(s)
|
37
|
+
stlf = stlf + m2[0]
|
38
|
+
s = m2.post_match
|
39
|
+
end
|
40
|
+
styles << [cls,stlf] if stlf.length > 0
|
41
|
+
css = m.post_match
|
42
|
+
end
|
43
|
+
|
44
|
+
r = /\<(.*?)class="(.*?)"(.*?)\>/m
|
45
|
+
html.gsub!(r) {
|
46
|
+
m = Regexp.last_match
|
47
|
+
clid = m[2]
|
48
|
+
stl = ""
|
49
|
+
styles.each { |x| stl = stl + x[1] if x[0].index(clid) }
|
50
|
+
stl = " style=\""+stl+"\" " if stl.length > 0
|
51
|
+
"<"+m[1]+"class=\""+m[2]+"\"" + stl + m[3]+">"
|
52
|
+
}
|
53
|
+
|
54
|
+
return html
|
55
|
+
end
|
56
|
+
|
57
|
+
def htm2mail(thehtml_in,thetex)
|
58
|
+
rstring = (0...15).map{ ('A'..'Z').to_a[rand(26)] }.join;
|
59
|
+
rstring2 = (0...15).map{ ('A'..'Z').to_a[rand(26)] }.join;
|
60
|
+
marker = rstring + "TEXMARKERSHOULDBEUNIQUE12375689"
|
61
|
+
marker2 = rstring2 + "TEXMARKERSHOULDBEUNIQUE12375689"
|
62
|
+
|
63
|
+
body =<<EOF
|
64
|
+
MIME-Version: 1.0
|
65
|
+
Content-type: multipart/mixed; boundary=#{marker}
|
66
|
+
|
67
|
+
--#{marker}
|
68
|
+
EOF
|
69
|
+
# Everything's in the body
|
70
|
+
thehtml_in = stripcss thehtml_in
|
71
|
+
thehtml_out = ""
|
72
|
+
|
73
|
+
# Find attachments
|
74
|
+
r = /(src)="(.*?)"/
|
75
|
+
attachs = Array.new
|
76
|
+
mimetypes = Array.new
|
77
|
+
|
78
|
+
cid = 0
|
79
|
+
while (m = r.match(thehtml_in))
|
80
|
+
thehtml_out = thehtml_out + m.pre_match
|
81
|
+
if File.readable?(m[2]) then
|
82
|
+
f = File.read(m[2])
|
83
|
+
thehtml_out = thehtml_out + m[1] + "=\"cid:#{rstring}%04d\"" % cid
|
84
|
+
attachs[cid] = [f].pack("m")
|
85
|
+
mimetypes[cid] = 'image/' + case m[2][(m[2].rindex('.')+1)..-1]
|
86
|
+
when 'gif' then 'jpeg'
|
87
|
+
when 'png' then 'png'
|
88
|
+
else 'jpeg'
|
89
|
+
end
|
90
|
+
cid = cid + 1
|
91
|
+
else
|
92
|
+
thehtml_out = thehtml_out + m[0]
|
93
|
+
end
|
94
|
+
thehtml_in = m.post_match
|
95
|
+
end
|
96
|
+
|
97
|
+
thehtml_out = thehtml_out + thehtml_in
|
98
|
+
thehtml_out = [thehtml_out].pack("M")
|
99
|
+
# Add html part
|
100
|
+
body = body + <<EOF
|
101
|
+
Content-Type: multipart/alternative; boundary=#{marker2}
|
102
|
+
|
103
|
+
--#{marker2}
|
104
|
+
Content-Type: text/plain
|
105
|
+
Content-Transfer-Encoding: 8bit
|
106
|
+
|
107
|
+
#{thetex}
|
108
|
+
--#{marker2}
|
109
|
+
Content-Type: text/html
|
110
|
+
Content-Transfer-Encoding: quoted-printable
|
111
|
+
|
112
|
+
#{thehtml_out}
|
113
|
+
--#{marker2}--
|
114
|
+
EOF
|
115
|
+
|
116
|
+
# Add attachments
|
117
|
+
for i in (0..(attachs.length-1))
|
118
|
+
cid = "<#{rstring}%04d>" % i;
|
119
|
+
data = attachs[i]
|
120
|
+
body = body + <<EOF2
|
121
|
+
--#{marker}
|
122
|
+
Content-Disposition: inline
|
123
|
+
Content-Type: #{mimetypes[i]}
|
124
|
+
Content-Transfer-Encoding: base64
|
125
|
+
Content-Id: #{cid}
|
126
|
+
|
127
|
+
#{data}
|
128
|
+
EOF2
|
129
|
+
end
|
130
|
+
|
131
|
+
body = body + <<EOF3
|
132
|
+
--#{marker}--
|
133
|
+
EOF3
|
134
|
+
|
135
|
+
return body
|
136
|
+
end
|
137
|
+
|
138
|
+
def sendmail(mailid,req)
|
139
|
+
pvdir = $userdir + '/preview/' + mailid
|
140
|
+
if ! File.directory? pvdir
|
141
|
+
return false,"Internal Error!"
|
142
|
+
end
|
143
|
+
Dir.chdir(pvdir);
|
144
|
+
return false,"Internal Error!" if ! File.readable?(pvdir+'/t.html')
|
145
|
+
return false,"Internal Error!" if ! File.readable?(pvdir+'/t.tex')
|
146
|
+
html = File.read(pvdir+'/t.html')
|
147
|
+
return true, htm2mail(html,req["body"])
|
148
|
+
end
|
149
|
+
|
150
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
module Texmailer
|
2
|
+
|
3
|
+
class DontCache
|
4
|
+
def initialize app
|
5
|
+
@app = app
|
6
|
+
end
|
7
|
+
def call env
|
8
|
+
res = @app.call(env)
|
9
|
+
res[1]["Expires"] = (Time.now - 100).utc.rfc2822
|
10
|
+
return res
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
def webapp
|
15
|
+
return Rack::Builder.new {
|
16
|
+
use DontCache
|
17
|
+
use Rack::Static, :urls => ["/preview"], :root => $userdir
|
18
|
+
|
19
|
+
map '/' do
|
20
|
+
run Proc.new {|env|
|
21
|
+
location = env["PATH_INFO"]
|
22
|
+
location = "/index.html" if location == '/'
|
23
|
+
Process.exit!(0) if location == '/die'
|
24
|
+
if File.file? $basedir+"/rhtml"+location then
|
25
|
+
code = 200
|
26
|
+
header = {"Content-Type" => "text/html"}
|
27
|
+
req = Rack::Request.new(env)
|
28
|
+
data = ERB.new(File.read($basedir+"/rhtml"+location)).result(binding)
|
29
|
+
[code, header, data]
|
30
|
+
else
|
31
|
+
[404, {"Content-Type" => "text/plain"}, "File not found: "+location]
|
32
|
+
end
|
33
|
+
}
|
34
|
+
end
|
35
|
+
}
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
metadata
ADDED
@@ -0,0 +1,104 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: texmailer
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 0
|
7
|
+
- 1
|
8
|
+
version: "0.1"
|
9
|
+
platform: ruby
|
10
|
+
authors:
|
11
|
+
- Ayan Chakrabarti
|
12
|
+
autorequire:
|
13
|
+
bindir: bin
|
14
|
+
cert_chain: []
|
15
|
+
|
16
|
+
date: 2010-08-19 00:00:00 -04:00
|
17
|
+
default_executable:
|
18
|
+
dependencies:
|
19
|
+
- !ruby/object:Gem::Dependency
|
20
|
+
name: rack
|
21
|
+
prerelease: false
|
22
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
segments:
|
27
|
+
- 1
|
28
|
+
- 1
|
29
|
+
- 0
|
30
|
+
version: 1.1.0
|
31
|
+
type: :runtime
|
32
|
+
version_requirements: *id001
|
33
|
+
- !ruby/object:Gem::Dependency
|
34
|
+
name: mongrel
|
35
|
+
prerelease: false
|
36
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
segments:
|
41
|
+
- 1
|
42
|
+
- 1
|
43
|
+
- 4
|
44
|
+
version: 1.1.4
|
45
|
+
type: :runtime
|
46
|
+
version_requirements: *id002
|
47
|
+
description: An application that runs a light local webserver and allows the generation of HTML mail from LaTeX.
|
48
|
+
email: ayan.chakrabarti@gmail.com
|
49
|
+
executables:
|
50
|
+
- texmailer
|
51
|
+
extensions: []
|
52
|
+
|
53
|
+
extra_rdoc_files: []
|
54
|
+
|
55
|
+
files:
|
56
|
+
- LICENSE
|
57
|
+
- README
|
58
|
+
- lib/texmailer/send.rb
|
59
|
+
- lib/texmailer/config.rb
|
60
|
+
- lib/texmailer/drafts.rb
|
61
|
+
- lib/texmailer/wapp.rb
|
62
|
+
- lib/texmailer/ca-bundle.crt
|
63
|
+
- lib/texmailer/rhtml/header.html
|
64
|
+
- lib/texmailer/rhtml/settings.html
|
65
|
+
- lib/texmailer/rhtml/blankprev.html
|
66
|
+
- lib/texmailer/rhtml/index.html
|
67
|
+
- lib/texmailer/rhtml/drafts.html
|
68
|
+
- lib/texmailer/rhtml/send.html
|
69
|
+
- bin/texmailer
|
70
|
+
has_rdoc: true
|
71
|
+
homepage: http://www.eecs.harvard.edu/~ayanc/texmailer/
|
72
|
+
licenses: []
|
73
|
+
|
74
|
+
post_install_message:
|
75
|
+
rdoc_options: []
|
76
|
+
|
77
|
+
require_paths:
|
78
|
+
- lib
|
79
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
80
|
+
requirements:
|
81
|
+
- - ">="
|
82
|
+
- !ruby/object:Gem::Version
|
83
|
+
segments:
|
84
|
+
- 1
|
85
|
+
- 8
|
86
|
+
- 1
|
87
|
+
version: 1.8.1
|
88
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
89
|
+
requirements:
|
90
|
+
- - ">="
|
91
|
+
- !ruby/object:Gem::Version
|
92
|
+
segments:
|
93
|
+
- 0
|
94
|
+
version: "0"
|
95
|
+
requirements:
|
96
|
+
- tex4ht and htlatex
|
97
|
+
- msmtp from (http://msmtp.sourceforge.net/)
|
98
|
+
rubyforge_project:
|
99
|
+
rubygems_version: 1.3.6
|
100
|
+
signing_key:
|
101
|
+
specification_version: 3
|
102
|
+
summary: An application that runs a light local webserver and allows the generation of HTML mail from LaTeX.
|
103
|
+
test_files: []
|
104
|
+
|