texrack 0.6.0 → 0.6.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -1
- data/README.md +2 -2
- data/config.ru +3 -1
- data/lib/texrack/endpoint.rb +18 -11
- data/lib/texrack/pdf_to_png.rb +3 -2
- data/lib/texrack/version.rb +1 -1
- metadata +3 -3
- checksums.yaml.gz.asc +0 -18
- data.tar.gz.asc +0 -18
- metadata.gz.asc +0 -18
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8e927a95d9a26f57660682245b8692cf66e92e59
|
4
|
+
data.tar.gz: 638cba00dce6aa7ac0789ca38725e5221b1aa4e8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 55342332aad05363d60a949b407acf9d4cc08361e321d843625f63fc02395b39ef771ef11b9bd2fc21ded597b85948e91179d271fb7c0a1be098a42b19cfbafa
|
7
|
+
data.tar.gz: 36fe4e980ad2d7cb24556ff10fbe4ac1f516a2255ea0861c7af8e7da09626cbe5627286b6b81620241a43273445505701ca71037f7bfcfb12febb9dc3474ebbf
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# texrack
|
1
|
+
# texrack [![Code Climate](https://codeclimate.com/github/PerfectlyNormal/texrack.png)](https://codeclimate.com/github/PerfectlyNormal/texrack)
|
2
2
|
|
3
3
|
Simple Rack middleware to render LaTeX to PNGs on the fly.
|
4
4
|
|
@@ -59,4 +59,4 @@ Generated images are cached by default, so we don't have to shell out to
|
|
59
59
|
pdflatex and imagemagick all the time. Configure `cache_dir` to store the
|
60
60
|
files somewhere safe, otherwise a tempdir is created and used.
|
61
61
|
|
62
|
-
The application sends ETags for each generated image.
|
62
|
+
The application sends ETags for each generated image.
|
data/config.ru
CHANGED
data/lib/texrack/endpoint.rb
CHANGED
@@ -22,22 +22,18 @@ module Texrack
|
|
22
22
|
end
|
23
23
|
|
24
24
|
def render_png
|
25
|
-
|
26
|
-
etag digest
|
27
|
-
cache_control :public, max_age: 60 * 60 * 24 * 365
|
28
|
-
expires 60 * 60 * 24 * 365
|
25
|
+
set_headers
|
29
26
|
|
30
27
|
begin
|
31
|
-
output
|
32
|
-
|
33
|
-
send_file output, disposition: :inline
|
34
|
-
else
|
28
|
+
output = Texrack::OutputFile.new(digest)
|
29
|
+
unless output.exists?
|
35
30
|
pdf_source = erb :latex
|
36
31
|
pdf = Texrack::LatexToPdf.new(pdf_source, logger).generate_pdf
|
37
|
-
|
32
|
+
Texrack::PdfToPng.new(pdf, trim?, logger).to_file(output)
|
38
33
|
output.finish
|
39
|
-
send_file png, disposition: :inline
|
40
34
|
end
|
35
|
+
|
36
|
+
send_file output, disposition: :inline
|
41
37
|
rescue Texrack::LatexFailedError
|
42
38
|
send_static_error "latex-failed.png"
|
43
39
|
rescue Texrack::LatexNotFoundError
|
@@ -62,10 +58,21 @@ module Texrack
|
|
62
58
|
}
|
63
59
|
end
|
64
60
|
|
61
|
+
def set_headers
|
62
|
+
content_type 'image/png'
|
63
|
+
etag digest
|
64
|
+
cache_control :public, max_age: 60 * 60 * 24 * 365
|
65
|
+
expires 60 * 60 * 24 * 365
|
66
|
+
end
|
67
|
+
|
65
68
|
def math_mode?
|
66
69
|
params[:math] != "0"
|
67
70
|
end
|
68
71
|
|
72
|
+
def trim?
|
73
|
+
params[:trim] == "1"
|
74
|
+
end
|
75
|
+
|
69
76
|
def always_respond_with_200?
|
70
77
|
params[:always_200] == "1"
|
71
78
|
end
|
@@ -83,7 +90,7 @@ module Texrack
|
|
83
90
|
end
|
84
91
|
|
85
92
|
def digest
|
86
|
-
@digest ||= Digest::SHA1.hexdigest("#{data}:#{math_mode?}:#{packages_source}")
|
93
|
+
@digest ||= Digest::SHA1.hexdigest("#{Texrack::VERSION}:#{data}:#{math_mode?}:#{trim?}:#{packages_source}")
|
87
94
|
end
|
88
95
|
|
89
96
|
def packages_source
|
data/lib/texrack/pdf_to_png.rb
CHANGED
@@ -3,11 +3,12 @@ require 'cocaine'
|
|
3
3
|
class Texrack::PdfToPng
|
4
4
|
attr_reader :pdf_path, :logger, :line
|
5
5
|
|
6
|
-
def initialize(pdf_path, logger)
|
6
|
+
def initialize(pdf_path, trim, logger)
|
7
7
|
@pdf_path = pdf_path
|
8
|
+
@trim = trim
|
8
9
|
@logger = logger
|
9
10
|
@line = Cocaine::CommandLine.new(command,
|
10
|
-
"-density 300x300 -quality 90 :in :out", logger: logger)
|
11
|
+
"-density 300x300 -quality 90 #{"-trim" if trim} :in :out", logger: logger)
|
11
12
|
end
|
12
13
|
|
13
14
|
def command
|
data/lib/texrack/version.rb
CHANGED
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.6.
|
4
|
+
version: 0.6.1
|
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: 2014-
|
11
|
+
date: 2014-10-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sinatra
|
@@ -85,7 +85,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
85
85
|
version: '0'
|
86
86
|
requirements: []
|
87
87
|
rubyforge_project:
|
88
|
-
rubygems_version: 2.1
|
88
|
+
rubygems_version: 2.4.1
|
89
89
|
signing_key:
|
90
90
|
specification_version: 4
|
91
91
|
summary: Rack microservice to render LaTeX as PNG
|
checksums.yaml.gz.asc
DELETED
@@ -1,18 +0,0 @@
|
|
1
|
-
-----BEGIN PGP SIGNATURE-----
|
2
|
-
Version: GnuPG/MacGPG2 v2.0.22 (Darwin)
|
3
|
-
Comment: GPGTools - http://gpgtools.org
|
4
|
-
|
5
|
-
iQIcBAABAgAGBQJTqDsmAAoJEH1ncb0Txu7XpfcQAImASoQjnlFnFlurrclyer5+
|
6
|
-
8PGUwB/URoG532lNiwj0JnCv7IgwNtYd2P/QnRZbjmIJjI+Q8x+0YS1fnHjXxr5+
|
7
|
-
V8xrFp6Y+Fe3vTh1Du+Aelr2ywsImBWpRiXQ5n0MegS8RnYwMOBXxDEU/YljwgEH
|
8
|
-
Sb18IbgRlGpCSEOwnNFO1Do0Twqo8qdp9ZoiPcKKo2by2iFcrCD5fbVy12gKK9tn
|
9
|
-
FSl6RHuI7lBE46YO69QyZRko5hFtqsu2zj0dNYSMS4RxiyWBNf1uuGHvApRFklqb
|
10
|
-
A9olXsFqZu5C0HQv+uiDXxjtnwroDLfmBsomRTCNLQNf85lMuNjyNu9L+0lYv+Z5
|
11
|
-
t39pC00M+bZB/GXUQZWRGNA1MhvTekMQcaeMIfVX1YfzCczGHhBk6QuwA5g7htyy
|
12
|
-
Y3cjT5Uc6ESaHLybpk3tLr7QqKWRVPZ2DKmj9XQ5ZnBET1nx/iAp5oVDOv7M+6R9
|
13
|
-
uYDTR5hfZ+GgfYIPADr8q1f+ffVWWNQamJpzC6/Ho/glk9p+6q4YwY1Jm/GA6LD2
|
14
|
-
Xbi+lo4d/nNrQeSwoamGg/6djvuwRc3svBdIECyNtFRjqoBhpJgGdBiUMbQ2qPaE
|
15
|
-
zcJMJWswIydCZ162hLRZboK1wUFgj5iJtr0bt1WJZ7n/wbFsSR7b1B07N6/dCOJR
|
16
|
-
+VAEV0AU2GpYhDutUm43
|
17
|
-
=ASTb
|
18
|
-
-----END PGP SIGNATURE-----
|
data.tar.gz.asc
DELETED
@@ -1,18 +0,0 @@
|
|
1
|
-
-----BEGIN PGP SIGNATURE-----
|
2
|
-
Version: GnuPG/MacGPG2 v2.0.22 (Darwin)
|
3
|
-
Comment: GPGTools - http://gpgtools.org
|
4
|
-
|
5
|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P/Az9UlBYxTw93E2juNpuzOWm
|
6
|
-
5Q/u/Sz5SY9AZ4b0wrr320dRdorWtUozIHphkQ6S/gqih/bn/bc2iHP4g5ohbuOH
|
7
|
-
d9ShqhrFGBIAciW/EjHkqSyvvzYY1tSPpESILlgwO0tF3iJAp5n+XY8APzqI79W4
|
8
|
-
OLv5cF5sxnsy8ZDH5AkrOwdpKW/Ef70OB29feJhrFZkEJPNmPaDPck7S68IiXP5c
|
9
|
-
dUSiaM10WYdKNpkx8i2DipsiY9lRPhz/VtdA9qWjEufJmSk18R+8jmZByjS2uarY
|
10
|
-
K8oT5vaj2e4TyPrczNG5t8uS+Jb2eUe/xHdHW351AWuR7mxOzNjEsBlq7vJG1kJd
|
11
|
-
mjqj8CYkmQW5eEekmdGGcqf9MEn0FgYJUTeHqRTbpaYiAEmtp2WM88iSftFAETTu
|
12
|
-
zrk11jSGe8EsS4qWpFTZKW0d3NuC3s5fIOP0FBsyu9GQUcXtvbPcE8U74IdN8Njf
|
13
|
-
ReeKv0o32ljbeP4xTesev8E+0GSP4b6U+LoEeH4OBIbpdzjFDXpC6FWqGMXOMxfu
|
14
|
-
OhKA4awTzkBWe3QLpYuZZmKQn+bYwcXzeOghedWpyFlnfdLGfkgBxYjatAr50FgU
|
15
|
-
BAcOQFnxrvluWD/+UgIURaOa+TwG3y8AX54+KgPcx1GbOOib8Mcu8fGOgRY6rB31
|
16
|
-
CuG/h6lOSjH4ly+AabMh
|
17
|
-
=Yymp
|
18
|
-
-----END PGP SIGNATURE-----
|