gollum-bibanon 1.4.2 → 1.4.3
Sign up to get free protection for your applications and to get access to all the features.
- data/HISTORY.md +0 -20
- data/README.md +0 -34
- data/{gollum.gemspec → gollum-bibanon.gemspec} +8 -9
- data/lib/gollum.rb +1 -1
- data/lib/gollum/frontend/app.rb +6 -20
- data/lib/gollum/sanitization.rb +1 -1
- data/test/test_app.rb +0 -38
- metadata +9 -99
- data/lib/gollum/tex.rb +0 -89
data/HISTORY.md
CHANGED
@@ -7,26 +7,6 @@
|
|
7
7
|
* Include the language of the code snippet when making a uniquely
|
8
8
|
identifiable sha of a code snippet while rendering a page.
|
9
9
|
|
10
|
-
# 1.4.1 (Bibanon mod) / 2012-02-05
|
11
|
-
|
12
|
-
* Major Enhancements
|
13
|
-
* reversing mediawiki_compat
|
14
|
-
* Minor Enhancements
|
15
|
-
* Fixed incorrect redirect in new versions of sinatra
|
16
|
-
* Bug Fixes
|
17
|
-
* fixed sanitization bug
|
18
|
-
|
19
|
-
# 1.4.0 (Bibanon mod) / 2012-02-04
|
20
|
-
|
21
|
-
* Major Enhancements
|
22
|
-
* Removed Mathjax support
|
23
|
-
* Minor Enhancements
|
24
|
-
* Underscore support in wikipages (for Mediawiki)
|
25
|
-
* Adds OmniAuth username to commit message.
|
26
|
-
* Magnet, IRC, and FTP links now allowed.
|
27
|
-
* Bug Fixes
|
28
|
-
* Some mods to make OmniAuth work better with Gollum (using OmniGollum)
|
29
|
-
|
30
10
|
# 1.3.1 / 2011-07-21
|
31
11
|
|
32
12
|
* Major Enhancements
|
data/README.md
CHANGED
@@ -16,40 +16,6 @@ number of ways depending on your needs. You can edit your wiki locally:
|
|
16
16
|
Gollum follows the rules of [Semantic Versioning](http://semver.org/) and uses
|
17
17
|
[TomDoc](http://tomdoc.org/) for inline documentation.
|
18
18
|
|
19
|
-
### Bibanon
|
20
|
-
|
21
|
-
This is a fork of Gollum used by the Bibliotheca Anonoma. It adds some extra functionality:
|
22
|
-
|
23
|
-
* [OmniAuth integration](https://github.com/github/gollum/pull/181) - Adds support for OmniGollum.
|
24
|
-
* [OmniAuth User Commit Message](https://github.com/treeofsephiroth/gollum/commit/8400ad0749288f658f735625b7c39550134f7586) Adds the username from OmniAuth to a commit message.
|
25
|
-
* [Gollum Pull Request](https://github.com/github/gollum/pull/166)
|
26
|
-
* [Fix `undefined method 'new' for Redcarpet:Module`](https://github.com/github/gollum/pull/271) - Forces the gem to use a working copy of redcarpet, rather than the new one.
|
27
|
-
* [Fix spaces in filenames breaking redirect](https://github.com/github/gollum/pull/249) - New edition of Sinatra uses + signs instead of dashes, breaking redirects.
|
28
|
-
* Magnet links - Now allowed.
|
29
|
-
|
30
|
-
### Wishlist
|
31
|
-
|
32
|
-
Functionalities we hope to implement in the future.
|
33
|
-
|
34
|
-
* Custom CSS - Instead of modding the CSS stylesheet bundled with Gollum, it would be nice to work like Ikiwiki and use a "local.css" file in the git repo, if it exists. It would also be cool if we made a tag that specified custom CSS for a single page.
|
35
|
-
* [Ikiwiki CSS extension](http://ikiwiki.info/css/)
|
36
|
-
|
37
|
-
* Extensions - Would make it possible to safely add extra functionality to wikilink tags, similar to that of Mediawiki Templates or ikiwiki plugins.
|
38
|
-
* [Basic support for extensions on Gollum](https://github.com/github/gollum/pull/58)
|
39
|
-
* [Gists embed implementation](https://github.com/github/gollum/issues/208)
|
40
|
-
|
41
|
-
* Shift JIS extension - Tag to tell gollum to use [monafont](http://monafont.sourceforge.net/index-e.html) on selected text. Should probably use @font-face.
|
42
|
-
* [Font Face Guide](http://sixrevisions.com/css/font-face-guide/)
|
43
|
-
* [Mozilla Font Face Guide](https://developer.mozilla.org/en/CSS/@font-face)
|
44
|
-
* It might help to see how [Google Webfont](https://www.google.com/webfonts) works and implement it in Gollum's CSS
|
45
|
-
|
46
|
-
* Page Locking - Would add ability to lock certain pages to editing. An example would be ikiwiki's page locking mechanism.
|
47
|
-
* [Ikiwiki Lockedit plugin](http://ikiwiki.info/plugins/lockedit/)
|
48
|
-
* File Uploading - Would add the ability to upload some files through the web interface, and implement restrictions to allow only certain extensions of a certain size.
|
49
|
-
* [Ikiwiki Attachments](http://ikiwiki.info/plugins/attachment/)
|
50
|
-
* [Ikiwiki File Checking](http://ikiwiki.info/plugins/filecheck/)
|
51
|
-
* Untrusted Git Push - Yes, this would be perfectly safe. Ikiwiki has the ability to accept commits from anyone in the world. What makes this safe is Ikiwiki's pre-commit checks, which check page locks and upload restrictions to block any change that cannot be done with the web interface.
|
52
|
-
* [Ikiwiki Implementation](http://ikiwiki.info/tips/untrusted_git_push/)
|
53
19
|
|
54
20
|
## INSTALLATION
|
55
21
|
|
@@ -1,15 +1,15 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.specification_version = 2 if s.respond_to? :specification_version=
|
3
3
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
4
|
-
s.rubygems_version = '1.3
|
4
|
+
s.rubygems_version = '1.4.3'
|
5
5
|
|
6
6
|
s.name = 'gollum-bibanon'
|
7
|
-
s.version = '1.4.
|
8
|
-
s.date = '2012-
|
9
|
-
s.rubyforge_project = 'gollum'
|
7
|
+
s.version = '1.4.3'
|
8
|
+
s.date = '2012-03-22'
|
9
|
+
s.rubyforge_project = 'gollum-bibanon'
|
10
10
|
|
11
11
|
s.summary = "A simple, Git-powered wiki, with Bibanon mods."
|
12
|
-
s.description = "A simple, Git-powered wiki with a sweet API and local frontend, modded for the Bibliotheca Anonoma. Uses the latest edition of Gollum
|
12
|
+
s.description = "A simple, Git-powered wiki with a sweet API and local frontend, modded for the Bibliotheca Anonoma. Uses the latest edition of Gollum."
|
13
13
|
|
14
14
|
s.authors = ["Tom Preston-Werner", "Rick Olson", "Tenshi Hinanawi"]
|
15
15
|
s.email = 'cockmomgler@gmail.com'
|
@@ -27,10 +27,10 @@ Gem::Specification.new do |s|
|
|
27
27
|
s.add_dependency('pygments.rb', "~> 0.2.0")
|
28
28
|
s.add_dependency('posix-spawn', "~> 0.3.0")
|
29
29
|
s.add_dependency('sinatra', "~> 1.0")
|
30
|
-
s.add_dependency('mustache
|
30
|
+
s.add_dependency('mustache', [">= 0.11.2", "< 1.0.0"])
|
31
31
|
s.add_dependency('sanitize', "~> 2.0.0")
|
32
32
|
s.add_dependency('nokogiri', "~> 1.4")
|
33
|
-
s.add_dependency('redcarpet'
|
33
|
+
s.add_dependency('redcarpet')
|
34
34
|
|
35
35
|
s.add_development_dependency('RedCloth')
|
36
36
|
s.add_development_dependency('mocha')
|
@@ -50,7 +50,7 @@ Gem::Specification.new do |s|
|
|
50
50
|
Rakefile
|
51
51
|
bin/gollum
|
52
52
|
docs/sanitization.md
|
53
|
-
gollum.gemspec
|
53
|
+
gollum-bibanon.gemspec
|
54
54
|
lib/gollum.rb
|
55
55
|
lib/gollum/blob_entry.rb
|
56
56
|
lib/gollum/committer.rb
|
@@ -101,7 +101,6 @@ Gem::Specification.new do |s|
|
|
101
101
|
lib/gollum/page.rb
|
102
102
|
lib/gollum/pagination.rb
|
103
103
|
lib/gollum/sanitization.rb
|
104
|
-
lib/gollum/tex.rb
|
105
104
|
lib/gollum/wiki.rb
|
106
105
|
templates/formatting.html
|
107
106
|
test/examples/lotr.git/COMMIT_EDITMSG
|
data/lib/gollum.rb
CHANGED
data/lib/gollum/frontend/app.rb
CHANGED
@@ -49,7 +49,7 @@ module Precious
|
|
49
49
|
@content = page.raw_data
|
50
50
|
mustache :edit
|
51
51
|
else
|
52
|
-
|
52
|
+
mustache :create
|
53
53
|
end
|
54
54
|
end
|
55
55
|
|
@@ -68,17 +68,7 @@ module Precious
|
|
68
68
|
|
69
69
|
redirect "/#{CGI.escape(Gollum::Page.cname(name))}"
|
70
70
|
end
|
71
|
-
|
72
|
-
get '/create/*' do
|
73
|
-
wiki = Gollum::Wiki.new(settings.gollum_path, settings.wiki_options)
|
74
|
-
@name = params[:splat].first
|
75
|
-
if wiki.page(@name)
|
76
|
-
redirect "/#{CGI.escape(@name)}"
|
77
|
-
else
|
78
|
-
mustache :create
|
79
|
-
end
|
80
|
-
end
|
81
|
-
|
71
|
+
|
82
72
|
post '/create' do
|
83
73
|
name = params[:page]
|
84
74
|
wiki = Gollum::Wiki.new(settings.gollum_path, settings.wiki_options)
|
@@ -87,7 +77,7 @@ module Precious
|
|
87
77
|
|
88
78
|
begin
|
89
79
|
wiki.write_page(name, format, params[:content], commit_message)
|
90
|
-
redirect "/#{CGI.escape(
|
80
|
+
redirect "/#{CGI.escape(name)}"
|
91
81
|
rescue Gollum::DuplicatePageError => e
|
92
82
|
@message = "Duplicate page: #{e.message}"
|
93
83
|
mustache :error
|
@@ -209,7 +199,8 @@ module Precious
|
|
209
199
|
content_type file.mime_type
|
210
200
|
file.raw_data
|
211
201
|
else
|
212
|
-
|
202
|
+
@name = name
|
203
|
+
mustache :create
|
213
204
|
end
|
214
205
|
end
|
215
206
|
|
@@ -223,12 +214,7 @@ module Precious
|
|
223
214
|
end
|
224
215
|
|
225
216
|
def commit_message
|
226
|
-
|
227
|
-
user = get_user
|
228
|
-
return { :message => params[:message], :name => user.name, :email => user.email}
|
229
|
-
else
|
230
|
-
return { :message => params[:message]}
|
231
|
-
end
|
217
|
+
{ :message => params[:message] }
|
232
218
|
end
|
233
219
|
end
|
234
220
|
end
|
data/lib/gollum/sanitization.rb
CHANGED
@@ -43,7 +43,7 @@ module Gollum
|
|
43
43
|
|
44
44
|
# Default whitelisted protocols for URLs.
|
45
45
|
PROTOCOLS = {
|
46
|
-
'a' => {'href' => ['http', 'https', 'mailto', 'ftp', 'irc',
|
46
|
+
'a' => {'href' => ['http', 'https', 'mailto', 'ftp', 'irc', :relative]},
|
47
47
|
'img' => {'src' => ['http', 'https', :relative]}
|
48
48
|
}.freeze
|
49
49
|
|
data/test/test_app.rb
CHANGED
@@ -85,44 +85,6 @@ context "Frontend" do
|
|
85
85
|
assert_equal 'def', page.version.message
|
86
86
|
end
|
87
87
|
|
88
|
-
test "redirects to create on non-existant page" do
|
89
|
-
name = "E"
|
90
|
-
get "/#{name}"
|
91
|
-
follow_redirect!
|
92
|
-
assert_equal "/create/#{name}", last_request.fullpath
|
93
|
-
assert last_response.ok?
|
94
|
-
end
|
95
|
-
|
96
|
-
test "edit redirects to create on non-existant page" do
|
97
|
-
name = "E"
|
98
|
-
get "/edit/#{name}"
|
99
|
-
follow_redirect!
|
100
|
-
assert_equal "/create/#{name}", last_request.fullpath
|
101
|
-
assert last_response.ok?
|
102
|
-
end
|
103
|
-
|
104
|
-
test "create redirects to page if already exists" do
|
105
|
-
name = "A"
|
106
|
-
get "/create/#{name}"
|
107
|
-
follow_redirect!
|
108
|
-
assert_equal "/#{name}", last_request.fullpath
|
109
|
-
assert last_response.ok?
|
110
|
-
end
|
111
|
-
|
112
|
-
test "creates pages with escaped characters in title" do
|
113
|
-
post "/create", :content => 'abc', :page => 'Title with spaces',
|
114
|
-
:format => 'markdown', :message => 'foo'
|
115
|
-
assert_equal 'http://example.org/Title-with-spaces', last_response.headers['Location']
|
116
|
-
get "/Title-with-spaces"
|
117
|
-
assert_match /abc/, last_response.body
|
118
|
-
|
119
|
-
post "/create", :content => 'ghi', :page => 'Title/with/slashes',
|
120
|
-
:format => 'markdown', :message => 'bar'
|
121
|
-
assert_equal 'http://example.org/Title-with-slashes', last_response.headers['Location']
|
122
|
-
get "/Title-with-slashes"
|
123
|
-
assert_match /ghi/, last_response.body
|
124
|
-
end
|
125
|
-
|
126
88
|
test "guards against creation of existing page" do
|
127
89
|
name = "A"
|
128
90
|
post "/create", :content => 'abc', :page => name,
|
metadata
CHANGED
@@ -1,13 +1,8 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gollum-bibanon
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash: 3
|
5
4
|
prerelease:
|
6
|
-
|
7
|
-
- 1
|
8
|
-
- 4
|
9
|
-
- 2
|
10
|
-
version: 1.4.2
|
5
|
+
version: 1.4.3
|
11
6
|
platform: ruby
|
12
7
|
authors:
|
13
8
|
- Tom Preston-Werner
|
@@ -17,7 +12,7 @@ autorequire:
|
|
17
12
|
bindir: bin
|
18
13
|
cert_chain: []
|
19
14
|
|
20
|
-
date: 2012-
|
15
|
+
date: 2012-03-22 00:00:00 Z
|
21
16
|
dependencies:
|
22
17
|
- !ruby/object:Gem::Dependency
|
23
18
|
name: grit
|
@@ -27,11 +22,6 @@ dependencies:
|
|
27
22
|
requirements:
|
28
23
|
- - ~>
|
29
24
|
- !ruby/object:Gem::Version
|
30
|
-
hash: 29
|
31
|
-
segments:
|
32
|
-
- 2
|
33
|
-
- 4
|
34
|
-
- 1
|
35
25
|
version: 2.4.1
|
36
26
|
type: :runtime
|
37
27
|
version_requirements: *id001
|
@@ -43,19 +33,9 @@ dependencies:
|
|
43
33
|
requirements:
|
44
34
|
- - ">="
|
45
35
|
- !ruby/object:Gem::Version
|
46
|
-
hash: 3
|
47
|
-
segments:
|
48
|
-
- 0
|
49
|
-
- 7
|
50
|
-
- 0
|
51
36
|
version: 0.7.0
|
52
37
|
- - <
|
53
38
|
- !ruby/object:Gem::Version
|
54
|
-
hash: 23
|
55
|
-
segments:
|
56
|
-
- 1
|
57
|
-
- 0
|
58
|
-
- 0
|
59
39
|
version: 1.0.0
|
60
40
|
type: :runtime
|
61
41
|
version_requirements: *id002
|
@@ -67,11 +47,6 @@ dependencies:
|
|
67
47
|
requirements:
|
68
48
|
- - ~>
|
69
49
|
- !ruby/object:Gem::Version
|
70
|
-
hash: 23
|
71
|
-
segments:
|
72
|
-
- 0
|
73
|
-
- 2
|
74
|
-
- 0
|
75
50
|
version: 0.2.0
|
76
51
|
type: :runtime
|
77
52
|
version_requirements: *id003
|
@@ -83,11 +58,6 @@ dependencies:
|
|
83
58
|
requirements:
|
84
59
|
- - ~>
|
85
60
|
- !ruby/object:Gem::Version
|
86
|
-
hash: 19
|
87
|
-
segments:
|
88
|
-
- 0
|
89
|
-
- 3
|
90
|
-
- 0
|
91
61
|
version: 0.3.0
|
92
62
|
type: :runtime
|
93
63
|
version_requirements: *id004
|
@@ -99,34 +69,20 @@ dependencies:
|
|
99
69
|
requirements:
|
100
70
|
- - ~>
|
101
71
|
- !ruby/object:Gem::Version
|
102
|
-
hash: 15
|
103
|
-
segments:
|
104
|
-
- 1
|
105
|
-
- 0
|
106
72
|
version: "1.0"
|
107
73
|
type: :runtime
|
108
74
|
version_requirements: *id005
|
109
75
|
- !ruby/object:Gem::Dependency
|
110
|
-
name: mustache
|
76
|
+
name: mustache
|
111
77
|
prerelease: false
|
112
78
|
requirement: &id006 !ruby/object:Gem::Requirement
|
113
79
|
none: false
|
114
80
|
requirements:
|
115
81
|
- - ">="
|
116
82
|
- !ruby/object:Gem::Version
|
117
|
-
hash: 55
|
118
|
-
segments:
|
119
|
-
- 0
|
120
|
-
- 11
|
121
|
-
- 2
|
122
83
|
version: 0.11.2
|
123
84
|
- - <
|
124
85
|
- !ruby/object:Gem::Version
|
125
|
-
hash: 23
|
126
|
-
segments:
|
127
|
-
- 1
|
128
|
-
- 0
|
129
|
-
- 0
|
130
86
|
version: 1.0.0
|
131
87
|
type: :runtime
|
132
88
|
version_requirements: *id006
|
@@ -138,11 +94,6 @@ dependencies:
|
|
138
94
|
requirements:
|
139
95
|
- - ~>
|
140
96
|
- !ruby/object:Gem::Version
|
141
|
-
hash: 15
|
142
|
-
segments:
|
143
|
-
- 2
|
144
|
-
- 0
|
145
|
-
- 0
|
146
97
|
version: 2.0.0
|
147
98
|
type: :runtime
|
148
99
|
version_requirements: *id007
|
@@ -154,10 +105,6 @@ dependencies:
|
|
154
105
|
requirements:
|
155
106
|
- - ~>
|
156
107
|
- !ruby/object:Gem::Version
|
157
|
-
hash: 7
|
158
|
-
segments:
|
159
|
-
- 1
|
160
|
-
- 4
|
161
108
|
version: "1.4"
|
162
109
|
type: :runtime
|
163
110
|
version_requirements: *id008
|
@@ -167,14 +114,9 @@ dependencies:
|
|
167
114
|
requirement: &id009 !ruby/object:Gem::Requirement
|
168
115
|
none: false
|
169
116
|
requirements:
|
170
|
-
- -
|
117
|
+
- - ">="
|
171
118
|
- !ruby/object:Gem::Version
|
172
|
-
|
173
|
-
segments:
|
174
|
-
- 1
|
175
|
-
- 17
|
176
|
-
- 2
|
177
|
-
version: 1.17.2
|
119
|
+
version: "0"
|
178
120
|
type: :runtime
|
179
121
|
version_requirements: *id009
|
180
122
|
- !ruby/object:Gem::Dependency
|
@@ -185,9 +127,6 @@ dependencies:
|
|
185
127
|
requirements:
|
186
128
|
- - ">="
|
187
129
|
- !ruby/object:Gem::Version
|
188
|
-
hash: 3
|
189
|
-
segments:
|
190
|
-
- 0
|
191
130
|
version: "0"
|
192
131
|
type: :development
|
193
132
|
version_requirements: *id010
|
@@ -199,9 +138,6 @@ dependencies:
|
|
199
138
|
requirements:
|
200
139
|
- - ">="
|
201
140
|
- !ruby/object:Gem::Version
|
202
|
-
hash: 3
|
203
|
-
segments:
|
204
|
-
- 0
|
205
141
|
version: "0"
|
206
142
|
type: :development
|
207
143
|
version_requirements: *id011
|
@@ -213,9 +149,6 @@ dependencies:
|
|
213
149
|
requirements:
|
214
150
|
- - ">="
|
215
151
|
- !ruby/object:Gem::Version
|
216
|
-
hash: 3
|
217
|
-
segments:
|
218
|
-
- 0
|
219
152
|
version: "0"
|
220
153
|
type: :development
|
221
154
|
version_requirements: *id012
|
@@ -227,9 +160,6 @@ dependencies:
|
|
227
160
|
requirements:
|
228
161
|
- - ">="
|
229
162
|
- !ruby/object:Gem::Version
|
230
|
-
hash: 3
|
231
|
-
segments:
|
232
|
-
- 0
|
233
163
|
version: "0"
|
234
164
|
type: :development
|
235
165
|
version_requirements: *id013
|
@@ -241,9 +171,6 @@ dependencies:
|
|
241
171
|
requirements:
|
242
172
|
- - ">="
|
243
173
|
- !ruby/object:Gem::Version
|
244
|
-
hash: 3
|
245
|
-
segments:
|
246
|
-
- 0
|
247
174
|
version: "0"
|
248
175
|
type: :development
|
249
176
|
version_requirements: *id014
|
@@ -255,11 +182,6 @@ dependencies:
|
|
255
182
|
requirements:
|
256
183
|
- - ~>
|
257
184
|
- !ruby/object:Gem::Version
|
258
|
-
hash: 1
|
259
|
-
segments:
|
260
|
-
- 0
|
261
|
-
- 6
|
262
|
-
- 3
|
263
185
|
version: 0.6.3
|
264
186
|
type: :development
|
265
187
|
version_requirements: *id015
|
@@ -271,15 +193,10 @@ dependencies:
|
|
271
193
|
requirements:
|
272
194
|
- - ~>
|
273
195
|
- !ruby/object:Gem::Version
|
274
|
-
hash: 63
|
275
|
-
segments:
|
276
|
-
- 0
|
277
|
-
- 9
|
278
|
-
- 2
|
279
196
|
version: 0.9.2
|
280
197
|
type: :development
|
281
198
|
version_requirements: *id016
|
282
|
-
description: A simple, Git-powered wiki with a sweet API and local frontend, modded for the Bibliotheca Anonoma. Uses the latest edition of Gollum
|
199
|
+
description: A simple, Git-powered wiki with a sweet API and local frontend, modded for the Bibliotheca Anonoma. Uses the latest edition of Gollum.
|
283
200
|
email: cockmomgler@gmail.com
|
284
201
|
executables:
|
285
202
|
- gollum
|
@@ -297,7 +214,7 @@ files:
|
|
297
214
|
- Rakefile
|
298
215
|
- bin/gollum
|
299
216
|
- docs/sanitization.md
|
300
|
-
- gollum.gemspec
|
217
|
+
- gollum-bibanon.gemspec
|
301
218
|
- lib/gollum.rb
|
302
219
|
- lib/gollum/blob_entry.rb
|
303
220
|
- lib/gollum/committer.rb
|
@@ -348,7 +265,6 @@ files:
|
|
348
265
|
- lib/gollum/page.rb
|
349
266
|
- lib/gollum/pagination.rb
|
350
267
|
- lib/gollum/sanitization.rb
|
351
|
-
- lib/gollum/tex.rb
|
352
268
|
- lib/gollum/wiki.rb
|
353
269
|
- templates/formatting.html
|
354
270
|
- test/examples/lotr.git/COMMIT_EDITMSG
|
@@ -466,23 +382,17 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
466
382
|
requirements:
|
467
383
|
- - ">="
|
468
384
|
- !ruby/object:Gem::Version
|
469
|
-
hash: 3
|
470
|
-
segments:
|
471
|
-
- 0
|
472
385
|
version: "0"
|
473
386
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
474
387
|
none: false
|
475
388
|
requirements:
|
476
389
|
- - ">="
|
477
390
|
- !ruby/object:Gem::Version
|
478
|
-
hash: 3
|
479
|
-
segments:
|
480
|
-
- 0
|
481
391
|
version: "0"
|
482
392
|
requirements: []
|
483
393
|
|
484
|
-
rubyforge_project: gollum
|
485
|
-
rubygems_version: 1.8.
|
394
|
+
rubyforge_project: gollum-bibanon
|
395
|
+
rubygems_version: 1.8.21
|
486
396
|
signing_key:
|
487
397
|
specification_version: 2
|
488
398
|
summary: A simple, Git-powered wiki, with Bibanon mods.
|
data/lib/gollum/tex.rb
DELETED
@@ -1,89 +0,0 @@
|
|
1
|
-
require 'fileutils'
|
2
|
-
require 'shellwords'
|
3
|
-
require 'tmpdir'
|
4
|
-
require 'posix/spawn'
|
5
|
-
|
6
|
-
module Gollum
|
7
|
-
module Tex
|
8
|
-
class Error < StandardError; end
|
9
|
-
|
10
|
-
extend POSIX::Spawn
|
11
|
-
|
12
|
-
Template = <<-EOS
|
13
|
-
\\documentclass[12pt]{article}
|
14
|
-
\\usepackage{color}
|
15
|
-
\\usepackage[dvips]{graphicx}
|
16
|
-
\\pagestyle{empty}
|
17
|
-
\\pagecolor{white}
|
18
|
-
\\begin{document}
|
19
|
-
{\\color{black}
|
20
|
-
\\begin{eqnarray*}
|
21
|
-
%s
|
22
|
-
\\end{eqnarray*}}
|
23
|
-
\\end{document}
|
24
|
-
EOS
|
25
|
-
|
26
|
-
class << self
|
27
|
-
attr_accessor :latex_path, :dvips_path, :convert_path
|
28
|
-
end
|
29
|
-
|
30
|
-
self.latex_path = 'latex'
|
31
|
-
self.dvips_path = 'dvips'
|
32
|
-
self.convert_path = 'convert'
|
33
|
-
|
34
|
-
def self.check_dependencies!
|
35
|
-
return if @dependencies_available
|
36
|
-
|
37
|
-
if `which latex` == ""
|
38
|
-
raise Error, "`latex` command not found"
|
39
|
-
end
|
40
|
-
|
41
|
-
if `which dvips` == ""
|
42
|
-
raise Error, "`dvips` command not found"
|
43
|
-
end
|
44
|
-
|
45
|
-
if `which convert` == ""
|
46
|
-
raise Error, "`convert` command not found"
|
47
|
-
end
|
48
|
-
|
49
|
-
if `which gs` == ""
|
50
|
-
raise Error, "`gs` command not found"
|
51
|
-
end
|
52
|
-
|
53
|
-
@dependencies_available = true
|
54
|
-
end
|
55
|
-
|
56
|
-
def self.render_formula(formula)
|
57
|
-
check_dependencies!
|
58
|
-
|
59
|
-
Dir.mktmpdir('tex') do |path|
|
60
|
-
tex_path = ::File.join(path, 'formula.tex')
|
61
|
-
dvi_path = ::File.join(path, 'formula.dvi')
|
62
|
-
eps_path = ::File.join(path, 'formula.eps')
|
63
|
-
png_path = ::File.join(path, 'formula.png')
|
64
|
-
|
65
|
-
::File.open(tex_path, 'w') { |f| f.write(Template % formula) }
|
66
|
-
|
67
|
-
result = sh latex_path, '-interaction=batchmode', 'formula.tex', :chdir => path
|
68
|
-
raise Error, "`latex` command failed: #{result}" unless ::File.exist?(dvi_path)
|
69
|
-
|
70
|
-
result = sh dvips_path, '-o', eps_path, '-E', dvi_path
|
71
|
-
raise Error, "`dvips` command failed: #{result}" unless ::File.exist?(eps_path)
|
72
|
-
result = sh convert_path, '+adjoin',
|
73
|
-
'-antialias',
|
74
|
-
'-transparent', 'white',
|
75
|
-
'-density', '150x150',
|
76
|
-
eps_path, png_path
|
77
|
-
raise Error, "`convert` command failed: #{result}" unless ::File.exist?(png_path)
|
78
|
-
|
79
|
-
::File.read(png_path)
|
80
|
-
end
|
81
|
-
end
|
82
|
-
|
83
|
-
private
|
84
|
-
def self.sh(*args)
|
85
|
-
pid = spawn *args
|
86
|
-
Process::waitpid(pid)
|
87
|
-
end
|
88
|
-
end
|
89
|
-
end
|