gollum 5.0.1 → 5.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CONTRIBUTING.md +2 -2
- data/Gemfile +1 -1
- data/HISTORY.md +21 -0
- data/README.md +1 -0
- data/Rakefile +2 -5
- data/bin/gollum +1 -1
- data/contrib/automation/gollum-post +66 -0
- data/gollum.gemspec +21 -17
- data/lib/gollum.rb +17 -1
- data/lib/gollum/app.rb +63 -31
- data/lib/gollum/assets.rb +3 -3
- data/lib/gollum/helpers.rb +1 -1
- data/lib/gollum/public/assets/.sprockets-manifest-15b663a27211dc9de9a452b4b74462d7.json +1 -0
- data/lib/gollum/public/assets/app-7a0bbff2e8bad3033e7c17e0e0f886f336a9d23d3b912dcd2ae389c48b4b63e6.css +21 -0
- data/lib/gollum/public/assets/app-7a0bbff2e8bad3033e7c17e0e0f886f336a9d23d3b912dcd2ae389c48b4b63e6.css.gz +0 -0
- data/lib/gollum/public/assets/app-7a4bd115f4bc7ece39bc8073ca0ffad7c5e55cc5837b1464a12dead4905cefb2.js +5 -0
- data/lib/gollum/public/assets/app-7a4bd115f4bc7ece39bc8073ca0ffad7c5e55cc5837b1464a12dead4905cefb2.js.gz +0 -0
- data/lib/gollum/public/assets/criticmarkup-31ae5d3282bbb8e7b7c3c9917e9fb68e3315a6b4a75da6cec48d21b8846905c4.css.gz +0 -0
- data/lib/gollum/public/assets/editor-db10c8351306e92f1926ba225d0cd9c8e886482b3b9820a85825ec3abab5f1cf.js +24 -0
- data/lib/gollum/public/assets/editor-db10c8351306e92f1926ba225d0cd9c8e886482b3b9820a85825ec3abab5f1cf.js.gz +0 -0
- data/lib/gollum/public/assets/print-512498c368be0d3fb1ba105dfa84289ae48380ec9fcbef948bd4e23b0b095bfb.css.gz +0 -0
- data/lib/gollum/public/gollum/javascript/app.js +1 -0
- data/lib/gollum/public/gollum/javascript/editor/gollum.editor.js +59 -0
- data/lib/gollum/public/gollum/javascript/editor/modes.js.erb +1 -1
- data/lib/gollum/public/gollum/javascript/gollum.js.erb +16 -15
- data/lib/gollum/public/gollum/javascript/polyfills.js +6 -0
- data/lib/gollum/public/gollum/stylesheets/primer.css +23 -0
- data/lib/gollum/public/gollum/stylesheets/template.scss.erb +132 -57
- data/lib/gollum/templates/commit.mustache +26 -0
- data/lib/gollum/templates/editor.mustache +7 -2
- data/lib/gollum/templates/history.mustache +5 -2
- data/lib/gollum/templates/latest_changes.mustache +8 -6
- data/lib/gollum/templates/layout.mustache +4 -5
- data/lib/gollum/templates/mobilenav.mustache +72 -0
- data/lib/gollum/templates/navbar.mustache +104 -42
- data/lib/gollum/templates/overview.mustache +2 -2
- data/lib/gollum/templates/search.mustache +2 -3
- data/lib/gollum/templates/wiki_content.mustache +18 -17
- data/lib/gollum/views/commit.rb +45 -0
- data/lib/gollum/views/compare.rb +19 -8
- data/lib/gollum/views/has_page.rb +0 -4
- data/lib/gollum/views/helpers.rb +13 -3
- data/lib/gollum/views/history.rb +4 -1
- data/lib/gollum/views/latest_changes.rb +1 -0
- data/lib/gollum/views/layout.rb +17 -1
- data/lib/gollum/views/overview.rb +6 -5
- data/lib/gollum/views/page.rb +15 -8
- data/lib/gollum/views/search.rb +2 -1
- metadata +33 -35
- data/lib/gollum/public/assets/.sprockets-manifest-3edc7e21737459b21fbf150f5dccd15c.json +0 -1
- data/lib/gollum/public/assets/app-982c7fca1832732a24e92474ca2729aeb56f2d0c05bb7a8ff913e9f58a6500d5.js +0 -5
- data/lib/gollum/public/assets/app-982c7fca1832732a24e92474ca2729aeb56f2d0c05bb7a8ff913e9f58a6500d5.js.gz +0 -0
- data/lib/gollum/public/assets/app-b205e593a30f1cc0054e2e9ed9fc8af3658d8ef4a62b9708c20f204560deefb7.css +0 -21
- data/lib/gollum/public/assets/app-b205e593a30f1cc0054e2e9ed9fc8af3658d8ef4a62b9708c20f204560deefb7.css.gz +0 -0
- data/lib/gollum/public/assets/editor-0dbae28c53db5a73d666d30504946671eb09948ffdaf1fdd9d1c8d856d4c0ba1.js +0 -24
- data/lib/gollum/public/assets/editor-0dbae28c53db5a73d666d30504946671eb09948ffdaf1fdd9d1c8d856d4c0ba1.js.gz +0 -0
- data/lib/gollum/public/gollum/stylesheets/_layout.scss +0 -83
- data/lib/gollum/public/gollum/stylesheets/primer.scss +0 -23
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 210167f0c5540675d37210272db4fe0da3bc6d75647c26a46c7d16a07fd9e1e7
|
4
|
+
data.tar.gz: 63298c72adf095678e6cea9b085c3f891ba025b2342d7132cce578974149c5b6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 98e609a98e3e38b87f7c929c61d5d07a2c09057050137aeec5bfb5f1d98c589ee965651fdf379688b1fc20845458300a8f0e4ad4314fa8cb999ef998f111654c
|
7
|
+
data.tar.gz: 6766945d35d5218eb1dd8efc78755e4331e894b5ae0a85d2e7fdaa825d88aef774c3485accccdd7a94f8bdbe478f80aca0e043143022471934c0f48564f838e3
|
data/CONTRIBUTING.md
CHANGED
@@ -21,7 +21,7 @@ Before submitting an issue, **please carefully look through the following places
|
|
21
21
|
|
22
22
|
Security vulnerabilities can be reported directly to the maintainers using these GPG keys:
|
23
23
|
|
24
|
-
* [@dometto](https://
|
24
|
+
* [@dometto](https://keys.openpgp.org/vks/v1/by-fingerprint/02354CC9F820B52CC2791979BB8CCC95FD83B795)
|
25
25
|
|
26
26
|
Lastly, please **consider helping out** by opening a Pull Request!
|
27
27
|
|
@@ -70,7 +70,7 @@ An example of how to add a test file to the bare repository lotr.git.
|
|
70
70
|
```
|
71
71
|
mkdir tmp
|
72
72
|
cd tmp
|
73
|
-
git clone ../lotr.git/
|
73
|
+
git clone ../test/examples/lotr.git/
|
74
74
|
git log
|
75
75
|
echo "test" > test.md
|
76
76
|
git add .
|
data/Gemfile
CHANGED
data/HISTORY.md
CHANGED
@@ -1,3 +1,24 @@
|
|
1
|
+
# 5.2.1 2021-02-25
|
2
|
+
|
3
|
+
* Fix include call to a missing asset (@benjaminwil). This caused slow first page loads on JRuby.
|
4
|
+
|
5
|
+
# 5.2 2021-02-24
|
6
|
+
|
7
|
+
* Improved styling and Primer upgrade (@benjaminwil)
|
8
|
+
* Add redirect to rename commit (@ViChyavIn)
|
9
|
+
* Updated dependencies
|
10
|
+
* Bugfixes
|
11
|
+
|
12
|
+
# 5.1.2
|
13
|
+
|
14
|
+
* Guard against malicious filenames in breadcrumbs
|
15
|
+
|
16
|
+
# 5.1
|
17
|
+
|
18
|
+
* Bugfixes
|
19
|
+
* Add autosave feature (#1576)
|
20
|
+
* Add Add quick access to diff of each commit in the history
|
21
|
+
|
1
22
|
# 5.0 / 2020-03-17
|
2
23
|
|
3
24
|
This is a major new release that introduces many new features, bugfixes, and removes major limitations. See [here](https://github.com/gollum/gollum/wiki/5.0-release-notes) for a list of changes.
|
data/README.md
CHANGED
@@ -4,6 +4,7 @@ gollum -- A git-based Wiki
|
|
4
4
|
[![Gem Version](https://badge.fury.io/rb/gollum.svg)](http://badge.fury.io/rb/gollum)
|
5
5
|
[![Build Status](https://travis-ci.org/gollum/gollum.svg?branch=master)](https://travis-ci.org/gollum/gollum)
|
6
6
|
[![Open Source Helpers](https://www.codetriage.com/gollum/gollum/badges/users.svg)](https://www.codetriage.com/gollum/gollum)
|
7
|
+
[![Cutting Edge Dependency Status](https://dometto-cuttingedge.herokuapp.com/github/gollum/gollum/svg 'Cutting Edge Dependency Status')](https://dometto-cuttingedge.herokuapp.com/github/gollum/gollum/info)
|
7
8
|
|
8
9
|
**Gollum version 5.0 is out!** See [here](https://github.com/gollum/gollum/wiki/5.0-release-notes) for a list of changes and new features compared to Gollum version 4.x, and see some [Screenshots](https://github.com/gollum/gollum/wiki/Screenshots) of Gollum's features.
|
9
10
|
|
data/Rakefile
CHANGED
@@ -181,11 +181,8 @@ end
|
|
181
181
|
|
182
182
|
desc 'Precompile assets'
|
183
183
|
task :precompile do
|
184
|
-
require './lib/gollum/
|
185
|
-
|
186
|
-
require 'sprockets'
|
187
|
-
require 'sprockets-helpers'
|
188
|
-
require 'sass'
|
184
|
+
require './lib/gollum/app.rb'
|
185
|
+
Precious::App.set(:environment, :production)
|
189
186
|
env = Precious::Assets.sprockets
|
190
187
|
path = ENV.fetch('GOLLUM_ASSETS_PATH', ::File.join(File.dirname(__FILE__), 'lib/gollum/public/assets'))
|
191
188
|
manifest = Sprockets::Manifest.new(env, path)
|
data/bin/gollum
CHANGED
@@ -152,7 +152,7 @@ MSG
|
|
152
152
|
opts.on('--template-dir [PATH]', 'Specify custom mustache template directory.') do |path|
|
153
153
|
wiki_options[:template_dir] = path
|
154
154
|
end
|
155
|
-
opts.on('--template-page', 'Use _Template
|
155
|
+
opts.on('--template-page', 'Use _Template.{ext} as a template for new pages.') do
|
156
156
|
wiki_options[:template_page] = true
|
157
157
|
end
|
158
158
|
opts.on('--lenient-tag-lookup', 'Internal links resolve case-insensitively, will treat spaces as hyphens, and will match the first page found with a certain filename, anywhere in the repository. Provides compatibility with Gollum 4.x.') do
|
@@ -0,0 +1,66 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
#
|
3
|
+
# Distributed under the terms of the MIT License.
|
4
|
+
#
|
5
|
+
# Author: Sam Baskinger <basking2@yahoo.com>
|
6
|
+
#
|
7
|
+
# Description: gollum-post is an example script that shows how
|
8
|
+
# to post a file to Gollum. This may be used
|
9
|
+
# to build scripts around CI/CD pipelines that
|
10
|
+
# publish their documentation to Gollum.
|
11
|
+
#
|
12
|
+
|
13
|
+
require 'uri'
|
14
|
+
require 'mechanize'
|
15
|
+
require 'digest'
|
16
|
+
|
17
|
+
GOLLUM=URI('https://mygollum.server')
|
18
|
+
|
19
|
+
m = Mechanize.new()
|
20
|
+
|
21
|
+
page="TestPage"
|
22
|
+
path="/automated/docs"
|
23
|
+
format="asciidoc"
|
24
|
+
content="""
|
25
|
+
= This is #{page}
|
26
|
+
|
27
|
+
This page is automatically generated.
|
28
|
+
"""
|
29
|
+
message='Posting current documentation.'
|
30
|
+
|
31
|
+
# Check if the page exists.
|
32
|
+
p = m.get("#{GOLLUM}#{path}/#{page}")
|
33
|
+
|
34
|
+
# If we were redirected to the creat page...
|
35
|
+
if p.uri.to_s =~ /\/gollum\/create/
|
36
|
+
|
37
|
+
# ... then create the page.
|
38
|
+
p = m.post("#{GOLLUM}/gollum/create",
|
39
|
+
'keybinding' => 'default',
|
40
|
+
'page' => page,
|
41
|
+
'path' => path,
|
42
|
+
'format' => 'asciidoc',
|
43
|
+
'message' => 'Publish bot.',
|
44
|
+
'content' => content)
|
45
|
+
else
|
46
|
+
# ... else, get the previous content and update it.
|
47
|
+
p = m.get("#{GOLLUM}/gollum/edit#{path}/#{page}")
|
48
|
+
|
49
|
+
# Get the previous content. You _could_ check if this is unchanged at this
|
50
|
+
# step and post nothing.
|
51
|
+
previous_content = p.xpath('//textarea[@id="gollum-editor-body"]')[0].text
|
52
|
+
|
53
|
+
# The previous ETag is the Git SHA-1. We need this to replace the previous contents.
|
54
|
+
prev_etag = Digest::SHA1.hexdigest("blob #{previous_content.length}\0#{previous_content}")
|
55
|
+
|
56
|
+
# Post the updated document using the ETag of the previous document to avoid collisions.
|
57
|
+
p = m.post("#{GOLLUM}/gollum/edit#{path}/#{page}",
|
58
|
+
'keybinding' => 'default',
|
59
|
+
'page' => page,
|
60
|
+
'path' => path,
|
61
|
+
'format' => 'asciidoc',
|
62
|
+
'message' => message,
|
63
|
+
'etag' => prev_etag,
|
64
|
+
'content' => content)
|
65
|
+
end
|
66
|
+
|
data/gollum.gemspec
CHANGED
@@ -5,8 +5,8 @@ Gem::Specification.new do |s|
|
|
5
5
|
s.required_ruby_version = '>= 1.9'
|
6
6
|
|
7
7
|
s.name = 'gollum'
|
8
|
-
s.version = '5.
|
9
|
-
s.date = '
|
8
|
+
s.version = '5.2.1'
|
9
|
+
s.date = '2021-02-25'
|
10
10
|
s.license = 'MIT'
|
11
11
|
|
12
12
|
s.summary = 'A simple, Git-powered wiki.'
|
@@ -23,18 +23,18 @@ Gem::Specification.new do |s|
|
|
23
23
|
s.rdoc_options = ['--charset=UTF-8']
|
24
24
|
s.extra_rdoc_files = %w[README.md LICENSE]
|
25
25
|
|
26
|
-
s.add_dependency 'gollum-lib', '~> 5.
|
27
|
-
s.add_dependency 'kramdown', '~> 2.
|
28
|
-
s.add_dependency 'kramdown-parser-gfm', '~> 1.
|
26
|
+
s.add_dependency 'gollum-lib', '~> 5.1'
|
27
|
+
s.add_dependency 'kramdown', '~> 2.3'
|
28
|
+
s.add_dependency 'kramdown-parser-gfm', '~> 1.1.0'
|
29
29
|
s.add_dependency 'sinatra', '~> 2.0'
|
30
30
|
s.add_dependency 'sinatra-contrib', '~> 2.0'
|
31
|
-
s.add_dependency 'mustache',
|
31
|
+
s.add_dependency 'mustache-sinatra', '~> 1.0'
|
32
32
|
s.add_dependency 'useragent', '~> 0.16.2'
|
33
33
|
s.add_dependency 'gemojione', '~> 4.1'
|
34
|
-
s.add_dependency 'octicons', '~>
|
34
|
+
s.add_dependency 'octicons', '~> 12.0'
|
35
35
|
s.add_dependency 'sprockets', '~> 3.7'
|
36
36
|
s.add_dependency 'sass', '~> 3.5'
|
37
|
-
s.add_dependency 'uglifier', '~>
|
37
|
+
s.add_dependency 'uglifier', '~> 4.2'
|
38
38
|
s.add_dependency 'sprockets-helpers', '~> 1.2'
|
39
39
|
s.add_dependency 'rss', '~> 0.2.9'
|
40
40
|
s.add_dependency 'therubyrhino', '~> 2.1.0'
|
@@ -59,6 +59,7 @@ Gem::Specification.new do |s|
|
|
59
59
|
bin/gollum-migrate-tags
|
60
60
|
config.rb
|
61
61
|
config.ru
|
62
|
+
contrib/automation/gollum-post
|
62
63
|
contrib/openrc/conf.d/gollum
|
63
64
|
contrib/openrc/init.d/gollum
|
64
65
|
contrib/systemd/gollum@.service
|
@@ -68,15 +69,15 @@ Gem::Specification.new do |s|
|
|
68
69
|
lib/gollum/app.rb
|
69
70
|
lib/gollum/assets.rb
|
70
71
|
lib/gollum/helpers.rb
|
71
|
-
lib/gollum/public/assets/.sprockets-manifest-
|
72
|
-
lib/gollum/public/assets/app-
|
73
|
-
lib/gollum/public/assets/app-
|
74
|
-
lib/gollum/public/assets/app-
|
75
|
-
lib/gollum/public/assets/app-
|
72
|
+
lib/gollum/public/assets/.sprockets-manifest-15b663a27211dc9de9a452b4b74462d7.json
|
73
|
+
lib/gollum/public/assets/app-7a0bbff2e8bad3033e7c17e0e0f886f336a9d23d3b912dcd2ae389c48b4b63e6.css
|
74
|
+
lib/gollum/public/assets/app-7a0bbff2e8bad3033e7c17e0e0f886f336a9d23d3b912dcd2ae389c48b4b63e6.css.gz
|
75
|
+
lib/gollum/public/assets/app-7a4bd115f4bc7ece39bc8073ca0ffad7c5e55cc5837b1464a12dead4905cefb2.js
|
76
|
+
lib/gollum/public/assets/app-7a4bd115f4bc7ece39bc8073ca0ffad7c5e55cc5837b1464a12dead4905cefb2.js.gz
|
76
77
|
lib/gollum/public/assets/criticmarkup-31ae5d3282bbb8e7b7c3c9917e9fb68e3315a6b4a75da6cec48d21b8846905c4.css
|
77
78
|
lib/gollum/public/assets/criticmarkup-31ae5d3282bbb8e7b7c3c9917e9fb68e3315a6b4a75da6cec48d21b8846905c4.css.gz
|
78
|
-
lib/gollum/public/assets/editor-
|
79
|
-
lib/gollum/public/assets/editor-
|
79
|
+
lib/gollum/public/assets/editor-db10c8351306e92f1926ba225d0cd9c8e886482b3b9820a85825ec3abab5f1cf.js
|
80
|
+
lib/gollum/public/assets/editor-db10c8351306e92f1926ba225d0cd9c8e886482b3b9820a85825ec3abab5f1cf.js.gz
|
80
81
|
lib/gollum/public/assets/print-512498c368be0d3fb1ba105dfa84289ae48380ec9fcbef948bd4e23b0b095bfb.css
|
81
82
|
lib/gollum/public/assets/print-512498c368be0d3fb1ba105dfa84289ae48380ec9fcbef948bd4e23b0b095bfb.css.gz
|
82
83
|
lib/gollum/public/gollum/javascript/HOWTO_UPDATE_ACE.md
|
@@ -1174,22 +1175,23 @@ Gem::Specification.new do |s|
|
|
1174
1175
|
lib/gollum/public/gollum/javascript/jquery-1.7.2.min.js
|
1175
1176
|
lib/gollum/public/gollum/javascript/jquery.resize.js
|
1176
1177
|
lib/gollum/public/gollum/javascript/mousetrap.min.js
|
1178
|
+
lib/gollum/public/gollum/javascript/polyfills.js
|
1177
1179
|
lib/gollum/public/gollum/stylesheets/_base.scss
|
1178
1180
|
lib/gollum/public/gollum/stylesheets/_breakpoint.scss
|
1179
1181
|
lib/gollum/public/gollum/stylesheets/_component.scss
|
1180
1182
|
lib/gollum/public/gollum/stylesheets/_features.scss
|
1181
|
-
lib/gollum/public/gollum/stylesheets/_layout.scss
|
1182
1183
|
lib/gollum/public/gollum/stylesheets/_spinners.scss
|
1183
1184
|
lib/gollum/public/gollum/stylesheets/app.scss
|
1184
1185
|
lib/gollum/public/gollum/stylesheets/criticmarkup.scss
|
1185
1186
|
lib/gollum/public/gollum/stylesheets/dialog.scss
|
1186
1187
|
lib/gollum/public/gollum/stylesheets/editor.scss
|
1187
1188
|
lib/gollum/public/gollum/stylesheets/emoji.scss
|
1188
|
-
lib/gollum/public/gollum/stylesheets/primer.
|
1189
|
+
lib/gollum/public/gollum/stylesheets/primer.css
|
1189
1190
|
lib/gollum/public/gollum/stylesheets/print.scss
|
1190
1191
|
lib/gollum/public/gollum/stylesheets/spinner.scss
|
1191
1192
|
lib/gollum/public/gollum/stylesheets/tables.scss
|
1192
1193
|
lib/gollum/public/gollum/stylesheets/template.scss.erb
|
1194
|
+
lib/gollum/templates/commit.mustache
|
1193
1195
|
lib/gollum/templates/compare.mustache
|
1194
1196
|
lib/gollum/templates/create.mustache
|
1195
1197
|
lib/gollum/templates/edit.mustache
|
@@ -1201,6 +1203,7 @@ Gem::Specification.new do |s|
|
|
1201
1203
|
lib/gollum/templates/history_authors/none.mustache
|
1202
1204
|
lib/gollum/templates/latest_changes.mustache
|
1203
1205
|
lib/gollum/templates/layout.mustache
|
1206
|
+
lib/gollum/templates/mobilenav.mustache
|
1204
1207
|
lib/gollum/templates/navbar.mustache
|
1205
1208
|
lib/gollum/templates/overview.mustache
|
1206
1209
|
lib/gollum/templates/page.mustache
|
@@ -1209,6 +1212,7 @@ Gem::Specification.new do |s|
|
|
1209
1212
|
lib/gollum/templates/searchbar.mustache
|
1210
1213
|
lib/gollum/templates/wiki_content.mustache
|
1211
1214
|
lib/gollum/uri_encode_component.rb
|
1215
|
+
lib/gollum/views/commit.rb
|
1212
1216
|
lib/gollum/views/compare.rb
|
1213
1217
|
lib/gollum/views/create.rb
|
1214
1218
|
lib/gollum/views/edit.rb
|
data/lib/gollum.rb
CHANGED
@@ -12,7 +12,7 @@ require 'rhino' if RUBY_PLATFORM == 'java'
|
|
12
12
|
require File.expand_path('../gollum/uri_encode_component', __FILE__)
|
13
13
|
|
14
14
|
module Gollum
|
15
|
-
VERSION = '5.
|
15
|
+
VERSION = '5.2.1'
|
16
16
|
|
17
17
|
def self.assets_path
|
18
18
|
::File.expand_path('gollum/public', ::File.dirname(__FILE__))
|
@@ -33,4 +33,20 @@ module Gollum
|
|
33
33
|
super(message || "Cannot write #{@dir}/#{@attempted_path}, found #{@dir}/#{@existing_path}.")
|
34
34
|
end
|
35
35
|
end
|
36
|
+
|
37
|
+
class TemplateFilter
|
38
|
+
@@filters = {}
|
39
|
+
|
40
|
+
def self.add_filter(pattern, &replacement)
|
41
|
+
@@filters[pattern] = replacement
|
42
|
+
end
|
43
|
+
|
44
|
+
def self.apply_filters(data)
|
45
|
+
@@filters.each do |pattern, replacement|
|
46
|
+
data.gsub!(pattern, replacement.call)
|
47
|
+
end
|
48
|
+
data
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
36
52
|
end
|
data/lib/gollum/app.rb
CHANGED
@@ -230,14 +230,15 @@ module Precious
|
|
230
230
|
halt 500 unless tempfile.is_a? Tempfile
|
231
231
|
|
232
232
|
if wiki.per_page_uploads
|
233
|
-
|
234
|
-
dir = request.referer.
|
235
|
-
sub(request.base_url, '').
|
236
|
-
sub(/.*gollum\/[-\w]+\//, '')
|
233
|
+
dir = request.referer.sub(request.base_url, '')
|
237
234
|
# remove base path if it is set
|
238
|
-
dir
|
235
|
+
dir.sub!(/^#{wiki.base_path}/, '') if wiki.base_path
|
236
|
+
# remove base_url and gollum/* subpath if necessary
|
237
|
+
dir.sub!(/^\/gollum\/[-\w]+\//, '')
|
239
238
|
# remove file extension
|
240
|
-
dir
|
239
|
+
dir.sub!(/#{::File.extname(dir)}$/, '')
|
240
|
+
# revert escaped whitespaces
|
241
|
+
dir.gsub!(/%20/, ' ')
|
241
242
|
dir = ::File.join('uploads', dir)
|
242
243
|
else
|
243
244
|
# store all uploads together
|
@@ -302,12 +303,13 @@ module Precious
|
|
302
303
|
redirect to("/#{page.escaped_url_path}")
|
303
304
|
return
|
304
305
|
end
|
305
|
-
|
306
|
-
|
306
|
+
|
307
307
|
# Renaming preserves format, so add the page's format to the renamed path to retrieve the renamed page
|
308
308
|
new_path = "#{rename}.#{Gollum::Page.format_to_ext(page.format)}"
|
309
309
|
# Add a redirect from the old page to the new
|
310
|
-
wiki.add_redirect(page.url_path, clean_url(new_path)) if @redirects_enabled
|
310
|
+
wiki.add_redirect(page.url_path, clean_url(new_path), commit) if @redirects_enabled
|
311
|
+
|
312
|
+
committer.commit
|
311
313
|
|
312
314
|
page = wiki_page(new_path).page
|
313
315
|
return if page.nil?
|
@@ -317,9 +319,8 @@ module Precious
|
|
317
319
|
post '/edit/*' do
|
318
320
|
etag = params[:etag]
|
319
321
|
path = "/#{clean_url(sanitize_empty_params(params[:path]))}"
|
320
|
-
page_name = CGI.unescape(params[:page])
|
321
322
|
wiki = wiki_new
|
322
|
-
page = wiki.page(::File.join(path,
|
323
|
+
page = wiki.page(::File.join(path, params[:page]))
|
323
324
|
|
324
325
|
return if page.nil?
|
325
326
|
if etag != page.sha
|
@@ -351,14 +352,11 @@ module Precious
|
|
351
352
|
|
352
353
|
get '/create/*' do
|
353
354
|
forbid unless @allow_editing
|
354
|
-
if settings.wiki_options[:template_page] then
|
355
|
-
temppage = wiki_page('/_Template')
|
356
|
-
@template_page = (temppage.page != nil) ? temppage.page.raw_data : 'Template page option is set, but no /_Template page is present or committed.'
|
357
|
-
end
|
358
355
|
wikip = wiki_page(params[:splat].first)
|
359
356
|
@name = wikip.name
|
360
357
|
@ext = wikip.ext
|
361
358
|
@path = wikip.path
|
359
|
+
@template_page = load_template(@path) if settings.wiki_options[:template_page]
|
362
360
|
@allow_uploads = wikip.wiki.allow_uploads
|
363
361
|
@upload_dest = find_upload_dest(wikip.fullpath)
|
364
362
|
|
@@ -416,7 +414,7 @@ module Precious
|
|
416
414
|
|
417
415
|
post '/preview' do
|
418
416
|
wiki = wiki_new
|
419
|
-
@name = params[:page] ? strip_page_name(
|
417
|
+
@name = params[:page] ? strip_page_name(params[:page]) : 'Preview'
|
420
418
|
@page = wiki.preview_page(@name, params[:content], params[:format])
|
421
419
|
['sidebar', 'header', 'footer'].each do |subpage|
|
422
420
|
@page.send("set_#{subpage}".to_sym, params[subpage]) if params[subpage]
|
@@ -459,20 +457,6 @@ module Precious
|
|
459
457
|
mustache :latest_changes
|
460
458
|
end
|
461
459
|
|
462
|
-
post '/compare/*' do
|
463
|
-
@file = clean_url(encodeURIComponent(params[:splat].first))
|
464
|
-
@versions = params[:versions] || []
|
465
|
-
if @versions.size < 2
|
466
|
-
redirect to("gollum/history/#{@file}")
|
467
|
-
else
|
468
|
-
redirect to("gollum/compare/%s/%s...%s" % [
|
469
|
-
@file,
|
470
|
-
@versions.last,
|
471
|
-
@versions.first]
|
472
|
-
)
|
473
|
-
end
|
474
|
-
end
|
475
|
-
|
476
460
|
get %r{
|
477
461
|
/compare/ # match any URL beginning with /compare/
|
478
462
|
(.+) # extract the full path (including any directories)
|
@@ -496,8 +480,51 @@ module Precious
|
|
496
480
|
end
|
497
481
|
end
|
498
482
|
|
483
|
+
get '/compare/*' do
|
484
|
+
@file = clean_url(encodeURIComponent(params[:splat].first))
|
485
|
+
@versions = params[:versions] || []
|
486
|
+
if @versions.size == 1
|
487
|
+
wikip = wiki_page(params[:splat].first)
|
488
|
+
commit = wikip.wiki.repo.commit(@versions.first)
|
489
|
+
parent = commit.parent
|
490
|
+
if parent.nil?
|
491
|
+
redirect to("#{@file}/#{@commit.id}")
|
492
|
+
else
|
493
|
+
@versions.push(parent.id)
|
494
|
+
end
|
495
|
+
end
|
496
|
+
if @versions.empty?
|
497
|
+
redirect to("gollum/history/#{@file}")
|
498
|
+
else
|
499
|
+
redirect to("gollum/compare/%s/%s...%s" % [
|
500
|
+
@file,
|
501
|
+
@versions.last,
|
502
|
+
@versions.first]
|
503
|
+
)
|
504
|
+
end
|
505
|
+
end
|
506
|
+
|
507
|
+
|
508
|
+
get %r{
|
509
|
+
/commit/ # match any URL beginning with /show/
|
510
|
+
(\w+) # match the SHA1
|
511
|
+
}x do |version|
|
512
|
+
@version = version
|
513
|
+
wiki = wiki_new
|
514
|
+
begin
|
515
|
+
@commit = wiki.repo.commit(version)
|
516
|
+
parent = @commit.parent
|
517
|
+
parent_id = parent.nil? ? nil : parent.id
|
518
|
+
@diff = wiki.repo.diff(parent_id, version)
|
519
|
+
mustache :commit
|
520
|
+
rescue Gollum::Git::NoSuchShaFound
|
521
|
+
@message = "Invalid commit: #{@version}"
|
522
|
+
mustache :error
|
523
|
+
end
|
524
|
+
end
|
525
|
+
|
499
526
|
get '/search' do
|
500
|
-
@query = params[:q]
|
527
|
+
@query = params[:q] || ''
|
501
528
|
@name = @query
|
502
529
|
if @query.empty?
|
503
530
|
@results = []
|
@@ -609,6 +636,11 @@ module Precious
|
|
609
636
|
end
|
610
637
|
end
|
611
638
|
|
639
|
+
def load_template(path)
|
640
|
+
template_page = wiki_page(::File.join(path, '_Template')).page || wiki_page('/_Template').page
|
641
|
+
template_page ? Gollum::TemplateFilter.apply_filters(template_page.raw_data) : nil
|
642
|
+
end
|
643
|
+
|
612
644
|
def update_wiki_page(wiki, page, content, commit, name = nil, format = nil)
|
613
645
|
return if !page ||
|
614
646
|
((!content || page.raw_data == content) && page.format == format)
|