texrack 0.3.0 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.asc +13 -13
- data/CHANGELOG.md +11 -0
- data/README.md +18 -2
- data/lib/texrack/endpoint.rb +6 -0
- data/lib/texrack/latex_to_pdf.rb +7 -2
- data/lib/texrack/pdf_to_png.rb +5 -1
- data/lib/texrack/version.rb +1 -1
- data/lib/texrack.rb +8 -0
- data.tar.gz.asc +13 -13
- metadata +2 -2
- metadata.gz.asc +13 -13
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d6317e26ded8ae7d0129684554de7d88e69a1e8b
|
4
|
+
data.tar.gz: 69b53f08a52c1fc208682845663ae7fb7e07a4b0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d111375ea46c941da09ae7e24041b738e333810eb993806b818de9212ec139f2dee4d3499e2017ba93ecd8ac077606107357354448ae5df0263084b7df10cfa7
|
7
|
+
data.tar.gz: b54563309cf3d815c712ec0d3fba2ed718895a390db4a0b906af8c1bed7681199b9aa1849a14cccc4cc800485a232f3ac7c3391720d3d1bdcfe9c752e07ac985
|
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
|
+
iQIcBAABAgAGBQJSe5GZAAoJEH1ncb0Txu7XINMP/1gRdSm8xaodlyEXmnLsBAda
|
6
|
+
G6ho7yTB4buwDSnnNU0d7+cU+83xwTL4lsWs/Eg318ciAMJURCpNPs8nfWtlnokd
|
7
|
+
jfYuh7hYBuQf2Bf0ymP3LtKjGICOYl/AuoNHzM77ro4x8cCnE3rskixE3hNn8KP+
|
8
|
+
aurZAQxRVQX7x1cJdd0Qy+mocWjuhZ7yOiBzHu+DCpGAP2FO3I7BhTnN2blchvr0
|
9
|
+
+GfevI83LOdj3Ai/r5wRXdGCv0DDpMCSulwLA5AAP4yRqyNy0EKafAIC35IK/9IF
|
10
|
+
j4LQZljaa2XjyZawiqswdF9ibMXNSOTbbzADqabCd1wiS+yAVnx55ea3PpwL/Zai
|
11
|
+
zZE4L1oJkos5yMYBnzy8WPCpfVkW7ZWmuvOriHGSQ2TgY9oEjN7mLVSdfm6ZqN0a
|
12
|
+
u9109ir6i9R9ZcfE8cz+L++hSU/r73jOepzy3L+VbBHgbQVTWlw4bMIggLENODu2
|
13
|
+
1uTClnOByBSPgjtR+JeP9a9DvkOkno40AxiyT1znTpfn7KOe5Yi4L1t10Fi855cj
|
14
|
+
m74/7z1kjKQX3+f6PZ71DZohw9+1LoLvNjpS1cYiYZBuiLK2L8Bq0TyidopLNwQ5
|
15
|
+
L5UbiBSdN/RNU3CTswcmD2Qnp2eSsMBVRTdi/28PlgRrD3oBQcbcrT1SejrhgNFq
|
16
|
+
MfMo+KltUt97YyZvnuBL
|
17
|
+
=VOKf
|
18
18
|
-----END PGP SIGNATURE-----
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,14 @@
|
|
1
|
+
# 0.5.0 / 2013-11-07
|
2
|
+
|
3
|
+
* A typo snuck in, referencing FileText instead of FileTest
|
4
|
+
* Make the generated PNG readable by the world, to avoid potential issues
|
5
|
+
with serving the file.
|
6
|
+
* Allow passing in a own logger, e.g. `Rails.logger`
|
7
|
+
|
8
|
+
# 0.4.0 / 2013-11-07
|
9
|
+
|
10
|
+
* Allow configuring where to find binaries
|
11
|
+
|
1
12
|
# 0.3.0 / 2013-11-05
|
2
13
|
|
3
14
|
* Allow forcing the response status to 200 OK
|
data/README.md
CHANGED
@@ -4,11 +4,27 @@ Simple Rack middleware to render LaTeX to PNGs on the fly.
|
|
4
4
|
|
5
5
|
## Requirements
|
6
6
|
|
7
|
-
* `pdflatex` must
|
8
|
-
* `convert` (from ImageMagick) must
|
7
|
+
* `pdflatex` must be installed
|
8
|
+
* `convert` (from ImageMagick) must be installed
|
9
9
|
|
10
10
|
## Configuration
|
11
11
|
|
12
|
+
If "pdflatex" or "convert" is not available in `PATH`, you can change
|
13
|
+
`Texrack.config` and specify where to find them.
|
14
|
+
|
15
|
+
If you want a custom logger, set `Texrack.config[:logger]` to anything
|
16
|
+
responding to `#warn`, `#debug`, `#info` and so on.
|
17
|
+
For example `Rails.logger` if mounting inside a Rails application.
|
18
|
+
|
19
|
+
The default configuration is
|
20
|
+
```ruby
|
21
|
+
Texrack.config = {
|
22
|
+
pdflatex: "pdflatex",
|
23
|
+
convert: "convert",
|
24
|
+
logger: nil,
|
25
|
+
}
|
26
|
+
```
|
27
|
+
|
12
28
|
## Usage
|
13
29
|
|
14
30
|
Either POST or GET to the configured URL with `data` set to the LaTeX source to
|
data/lib/texrack/endpoint.rb
CHANGED
@@ -5,6 +5,7 @@ module Texrack
|
|
5
5
|
class Endpoint < Sinatra::Base
|
6
6
|
enable :logging
|
7
7
|
set :public_folder, File.dirname(__FILE__) + '/static'
|
8
|
+
set :views, File.dirname(__FILE__) + '/views'
|
8
9
|
|
9
10
|
get '/' do
|
10
11
|
if data != ""
|
@@ -27,6 +28,7 @@ module Texrack
|
|
27
28
|
pdf = Texrack::LatexToPdf.new(pdf_source, logger).generate_pdf
|
28
29
|
png = Texrack::PdfToPng.new(pdf, logger).to_file(output)
|
29
30
|
send_file png, disposition: :inline
|
31
|
+
File.chmod(0644, png)
|
30
32
|
rescue Texrack::LatexFailedError
|
31
33
|
send_static_error "latex-failed.png"
|
32
34
|
rescue Texrack::LatexNotFoundError
|
@@ -39,6 +41,10 @@ module Texrack
|
|
39
41
|
end
|
40
42
|
|
41
43
|
helpers do
|
44
|
+
def logger
|
45
|
+
@logger ||= (Texrack.config[:logger] || Logger.new(STDERR))
|
46
|
+
end
|
47
|
+
|
42
48
|
def send_static_error(filename)
|
43
49
|
send_file File.join(settings.public_folder, filename), {
|
44
50
|
disposition: :inline,
|
data/lib/texrack/latex_to_pdf.rb
CHANGED
@@ -24,8 +24,8 @@ class Texrack::LatexToPdf
|
|
24
24
|
Dir.chdir File.dirname(input)
|
25
25
|
args = %w[-shell-escape -interaction batchmode -halt-on-error] + [input.path]
|
26
26
|
|
27
|
-
logger.debug "Texrack executing:
|
28
|
-
exec
|
27
|
+
logger.debug "Texrack executing: #{command} #{args}"
|
28
|
+
exec command, *args
|
29
29
|
rescue
|
30
30
|
logger.error "#{$!.message}:\n#{$!.backtrace.join("\n")}\n"
|
31
31
|
ensure
|
@@ -46,7 +46,12 @@ class Texrack::LatexToPdf
|
|
46
46
|
output
|
47
47
|
end
|
48
48
|
|
49
|
+
def command
|
50
|
+
Texrack.config[:pdflatex] || "pdflatex"
|
51
|
+
end
|
52
|
+
|
49
53
|
def has_pdflatex?
|
54
|
+
return true if File.exists?(command) && FileTest.executable?(command)
|
50
55
|
ENV["PATH"].split(':').any? {|x| FileTest.executable? "#{x}/pdflatex" }
|
51
56
|
end
|
52
57
|
private :has_pdflatex?
|
data/lib/texrack/pdf_to_png.rb
CHANGED
@@ -6,10 +6,14 @@ class Texrack::PdfToPng
|
|
6
6
|
def initialize(pdf_path, logger)
|
7
7
|
@pdf_path = pdf_path
|
8
8
|
@logger = logger
|
9
|
-
@line = Cocaine::CommandLine.new(
|
9
|
+
@line = Cocaine::CommandLine.new(command,
|
10
10
|
"-density 300x300 -quality 90 :in :out", logger: logger)
|
11
11
|
end
|
12
12
|
|
13
|
+
def command
|
14
|
+
Texrack.config[:convert] || "convert"
|
15
|
+
end
|
16
|
+
|
13
17
|
def to_file(file)
|
14
18
|
line.run(in: pdf_path, out: file.path)
|
15
19
|
file.path
|
data/lib/texrack/version.rb
CHANGED
data/lib/texrack.rb
CHANGED
@@ -7,4 +7,12 @@ module Texrack
|
|
7
7
|
class LatexNotFoundError < StandardError; end
|
8
8
|
class ConvertNotFoundError < StandardError; end
|
9
9
|
class LatexFailedError < StandardError; end
|
10
|
+
|
11
|
+
def self.config
|
12
|
+
@config ||= {
|
13
|
+
pdflatex: "pdflatex",
|
14
|
+
convert: "convert",
|
15
|
+
logger: nil
|
16
|
+
}
|
17
|
+
end
|
10
18
|
end
|
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
|
+
iQIcBAABAgAGBQJSe5GYAAoJEH1ncb0Txu7XYhcP/1OiDgOwvI2ID2AUtaGhi1yp
|
6
|
+
JqsK/zcaBJtf6+2dSCACekxxVe74n7DwI9j4yu2egR7dgFfB1XnG4cg4FFxaOnIK
|
7
|
+
1UW7JQ8+DFHDLEOIzKgg9OECJtvyJQSvZIuDINgOl/R5myK4a5U85U5Ico9mN95Q
|
8
|
+
k/6iE9t3nKGYlzUZ/McHw6TiIC9LuGfjvCUgTKmWzkSgWRpXj7tV0N8afvz9PHo0
|
9
|
+
doBjux5osSanEvjGapa0tf2m+0r5drrad6p7qcBARCTEmRPqzljoxIAOSfA9Abv6
|
10
|
+
enb2clhWAc8UIwt5pud3yuIIcI66Zp56ZWoUyil1JC+ciXer7LHwYZFF6yuOF/L+
|
11
|
+
idX4aqF/REtXw8xAzu8QyM6qiD2abH89mKVOaOaS5VvnciN4gwdcDyMBr6AOgRG1
|
12
|
+
vwuPtJlA4n4Rjs1CxWLFdsd/RwGXioQmdXYXdzQQ/ocwatH50UE3WgylRwgwX2kP
|
13
|
+
2BEVkpSdCeikFZFWhsfJwYgIoEV0q2p8UiS45nCEnDA+GV2DcW/7VCSZb63wZ2p3
|
14
|
+
0wRaanrZYC59/aJ6apy6VETMLsMKnau5+jKpooWhdl051roGrBkR8Si0SJOMTxWU
|
15
|
+
hBhbJgO9/1UggMCErDJHHkoGYxrXP9El72Y5eDOcf4v5VphF+yQ6sGhhnONVO3TO
|
16
|
+
RD0PZqRgH62ieTOtjH01
|
17
|
+
=2+ib
|
18
18
|
-----END PGP SIGNATURE-----
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: texrack
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.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-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sinatra
|
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
|
+
iQIcBAABAgAGBQJSe5GYAAoJEH1ncb0Txu7XaboP/A9/Omb/3z5qZ02f1G1uHoDW
|
6
|
+
FGy2hqn8NrjCJZD+NlwULzcCNRY9tSISGDHEsxvLuKHKkEnrJngTRPSmqLUdx8AE
|
7
|
+
xyMrRTxyDTlgIBnl7P+e2Jmv+L8UlIMTTvWk7tpto7Q7AKRMbhsTyruNEaKgvXfc
|
8
|
+
mvS0fEcI4S+F6eM0eYp9AzVbtB4/LTRZjRFMfWTJwdbcKqNdRcjzWgclPYK0ww1a
|
9
|
+
oAVZikG6ADRgfzA2is8TaAm5Ik148GCoKppUiNtggwwtlpV24KZHLYUpw6J6SFJ3
|
10
|
+
t6jpA5cBEq8owObm7iJts3ajEDVqdbIJVgE8xVI9eyX5kVNhyg+b6TzzxpLprJkm
|
11
|
+
qvP6h5vsGyhfgm2k87lPioeGSaLW/Ragf8YXOTRBhwGaGdHWxCr7nfz68Dp26fKP
|
12
|
+
hgeoTM0r3Y4ZD2OFOXGgrQm7+fjoRlsSkRPVgbEzE0uYfsXcf+jHvyQ1/3peDl/X
|
13
|
+
Esead3KVdOYBQ6PJstEGjAEHaYeaYUzuJLIdEa6+EW8iH9dNT9iMIsuyn2d7IscX
|
14
|
+
GGogm0NPeH2miuBpbGQIHm8dVTRzQ8A1Ieezw2iZH44Isr0ktdbq+QSuriYISlwE
|
15
|
+
povDu1thYdKhQ7zqNBAoLywXj7uoOYP1cuXciZ6wNmRjJTjqbDixQ2tQ+3Y40Vwj
|
16
|
+
4dwV7LzAjH1qx2h1IZ0w
|
17
|
+
=mWad
|
18
18
|
-----END PGP SIGNATURE-----
|