texrack 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +6 -14
- checksums.yaml.gz.asc +13 -13
- data.tar.gz.asc +13 -13
- data/CHANGELOG.md +14 -0
- data/README.md +5 -0
- data/lib/texrack/endpoint.rb +28 -20
- data/lib/texrack/latex_to_pdf.rb +5 -15
- data/lib/texrack/static/latex-failed.png +0 -0
- data/lib/texrack/static/missing-convert.png +0 -0
- data/lib/texrack/static/missing-pdflatex.png +0 -0
- data/lib/texrack/version.rb +1 -1
- data/lib/texrack/views/latex.erb +1 -1
- metadata +12 -12
- metadata.gz.asc +13 -13
checksums.yaml
CHANGED
@@ -1,15 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
metadata.gz: !binary |-
|
9
|
-
M2Q2NTQ0ZDRjMTg3NjE5OTM5MmExM2U5ZmM2MzdhMDg4ZDQxNDczZmI0YTcz
|
10
|
-
OTY1MzQ1ZGU0ZTZiOGU5MjIyNTgwNzMwOGEwZmNjMTI0Mjc2N2UxN2RjZmNl
|
11
|
-
MDU0NjBlZTFkN2Q2NTIzYmI4MTM5YzNlZmY0NDM0NWExODQ5ZWQ=
|
12
|
-
data.tar.gz: !binary |-
|
13
|
-
OTIyYzU4NTA2YmIyMzViODEwMDQ5NjNlNTFhZjFjNjVhMGVhYTdmMGE5YWQ5
|
14
|
-
NDFkYWFkMTJmYTAxNmQwYWZlMDU5MWMxZWMyMzI4ZGQ1NDAzNGVhODdjNWQz
|
15
|
-
NTMwMTAwMjZjMDcwZDY2MTE2ZGU0YjQ1OGJmNzM0OGY0MWZjMDI=
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 4aea4cde344abda376e29d4adbb6415644d75d67
|
4
|
+
data.tar.gz: c2d87b2eee6ea9963d8c41cc0710775a3f3d948c
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 48f349be4326492b76c5908c1c9f4b726d5b7e57c47892bd93ca52aa38b0111d316ff00236b0ed0c157b11b299fbd0b90154b75a1a8f9abf2649e63e53cc9a52
|
7
|
+
data.tar.gz: 0eaab0480d74bf0e6602057bd9fce79e259832ed69e589240e0a9f9654ac58b97b2b2938aef9c1c8bcdf40c5b2235dd2331e47090892f6adbd1c30d349e6eec2
|
checksums.yaml.gz.asc
CHANGED
@@ -2,17 +2,17 @@
|
|
2
2
|
Version: GnuPG/MacGPG2 v2.0.20 (Darwin)
|
3
3
|
Comment: GPGTools - http://gpgtools.org
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
=
|
5
|
+
iQIcBAABAgAGBQJSePZ+AAoJEH1ncb0Txu7XyKoQAI9383kh4LNjO6W23K5ipagY
|
6
|
+
dcSrmSvn1XDIJvAJyFtQpBaGVxdcGJW8U5E8LCEhD3UE93mOfgC86HGuQLO0/0EC
|
7
|
+
M87VvLp2rtwa+FoEF+e6Y5FYLahuLFlSnomDDhWwAcU85eazr3ARSprdx6e8iH3B
|
8
|
+
N0xplsS1mpoBbZ1tn4pAinDx2IU/iqnqYadPgMPpqJ3+jjDKZn9vNTCbpwLphVOA
|
9
|
+
xbGWJiu1CKWs1gCUWcwR9uUMWTqcPXkfforJmJdZd7lZ1KccMc1HoNY9JykRpRgu
|
10
|
+
VRGmGmRnu/P+MwO+AdeQnXamcld95rMU7ktnQM0YIAbp8LcaDCZ7SruXzlaXUYQg
|
11
|
+
YFNbdvfkW0aGR0RLcAK2DWtUDcPcgPuCz23q6YO4kZhmToIR4monO+ZohmsJEfUB
|
12
|
+
RvA+sljHqBwwMF2N42dGYm1pwhKm//28GHWlxIt4sRrbtM1xSiOZh/Pi9u9l+QC6
|
13
|
+
AgMcdaVdKut1EN0BzjSHZwSVHUf1vZWaRDxYZWmgMrPFhxPbYhex63+2f9RoGZN2
|
14
|
+
ICE9Fiq30k+1iyFATTvv8xdJzxUVdj+f8Wk4+mMHC2RzZ7AySPLDkXktWPIUOC1W
|
15
|
+
I3SElQ42lIn668t3MRMpRjHJuZz06/MILVi2mVFcJ1jPJg6PtUDpKq1Do6xaOXYx
|
16
|
+
NMcmLMvksi0DxwW2j8uQ
|
17
|
+
=391P
|
18
18
|
-----END PGP SIGNATURE-----
|
data.tar.gz.asc
CHANGED
@@ -2,17 +2,17 @@
|
|
2
2
|
Version: GnuPG/MacGPG2 v2.0.20 (Darwin)
|
3
3
|
Comment: GPGTools - http://gpgtools.org
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
=
|
5
|
+
iQIcBAABAgAGBQJSePZ+AAoJEH1ncb0Txu7XvuoP/0w4NpPnGkp70nQUjdCV4OWv
|
6
|
+
xYW/7mxq48b/63uLflAQNMtuuySG4bc73C8eYVlvFF39qsxopHmJUDBeh1aQUiW4
|
7
|
+
02lv50CqInokYs2CT3grJpGv97YGVy8JnbmP0W2lRdZnp/GdxrRTKEr9IdpsIn60
|
8
|
+
/PL2pMd94c4g0we5wngis3t/PoFyHLrIEVlixVmF6ofM1BAArZb3JqhHEFyxcuYT
|
9
|
+
7/ZKeUkZRbUKAQkwBiTqQzdPujWqcLQDkNWZZWdhie4P/xqK0Uj9kwqLAOFY2mAk
|
10
|
+
E/K79WFrqwLcKLerwCIqiU+hjIuJpavvbBD8cwwgboYCbSqzC+NbxwDuzPnkB1vO
|
11
|
+
wEU+rU885KtxI1qKhFXSuHAitvOATHabaOyvQlHn+iexZUtt91SbobwV+sqg0Eda
|
12
|
+
F42VJ0xnZZrVYjOLfLwkj3PXj5QVTRP2RfnXOVE7Vwqe8K4iSXS4ahQKaRLRQlwZ
|
13
|
+
OZIwXRk+c8fXsKgXSbiXMxIKWxbh79pTBJ7myFp72L4iN47pZ6z3agBTc+IqCa5Q
|
14
|
+
79pNhXRWLAbeTXu6i6+H08EHpDMm7dGBFPb2cmV4KgLjfhZyna1fdnkWqKZP6p3T
|
15
|
+
wHIxq0tphfvhHdfcYoUcD9iHROn14i0f5z+MpEpMbQvVDzAQfpskRUx6spwyXyIG
|
16
|
+
ubc4VCkcsK7pxxZRcflN
|
17
|
+
=km1K
|
18
18
|
-----END PGP SIGNATURE-----
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
# 0.3.0 / 2013-11-05
|
2
|
+
|
3
|
+
* Allow forcing the response status to 200 OK
|
4
|
+
* Remove unused code
|
5
|
+
|
6
|
+
# 0.2.0 / 2013-11-01
|
7
|
+
|
8
|
+
* Replace RMagick with Cocaine and ImageMagick
|
9
|
+
* Better error handling
|
10
|
+
* Work when mounted somewhere other than /
|
11
|
+
|
12
|
+
# 0.1.0 / 2013-10-28
|
13
|
+
|
14
|
+
* Initial version
|
data/README.md
CHANGED
@@ -31,3 +31,8 @@ turns into
|
|
31
31
|
\usepackage[usenames,dvipsnames,svgnames,table]{xcolor}
|
32
32
|
\usepackage{amssymb}
|
33
33
|
```
|
34
|
+
|
35
|
+
### Always respond with 200 OK
|
36
|
+
If you are dealing with software incapable of proper status codes (looking at
|
37
|
+
you, Flash), you can pass `always_200=1` and it'll respond with 200 OK even
|
38
|
+
though we should really respond with a 5xx.
|
data/lib/texrack/endpoint.rb
CHANGED
@@ -7,57 +7,65 @@ module Texrack
|
|
7
7
|
set :public_folder, File.dirname(__FILE__) + '/static'
|
8
8
|
|
9
9
|
get '/' do
|
10
|
-
if
|
11
|
-
render_png
|
10
|
+
if data != ""
|
11
|
+
render_png
|
12
12
|
else
|
13
13
|
erb :form
|
14
14
|
end
|
15
15
|
end
|
16
16
|
|
17
17
|
post '/' do
|
18
|
-
render_png
|
18
|
+
render_png
|
19
19
|
end
|
20
20
|
|
21
|
-
def render_png
|
21
|
+
def render_png
|
22
22
|
content_type 'image/png'
|
23
|
+
|
23
24
|
begin
|
24
|
-
@data = source
|
25
25
|
output = Tempfile.new(["texrack-output", ".png"])
|
26
26
|
pdf_source = erb :latex
|
27
27
|
pdf = Texrack::LatexToPdf.new(pdf_source, logger).generate_pdf
|
28
28
|
png = Texrack::PdfToPng.new(pdf, logger).to_file(output)
|
29
|
-
send_file png,
|
30
|
-
disposition: :inline
|
31
|
-
}
|
29
|
+
send_file png, disposition: :inline
|
32
30
|
rescue Texrack::LatexFailedError
|
33
|
-
|
34
|
-
disposition: :inline,
|
35
|
-
status: 500
|
36
|
-
}
|
31
|
+
send_static_error "latex-failed.png"
|
37
32
|
rescue Texrack::LatexNotFoundError
|
38
33
|
logger.error "Could not find pdflatex in #{ENV['PATH']}"
|
39
|
-
|
40
|
-
disposition: :inline,
|
41
|
-
status: 500
|
42
|
-
}
|
34
|
+
send_static_error "missing-pdflatex.png"
|
43
35
|
rescue Texrack::ConvertNotFoundError
|
44
36
|
logger.error "Could not find convert (ImageMagick) in #{ENV['PATH']}"
|
45
|
-
|
46
|
-
disposition: :inline,
|
47
|
-
status: 500
|
48
|
-
}
|
37
|
+
send_static_error "missing-convert.png"
|
49
38
|
end
|
50
39
|
end
|
51
40
|
|
52
41
|
helpers do
|
42
|
+
def send_static_error(filename)
|
43
|
+
send_file File.join(settings.public_folder, filename), {
|
44
|
+
disposition: :inline,
|
45
|
+
status: error_status
|
46
|
+
}
|
47
|
+
end
|
48
|
+
|
53
49
|
def math_mode?
|
54
50
|
params[:math] != "0"
|
55
51
|
end
|
56
52
|
|
53
|
+
def always_respond_with_200?
|
54
|
+
params[:always_200] == "1"
|
55
|
+
end
|
56
|
+
|
57
|
+
def error_status
|
58
|
+
always_respond_with_200? ? 200 : 500
|
59
|
+
end
|
60
|
+
|
57
61
|
def root_path
|
58
62
|
"#{env['SCRIPT_NAME']}/"
|
59
63
|
end
|
60
64
|
|
65
|
+
def data
|
66
|
+
params[:data].to_s.strip
|
67
|
+
end
|
68
|
+
|
61
69
|
def packages
|
62
70
|
found = {}
|
63
71
|
params[:packages].to_s.split("|").each do |package|
|
data/lib/texrack/latex_to_pdf.rb
CHANGED
@@ -1,14 +1,9 @@
|
|
1
1
|
class Texrack::LatexToPdf
|
2
|
-
|
3
|
-
@config ||= {command: 'pdflatex', arguments: [], parse_twice: false}
|
4
|
-
end
|
5
|
-
|
6
|
-
attr_reader :config, :latex, :logger
|
2
|
+
attr_reader :latex, :logger
|
7
3
|
|
8
|
-
def initialize(latex, logger=Logger.new(STDOUT)
|
4
|
+
def initialize(latex, logger=Logger.new(STDOUT))
|
9
5
|
@latex = latex
|
10
6
|
@logger = logger
|
11
|
-
@config = self.class.config.merge(overrides)
|
12
7
|
end
|
13
8
|
|
14
9
|
# Converts a string of LaTeX code into a binary string of PDF.
|
@@ -27,15 +22,10 @@ class Texrack::LatexToPdf
|
|
27
22
|
fork do
|
28
23
|
begin
|
29
24
|
Dir.chdir File.dirname(input)
|
30
|
-
args =
|
31
|
-
|
32
|
-
if config[:parse_twice]
|
33
|
-
logger.debug("Texrack executing (parse twice): #{config[:command]} -draftmode #{args}")
|
34
|
-
system config[:command], '-draftmode', *args
|
35
|
-
end
|
25
|
+
args = %w[-shell-escape -interaction batchmode -halt-on-error] + [input.path]
|
36
26
|
|
37
|
-
logger.debug "Texrack executing:
|
38
|
-
exec
|
27
|
+
logger.debug "Texrack executing: pdflatex #{args}"
|
28
|
+
exec "pdflatex", *args
|
39
29
|
rescue
|
40
30
|
logger.error "#{$!.message}:\n#{$!.backtrace.join("\n")}\n"
|
41
31
|
ensure
|
Binary file
|
Binary file
|
Binary file
|
data/lib/texrack/version.rb
CHANGED
data/lib/texrack/views/latex.erb
CHANGED
metadata
CHANGED
@@ -1,43 +1,43 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: texrack
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Per Christian B. Viken
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-11-
|
11
|
+
date: 2013-11-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
+
name: sinatra
|
14
15
|
requirement: !ruby/object:Gem::Requirement
|
15
16
|
requirements:
|
16
17
|
- - ~>
|
17
18
|
- !ruby/object:Gem::Version
|
18
19
|
version: 1.4.4
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
19
22
|
version_requirements: !ruby/object:Gem::Requirement
|
20
23
|
requirements:
|
21
24
|
- - ~>
|
22
25
|
- !ruby/object:Gem::Version
|
23
26
|
version: 1.4.4
|
24
|
-
type: :runtime
|
25
|
-
prerelease: false
|
26
|
-
name: sinatra
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
|
+
name: cocaine
|
28
29
|
requirement: !ruby/object:Gem::Requirement
|
29
30
|
requirements:
|
30
31
|
- - ~>
|
31
32
|
- !ruby/object:Gem::Version
|
32
33
|
version: 0.5.3
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
33
36
|
version_requirements: !ruby/object:Gem::Requirement
|
34
37
|
requirements:
|
35
38
|
- - ~>
|
36
39
|
- !ruby/object:Gem::Version
|
37
40
|
version: 0.5.3
|
38
|
-
type: :runtime
|
39
|
-
prerelease: false
|
40
|
-
name: cocaine
|
41
41
|
description: texrack is a microservice that renders LaTeX as PNG files. Can be mounted
|
42
42
|
in a Rack app
|
43
43
|
email:
|
@@ -48,6 +48,7 @@ extra_rdoc_files:
|
|
48
48
|
- MIT-LICENSE
|
49
49
|
- README.md
|
50
50
|
files:
|
51
|
+
- CHANGELOG.md
|
51
52
|
- MIT-LICENSE
|
52
53
|
- README.md
|
53
54
|
- config.ru
|
@@ -73,19 +74,18 @@ require_paths:
|
|
73
74
|
- lib
|
74
75
|
required_ruby_version: !ruby/object:Gem::Requirement
|
75
76
|
requirements:
|
76
|
-
- -
|
77
|
+
- - '>='
|
77
78
|
- !ruby/object:Gem::Version
|
78
79
|
version: '0'
|
79
80
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
80
81
|
requirements:
|
81
|
-
- -
|
82
|
+
- - '>='
|
82
83
|
- !ruby/object:Gem::Version
|
83
84
|
version: '0'
|
84
85
|
requirements: []
|
85
86
|
rubyforge_project:
|
86
|
-
rubygems_version: 2.
|
87
|
+
rubygems_version: 2.1.10
|
87
88
|
signing_key:
|
88
89
|
specification_version: 4
|
89
90
|
summary: Rack microservice to render LaTeX as PNG
|
90
91
|
test_files: []
|
91
|
-
has_rdoc:
|
metadata.gz.asc
CHANGED
@@ -2,17 +2,17 @@
|
|
2
2
|
Version: GnuPG/MacGPG2 v2.0.20 (Darwin)
|
3
3
|
Comment: GPGTools - http://gpgtools.org
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
+
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
=
|
5
|
+
iQIcBAABAgAGBQJSePZ9AAoJEH1ncb0Txu7XD9wP/26fhxMMP+dioXtmzUmPGm5S
|
6
|
+
BCWF8BztPSrydWQyvFDrjE02C/t9NX71p428L6Qz+xgIb4/8i/dcFVjVwSUPBhcX
|
7
|
+
dnYUqEnbVnJFU7SkKAU29+cp1lntAyR13D3vb6WquYQNasOlRlFXVCjC7miYWIPE
|
8
|
+
yWhP5XRkfsnz4N9GflMd5Vt3zGn1BBePMWAvgOgZ464OWF/pMIn7qf6ITB/dKoHo
|
9
|
+
4UAXEmhAESmrXgGnAWNSde0Dy6HIrszWcuOOk6i+cGCR74VjnfAM7y9882O92VxI
|
10
|
+
CtaCTULZdgJaz8pEKtbIL2hKfo+EMfvmKib95ZGZbWTjRLuocGv4Frqoxnm6lIBT
|
11
|
+
NIR+vKcwH4p9SOyLWVpfeMs0hTGhAUddGv5MuxptqHWUUZysGB15SxkY2prfdYBX
|
12
|
+
qLGIGOZZd5dPIRdmpFTScW4rduvROybXoPpXnoALMU+X/1B5+pFFhq6GPY8xV1gz
|
13
|
+
TQoVQfv2wS/IKSf1wKMc43u4lEwAE6SKu50n6lQ0McDgadoY8QSri5S5IdCE17Rj
|
14
|
+
2fLK9bjIxOUu1YB0M7gM6py/HONtdhyFi+m7hrOz3pR5n4p+s4wz4JlGnvaFx0mv
|
15
|
+
W2Vigv62cA3KKqN0dBs+X71KQ9HWlqSGaDcGTjYUn84ZiiN28/loT4iK/XdaZHQI
|
16
|
+
9udoJjCfPa9bgMNk+yZw
|
17
|
+
=V8na
|
18
18
|
-----END PGP SIGNATURE-----
|