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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b523a5a1e75e256049dfb84edf012060fdb50337
4
- data.tar.gz: 90e7971413c416e2d5e2318878a0e6313ec5332c
3
+ metadata.gz: 8e927a95d9a26f57660682245b8692cf66e92e59
4
+ data.tar.gz: 638cba00dce6aa7ac0789ca38725e5221b1aa4e8
5
5
  SHA512:
6
- metadata.gz: e46b080448db5c47d3d18453bdc47addc72553bd5f4ce18379787231a5537f214e8c1fcdaa95ae3f8094ddd698f57a7980eec94fd1b0869292d6fcb98f8fa98d
7
- data.tar.gz: bbc0d57800af7de61d334a3a08215c3863f3cacfb0d1e7cf643da9744a40496f21a4162c3e6fa85e7320c0029b1496e9320e0162273db9be60a2ffb0fb26e6f5
6
+ metadata.gz: 55342332aad05363d60a949b407acf9d4cc08361e321d843625f63fc02395b39ef771ef11b9bd2fc21ded597b85948e91179d271fb7c0a1be098a42b19cfbafa
7
+ data.tar.gz: 36fe4e980ad2d7cb24556ff10fbe4ac1f516a2255ea0861c7af8e7da09626cbe5627286b6b81620241a43273445505701ca71037f7bfcfb12febb9dc3474ebbf
@@ -1,4 +1,9 @@
1
- # 0.6.0 / unreleased
1
+ # 0.6.1 / 2014-10-27
2
+
3
+ * Expire the cache when the version of Texrack changes
4
+ * Pass trim=1 to have ImageMagick trim the image before returning it
5
+
6
+ # 0.6.0 / 2014-06-23
2
7
 
3
8
  * Cache the generated images and return proper ETags
4
9
 
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
@@ -1,4 +1,6 @@
1
- $:.unshift 'lib'
1
+ require 'bundler'
2
+ Bundler.setup
3
+
2
4
  require 'logger'
3
5
  require 'rack/conditionalget'
4
6
  require 'texrack'
@@ -22,22 +22,18 @@ module Texrack
22
22
  end
23
23
 
24
24
  def render_png
25
- content_type 'image/png'
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 = Texrack::OutputFile.new(digest)
32
- if output.exists?
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
- png = Texrack::PdfToPng.new(pdf, logger).to_file(output)
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
@@ -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
@@ -1,3 +1,3 @@
1
1
  module Texrack
2
- VERSION = '0.6.0'
2
+ VERSION = '0.6.1'
3
3
  end
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.0
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-06-23 00:00:00.000000000 Z
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.11
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
@@ -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
- iQIcBAABAgAGBQJTqDsmAAoJEH1ncb0Txu7XtUMP/RrEIOUh2KBGm9gl/STVGQZ7
6
- VPdAYz3Ze00Kqe0fxwuBaHBzliLoW+PYv3S8zg7iUkQrHbQrcA6X4BydknsLQBnA
7
- pLhyO/GXoMWawJTwf1PdnVhAPIkbdHy0pZ0F/FM9JJtakXS7TDNrnvTkaJaZ+3CY
8
- pvYUIEj5qeCg9+cLbSPLKX/uYnQ6a7eR9dJCE3LrkAIj79ATXMUMEzDUNm3wifIE
9
- vgfcjz/D7gRedqD6d8OVLyf2FwIdHSxCkDE9ZqH1a9c/zkCPQEKJuvnyjnZshaqX
10
- JuNIhV0S/7sAVEx5szAHu3lJP1iLsHbFTHOxNQu7ChOz9rln7vXeveoAB7UsSiXC
11
- /tNYBMYY9h3MJyrVUi7+Sj9mD/Rs9OfIr+hfAGFLr1jZIyiIDG6JSd1GBF32p14/
12
- LoLsLnXRAsWAo+YS4VjeHPJBKSdCBPt+zM0o19V79rcJBLU4XFDPk0FSl+AHEa8V
13
- Yr9bYJ+3A40567CbRRslGTrJBmQ/4VTM9hzbFaUzMBS2hxnEbXd68zWP/GAi1RwU
14
- v5V0Guwu9ZXBMupBRGARUWAIiYvmQ1/x6vIZxufpsXBKttgysHQM0LSiV73PMhme
15
- V2BkNlCKm64eHUrIix1kMMmJS769p+dr0ExdEqQWMwY7ASQFA5TzytQNA+6/AlW4
16
- flr7SfGnDJUjTT2JkATk
17
- =s9QM
18
- -----END PGP SIGNATURE-----
metadata.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
- iQIcBAABAgAGBQJTqDsmAAoJEH1ncb0Txu7XnfcP/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-----