gollum 2.7.0 → 3.0.0
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of gollum might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/Gemfile +1 -1
- data/README.md +3 -3
- data/Rakefile +10 -2
- data/bin/gollum +11 -9
- data/gollum.gemspec +22 -17
- data/lib/gollum.rb +4 -3
- data/lib/gollum/app.rb +101 -101
- data/lib/gollum/helpers.rb +3 -3
- data/lib/gollum/public/gollum/css/gollum.css +1 -1
- data/lib/gollum/public/gollum/css/template.css +263 -65
- data/lib/gollum/public/gollum/fonts/FontAwesome.otf +0 -0
- data/lib/gollum/public/gollum/fonts/fontawesome-webfont.eot +0 -0
- data/lib/gollum/public/gollum/fonts/fontawesome-webfont.svg +414 -0
- data/lib/gollum/public/gollum/fonts/fontawesome-webfont.ttf +0 -0
- data/lib/gollum/public/gollum/fonts/fontawesome-webfont.woff +0 -0
- data/lib/gollum/uri_encode_component.rb +145 -113
- data/lib/gollum/views/compare.rb +16 -14
- data/lib/gollum/views/edit.rb +4 -4
- data/lib/gollum/views/editable.rb +1 -1
- data/lib/gollum/views/file_view.rb +2 -2
- data/lib/gollum/views/history.rb +14 -14
- data/lib/gollum/views/page.rb +9 -9
- data/lib/gollum/views/pages.rb +2 -2
- metadata +71 -40
- data/templates/formatting.html +0 -92
- data/templates/helper_wiki.rb +0 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ae63e46f52e80b39d9876f199ecf4adc35cb4ed3
|
4
|
+
data.tar.gz: 2e899d40a26492fb28fa9719fd07fb28cfe114be
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5a239050238237bc42b2a3b0dd7a74c1b5a2f618945eb4dede46794cd20f150ecbbc1475743bfc765a5007e137fe57b5adac727fb776caafc2a7570b3fb9d2f1
|
7
|
+
data.tar.gz: 8a033dc8543467eba6a508c6a01e035d05d02aa5a804a668787437f923d6eb1c055a990e7b0282554f673fff51079a8b6dde20b913993b5c959a112a2b4a64fe
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
gollum -- A wiki built on top of Git
|
2
2
|
====================================
|
3
3
|
|
4
|
-
[![Gem Version](https://badge.fury.io/rb/gollum.
|
5
|
-
[![Build Status](https://
|
6
|
-
[![Dependency Status](https://gemnasium.com/gollum/gollum.
|
4
|
+
[![Gem Version](https://badge.fury.io/rb/gollum.svg)](http://badge.fury.io/rb/gollum)
|
5
|
+
[![Build Status](https://travis-ci.org/gollum/gollum.svg?branch=master)](https://travis-ci.org/gollum/gollum)
|
6
|
+
[![Dependency Status](https://gemnasium.com/gollum/gollum.svg)](https://gemnasium.com/gollum/gollum)
|
7
7
|
|
8
8
|
## DESCRIPTION
|
9
9
|
|
data/Rakefile
CHANGED
@@ -107,20 +107,23 @@ end
|
|
107
107
|
#
|
108
108
|
#############################################################################
|
109
109
|
|
110
|
-
desc 'Create a release build'
|
110
|
+
desc 'Create a release build and push to rubygems'
|
111
111
|
task :release => :build do
|
112
112
|
unless `git branch` =~ /^\* master$/
|
113
113
|
puts "You must be on the master branch to release!"
|
114
114
|
exit!
|
115
115
|
end
|
116
116
|
sh "git commit --allow-empty -a -m 'Release #{version}'"
|
117
|
-
sh "git pull"
|
117
|
+
sh "git pull --rebase origin master"
|
118
118
|
sh "git tag v#{version}"
|
119
119
|
sh "git push origin master"
|
120
120
|
sh "git push origin v#{version}"
|
121
121
|
sh "gem push pkg/#{name}-#{version}.gem"
|
122
122
|
end
|
123
123
|
|
124
|
+
desc 'Publish to rubygems. Same as release'
|
125
|
+
task :publish => :release
|
126
|
+
|
124
127
|
desc 'Build gem'
|
125
128
|
task :build => :gemspec do
|
126
129
|
sh "mkdir -p pkg"
|
@@ -128,6 +131,11 @@ task :build => :gemspec do
|
|
128
131
|
sh "mv #{gem_file} pkg"
|
129
132
|
end
|
130
133
|
|
134
|
+
desc "Build and install"
|
135
|
+
task :install => :build do
|
136
|
+
sh "gem install --local --no-ri --no-rdoc pkg/#{name}-#{version}.gem"
|
137
|
+
end
|
138
|
+
|
131
139
|
desc 'Update gemspec'
|
132
140
|
task :gemspec => :validate do
|
133
141
|
# read spec file and split out manifest section
|
data/bin/gollum
CHANGED
@@ -17,10 +17,10 @@ require 'optparse'
|
|
17
17
|
require 'rubygems'
|
18
18
|
require 'gollum'
|
19
19
|
|
20
|
-
exec
|
21
|
-
options
|
20
|
+
exec = {}
|
21
|
+
options = { 'port' => 4567, 'bind' => '0.0.0.0' }
|
22
22
|
wiki_options = {
|
23
|
-
:live_preview
|
23
|
+
:live_preview => false,
|
24
24
|
:allow_uploads => false,
|
25
25
|
}
|
26
26
|
|
@@ -85,7 +85,7 @@ opts = OptionParser.new do |opts|
|
|
85
85
|
end
|
86
86
|
|
87
87
|
opts.on("--allow-uploads [MODE]", [:dir, :page], "Allows file uploads. Modes: dir (default, store all uploads in the same directory), page (store each upload at the same location as the page).") do |mode|
|
88
|
-
wiki_options[:allow_uploads]
|
88
|
+
wiki_options[:allow_uploads] = true
|
89
89
|
wiki_options[:per_page_uploads] = true if mode == :page
|
90
90
|
end
|
91
91
|
|
@@ -120,8 +120,8 @@ end
|
|
120
120
|
|
121
121
|
# --gollum-path wins over ARGV[0]
|
122
122
|
gollum_path = wiki_options[:gollum_path] ?
|
123
|
-
|
124
|
-
|
123
|
+
wiki_options[:gollum_path] :
|
124
|
+
ARGV[0] || Dir.pwd
|
125
125
|
|
126
126
|
if options['irb']
|
127
127
|
require 'irb'
|
@@ -151,7 +151,9 @@ if options['irb']
|
|
151
151
|
begin
|
152
152
|
require 'gollum-lib'
|
153
153
|
wiki = Gollum::Wiki.new(gollum_path, wiki_options)
|
154
|
-
if !wiki.exist? then
|
154
|
+
if !wiki.exist? then
|
155
|
+
raise Gollum::InvalidGitRepositoryError
|
156
|
+
end
|
155
157
|
puts "Loaded Gollum wiki at #{File.expand_path(gollum_path).inspect}."
|
156
158
|
puts
|
157
159
|
puts %( page = wiki.page('page-name'))
|
@@ -193,7 +195,7 @@ else
|
|
193
195
|
def initialize base_path
|
194
196
|
@mg = Rack::Builder.new do
|
195
197
|
map '/' do
|
196
|
-
run Proc.new { [
|
198
|
+
run Proc.new { [302, { 'Location' => "/#{base_path}" }, []] }
|
197
199
|
end
|
198
200
|
|
199
201
|
map "/#{base_path}" do
|
@@ -209,4 +211,4 @@ else
|
|
209
211
|
# Rack::Handler does not work with Ctrl + C. Use Rack::Server instead.
|
210
212
|
Rack::Server.new(:app => MapGollum.new(base_path), :Port => options['port'], :Host => options['bind']).start
|
211
213
|
end
|
212
|
-
end
|
214
|
+
end
|
data/gollum.gemspec
CHANGED
@@ -1,38 +1,40 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.specification_version = 2 if s.respond_to? :specification_version=
|
3
|
-
s.required_rubygems_version = Gem::Requirement.new(
|
3
|
+
s.required_rubygems_version = Gem::Requirement.new('>= 0') if s.respond_to? :required_rubygems_version=
|
4
4
|
s.rubygems_version = '1.3.5'
|
5
|
-
s.required_ruby_version =
|
5
|
+
s.required_ruby_version = '>= 1.9'
|
6
6
|
|
7
7
|
s.name = 'gollum'
|
8
|
-
s.version = '
|
9
|
-
s.date = '2014-
|
8
|
+
s.version = '3.0.0'
|
9
|
+
s.date = '2014-04-05'
|
10
10
|
s.rubyforge_project = 'gollum'
|
11
11
|
s.license = 'MIT'
|
12
12
|
|
13
|
-
s.summary =
|
14
|
-
s.description =
|
13
|
+
s.summary = 'A simple, Git-powered wiki.'
|
14
|
+
s.description = 'A simple, Git-powered wiki with a sweet API and local frontend.'
|
15
15
|
|
16
|
-
s.authors = [
|
16
|
+
s.authors = ['Tom Preston-Werner', 'Rick Olson']
|
17
17
|
s.email = 'tom@github.com'
|
18
18
|
s.homepage = 'http://github.com/gollum/gollum'
|
19
19
|
|
20
20
|
s.require_paths = %w[lib]
|
21
21
|
|
22
|
-
s.executables = [
|
22
|
+
s.executables = ['gollum']
|
23
23
|
|
24
|
-
s.rdoc_options = [
|
24
|
+
s.rdoc_options = ['--charset=UTF-8']
|
25
25
|
s.extra_rdoc_files = %w[README.md LICENSE]
|
26
26
|
|
27
|
-
s.add_dependency 'gollum-lib', '~>
|
28
|
-
s.add_dependency 'github-markdown', '~> 0.
|
29
|
-
s.add_dependency 'sinatra', '~> 1.4', '>= 1.4.
|
30
|
-
s.add_dependency 'mustache', ['>= 0.99.
|
31
|
-
s.add_dependency 'useragent', '~> 0.
|
27
|
+
s.add_dependency 'gollum-lib', '~> 3.0'
|
28
|
+
s.add_dependency 'github-markdown', '~> 0.6.5'
|
29
|
+
s.add_dependency 'sinatra', '~> 1.4', '>= 1.4.4'
|
30
|
+
s.add_dependency 'mustache', ['>= 0.99.5', '< 1.0.0']
|
31
|
+
s.add_dependency 'useragent', '~> 0.10.0'
|
32
32
|
|
33
33
|
s.add_development_dependency 'rack-test', '~> 0.6.2'
|
34
|
-
s.add_development_dependency 'shoulda', '~> 3.
|
34
|
+
s.add_development_dependency 'shoulda', '~> 3.5.0'
|
35
35
|
s.add_development_dependency 'minitest-reporters', '~> 0.14.16'
|
36
|
+
s.add_development_dependency 'twitter_cldr', '~> 2.4.2'
|
37
|
+
s.add_development_dependency 'mocha', '~> 1.0.0'
|
36
38
|
|
37
39
|
# = MANIFEST =
|
38
40
|
s.files = %w[
|
@@ -55,6 +57,11 @@ Gem::Specification.new do |s|
|
|
55
57
|
lib/gollum/public/gollum/css/ie7.css
|
56
58
|
lib/gollum/public/gollum/css/print.css
|
57
59
|
lib/gollum/public/gollum/css/template.css
|
60
|
+
lib/gollum/public/gollum/fonts/FontAwesome.otf
|
61
|
+
lib/gollum/public/gollum/fonts/fontawesome-webfont.eot
|
62
|
+
lib/gollum/public/gollum/fonts/fontawesome-webfont.svg
|
63
|
+
lib/gollum/public/gollum/fonts/fontawesome-webfont.ttf
|
64
|
+
lib/gollum/public/gollum/fonts/fontawesome-webfont.woff
|
58
65
|
lib/gollum/public/gollum/images/dirty-shade.png
|
59
66
|
lib/gollum/public/gollum/images/fileview/document.png
|
60
67
|
lib/gollum/public/gollum/images/fileview/folder-horizontal.png
|
@@ -533,8 +540,6 @@ Gem::Specification.new do |s|
|
|
533
540
|
licenses/unity_asset_pool/COPYRIGHT
|
534
541
|
openrc/conf.d/gollum
|
535
542
|
openrc/init.d/gollum
|
536
|
-
templates/formatting.html
|
537
|
-
templates/helper_wiki.rb
|
538
543
|
]
|
539
544
|
# = MANIFEST =
|
540
545
|
|
data/lib/gollum.rb
CHANGED
@@ -13,16 +13,17 @@ require File.expand_path('../gollum/uri_encode_component', __FILE__)
|
|
13
13
|
|
14
14
|
# Set ruby to UTF-8 mode
|
15
15
|
# This is required for Ruby 1.8.7 which gollum still supports.
|
16
|
-
$KCODE = 'U' if RUBY_VERSION[0,3] == '1.8'
|
16
|
+
$KCODE = 'U' if RUBY_VERSION[0, 3] == '1.8'
|
17
17
|
|
18
18
|
module Gollum
|
19
|
-
VERSION = '
|
19
|
+
VERSION = '3.0.0'
|
20
20
|
|
21
21
|
def self.assets_path
|
22
22
|
::File.expand_path('gollum/public', ::File.dirname(__FILE__))
|
23
23
|
end
|
24
24
|
|
25
|
-
class Error < StandardError;
|
25
|
+
class Error < StandardError;
|
26
|
+
end
|
26
27
|
|
27
28
|
class DuplicatePageError < Error
|
28
29
|
attr_accessor :dir
|
data/lib/gollum/app.rb
CHANGED
@@ -43,7 +43,7 @@ module Precious
|
|
43
43
|
register Mustache::Sinatra
|
44
44
|
include Precious::Helpers
|
45
45
|
|
46
|
-
dir
|
46
|
+
dir = File.dirname(File.expand_path(__FILE__))
|
47
47
|
|
48
48
|
# Detect unsupported browsers.
|
49
49
|
Browser = Struct.new(:browser, :version)
|
@@ -56,23 +56,23 @@ module Precious
|
|
56
56
|
|
57
57
|
def supported_useragent?(user_agent)
|
58
58
|
ua = UserAgent.parse(user_agent)
|
59
|
-
@@min_ua.detect {|min| ua >= min }
|
59
|
+
@@min_ua.detect { |min| ua >= min }
|
60
60
|
end
|
61
61
|
|
62
62
|
# We want to serve public assets for now
|
63
63
|
set :public_folder, "#{dir}/public/gollum"
|
64
|
-
set :static,
|
64
|
+
set :static, true
|
65
65
|
set :default_markup, :markdown
|
66
66
|
|
67
67
|
set :mustache, {
|
68
|
-
|
69
|
-
|
68
|
+
# Tell mustache where the Views constant lives
|
69
|
+
:namespace => Precious,
|
70
70
|
|
71
|
-
|
72
|
-
|
71
|
+
# Mustache templates live here
|
72
|
+
:templates => "#{dir}/templates",
|
73
73
|
|
74
|
-
|
75
|
-
|
74
|
+
# Tell mustache where the views are
|
75
|
+
:views => "#{dir}/views"
|
76
76
|
}
|
77
77
|
|
78
78
|
# Sinatra error handling
|
@@ -90,7 +90,7 @@ module Precious
|
|
90
90
|
# above will detect base_path when it's used with map in a config.ru
|
91
91
|
settings.wiki_options.merge!({ :base_path => @base_url })
|
92
92
|
@css = settings.wiki_options[:css]
|
93
|
-
@js
|
93
|
+
@js = settings.wiki_options[:js]
|
94
94
|
end
|
95
95
|
|
96
96
|
get '/' do
|
@@ -139,9 +139,9 @@ module Precious
|
|
139
139
|
end
|
140
140
|
redirect to(live_preview_url)
|
141
141
|
else
|
142
|
-
@page
|
142
|
+
@page = page
|
143
143
|
@page.version = wiki.repo.log(wiki.ref, @page.path).first
|
144
|
-
@content
|
144
|
+
@content = page.text_data
|
145
145
|
mustache :edit
|
146
146
|
end
|
147
147
|
else
|
@@ -163,9 +163,9 @@ module Precious
|
|
163
163
|
tempfile = params[:file][:tempfile]
|
164
164
|
end
|
165
165
|
|
166
|
-
dir
|
167
|
-
ext
|
168
|
-
format
|
166
|
+
dir = wiki.per_page_uploads ? params[:upload_dest] : 'uploads'
|
167
|
+
ext = ::File.extname(fullname)
|
168
|
+
format = ext.split('.').last || 'txt'
|
169
169
|
filename = ::File.basename(fullname, ext)
|
170
170
|
contents = ::File.read(tempfile)
|
171
171
|
reponame = filename + '.' + format
|
@@ -173,10 +173,10 @@ module Precious
|
|
173
173
|
head = wiki.repo.head
|
174
174
|
|
175
175
|
options = {
|
176
|
-
|
177
|
-
|
176
|
+
:message => "Uploaded file to #{dir}/#{reponame}",
|
177
|
+
:parent => wiki.repo.head.commit,
|
178
178
|
}
|
179
|
-
author
|
179
|
+
author = session['gollum.author']
|
180
180
|
unless author.nil?
|
181
181
|
options.merge! author
|
182
182
|
end
|
@@ -197,37 +197,37 @@ module Precious
|
|
197
197
|
end
|
198
198
|
|
199
199
|
post '/rename/*' do
|
200
|
-
wikip
|
200
|
+
wikip = wiki_page(params[:splat].first)
|
201
201
|
halt 500 if wikip.nil?
|
202
|
-
wiki
|
203
|
-
page
|
204
|
-
rename
|
202
|
+
wiki = wikip.wiki
|
203
|
+
page = wiki.paged(wikip.name, wikip.path, exact = true)
|
204
|
+
rename = params[:rename]
|
205
205
|
halt 500 if page.nil?
|
206
206
|
halt 500 if rename.nil? or rename.empty?
|
207
207
|
|
208
208
|
# Fixup the rename if it is a relative path
|
209
209
|
# In 1.8.7 rename[0] != rename[0..0]
|
210
210
|
if rename[0..0] != '/'
|
211
|
-
source_dir
|
212
|
-
source_dir
|
211
|
+
source_dir = ::File.dirname(page.path)
|
212
|
+
source_dir = '' if source_dir == '.'
|
213
213
|
(target_dir, target_name) = ::File.split(rename)
|
214
|
-
target_dir
|
215
|
-
rename
|
214
|
+
target_dir = target_dir == '' ? source_dir : "#{source_dir}/#{target_dir}"
|
215
|
+
rename = "#{target_dir}/#{target_name}"
|
216
216
|
end
|
217
217
|
|
218
218
|
committer = Gollum::Committer.new(wiki, commit_message)
|
219
|
-
commit = {:committer => committer}
|
219
|
+
commit = { :committer => committer }
|
220
220
|
|
221
221
|
success = wiki.rename_page(page, rename, commit)
|
222
222
|
if !success
|
223
|
-
|
224
|
-
|
225
|
-
|
223
|
+
# This occurs on NOOPs, for example renaming A => A
|
224
|
+
redirect to("/#{page.escaped_url_path}")
|
225
|
+
return
|
226
226
|
end
|
227
227
|
committer.commit
|
228
228
|
|
229
229
|
wikip = wiki_page(rename)
|
230
|
-
page
|
230
|
+
page = wiki.paged(wikip.name, wikip.path, exact = true)
|
231
231
|
return if page.nil?
|
232
232
|
redirect to("/#{page.escaped_url_path}")
|
233
233
|
end
|
@@ -239,11 +239,11 @@ module Precious
|
|
239
239
|
page = wiki.paged(page_name, path, exact = true)
|
240
240
|
return if page.nil?
|
241
241
|
committer = Gollum::Committer.new(wiki, commit_message)
|
242
|
-
commit = {:committer => committer}
|
242
|
+
commit = { :committer => committer }
|
243
243
|
|
244
244
|
update_wiki_page(wiki, page, params[:content], commit, page.name, params[:format])
|
245
|
-
update_wiki_page(wiki, page.header,
|
246
|
-
update_wiki_page(wiki, page.footer,
|
245
|
+
update_wiki_page(wiki, page.header, params[:header], commit) if params[:header]
|
246
|
+
update_wiki_page(wiki, page.footer, params[:footer], commit) if params[:footer]
|
247
247
|
update_wiki_page(wiki, page.sidebar, params[:sidebar], commit) if params[:sidebar]
|
248
248
|
committer.commit
|
249
249
|
|
@@ -252,9 +252,9 @@ module Precious
|
|
252
252
|
|
253
253
|
get '/delete/*' do
|
254
254
|
wikip = wiki_page(params[:splat].first)
|
255
|
-
name
|
256
|
-
wiki
|
257
|
-
page
|
255
|
+
name = wikip.name
|
256
|
+
wiki = wikip.wiki
|
257
|
+
page = wikip.page
|
258
258
|
unless page.nil?
|
259
259
|
wiki.delete_page(page, { :message => "Destroyed #{name} (#{page.format})" })
|
260
260
|
end
|
@@ -286,10 +286,10 @@ module Precious
|
|
286
286
|
end
|
287
287
|
|
288
288
|
post '/create' do
|
289
|
-
name
|
290
|
-
path
|
291
|
-
format
|
292
|
-
wiki
|
289
|
+
name = params[:page].to_url
|
290
|
+
path = sanitize_empty_params(params[:path]) || ''
|
291
|
+
format = params[:format].intern
|
292
|
+
wiki = wiki_new
|
293
293
|
|
294
294
|
path.gsub!(/^\//, '')
|
295
295
|
|
@@ -305,15 +305,15 @@ module Precious
|
|
305
305
|
end
|
306
306
|
|
307
307
|
post '/revert/*/:sha1/:sha2' do
|
308
|
-
wikip
|
309
|
-
@path
|
310
|
-
@name
|
311
|
-
wiki
|
312
|
-
@page
|
313
|
-
sha1
|
314
|
-
sha2
|
315
|
-
|
316
|
-
commit
|
308
|
+
wikip = wiki_page(params[:splat].first)
|
309
|
+
@path = wikip.path
|
310
|
+
@name = wikip.name
|
311
|
+
wiki = wikip.wiki
|
312
|
+
@page = wiki.paged(@name, @path)
|
313
|
+
sha1 = params[:sha1]
|
314
|
+
sha2 = params[:sha2]
|
315
|
+
|
316
|
+
commit = commit_message
|
317
317
|
commit[:message] = "Revert commit #{sha1.chars.take(7).join}"
|
318
318
|
if wiki.revert_page(@page, sha1, sha2, commit)
|
319
319
|
redirect to("/#{@page.escaped_url_path}")
|
@@ -328,23 +328,23 @@ module Precious
|
|
328
328
|
end
|
329
329
|
|
330
330
|
post '/preview' do
|
331
|
-
wiki
|
332
|
-
@name
|
333
|
-
@page
|
334
|
-
@content
|
335
|
-
@toc_content
|
336
|
-
@mathjax
|
337
|
-
@h1_title
|
338
|
-
@editable
|
331
|
+
wiki = wiki_new
|
332
|
+
@name = params[:page] || "Preview"
|
333
|
+
@page = wiki.preview_page(@name, params[:content], params[:format])
|
334
|
+
@content = @page.formatted_data
|
335
|
+
@toc_content = wiki.universal_toc ? @page.toc_data : nil
|
336
|
+
@mathjax = wiki.mathjax
|
337
|
+
@h1_title = wiki.h1_title
|
338
|
+
@editable = false
|
339
339
|
@allow_uploads = wiki.allow_uploads
|
340
340
|
mustache :page
|
341
341
|
end
|
342
342
|
|
343
343
|
get '/history/*' do
|
344
|
-
@page
|
345
|
-
@page_num
|
344
|
+
@page = wiki_page(params[:splat].first).page
|
345
|
+
@page_num = [params[:page].to_i, 1].max
|
346
346
|
unless @page.nil?
|
347
|
-
@versions
|
347
|
+
@versions = @page.versions :page => @page_num
|
348
348
|
mustache :history
|
349
349
|
else
|
350
350
|
redirect to("/")
|
@@ -358,10 +358,10 @@ module Precious
|
|
358
358
|
redirect to("/history/#{@file}")
|
359
359
|
else
|
360
360
|
redirect to("/compare/%s/%s...%s" % [
|
361
|
-
|
362
|
-
|
363
|
-
|
364
|
-
|
361
|
+
@file,
|
362
|
+
@versions.last,
|
363
|
+
@versions.first]
|
364
|
+
)
|
365
365
|
end
|
366
366
|
end
|
367
367
|
|
@@ -373,14 +373,14 @@ module Precious
|
|
373
373
|
\.{2,3} # match .. or ...
|
374
374
|
(.+) # match the second SHA1
|
375
375
|
}x do |path, start_version, end_version|
|
376
|
-
wikip
|
377
|
-
@path
|
378
|
-
@name
|
379
|
-
@versions
|
380
|
-
wiki
|
381
|
-
@page
|
382
|
-
diffs
|
383
|
-
@diff
|
376
|
+
wikip = wiki_page(path)
|
377
|
+
@path = wikip.path
|
378
|
+
@name = wikip.name
|
379
|
+
@versions = [start_version, end_version]
|
380
|
+
wiki = wikip.wiki
|
381
|
+
@page = wikip.page
|
382
|
+
diffs = wiki.repo.diff(@versions.first, @versions.last, @page.path)
|
383
|
+
@diff = diffs.first
|
384
384
|
mustache :compare
|
385
385
|
end
|
386
386
|
|
@@ -391,8 +391,8 @@ module Precious
|
|
391
391
|
name = wikip.name
|
392
392
|
path = wikip.path
|
393
393
|
if page = wikip.page
|
394
|
-
@page
|
395
|
-
@name
|
394
|
+
@page = page
|
395
|
+
@name = name
|
396
396
|
@content = page.formatted_data
|
397
397
|
@version = version
|
398
398
|
mustache :page
|
@@ -402,11 +402,11 @@ module Precious
|
|
402
402
|
end
|
403
403
|
|
404
404
|
get '/search' do
|
405
|
-
@query
|
406
|
-
wiki
|
405
|
+
@query = params[:q]
|
406
|
+
wiki = wiki_new
|
407
407
|
# Sort wiki search results by count (desc) and then by name (asc)
|
408
|
-
@results = wiki.search(@query).sort{ |a, b| (a[:count] <=> b[:count]).nonzero? || b[:name] <=> a[:name] }.reverse
|
409
|
-
@name
|
408
|
+
@results = wiki.search(@query).sort { |a, b| (a[:count] <=> b[:count]).nonzero? || b[:name] <=> a[:name] }.reverse
|
409
|
+
@name = @query
|
410
410
|
mustache :search
|
411
411
|
end
|
412
412
|
|
@@ -426,16 +426,16 @@ module Precious
|
|
426
426
|
end
|
427
427
|
|
428
428
|
get '/fileview' do
|
429
|
-
wiki
|
430
|
-
options
|
431
|
-
content
|
429
|
+
wiki = wiki_new
|
430
|
+
options = settings.wiki_options
|
431
|
+
content = wiki.pages
|
432
432
|
# if showing all files include wiki.files
|
433
|
-
content
|
433
|
+
content += wiki.files if options[:show_all]
|
434
434
|
|
435
435
|
# must pass wiki_options to FileView
|
436
436
|
# --show-all and --collapse-tree can be set.
|
437
437
|
@results = Gollum::FileView.new(content, options).render_files
|
438
|
-
@ref
|
438
|
+
@ref = wiki.ref
|
439
439
|
mustache :file_view, { :layout => false }
|
440
440
|
end
|
441
441
|
|
@@ -450,21 +450,21 @@ module Precious
|
|
450
450
|
path = extract_path(fullpath) || '/'
|
451
451
|
|
452
452
|
if page = wiki.paged(name, path, exact = true)
|
453
|
-
@page
|
454
|
-
@name
|
455
|
-
@content
|
456
|
-
@upload_dest
|
457
|
-
|
458
|
-
|
459
|
-
|
453
|
+
@page = page
|
454
|
+
@name = name
|
455
|
+
@content = page.formatted_data
|
456
|
+
@upload_dest = settings.wiki_options[:allow_uploads] ?
|
457
|
+
(settings.wiki_options[:per_page_uploads] ?
|
458
|
+
"#{path}/#{@name}".sub(/^\/\//, '') : 'uploads'
|
459
|
+
) : ''
|
460
460
|
|
461
461
|
# Extensions and layout data
|
462
|
-
@editable
|
463
|
-
@page_exists
|
464
|
-
@toc_content
|
465
|
-
@mathjax
|
466
|
-
@h1_title
|
467
|
-
@bar_side
|
462
|
+
@editable = true
|
463
|
+
@page_exists = !page.versions.empty?
|
464
|
+
@toc_content = wiki.universal_toc ? @page.toc_data : nil
|
465
|
+
@mathjax = wiki.mathjax
|
466
|
+
@h1_title = wiki.h1_title
|
467
|
+
@bar_side = wiki.bar_side
|
468
468
|
@allow_uploads = wiki.allow_uploads
|
469
469
|
|
470
470
|
mustache :page
|
@@ -483,9 +483,9 @@ module Precious
|
|
483
483
|
|
484
484
|
def update_wiki_page(wiki, page, content, commit, name = nil, format = nil)
|
485
485
|
return if !page ||
|
486
|
-
|
486
|
+
((!content || page.raw_data == content) && page.format == format)
|
487
487
|
name ||= page.name
|
488
|
-
format
|
488
|
+
format = (format || page.format).to_sym
|
489
489
|
content ||= page.raw_data
|
490
490
|
wiki.update_page(page, name, format, content.to_s, commit)
|
491
491
|
end
|
@@ -499,8 +499,8 @@ module Precious
|
|
499
499
|
# message is sourced from the incoming request parameters
|
500
500
|
# author details are sourced from the session, to be populated by rack middleware ahead of us
|
501
501
|
def commit_message
|
502
|
-
msg
|
503
|
-
commit_message
|
502
|
+
msg = (params[:message].nil? or params[:message].empty?) ? "[no message]" : params[:message]
|
503
|
+
commit_message = { :message => msg }
|
504
504
|
author_parameters = session['gollum.author']
|
505
505
|
commit_message.merge! author_parameters unless author_parameters.nil?
|
506
506
|
commit_message
|