gollum 5.0.0 → 5.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (60) hide show
  1. checksums.yaml +4 -4
  2. data/CONTRIBUTING.md +2 -2
  3. data/Gemfile +1 -1
  4. data/HISTORY.md +17 -0
  5. data/README.md +2 -1
  6. data/Rakefile +2 -5
  7. data/bin/gollum +3 -24
  8. data/bin/gollum-migrate-tags +4 -3
  9. data/contrib/automation/gollum-post +66 -0
  10. data/gollum.gemspec +21 -17
  11. data/lib/gollum.rb +17 -1
  12. data/lib/gollum/app.rb +90 -33
  13. data/lib/gollum/assets.rb +3 -3
  14. data/lib/gollum/helpers.rb +1 -1
  15. data/lib/gollum/public/assets/.sprockets-manifest-e3f9b0be36ac3bccc4c006a52e352500.json +1 -0
  16. data/lib/gollum/public/assets/app-7a0bbff2e8bad3033e7c17e0e0f886f336a9d23d3b912dcd2ae389c48b4b63e6.css +21 -0
  17. data/lib/gollum/public/assets/app-7a0bbff2e8bad3033e7c17e0e0f886f336a9d23d3b912dcd2ae389c48b4b63e6.css.gz +0 -0
  18. data/lib/gollum/public/assets/app-7a4bd115f4bc7ece39bc8073ca0ffad7c5e55cc5837b1464a12dead4905cefb2.js +5 -0
  19. data/lib/gollum/public/assets/app-7a4bd115f4bc7ece39bc8073ca0ffad7c5e55cc5837b1464a12dead4905cefb2.js.gz +0 -0
  20. data/lib/gollum/public/assets/criticmarkup-31ae5d3282bbb8e7b7c3c9917e9fb68e3315a6b4a75da6cec48d21b8846905c4.css.gz +0 -0
  21. data/lib/gollum/public/assets/editor-db10c8351306e92f1926ba225d0cd9c8e886482b3b9820a85825ec3abab5f1cf.js +24 -0
  22. data/lib/gollum/public/assets/editor-db10c8351306e92f1926ba225d0cd9c8e886482b3b9820a85825ec3abab5f1cf.js.gz +0 -0
  23. data/lib/gollum/public/assets/print-512498c368be0d3fb1ba105dfa84289ae48380ec9fcbef948bd4e23b0b095bfb.css.gz +0 -0
  24. data/lib/gollum/public/gollum/javascript/app.js +1 -0
  25. data/lib/gollum/public/gollum/javascript/editor/gollum.editor.js +59 -0
  26. data/lib/gollum/public/gollum/javascript/editor/modes.js.erb +1 -1
  27. data/lib/gollum/public/gollum/javascript/gollum.js.erb +16 -15
  28. data/lib/gollum/public/gollum/javascript/polyfills.js +6 -0
  29. data/lib/gollum/public/gollum/stylesheets/primer.css +23 -0
  30. data/lib/gollum/public/gollum/stylesheets/template.scss.erb +132 -57
  31. data/lib/gollum/templates/commit.mustache +26 -0
  32. data/lib/gollum/templates/editor.mustache +7 -2
  33. data/lib/gollum/templates/history.mustache +5 -2
  34. data/lib/gollum/templates/latest_changes.mustache +8 -6
  35. data/lib/gollum/templates/layout.mustache +5 -5
  36. data/lib/gollum/templates/mobilenav.mustache +72 -0
  37. data/lib/gollum/templates/navbar.mustache +104 -42
  38. data/lib/gollum/templates/overview.mustache +2 -2
  39. data/lib/gollum/templates/search.mustache +2 -3
  40. data/lib/gollum/templates/wiki_content.mustache +18 -17
  41. data/lib/gollum/views/commit.rb +45 -0
  42. data/lib/gollum/views/compare.rb +19 -8
  43. data/lib/gollum/views/has_page.rb +0 -4
  44. data/lib/gollum/views/helpers.rb +13 -3
  45. data/lib/gollum/views/history.rb +4 -1
  46. data/lib/gollum/views/latest_changes.rb +1 -0
  47. data/lib/gollum/views/layout.rb +17 -1
  48. data/lib/gollum/views/overview.rb +6 -5
  49. data/lib/gollum/views/page.rb +15 -8
  50. data/lib/gollum/views/search.rb +2 -1
  51. metadata +34 -36
  52. data/lib/gollum/public/assets/.sprockets-manifest-3edc7e21737459b21fbf150f5dccd15c.json +0 -1
  53. data/lib/gollum/public/assets/app-982c7fca1832732a24e92474ca2729aeb56f2d0c05bb7a8ff913e9f58a6500d5.js +0 -5
  54. data/lib/gollum/public/assets/app-982c7fca1832732a24e92474ca2729aeb56f2d0c05bb7a8ff913e9f58a6500d5.js.gz +0 -0
  55. data/lib/gollum/public/assets/app-b205e593a30f1cc0054e2e9ed9fc8af3658d8ef4a62b9708c20f204560deefb7.css +0 -21
  56. data/lib/gollum/public/assets/app-b205e593a30f1cc0054e2e9ed9fc8af3658d8ef4a62b9708c20f204560deefb7.css.gz +0 -0
  57. data/lib/gollum/public/assets/editor-0dbae28c53db5a73d666d30504946671eb09948ffdaf1fdd9d1c8d856d4c0ba1.js +0 -24
  58. data/lib/gollum/public/assets/editor-0dbae28c53db5a73d666d30504946671eb09948ffdaf1fdd9d1c8d856d4c0ba1.js.gz +0 -0
  59. data/lib/gollum/public/gollum/stylesheets/_layout.scss +0 -83
  60. 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: 3746893fd4bb885fa53c453b7224916685babb8c129a65d56ccd8c31b73e0d43
4
- data.tar.gz: 1a83709ed4921c25ea91743b36b27dc788409866a4705b71eb285920696b9853
3
+ metadata.gz: 23148936db7deffae2b5a40b895ecf6b2062732b3168adec5aec1d0e7e156498
4
+ data.tar.gz: 67c9f07ecaac82d1b3bef8562ae32651782da8619fab46f2fdd3dc22b7783b2d
5
5
  SHA512:
6
- metadata.gz: f43522071d711ee1fa8446636fc621db6be4c3721184018a8a050f11fb6485ef06642f0b09f056a9ec4cf3ac5da58f6b75f06315cc78823d0ce8ed35990e9c82
7
- data.tar.gz: 447f15b9174f3375825739f35f54baea66e5f583337aeb1e7ccbb87d439cd04cd1f21216e074c6dae01514261c6f6a1937558b8969621237cc543418f19f4536
6
+ metadata.gz: c6a9d7a5f643fb3f28b005f64991693090e77c2f272e50867a7dc5416b401f18f9d8598486b07c0df3633cce1e9fb1a1e9f8ad6d06e528cfd654bc5d0f2786e1
7
+ data.tar.gz: aecfcaf6e11c2a82e3e767cbe556c84fecf109b31b46b922a31e76b37c53679bcd77a8961a1eee46e63b7ce452f7331ba239e0cc9e596b00a45fc07efb5d7e28
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://pgp.mit.edu/pks/lookup?op=vindex&search=0xD637E455CD3E27BF)
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
@@ -6,5 +6,5 @@ end
6
6
 
7
7
  gemspec
8
8
 
9
- gem "rake", '~> 12.3', '>= 12.3.3'
9
+ gem "rake", '~> 13.0'
10
10
 
data/HISTORY.md CHANGED
@@ -1,3 +1,20 @@
1
+ # 5.2 2021-02-24
2
+
3
+ * Improved styling and Primer upgrade (@benjaminwil)
4
+ * Add redirect to rename commit (@ViChyavIn)
5
+ * Updated dependencies
6
+ * Bugfixes
7
+
8
+ # 5.1.2
9
+
10
+ * Guard against malicious filenames in breadcrumbs
11
+
12
+ # 5.1
13
+
14
+ * Bugfixes
15
+ * Add autosave feature (#1576)
16
+ * Add Add quick access to diff of each commit in the history
17
+
1
18
  # 5.0 / 2020-03-17
2
19
 
3
20
  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
 
@@ -17,7 +18,7 @@ Gollum is a simple wiki system built on top of Git. A Gollum Wiki is simply a gi
17
18
  * May be written in a variety of [markups](#markups).
18
19
  * Can be edited with your favourite system editor or IDE (changes will be visible after committing) or with the built-in web interface.
19
20
  * Can be displayed in all versions, reverted, etc.
20
- * Gollum strives to be compatible with GitHub wikis (see `--hyphened-tag-lookup`)
21
+ * Gollum strives to be compatible with GitHub wikis (see `--lenient-tag-lookup`)
21
22
  * Gollum supports advanced functionality like:
22
23
  * [UML diagrams](https://github.com/gollum/gollum/wiki#plantuml-diagrams)
23
24
  * [BibTeX and Citation support](https://github.com/gollum/gollum/wiki/BibTeX-and-Citations)
data/Rakefile CHANGED
@@ -181,11 +181,8 @@ end
181
181
 
182
182
  desc 'Precompile assets'
183
183
  task :precompile do
184
- require './lib/gollum/views/helpers.rb'
185
- require './lib/gollum/assets.rb'
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 in root as a template for new pages.') do
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
@@ -172,6 +172,7 @@ MSG
172
172
  end
173
173
  opts.on('--version', 'Display the current version of Gollum.') do
174
174
  puts 'Gollum ' + Gollum::VERSION
175
+ exit 0
175
176
  end
176
177
  opts.on('--versions', 'Display the current version of Gollum and auxiliary gems.') do
177
178
  require 'gollum-lib'
@@ -286,29 +287,7 @@ else
286
287
  else
287
288
  require 'rack'
288
289
 
289
- class MapGollum
290
- def initialize(base_path)
291
- @mg = Rack::Builder.new do
292
-
293
- map "/#{base_path}" do
294
- run Precious::App
295
- end
296
- map '/' do
297
- run Proc.new { [302, { 'Location' => "/#{base_path}" }, []] }
298
- end
299
- map '/*' do
300
- run Proc.new { [302, { 'Location' => "/#{base_path}" }, []] }
301
- end
302
-
303
- end
304
- end
305
-
306
- def call(env)
307
- @mg.call(env)
308
- end
309
- end
310
-
311
290
  # Rack::Handler does not work with Ctrl + C. Use Rack::Server instead.
312
- Rack::Server.new(:app => MapGollum.new(base_path), :Port => options[:port], :Host => options[:bind]).start
291
+ Rack::Server.new(:app => Precious::MapGollum.new(base_path), :Port => options[:port], :Host => options[:bind]).start
313
292
  end
314
293
  end
@@ -4,8 +4,6 @@ require 'optparse'
4
4
  require 'pathname'
5
5
  require 'rubygems'
6
6
 
7
- REPO = ARGV[0] || Dir.pwd
8
-
9
7
  wiki_options = {}
10
8
  options = {}
11
9
 
@@ -83,12 +81,15 @@ begin
83
81
  const = setting.to_s.upcase
84
82
  Object.const_set(const, value) unless Object.const_defined?(const)
85
83
  end
84
+ wiki_options[:page_file_dir] = setting(:page_file_dir) ? setting(:page_file_dir) : wiki_options[:page_file_dir] # Allow settings :page_file_dir through PAGE_FILE_DIR constant.
86
85
  rescue OptionParser::InvalidOption
87
86
  puts "gollum-migrate-tags: #{$!.message}"
88
87
  puts "gollum-migrate-tags: try 'gollum-migrate-tags --help' for more information"
89
88
  exit
90
89
  end
91
90
 
91
+ REPO = ARGV[0] || Dir.pwd
92
+
92
93
  require 'gollum-lib'
93
94
 
94
95
  if cfg = options[:config]
@@ -261,7 +262,7 @@ wiki.pages.each do |page|
261
262
  log(:info,"Page #{page.path}")
262
263
  new_data = page.formatted_data
263
264
  if setting(:no_dry_run)
264
- path = ::File.join([wiki.path, wiki.page_file_dir, page.path].compact)
265
+ path = ::File.join(wiki.path, page.path)
265
266
  f = File.new(path, 'w')
266
267
  f.write(new_data)
267
268
  f.close
@@ -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.0.0'
9
- s.date = '2020-03-30'
8
+ s.version = '5.2'
9
+ s.date = '2021-02-24'
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.0'
27
- s.add_dependency 'kramdown', '~> 2.1.0'
28
- s.add_dependency 'kramdown-parser-gfm', '~> 1.0.0'
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', ['>= 0.99.5', '< 1.0.0']
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', '~> 8.5'
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', '~> 3.2'
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-3edc7e21737459b21fbf150f5dccd15c.json
72
- lib/gollum/public/assets/app-982c7fca1832732a24e92474ca2729aeb56f2d0c05bb7a8ff913e9f58a6500d5.js
73
- lib/gollum/public/assets/app-982c7fca1832732a24e92474ca2729aeb56f2d0c05bb7a8ff913e9f58a6500d5.js.gz
74
- lib/gollum/public/assets/app-b205e593a30f1cc0054e2e9ed9fc8af3658d8ef4a62b9708c20f204560deefb7.css
75
- lib/gollum/public/assets/app-b205e593a30f1cc0054e2e9ed9fc8af3658d8ef4a62b9708c20f204560deefb7.css.gz
72
+ lib/gollum/public/assets/.sprockets-manifest-e3f9b0be36ac3bccc4c006a52e352500.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-0dbae28c53db5a73d666d30504946671eb09948ffdaf1fdd9d1c8d856d4c0ba1.js
79
- lib/gollum/public/assets/editor-0dbae28c53db5a73d666d30504946671eb09948ffdaf1fdd9d1c8d856d4c0ba1.js.gz
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.scss
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.0.0'
15
+ VERSION = '5.2'
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
@@ -40,6 +40,30 @@ Gollum::set_git_max_filesize(190 * 10**6)
40
40
  # See the wiki.rb file for more details on wiki options
41
41
 
42
42
  module Precious
43
+
44
+ # For use with the --base-path option.
45
+ class MapGollum
46
+ def initialize(base_path)
47
+ @mg = Rack::Builder.new do
48
+
49
+ map "/#{base_path}" do
50
+ run Precious::App
51
+ end
52
+ map '/' do
53
+ run Proc.new { [302, { 'Location' => "/#{base_path}" }, []] }
54
+ end
55
+ map '/*' do
56
+ run Proc.new { [302, { 'Location' => "/#{base_path}" }, []] }
57
+ end
58
+
59
+ end
60
+ end
61
+
62
+ def call(env)
63
+ @mg.call(env)
64
+ end
65
+ end
66
+
43
67
  class App < Sinatra::Base
44
68
  register Mustache::Sinatra
45
69
  register Sinatra::Namespace
@@ -188,7 +212,8 @@ module Precious
188
212
  @etag = page.sha
189
213
  mustache :edit
190
214
  else
191
- redirect_to("/create/#{encodeURIComponent(@name)}")
215
+ path = ::File.join('gollum/create', @path, @name)
216
+ redirect to(clean_url(encodeURIComponent(path)))
192
217
  end
193
218
  end
194
219
 
@@ -205,14 +230,15 @@ module Precious
205
230
  halt 500 unless tempfile.is_a? Tempfile
206
231
 
207
232
  if wiki.per_page_uploads
208
- # remove base_url and gollum/* subpath if necessary
209
- dir = request.referer.
210
- sub(request.base_url, '').
211
- sub(/.*gollum\/[-\w]+\//, '')
233
+ dir = request.referer.sub(request.base_url, '')
212
234
  # remove base path if it is set
213
- dir = dir.sub(wiki.base_path, '') if wiki.base_path
235
+ dir.sub!(/^#{wiki.base_path}/, '') if wiki.base_path
236
+ # remove base_url and gollum/* subpath if necessary
237
+ dir.sub!(/^\/gollum\/[-\w]+\//, '')
214
238
  # remove file extension
215
- dir = dir.sub(::File.extname(dir), '')
239
+ dir.sub!(/#{::File.extname(dir)}$/, '')
240
+ # revert escaped whitespaces
241
+ dir.gsub!(/%20/, ' ')
216
242
  dir = ::File.join('uploads', dir)
217
243
  else
218
244
  # store all uploads together
@@ -277,12 +303,13 @@ module Precious
277
303
  redirect to("/#{page.escaped_url_path}")
278
304
  return
279
305
  end
280
- committer.commit
281
-
306
+
282
307
  # Renaming preserves format, so add the page's format to the renamed path to retrieve the renamed page
283
308
  new_path = "#{rename}.#{Gollum::Page.format_to_ext(page.format)}"
284
309
  # Add a redirect from the old page to the new
285
- 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
286
313
 
287
314
  page = wiki_page(new_path).page
288
315
  return if page.nil?
@@ -292,9 +319,8 @@ module Precious
292
319
  post '/edit/*' do
293
320
  etag = params[:etag]
294
321
  path = "/#{clean_url(sanitize_empty_params(params[:path]))}"
295
- page_name = CGI.unescape(params[:page])
296
322
  wiki = wiki_new
297
- page = wiki.page(::File.join(path, page_name))
323
+ page = wiki.page(::File.join(path, params[:page]))
298
324
 
299
325
  return if page.nil?
300
326
  if etag != page.sha
@@ -326,14 +352,11 @@ module Precious
326
352
 
327
353
  get '/create/*' do
328
354
  forbid unless @allow_editing
329
- if settings.wiki_options[:template_page] then
330
- temppage = wiki_page('/_Template')
331
- @template_page = (temppage.page != nil) ? temppage.page.raw_data : 'Template page option is set, but no /_Template page is present or committed.'
332
- end
333
355
  wikip = wiki_page(params[:splat].first)
334
356
  @name = wikip.name
335
357
  @ext = wikip.ext
336
358
  @path = wikip.path
359
+ @template_page = load_template(@path) if settings.wiki_options[:template_page]
337
360
  @allow_uploads = wikip.wiki.allow_uploads
338
361
  @upload_dest = find_upload_dest(wikip.fullpath)
339
362
 
@@ -391,7 +414,7 @@ module Precious
391
414
 
392
415
  post '/preview' do
393
416
  wiki = wiki_new
394
- @name = params[:page] ? strip_page_name(CGI.unescape(params[:page])) : 'Preview'
417
+ @name = params[:page] ? strip_page_name(params[:page]) : 'Preview'
395
418
  @page = wiki.preview_page(@name, params[:content], params[:format])
396
419
  ['sidebar', 'header', 'footer'].each do |subpage|
397
420
  @page.send("set_#{subpage}".to_sym, params[subpage]) if params[subpage]
@@ -413,8 +436,8 @@ module Precious
413
436
  @page = wikip.page
414
437
  @page_num = [params[:page_num].to_i, 1].max
415
438
  @max_count = settings.wiki_options.fetch(:pagination_count, 10)
416
- @wiki = @page.wiki
417
439
  unless @page.nil?
440
+ @wiki = @page.wiki
418
441
  @versions = @page.versions(
419
442
  per_page: @max_count,
420
443
  page_num: @page_num,
@@ -434,20 +457,6 @@ module Precious
434
457
  mustache :latest_changes
435
458
  end
436
459
 
437
- post '/compare/*' do
438
- @file = encodeURIComponent(params[:splat].first)
439
- @versions = params[:versions] || []
440
- if @versions.size < 2
441
- redirect_to("/history/#{@file}")
442
- else
443
- redirect_to("/compare/%s/%s...%s" % [
444
- @file,
445
- @versions.last,
446
- @versions.first]
447
- )
448
- end
449
- end
450
-
451
460
  get %r{
452
461
  /compare/ # match any URL beginning with /compare/
453
462
  (.+) # extract the full path (including any directories)
@@ -471,8 +480,51 @@ module Precious
471
480
  end
472
481
  end
473
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
+
474
526
  get '/search' do
475
- @query = params[:q]
527
+ @query = params[:q] || ''
476
528
  @name = @query
477
529
  if @query.empty?
478
530
  @results = []
@@ -584,6 +636,11 @@ module Precious
584
636
  end
585
637
  end
586
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
+
587
644
  def update_wiki_page(wiki, page, content, commit, name = nil, format = nil)
588
645
  return if !page ||
589
646
  ((!content || page.raw_data == content) && page.format == format)