gollum-lib 5.2.4 → 6.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile +7 -1
- data/HISTORY.md +19 -3
- data/LATEST_CHANGES.md +14 -2
- data/Rakefile +4 -4
- data/gemspec.rb +5 -6
- data/gollum-lib.gemspec +2 -2
- data/gollum-lib_java.gemspec +1 -1
- data/lib/gollum-lib/committer.rb +2 -0
- data/lib/gollum-lib/file.rb +33 -23
- data/lib/gollum-lib/filter/code.rb +1 -1
- data/lib/gollum-lib/filter/macro.rb +15 -12
- data/lib/gollum-lib/filter/plantuml.rb +21 -16
- data/lib/gollum-lib/filter/render.rb +5 -1
- data/lib/gollum-lib/filter/tags.rb +10 -3
- data/lib/gollum-lib/filter/yaml.rb +20 -1
- data/lib/gollum-lib/git_access.rb +3 -7
- data/lib/gollum-lib/helpers.rb +3 -3
- data/lib/gollum-lib/macro/flash.rb +11 -0
- data/lib/gollum-lib/macro/icon.rb +9 -0
- data/lib/gollum-lib/macro/note.rb +2 -12
- data/lib/gollum-lib/macro/warn.rb +1 -3
- data/lib/gollum-lib/macro.rb +1 -1
- data/lib/gollum-lib/markup.rb +8 -2
- data/lib/gollum-lib/page.rb +26 -9
- data/lib/gollum-lib/version.rb +1 -1
- data/lib/gollum-lib/wiki.rb +9 -5
- data/lib/gollum-lib.rb +0 -1
- metadata +11 -25
- data/lib/gollum-lib/file_view.rb +0 -164
- data/lib/gollum-lib/macro/octicon.rb +0 -12
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: fe628f4e51c08652919a35f540f680f7c552c5ad8bab2bef986d2bf70dd828e7
|
|
4
|
+
data.tar.gz: 236d3fe12527b806ee2131de0339c99ea7df55f01399895d469034e1dae7d655
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 63c2dbdccde9211a4123e8954689f390140e5054a34175771da8e34ecbf358a7cf7fad8984fa69619db5b9c00d91af1019f1350b8b82a78b594b6c00c9ecbccd
|
|
7
|
+
data.tar.gz: 91d14006c4a1a923156ba49177d10fb954f0f8e74761704e513fdd74bfe5726373a43078fd4e21604897356d01a6b79f117d76870d4a7b38e441719d025c391c
|
data/Gemfile
CHANGED
data/HISTORY.md
CHANGED
|
@@ -1,8 +1,24 @@
|
|
|
1
|
-
#
|
|
1
|
+
# 6.0 / 2023-08-01
|
|
2
2
|
|
|
3
|
-
*
|
|
3
|
+
* Default to local PlantUML server for security. #412. (@manofstick)
|
|
4
|
+
* Allow use of default branch name `main` or `master. Resolves https://github.com/gollum/gollum/issues/1813. (@dometto)
|
|
5
|
+
* Feature: [support for custom rendering of languages in codeblocks](https://github.com/gollum/gollum/wiki/Custom-language-handlers). #433. (@dometto)
|
|
6
|
+
* Support use of commit notes in Gollum::Committer. #435. (@dometto, @bartkamphorst)
|
|
7
|
+
* Remove octicons from gollum-lib. Icon macros must now be styled independently. #441. (@bartkamphorst)
|
|
8
|
+
* Huge performance increase for large wikis! :rocket: #437. (@dometto)
|
|
9
|
+
|
|
10
|
+
## Bugfixes
|
|
11
|
+
|
|
12
|
+
* Fix the use of boolean arguments in Macros. #441. (@dometto)
|
|
13
|
+
* Fix broken relative links: these were previously not rendered as relative. #443. (@dometto)
|
|
4
14
|
|
|
15
|
+
# 5.2.4 / 2023-03-22
|
|
5
16
|
|
|
17
|
+
* Bugfix release: address XSS vulnerability ( @6661620a, @dometto)
|
|
18
|
+
|
|
19
|
+
# 5.2.3 / 2023-03-13
|
|
20
|
+
|
|
21
|
+
* Bugfix release: update adapter dependencies for Ruby 3.2 support.
|
|
6
22
|
|
|
7
23
|
# 5.2.2 / 2023-01-18
|
|
8
24
|
|
|
@@ -48,7 +64,7 @@ For a detailed overview of changes in 5.0 and a guide to migrating your wiki, se
|
|
|
48
64
|
** Dependency updates
|
|
49
65
|
** Bugfixes
|
|
50
66
|
** New Macro for listing contents of (sub)directories: `Navigation()`
|
|
51
|
-
** Table of Contents now supports setting max heading level
|
|
67
|
+
** Table of Contents now supports setting max heading level
|
|
52
68
|
|
|
53
69
|
# v4.0.2 / 2015-01-19
|
|
54
70
|
|
data/LATEST_CHANGES.md
CHANGED
|
@@ -1,3 +1,15 @@
|
|
|
1
|
-
#
|
|
1
|
+
# 6.1.0
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
This is largely a bugfix release.
|
|
4
|
+
|
|
5
|
+
New features:
|
|
6
|
+
|
|
7
|
+
- Added support for GitLab style PlantUML blocks and additional diagram types. #461 (@dometto)
|
|
8
|
+
|
|
9
|
+
Bugfixes:
|
|
10
|
+
|
|
11
|
+
- Ensured "copy to clipboard" button appears normally when Pygments is enabled. #460 (@x789034)
|
|
12
|
+
- Don't use real `anon.com` domain in anonymous git committer emails. #458 (@jmtd)
|
|
13
|
+
- Removed dead code, `Gollum::FileView`. #455 (@benjaminwil)
|
|
14
|
+
- HTML escape YAML after parsing to prevent invalidating YAML string #454 (@dometto)
|
|
15
|
+
- Ensured `[[include:<path>]]` helper works with absolute paths. Note that this was meant to be included in the 6.0 release but was not. Sorry for any confusion. #452 (@dometto)
|
data/Rakefile
CHANGED
|
@@ -194,10 +194,10 @@ task :changelog do
|
|
|
194
194
|
exit!
|
|
195
195
|
end
|
|
196
196
|
end
|
|
197
|
-
|
|
197
|
+
|
|
198
198
|
latest_changes = File.open(latest_changes_file)
|
|
199
199
|
version_pattern = "# #{version}"
|
|
200
|
-
|
|
200
|
+
|
|
201
201
|
if !`grep "#{version_pattern}" #{history_file}`.empty?
|
|
202
202
|
puts "#{version} is already described in #{history_file}"
|
|
203
203
|
exit!
|
|
@@ -212,13 +212,13 @@ task :changelog do
|
|
|
212
212
|
puts "#{latest_changes_file} is empty!"
|
|
213
213
|
exit!
|
|
214
214
|
end
|
|
215
|
-
|
|
215
|
+
|
|
216
216
|
body = latest_changes.read
|
|
217
217
|
body.scan(/\s*#\s+\d\.\d.*/) do |match|
|
|
218
218
|
puts "#{latest_changes_file} may not contain multiple markdown headers!"
|
|
219
219
|
exit!
|
|
220
220
|
end
|
|
221
|
-
|
|
221
|
+
|
|
222
222
|
temp = Tempfile.new
|
|
223
223
|
temp.puts("#{version_pattern} / #{date}\n#{body}\n\n")
|
|
224
224
|
temp.close
|
data/gemspec.rb
CHANGED
|
@@ -26,14 +26,13 @@ def specification(version, default_adapter, platform = nil)
|
|
|
26
26
|
s.add_dependency 'loofah', '~> 2.3'
|
|
27
27
|
s.add_dependency 'github-markup', '~> 4.0'
|
|
28
28
|
s.add_dependency 'gemojione', '~> 4.1'
|
|
29
|
-
s.add_dependency 'octicons', '~> 12.0'
|
|
30
29
|
s.add_dependency 'twitter-text', '1.14.7'
|
|
31
30
|
|
|
32
31
|
s.add_development_dependency 'org-ruby', '~> 0.9.9'
|
|
33
32
|
s.add_development_dependency 'kramdown', '~> 2.3'
|
|
34
33
|
s.add_development_dependency 'kramdown-parser-gfm', '~> 1.1.0'
|
|
35
34
|
s.add_development_dependency 'RedCloth', '~> 4.2.9'
|
|
36
|
-
s.add_development_dependency 'mocha', '~>
|
|
35
|
+
s.add_development_dependency 'mocha', '~> 2.0'
|
|
37
36
|
s.add_development_dependency 'shoulda', '~> 4.0'
|
|
38
37
|
s.add_development_dependency 'wikicloth', '~> 0.8.3'
|
|
39
38
|
s.add_development_dependency 'bibtex-ruby', '~> 6.0'
|
|
@@ -45,12 +44,12 @@ def specification(version, default_adapter, platform = nil)
|
|
|
45
44
|
s.add_development_dependency 'rb-readline', '~> 0.5.1'
|
|
46
45
|
# updating minitest-reporters requires a new minitest which fails with gollum's tests.
|
|
47
46
|
s.add_development_dependency 'test-unit', '~> 3.3'
|
|
48
|
-
s.add_development_dependency 'minitest-reporters', '~> 1.
|
|
47
|
+
s.add_development_dependency 'minitest-reporters', '~> 1.5'
|
|
49
48
|
s.add_development_dependency 'nokogiri-diff', '~> 0.2.0'
|
|
50
49
|
s.add_development_dependency 'guard', '~> 2.16'
|
|
51
50
|
s.add_development_dependency 'guard-minitest', '~> 2.4'
|
|
52
51
|
s.add_development_dependency 'twitter_cldr', '~> 6.4'
|
|
53
|
-
|
|
52
|
+
|
|
54
53
|
# = MANIFEST =
|
|
55
54
|
s.files = %w[
|
|
56
55
|
Gemfile
|
|
@@ -68,7 +67,6 @@ def specification(version, default_adapter, platform = nil)
|
|
|
68
67
|
lib/gollum-lib/blob_entry.rb
|
|
69
68
|
lib/gollum-lib/committer.rb
|
|
70
69
|
lib/gollum-lib/file.rb
|
|
71
|
-
lib/gollum-lib/file_view.rb
|
|
72
70
|
lib/gollum-lib/filter.rb
|
|
73
71
|
lib/gollum-lib/filter/bibtex.rb
|
|
74
72
|
lib/gollum-lib/filter/code.rb
|
|
@@ -90,10 +88,11 @@ def specification(version, default_adapter, platform = nil)
|
|
|
90
88
|
lib/gollum-lib/macro.rb
|
|
91
89
|
lib/gollum-lib/macro/all_pages.rb
|
|
92
90
|
lib/gollum-lib/macro/audio.rb
|
|
91
|
+
lib/gollum-lib/macro/flash.rb
|
|
93
92
|
lib/gollum-lib/macro/global_toc.rb
|
|
93
|
+
lib/gollum-lib/macro/icon.rb
|
|
94
94
|
lib/gollum-lib/macro/navigation.rb
|
|
95
95
|
lib/gollum-lib/macro/note.rb
|
|
96
|
-
lib/gollum-lib/macro/octicon.rb
|
|
97
96
|
lib/gollum-lib/macro/series.rb
|
|
98
97
|
lib/gollum-lib/macro/video.rb
|
|
99
98
|
lib/gollum-lib/macro/warn.rb
|
data/gollum-lib.gemspec
CHANGED
|
@@ -3,8 +3,8 @@ require File.join(File.dirname(__FILE__), 'lib', 'gollum-lib', 'version.rb')
|
|
|
3
3
|
# This file needs to conditionally define the default adapter for MRI and Java, because this is the file that is included from the Gemfile.
|
|
4
4
|
# In addition, the default Java adapter needs to be defined in gollum-lib_java.gemspec beause that file is used to *build* the Java gem.
|
|
5
5
|
if RUBY_PLATFORM == 'java' then
|
|
6
|
-
default_adapter = ['gollum-rjgit_adapter', '~>
|
|
6
|
+
default_adapter = ['gollum-rjgit_adapter', '~> 2.0']
|
|
7
7
|
else
|
|
8
|
-
default_adapter = ['gollum-rugged_adapter', '~>
|
|
8
|
+
default_adapter = ['gollum-rugged_adapter', '~> 3.0']
|
|
9
9
|
end
|
|
10
10
|
Gem::Specification.new &specification(Gollum::Lib::VERSION, default_adapter)
|
data/gollum-lib_java.gemspec
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
require File.join(File.dirname(__FILE__), 'gemspec.rb')
|
|
2
2
|
require File.join(File.dirname(__FILE__), 'lib', 'gollum-lib', 'version.rb')
|
|
3
|
-
default_adapter = ['gollum-rjgit_adapter', '~> 0
|
|
3
|
+
default_adapter = ['gollum-rjgit_adapter', '~> 2.0']
|
|
4
4
|
Gem::Specification.new &specification(Gollum::Lib::VERSION, default_adapter, "java")
|
data/lib/gollum-lib/committer.rb
CHANGED
|
@@ -18,6 +18,7 @@ module Gollum
|
|
|
18
18
|
# :message - The String commit message.
|
|
19
19
|
# :name - The String author full name.
|
|
20
20
|
# :email - The String email address.
|
|
21
|
+
# :note - Optional String containing info about the commit. Not used, but can be accessed from inside the :post_commit Hook.
|
|
21
22
|
# :parent - Optional Gollum::Git::Commit parent to this update.
|
|
22
23
|
# :tree - Optional String SHA of the tree to create the
|
|
23
24
|
# index from.
|
|
@@ -128,6 +129,7 @@ module Gollum
|
|
|
128
129
|
@callbacks.each do |cb|
|
|
129
130
|
cb.call(self, sha1)
|
|
130
131
|
end
|
|
132
|
+
@wiki.repo.commit(sha1).note=@options[:note] if @options[:note]
|
|
131
133
|
Hook.execute(:post_commit, self, sha1)
|
|
132
134
|
sha1
|
|
133
135
|
end
|
data/lib/gollum-lib/file.rb
CHANGED
|
@@ -8,18 +8,21 @@ module Gollum
|
|
|
8
8
|
|
|
9
9
|
class << self
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
11
|
+
# Get a canonical path to a file.
|
|
12
|
+
# Ensures that the result is always under page_file_dir (prevents path traversal), if set.
|
|
13
|
+
# Removes leading slashes.
|
|
14
|
+
#
|
|
15
|
+
# path - One or more String path elements to join together. `nil` values are ignored.
|
|
16
|
+
# page_file_dir - kwarg String, default: nil
|
|
17
|
+
def canonical_path(*path, page_file_dir: nil)
|
|
18
|
+
prefix = Pathname.new('/') + page_file_dir.to_s
|
|
19
|
+
rest = Pathname.new('/').join(*path.compact).cleanpath.to_s[1..-1]
|
|
20
|
+
result = (prefix + rest).cleanpath.to_s[1..-1]
|
|
21
|
+
result.sub!(/^\/+/, '') if Gem.win_platform? # On Windows, Pathname#cleanpath will leave double slashes at the start of a path, so replace all (not just the first) leading slashes
|
|
22
|
+
result
|
|
23
|
+
end
|
|
21
24
|
|
|
22
|
-
# For use with self.
|
|
25
|
+
# For use with self.find: returns true if 'query' and 'match_path' match, strictly or taking account of the following parameters:
|
|
23
26
|
# hyphened_tags - If true, replace spaces in match_path with hyphens.
|
|
24
27
|
# case_insensitive - If true, compare query and match_path case-insensitively
|
|
25
28
|
def path_compare(query, match_path, hyphened_tags, case_insensitive)
|
|
@@ -41,24 +44,31 @@ module Gollum
|
|
|
41
44
|
# version - The String version ID to find.
|
|
42
45
|
# try_on_disk - If true, try to return just a reference to a file
|
|
43
46
|
# that exists on the disk.
|
|
44
|
-
# global_match - If true, find a File matching path's filename, but not
|
|
47
|
+
# global_match - If true, find a File matching path's filename, but not its directory (so anywhere in the repo)
|
|
45
48
|
#
|
|
46
49
|
# Returns a Gollum::File or nil if the file could not be found. Note
|
|
47
50
|
# that if you specify try_on_disk=true, you may or may not get a file
|
|
48
51
|
# for which on_disk? is actually true.
|
|
49
52
|
def self.find(wiki, path, version, try_on_disk = false, global_match = false)
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
query_path.sub!(/^\/\//, '/') if Gem.win_platform? # On Windows, Pathname#cleanpath will leave double slashes at the start of a path intact, so sub them out.
|
|
53
|
+
query_path = self.canonical_path(path, page_file_dir: wiki.page_file_dir)
|
|
54
|
+
dir, filename = Pathname.new(query_path).split
|
|
55
|
+
dir = dir.to_s
|
|
54
56
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
57
|
+
if global_match && self.respond_to?(:global_find) # Only implemented for Gollum::Page
|
|
58
|
+
return self.global_find(wiki, version, query_path, try_on_disk)
|
|
59
|
+
else
|
|
60
|
+
begin
|
|
61
|
+
root = wiki.commit_for(version)
|
|
62
|
+
return nil unless root
|
|
63
|
+
tree = dir == '.' ? root.tree : root.tree / dir
|
|
64
|
+
return nil unless tree
|
|
65
|
+
entry = tree.find_blob do |blob_name|
|
|
66
|
+
path_compare(filename.to_s, blob_name, wiki.hyphened_tag_lookup, wiki.case_insensitive_tag_lookup)
|
|
67
|
+
end
|
|
68
|
+
entry ? self.new(wiki, entry, dir, version, try_on_disk) : nil
|
|
69
|
+
rescue Gollum::Git::NoSuchShaFound
|
|
70
|
+
nil
|
|
58
71
|
end
|
|
59
|
-
entry ? self.new(wiki, entry.blob(wiki.repo), entry.dir, version, try_on_disk) : nil
|
|
60
|
-
rescue Gollum::Git::NoSuchShaFound
|
|
61
|
-
nil
|
|
62
72
|
end
|
|
63
73
|
end
|
|
64
74
|
|
|
@@ -74,7 +84,7 @@ module Gollum
|
|
|
74
84
|
def initialize(wiki, blob, path, version, try_on_disk = false)
|
|
75
85
|
@wiki = wiki
|
|
76
86
|
@blob = blob
|
|
77
|
-
@path =
|
|
87
|
+
@path = self.class.canonical_path(path, blob.name)
|
|
78
88
|
@version = version.is_a?(Gollum::Git::Commit) ? version : @wiki.commit_for(version)
|
|
79
89
|
get_disk_reference if try_on_disk
|
|
80
90
|
end
|
|
@@ -92,7 +92,7 @@ class Gollum::Filter::Code < Gollum::Filter
|
|
|
92
92
|
lexer = Pygments::Lexer[(lang)] || Pygments::Lexer['text']
|
|
93
93
|
|
|
94
94
|
# must set startinline to true for php to be highlighted without <?
|
|
95
|
-
hl_code = lexer.highlight(code, :options => { :encoding => encoding.to_s, :startinline => true })
|
|
95
|
+
hl_code = lexer.highlight(code, :options => { :encoding => encoding.to_s, :wrapcode => true, :startinline => true })
|
|
96
96
|
else # Rouge
|
|
97
97
|
begin
|
|
98
98
|
# if `lang` was not defined then assume plaintext
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
# ~*~ encoding: utf-8 ~*~
|
|
2
|
-
|
|
2
|
+
|
|
3
3
|
|
|
4
4
|
# Replace specified tokens with dynamically generated content.
|
|
5
5
|
class Gollum::Filter::Macro < Gollum::Filter
|
|
@@ -22,13 +22,18 @@ class Gollum::Filter::Macro < Gollum::Filter
|
|
|
22
22
|
argstr.scan(/,?\s*(#{arg})\s*/) do |arguments|
|
|
23
23
|
# Stabstabstab
|
|
24
24
|
argument = arguments.first
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
25
|
+
|
|
26
|
+
case argument
|
|
27
|
+
in /^([a-z0-9_]+)="(.*?)"/
|
|
28
|
+
opts[Regexp.last_match[1]] = Regexp.last_match[2]
|
|
29
|
+
in /^"(.*)"$/
|
|
30
|
+
args << Regexp.last_match[1].gsub("\\\"", "\"")
|
|
31
|
+
in /\s*false\s*/
|
|
32
|
+
args << false
|
|
33
|
+
in /\s*true\s*/
|
|
34
|
+
args << true
|
|
35
|
+
else
|
|
36
|
+
args << argument
|
|
32
37
|
end
|
|
33
38
|
end
|
|
34
39
|
|
|
@@ -48,13 +53,11 @@ class Gollum::Filter::Macro < Gollum::Filter
|
|
|
48
53
|
begin
|
|
49
54
|
Gollum::Macro.instance(macro, @markup.wiki, @markup.page).render(*args)
|
|
50
55
|
rescue StandardError => e
|
|
51
|
-
|
|
52
|
-
icon.options[:class] << ' mr-2'
|
|
53
|
-
"<div class='flash flash-error'>#{icon.to_svg}Macro Error for #{macro}: #{e.message}</div>"
|
|
56
|
+
%Q(<div class="flash flash-error gollum-macro-error my-2">Macro Error for #{macro}: #{e.message}</div>)
|
|
54
57
|
end
|
|
55
58
|
end
|
|
56
59
|
end
|
|
57
60
|
|
|
58
|
-
|
|
61
|
+
data
|
|
59
62
|
end
|
|
60
63
|
end
|
|
@@ -36,8 +36,9 @@ require 'zlib'
|
|
|
36
36
|
# at: http://plantuml.sourceforge.net/
|
|
37
37
|
#
|
|
38
38
|
class Gollum::Filter::PlantUML < Gollum::Filter
|
|
39
|
-
|
|
40
|
-
|
|
39
|
+
UML_KINDS = ['uml', 'json', 'yaml', 'ebnf', 'regex', 'salt', 'ditaa', 'gantt', 'chronology', 'mindmap', 'wbs', 'math', 'latex', 'chen']
|
|
40
|
+
UML_REGEX = /\s*(@start(#{Regexp.union(UML_KINDS)})([ \t\f\v]+[^\r\n]+|[ \t\r\f\v]*)\n.+?\r?\n@end\2\r?$)/m
|
|
41
|
+
DEFAULT_URL = 'http://localhost:8080/plantuml/png'
|
|
41
42
|
|
|
42
43
|
# Configuration class used to change the behaviour of the PlatnUML filter.
|
|
43
44
|
#
|
|
@@ -69,7 +70,7 @@ class Gollum::Filter::PlantUML < Gollum::Filter
|
|
|
69
70
|
# Extract all sequence diagram blocks into the map and replace with
|
|
70
71
|
# placeholders.
|
|
71
72
|
def extract(data)
|
|
72
|
-
data.gsub(
|
|
73
|
+
data.gsub(UML_REGEX) do
|
|
73
74
|
id = "#{open_pattern}#{Digest::SHA1.hexdigest($1)}#{close_pattern}"
|
|
74
75
|
@map[id] = { :code => $1 }
|
|
75
76
|
id
|
|
@@ -81,12 +82,21 @@ class Gollum::Filter::PlantUML < Gollum::Filter
|
|
|
81
82
|
def process(data)
|
|
82
83
|
@map.each do |id, spec|
|
|
83
84
|
data.gsub!(id) do
|
|
84
|
-
render_plantuml(
|
|
85
|
+
render_plantuml(spec[:code])
|
|
85
86
|
end
|
|
86
87
|
end
|
|
87
88
|
data
|
|
88
89
|
end
|
|
89
90
|
|
|
91
|
+
def render_plantuml(code)
|
|
92
|
+
if check_server
|
|
93
|
+
plantuml_url = gen_url(code)
|
|
94
|
+
"<img src=\"#{gen_url(code)}\" />"
|
|
95
|
+
else
|
|
96
|
+
html_error("Sorry, unable to render PlantUML diagram at this time")
|
|
97
|
+
end
|
|
98
|
+
end
|
|
99
|
+
|
|
90
100
|
private
|
|
91
101
|
|
|
92
102
|
def server_url
|
|
@@ -101,15 +111,6 @@ class Gollum::Filter::PlantUML < Gollum::Filter
|
|
|
101
111
|
PlantUML::configuration.verify_ssl
|
|
102
112
|
end
|
|
103
113
|
|
|
104
|
-
def render_plantuml(id, code)
|
|
105
|
-
if check_server
|
|
106
|
-
plantuml_url = gen_url(code)
|
|
107
|
-
"<img src=\"#{gen_url(code)}\" />"
|
|
108
|
-
else
|
|
109
|
-
html_error("Sorry, unable to render PlantUML diagram at this time")
|
|
110
|
-
end
|
|
111
|
-
end
|
|
112
|
-
|
|
113
114
|
# Compression code used to generate PlantUML URLs. Taken directly from the
|
|
114
115
|
# Transcoder class in the PlantUML java code.
|
|
115
116
|
def gen_url(text)
|
|
@@ -153,9 +154,9 @@ class Gollum::Filter::PlantUML < Gollum::Filter
|
|
|
153
154
|
c3 = ((b2 & 0xF) << 2) | (b3 >> 6)
|
|
154
155
|
c4 = b3 & 0x3F
|
|
155
156
|
return encode6bit(c1 & 0x3F).chr +
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
157
|
+
encode6bit(c2 & 0x3F).chr +
|
|
158
|
+
encode6bit(c3 & 0x3F).chr +
|
|
159
|
+
encode6bit(c4 & 0x3F).chr
|
|
159
160
|
end
|
|
160
161
|
|
|
161
162
|
# Make a call to the PlantUML server with the simplest diagram possible to
|
|
@@ -173,3 +174,7 @@ class Gollum::Filter::PlantUML < Gollum::Filter
|
|
|
173
174
|
return false
|
|
174
175
|
end
|
|
175
176
|
end
|
|
177
|
+
|
|
178
|
+
Gollum::Filter::Code.language_handlers[/plantuml/] = Proc.new {
|
|
179
|
+
|lang, code| Gollum::Filter::PlantUML.new(code).render_plantuml("@startuml\n#{code}\n@enduml\n")
|
|
180
|
+
}
|
|
@@ -6,7 +6,11 @@ class Gollum::Filter::Render < Gollum::Filter
|
|
|
6
6
|
working_dir = Pathname.new(@markup.wiki.path).join(@markup.dir)
|
|
7
7
|
working_dir = working_dir.exist? ? working_dir.to_s : '.'
|
|
8
8
|
Dir.chdir(working_dir) do
|
|
9
|
-
|
|
9
|
+
if block = @markup.custom_renderer
|
|
10
|
+
data = block.call(data)
|
|
11
|
+
else
|
|
12
|
+
data = GitHub::Markup.render_s(@markup.format, data)
|
|
13
|
+
end
|
|
10
14
|
end
|
|
11
15
|
if data.nil?
|
|
12
16
|
raise "There was an error converting #{@markup.name} to HTML."
|
|
@@ -120,8 +120,9 @@ class Gollum::Filter::Tags < Gollum::Filter
|
|
|
120
120
|
def process_include_tag(tag)
|
|
121
121
|
len = INCLUDE_TAG.length
|
|
122
122
|
return html_error('Cannot process include directive: no page name given') if tag.length <= len
|
|
123
|
-
|
|
124
|
-
|
|
123
|
+
page_path = Pathname.new(tag[len..-1])
|
|
124
|
+
resolved_page = page_path.relative? ? (Pathname.new(@markup.dir) + page_path) : page_path
|
|
125
|
+
resolved_page_name = resolved_page.cleanpath.to_s
|
|
125
126
|
if @markup.include_levels > 0
|
|
126
127
|
page = find_page_or_file_from_path(resolved_page_name)
|
|
127
128
|
if page
|
|
@@ -231,7 +232,13 @@ class Gollum::Filter::Tags < Gollum::Filter
|
|
|
231
232
|
name = page ? path_to_link_text(link) : link
|
|
232
233
|
end
|
|
233
234
|
|
|
234
|
-
|
|
235
|
+
if page
|
|
236
|
+
link = page.escaped_url_path
|
|
237
|
+
else
|
|
238
|
+
link = Pathname.new(link).relative? ? "#{@markup.dir.to_s}/#{link}" : link
|
|
239
|
+
link = ERB::Util.url_encode(link).force_encoding('utf-8')
|
|
240
|
+
end
|
|
241
|
+
|
|
235
242
|
generate_link(link, name, extra, presence)
|
|
236
243
|
end
|
|
237
244
|
|
|
@@ -10,7 +10,7 @@ class Gollum::Filter::YAML < Gollum::Filter
|
|
|
10
10
|
data.gsub!(YAML_FRONT_MATTER_REGEXP) do
|
|
11
11
|
@markup.metadata ||= {}
|
|
12
12
|
begin
|
|
13
|
-
frontmatter = ::YAML.safe_load(
|
|
13
|
+
frontmatter = sanitize_frontmatter(::YAML.safe_load(Regexp.last_match[1]))
|
|
14
14
|
@markup.metadata.merge!(frontmatter) if frontmatter.respond_to?(:keys) && frontmatter.respond_to?(:values)
|
|
15
15
|
rescue ::Psych::SyntaxError, ::Psych::DisallowedClass, ::Psych::BadAlias => error
|
|
16
16
|
@markup.metadata['errors'] ||= []
|
|
@@ -24,4 +24,23 @@ class Gollum::Filter::YAML < Gollum::Filter
|
|
|
24
24
|
def process(data)
|
|
25
25
|
data
|
|
26
26
|
end
|
|
27
|
+
|
|
28
|
+
private
|
|
29
|
+
|
|
30
|
+
def sanitize_frontmatter(obj)
|
|
31
|
+
case obj
|
|
32
|
+
when Hash
|
|
33
|
+
obj.map do |k, v|
|
|
34
|
+
[sanitize(k.to_s), sanitize_frontmatter(v)]
|
|
35
|
+
end.to_h
|
|
36
|
+
when Array
|
|
37
|
+
obj.map! do |v|
|
|
38
|
+
sanitize_frontmatter(v)
|
|
39
|
+
end
|
|
40
|
+
when String
|
|
41
|
+
sanitize(obj)
|
|
42
|
+
else
|
|
43
|
+
obj
|
|
44
|
+
end
|
|
45
|
+
end
|
|
27
46
|
end
|
|
@@ -161,15 +161,11 @@ module Gollum
|
|
|
161
161
|
items = []
|
|
162
162
|
tree.each do |entry|
|
|
163
163
|
if entry[:type] == 'blob'
|
|
164
|
-
|
|
164
|
+
next if @page_file_dir && !entry[:path].start_with?("#{@page_file_dir}/")
|
|
165
|
+
items << BlobEntry.new(entry[:sha], entry[:path], entry[:size], entry[:mode])
|
|
165
166
|
end
|
|
166
167
|
end
|
|
167
|
-
|
|
168
|
-
regex = /^#{dir}\//
|
|
169
|
-
items.select { |i| i.path =~ regex }
|
|
170
|
-
else
|
|
171
|
-
items
|
|
172
|
-
end
|
|
168
|
+
items
|
|
173
169
|
end
|
|
174
170
|
|
|
175
171
|
# Reads the content from the Git db at the given SHA.
|
data/lib/gollum-lib/helpers.rb
CHANGED
|
@@ -3,12 +3,12 @@
|
|
|
3
3
|
module Gollum
|
|
4
4
|
module Helpers
|
|
5
5
|
|
|
6
|
-
#
|
|
6
|
+
# Replace url-encoded slashes ('%2F') with slashes
|
|
7
|
+
# Clean up double slashes
|
|
7
8
|
def trim_leading_slashes(url)
|
|
8
9
|
return nil if url.nil?
|
|
9
10
|
url.gsub!('%2F', '/')
|
|
10
|
-
|
|
11
|
-
url
|
|
11
|
+
Pathname.new(url).cleanpath.to_s
|
|
12
12
|
end
|
|
13
13
|
|
|
14
14
|
# Take a link path and turn it into a string for display as link text.
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
module Gollum
|
|
2
|
+
class Macro
|
|
3
|
+
class Flash < Gollum::Macro
|
|
4
|
+
def render(message, icon='', type='')
|
|
5
|
+
flash_type = ['warn', 'error', 'success'].include?(type) ? "flash-#{type}" : ''
|
|
6
|
+
flash_icon = icon.empty? ? '' : %Q(data-gollum-icon="#{icon}")
|
|
7
|
+
%Q(<div class="flash #{flash_type} my-2" #{flash_icon}>#{message}</div>)
|
|
8
|
+
end
|
|
9
|
+
end
|
|
10
|
+
end
|
|
11
|
+
end
|
|
@@ -1,18 +1,8 @@
|
|
|
1
1
|
module Gollum
|
|
2
2
|
class Macro
|
|
3
3
|
class Note < Gollum::Macro
|
|
4
|
-
def render(notice
|
|
5
|
-
|
|
6
|
-
unless octicon.empty?
|
|
7
|
-
begin
|
|
8
|
-
icon = Octicons::Octicon.new(octicon, {width: 24, height: 24})
|
|
9
|
-
rescue RuntimeError
|
|
10
|
-
icon = Octicons::Octicon.new('info', {width: 24, height: 24})
|
|
11
|
-
end
|
|
12
|
-
icon.options[:class] << ' mr-2'
|
|
13
|
-
icon = icon.to_svg
|
|
14
|
-
end
|
|
15
|
-
"<div class='flash'>#{icon}#{notice}</div>"
|
|
4
|
+
def render(notice)
|
|
5
|
+
%Q(<div class="flash gollum-note my-2">#{notice}</div>)
|
|
16
6
|
end
|
|
17
7
|
end
|
|
18
8
|
end
|
|
@@ -2,9 +2,7 @@ module Gollum
|
|
|
2
2
|
class Macro
|
|
3
3
|
class Warn < Gollum::Macro
|
|
4
4
|
def render(warning)
|
|
5
|
-
|
|
6
|
-
icon.options[:class] << ' mr-2'
|
|
7
|
-
"<div class='flash flash-warn'>#{icon.to_svg}#{warning}</div>"
|
|
5
|
+
%Q(<div class="flash flash-warn gollum-warning my-2">#{warning}</div>)
|
|
8
6
|
end
|
|
9
7
|
end
|
|
10
8
|
end
|
data/lib/gollum-lib/macro.rb
CHANGED
data/lib/gollum-lib/markup.rb
CHANGED
|
@@ -61,7 +61,9 @@ module Gollum
|
|
|
61
61
|
:extensions => new_extension,
|
|
62
62
|
:reverse_links => options.fetch(:reverse_links, false),
|
|
63
63
|
:skip_filters => options.fetch(:skip_filters, nil),
|
|
64
|
-
:enabled => options.fetch(:enabled, true)
|
|
64
|
+
:enabled => options.fetch(:enabled, true),
|
|
65
|
+
:render => options.fetch(:render, nil)
|
|
66
|
+
}
|
|
65
67
|
@extensions.concat(new_extension)
|
|
66
68
|
end
|
|
67
69
|
end
|
|
@@ -102,6 +104,10 @@ module Gollum
|
|
|
102
104
|
self.class.formats[@format][:reverse_links]
|
|
103
105
|
end
|
|
104
106
|
|
|
107
|
+
def custom_renderer
|
|
108
|
+
self.class.formats[@format].fetch(:render, nil)
|
|
109
|
+
end
|
|
110
|
+
|
|
105
111
|
# Whether or not a particular filter should be skipped for this format.
|
|
106
112
|
def skip_filter?(filter)
|
|
107
113
|
if self.class.formats[@format][:skip_filters].respond_to?(:include?)
|
|
@@ -119,7 +125,7 @@ module Gollum
|
|
|
119
125
|
# filter_chain - the chain to process
|
|
120
126
|
#
|
|
121
127
|
# Returns the formatted data
|
|
122
|
-
def process_chain(data, filter_chain)
|
|
128
|
+
def process_chain(data, filter_chain, &block)
|
|
123
129
|
# First we extract the data through the chain...
|
|
124
130
|
filter_chain.each do |filter|
|
|
125
131
|
data = filter.extract(data)
|
data/lib/gollum-lib/page.rb
CHANGED
|
@@ -6,22 +6,39 @@ module Gollum
|
|
|
6
6
|
SUBPAGENAMES = [:header, :footer, :sidebar]
|
|
7
7
|
|
|
8
8
|
class << self
|
|
9
|
-
# For use with self.
|
|
9
|
+
# For use with self.global_find: returns true if the given query corresponds to the in-repo path of the BlobEntry.
|
|
10
10
|
#
|
|
11
11
|
# query - The String path to match.
|
|
12
12
|
# entry - The BlobEntry to check against.
|
|
13
|
-
|
|
14
|
-
def path_match(query, entry, global_match = false, hyphened_tags = false, case_insensitive = false)
|
|
13
|
+
def global_path_match(query, entry, hyphened_tags = false, case_insensitive = false)
|
|
15
14
|
return false if "#{entry.name}".empty?
|
|
16
15
|
return false unless valid_extension?(entry.name)
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
].compact)
|
|
16
|
+
match_path = Pathname.new('/').join(*[
|
|
17
|
+
entry.dir,
|
|
18
|
+
entry.name
|
|
19
|
+
].compact
|
|
20
|
+
).to_s
|
|
23
21
|
path_compare(query, match_path, hyphened_tags, case_insensitive)
|
|
24
22
|
end
|
|
23
|
+
|
|
24
|
+
def global_find(wiki, version, query, try_on_disk)
|
|
25
|
+
map = wiki.tree_map_for(version.to_s)
|
|
26
|
+
begin
|
|
27
|
+
entry = map.detect do |entry|
|
|
28
|
+
global_path_match(query, entry, wiki.hyphened_tag_lookup, wiki.case_insensitive_tag_lookup)
|
|
29
|
+
end
|
|
30
|
+
entry ? self.new(wiki, entry.blob(wiki.repo), entry.dir, version, try_on_disk) : nil
|
|
31
|
+
rescue Gollum::Git::NoSuchShaFound
|
|
32
|
+
nil
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def path_compare(query, match_path, hyphened_tags, case_insensitive)
|
|
37
|
+
return false unless valid_extension?(match_path)
|
|
38
|
+
cmp = valid_extension?(query) ? match_path : strip_filename(match_path)
|
|
39
|
+
super(query, cmp, hyphened_tags, case_insensitive)
|
|
40
|
+
end
|
|
41
|
+
|
|
25
42
|
end
|
|
26
43
|
|
|
27
44
|
# Checks if a filename has a valid, registered extension
|
data/lib/gollum-lib/version.rb
CHANGED
data/lib/gollum-lib/wiki.rb
CHANGED
|
@@ -7,7 +7,7 @@ module Gollum
|
|
|
7
7
|
|
|
8
8
|
class << self
|
|
9
9
|
# Sets the default ref for the wiki.
|
|
10
|
-
attr_writer :
|
|
10
|
+
attr_writer :default_refs
|
|
11
11
|
|
|
12
12
|
# Sets the default name for commits.
|
|
13
13
|
attr_writer :default_committer_name
|
|
@@ -19,8 +19,12 @@ module Gollum
|
|
|
19
19
|
# These defaults can be overridden by options passed directly to initialize()
|
|
20
20
|
attr_writer :default_options
|
|
21
21
|
|
|
22
|
-
def
|
|
23
|
-
|
|
22
|
+
def find_default_ref(repo)
|
|
23
|
+
repo.find_branch(self.default_refs) || Gollum::Git.global_default_branch || self.default_refs.first
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def default_refs
|
|
27
|
+
@default_refs || ['master', 'main']
|
|
24
28
|
end
|
|
25
29
|
|
|
26
30
|
def default_committer_name
|
|
@@ -28,7 +32,7 @@ module Gollum
|
|
|
28
32
|
end
|
|
29
33
|
|
|
30
34
|
def default_committer_email
|
|
31
|
-
@default_committer_email || 'anon@
|
|
35
|
+
@default_committer_email || 'anon@anonymous.invalid'
|
|
32
36
|
end
|
|
33
37
|
|
|
34
38
|
def default_options
|
|
@@ -132,7 +136,7 @@ module Gollum
|
|
|
132
136
|
@access = options.fetch :access, GitAccess.new(path, @page_file_dir, @repo_is_bare)
|
|
133
137
|
@base_path = options.fetch :base_path, "/"
|
|
134
138
|
@repo = @access.repo
|
|
135
|
-
@ref = options.fetch :ref, self.class.
|
|
139
|
+
@ref = options.fetch :ref, self.class.find_default_ref(@repo)
|
|
136
140
|
@universal_toc = options.fetch :universal_toc, false
|
|
137
141
|
@mathjax = options.fetch :mathjax, false
|
|
138
142
|
@global_tag_lookup = options.fetch :global_tag_lookup, false
|
data/lib/gollum-lib.rb
CHANGED
|
@@ -28,7 +28,6 @@ require File.expand_path('../gollum-lib/redirects', __FILE__)
|
|
|
28
28
|
require File.expand_path('../gollum-lib/file', __FILE__)
|
|
29
29
|
require File.expand_path('../gollum-lib/page', __FILE__)
|
|
30
30
|
require File.expand_path('../gollum-lib/macro', __FILE__)
|
|
31
|
-
require File.expand_path('../gollum-lib/file_view', __FILE__)
|
|
32
31
|
require File.expand_path('../gollum-lib/markup', __FILE__)
|
|
33
32
|
require File.expand_path('../gollum-lib/markups', __FILE__)
|
|
34
33
|
require File.expand_path('../gollum-lib/sanitization', __FILE__)
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: gollum-lib
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version:
|
|
4
|
+
version: 6.1.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Tom Preston-Werner
|
|
@@ -9,7 +9,7 @@ authors:
|
|
|
9
9
|
autorequire:
|
|
10
10
|
bindir: bin
|
|
11
11
|
cert_chain: []
|
|
12
|
-
date:
|
|
12
|
+
date: 2025-10-20 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
|
14
14
|
- !ruby/object:Gem::Dependency
|
|
15
15
|
name: gollum-rugged_adapter
|
|
@@ -17,14 +17,14 @@ dependencies:
|
|
|
17
17
|
requirements:
|
|
18
18
|
- - "~>"
|
|
19
19
|
- !ruby/object:Gem::Version
|
|
20
|
-
version: '
|
|
20
|
+
version: '3.0'
|
|
21
21
|
type: :runtime
|
|
22
22
|
prerelease: false
|
|
23
23
|
version_requirements: !ruby/object:Gem::Requirement
|
|
24
24
|
requirements:
|
|
25
25
|
- - "~>"
|
|
26
26
|
- !ruby/object:Gem::Version
|
|
27
|
-
version: '
|
|
27
|
+
version: '3.0'
|
|
28
28
|
- !ruby/object:Gem::Dependency
|
|
29
29
|
name: rouge
|
|
30
30
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -95,20 +95,6 @@ dependencies:
|
|
|
95
95
|
- - "~>"
|
|
96
96
|
- !ruby/object:Gem::Version
|
|
97
97
|
version: '4.1'
|
|
98
|
-
- !ruby/object:Gem::Dependency
|
|
99
|
-
name: octicons
|
|
100
|
-
requirement: !ruby/object:Gem::Requirement
|
|
101
|
-
requirements:
|
|
102
|
-
- - "~>"
|
|
103
|
-
- !ruby/object:Gem::Version
|
|
104
|
-
version: '12.0'
|
|
105
|
-
type: :runtime
|
|
106
|
-
prerelease: false
|
|
107
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
108
|
-
requirements:
|
|
109
|
-
- - "~>"
|
|
110
|
-
- !ruby/object:Gem::Version
|
|
111
|
-
version: '12.0'
|
|
112
98
|
- !ruby/object:Gem::Dependency
|
|
113
99
|
name: twitter-text
|
|
114
100
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -185,14 +171,14 @@ dependencies:
|
|
|
185
171
|
requirements:
|
|
186
172
|
- - "~>"
|
|
187
173
|
- !ruby/object:Gem::Version
|
|
188
|
-
version: '
|
|
174
|
+
version: '2.0'
|
|
189
175
|
type: :development
|
|
190
176
|
prerelease: false
|
|
191
177
|
version_requirements: !ruby/object:Gem::Requirement
|
|
192
178
|
requirements:
|
|
193
179
|
- - "~>"
|
|
194
180
|
- !ruby/object:Gem::Version
|
|
195
|
-
version: '
|
|
181
|
+
version: '2.0'
|
|
196
182
|
- !ruby/object:Gem::Dependency
|
|
197
183
|
name: shoulda
|
|
198
184
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -325,14 +311,14 @@ dependencies:
|
|
|
325
311
|
requirements:
|
|
326
312
|
- - "~>"
|
|
327
313
|
- !ruby/object:Gem::Version
|
|
328
|
-
version: '1.
|
|
314
|
+
version: '1.5'
|
|
329
315
|
type: :development
|
|
330
316
|
prerelease: false
|
|
331
317
|
version_requirements: !ruby/object:Gem::Requirement
|
|
332
318
|
requirements:
|
|
333
319
|
- - "~>"
|
|
334
320
|
- !ruby/object:Gem::Version
|
|
335
|
-
version: '1.
|
|
321
|
+
version: '1.5'
|
|
336
322
|
- !ruby/object:Gem::Dependency
|
|
337
323
|
name: nokogiri-diff
|
|
338
324
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -412,7 +398,6 @@ files:
|
|
|
412
398
|
- lib/gollum-lib/blob_entry.rb
|
|
413
399
|
- lib/gollum-lib/committer.rb
|
|
414
400
|
- lib/gollum-lib/file.rb
|
|
415
|
-
- lib/gollum-lib/file_view.rb
|
|
416
401
|
- lib/gollum-lib/filter.rb
|
|
417
402
|
- lib/gollum-lib/filter/bibtex.rb
|
|
418
403
|
- lib/gollum-lib/filter/code.rb
|
|
@@ -434,10 +419,11 @@ files:
|
|
|
434
419
|
- lib/gollum-lib/macro.rb
|
|
435
420
|
- lib/gollum-lib/macro/all_pages.rb
|
|
436
421
|
- lib/gollum-lib/macro/audio.rb
|
|
422
|
+
- lib/gollum-lib/macro/flash.rb
|
|
437
423
|
- lib/gollum-lib/macro/global_toc.rb
|
|
424
|
+
- lib/gollum-lib/macro/icon.rb
|
|
438
425
|
- lib/gollum-lib/macro/navigation.rb
|
|
439
426
|
- lib/gollum-lib/macro/note.rb
|
|
440
|
-
- lib/gollum-lib/macro/octicon.rb
|
|
441
427
|
- lib/gollum-lib/macro/series.rb
|
|
442
428
|
- lib/gollum-lib/macro/video.rb
|
|
443
429
|
- lib/gollum-lib/macro/warn.rb
|
|
@@ -470,7 +456,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
470
456
|
- !ruby/object:Gem::Version
|
|
471
457
|
version: '0'
|
|
472
458
|
requirements: []
|
|
473
|
-
rubygems_version: 3.
|
|
459
|
+
rubygems_version: 3.5.22
|
|
474
460
|
signing_key:
|
|
475
461
|
specification_version: 4
|
|
476
462
|
summary: A simple, Git-powered wiki.
|
data/lib/gollum-lib/file_view.rb
DELETED
|
@@ -1,164 +0,0 @@
|
|
|
1
|
-
# ~*~ encoding: utf-8 ~*~
|
|
2
|
-
module Gollum
|
|
3
|
-
# FileView requires that:
|
|
4
|
-
# - All files in root dir are processed first
|
|
5
|
-
# - Then all the folders are sorted and processed
|
|
6
|
-
|
|
7
|
-
class FileView
|
|
8
|
-
# common use cases:
|
|
9
|
-
# set pages to wiki.pages and show_all to false
|
|
10
|
-
# set pages to wiki.pages + wiki.files and show_all to true
|
|
11
|
-
def initialize(pages, options = {})
|
|
12
|
-
@pages = pages
|
|
13
|
-
@wiki = @pages.first ? @pages.first.wiki : nil
|
|
14
|
-
@show_all = options[:show_all] || false
|
|
15
|
-
@checked = options[:collapse_tree] ? '' : "checked"
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
def enclose_tree(string)
|
|
19
|
-
sanitize_html(%Q(<ol class="tree">\n) + string + %Q(</ol>))
|
|
20
|
-
end
|
|
21
|
-
|
|
22
|
-
def new_page(page)
|
|
23
|
-
name = page.name
|
|
24
|
-
url, valid_page = url_for_page page
|
|
25
|
-
%Q( <li class="file"><a href="#{url}"><span class="icon"></span>#{name}</a>#{valid_page ? "" : delete_file(url, valid_page)}</li>)
|
|
26
|
-
end
|
|
27
|
-
|
|
28
|
-
def delete_file(url, valid_page)
|
|
29
|
-
%Q(<form method="POST" action="/deleteFile/#{url}" onsubmit="return confirm('Do you really want to delete the file #{url}?');"><button type="submit" name="delete" value="true"></button></form>)
|
|
30
|
-
end
|
|
31
|
-
|
|
32
|
-
def new_folder(folder_path)
|
|
33
|
-
new_sub_folder folder_path
|
|
34
|
-
end
|
|
35
|
-
|
|
36
|
-
def new_sub_folder(path)
|
|
37
|
-
<<-HTML
|
|
38
|
-
<li>
|
|
39
|
-
<label>#{path}</label> <input type="checkbox" #{@checked} />
|
|
40
|
-
<ol>
|
|
41
|
-
HTML
|
|
42
|
-
end
|
|
43
|
-
|
|
44
|
-
def end_folder
|
|
45
|
-
"</ol></li>\n"
|
|
46
|
-
end
|
|
47
|
-
|
|
48
|
-
def url_for_page(page)
|
|
49
|
-
url = ''
|
|
50
|
-
valid_page_name = false
|
|
51
|
-
if @show_all
|
|
52
|
-
# Remove ext for valid pages.
|
|
53
|
-
filename = page.filename
|
|
54
|
-
valid_page_name = Page::valid_page_name?(filename)
|
|
55
|
-
filename = valid_page_name ? filename.chomp(::File.extname(filename)) : filename
|
|
56
|
-
|
|
57
|
-
url = ::File.join(::File.dirname(page.path), filename)
|
|
58
|
-
else
|
|
59
|
-
url = ::File.join(::File.dirname(page.path), page.filename_stripped)
|
|
60
|
-
end
|
|
61
|
-
url = url[2..-1] if url[0, 2] == './'
|
|
62
|
-
return url, valid_page_name
|
|
63
|
-
end
|
|
64
|
-
|
|
65
|
-
def render_files
|
|
66
|
-
html = ''
|
|
67
|
-
count = @pages.size
|
|
68
|
-
folder_start = -1
|
|
69
|
-
|
|
70
|
-
# Process all pages until folders start
|
|
71
|
-
count.times do |index|
|
|
72
|
-
page = @pages[index]
|
|
73
|
-
path = page.path
|
|
74
|
-
|
|
75
|
-
unless path.include? '/'
|
|
76
|
-
# Page processed (not contained in a folder)
|
|
77
|
-
html += new_page page
|
|
78
|
-
else
|
|
79
|
-
# Folders start at the next index
|
|
80
|
-
folder_start = index
|
|
81
|
-
break # Pages finished, move on to folders
|
|
82
|
-
end
|
|
83
|
-
end
|
|
84
|
-
|
|
85
|
-
# If there are no folders, then we're done.
|
|
86
|
-
return enclose_tree(html) if folder_start <= -1
|
|
87
|
-
|
|
88
|
-
# Handle special case of only one folder.
|
|
89
|
-
if (count - folder_start == 1)
|
|
90
|
-
page = @pages[folder_start]
|
|
91
|
-
html += <<-HTML
|
|
92
|
-
<li>
|
|
93
|
-
<label>#{::File.dirname(page.path)}</label> <input type="checkbox" #{@checked} />
|
|
94
|
-
<ol>
|
|
95
|
-
#{new_page page}
|
|
96
|
-
</ol>
|
|
97
|
-
</li>
|
|
98
|
-
HTML
|
|
99
|
-
|
|
100
|
-
return enclose_tree(html)
|
|
101
|
-
end
|
|
102
|
-
|
|
103
|
-
sorted_folders = []
|
|
104
|
-
(folder_start).upto count - 1 do |index|
|
|
105
|
-
sorted_folders += [[@pages[index].path, index]]
|
|
106
|
-
end
|
|
107
|
-
|
|
108
|
-
# http://stackoverflow.com/questions/3482814/sorting-list-of-string-paths-in-vb-net
|
|
109
|
-
sorted_folders.sort! do |first, second|
|
|
110
|
-
a = first[0]
|
|
111
|
-
b = second[0]
|
|
112
|
-
|
|
113
|
-
# use :: operator because gollum defines its own conflicting File class
|
|
114
|
-
dir_compare = ::File.dirname(a) <=> ::File.dirname(b)
|
|
115
|
-
|
|
116
|
-
# Sort based on directory name unless they're equal (0) in
|
|
117
|
-
# which case sort based on file name.
|
|
118
|
-
if dir_compare == 0
|
|
119
|
-
::File.basename(a) <=> ::File.basename(b)
|
|
120
|
-
else
|
|
121
|
-
dir_compare
|
|
122
|
-
end
|
|
123
|
-
end
|
|
124
|
-
|
|
125
|
-
# keep track of folder depth, 0 = at root.
|
|
126
|
-
cwd_array = []
|
|
127
|
-
changed = false
|
|
128
|
-
|
|
129
|
-
# process rest of folders
|
|
130
|
-
(0...sorted_folders.size).each do |i|
|
|
131
|
-
page = @pages[sorted_folders[i][1]]
|
|
132
|
-
path = page.path
|
|
133
|
-
folder = ::File.dirname path
|
|
134
|
-
|
|
135
|
-
tmp_array = folder.split '/'
|
|
136
|
-
|
|
137
|
-
(0...tmp_array.size).each do |index|
|
|
138
|
-
if cwd_array[index].nil? || changed
|
|
139
|
-
html += new_sub_folder tmp_array[index]
|
|
140
|
-
next
|
|
141
|
-
end
|
|
142
|
-
|
|
143
|
-
if cwd_array[index] != tmp_array[index]
|
|
144
|
-
changed = true
|
|
145
|
-
(cwd_array.size - index).times do
|
|
146
|
-
html += end_folder
|
|
147
|
-
end
|
|
148
|
-
html += new_sub_folder tmp_array[index]
|
|
149
|
-
end
|
|
150
|
-
end
|
|
151
|
-
|
|
152
|
-
html += new_page page
|
|
153
|
-
cwd_array = tmp_array
|
|
154
|
-
changed = false
|
|
155
|
-
end
|
|
156
|
-
|
|
157
|
-
enclose_tree(html)
|
|
158
|
-
end # end render_files
|
|
159
|
-
|
|
160
|
-
def sanitize_html(data)
|
|
161
|
-
@wiki ? @wiki.sanitizer.clean(data) : data
|
|
162
|
-
end
|
|
163
|
-
end # end FileView class
|
|
164
|
-
end # end Gollum module
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
module Gollum
|
|
2
|
-
class Macro
|
|
3
|
-
class Octicon < Gollum::Macro
|
|
4
|
-
def render(symbol, height = nil, width = nil)
|
|
5
|
-
parameters = {}
|
|
6
|
-
parameters[:height] = height if height
|
|
7
|
-
parameters[:width] = width if width
|
|
8
|
-
"<div>#{Octicons::Octicon.new(symbol, parameters).to_svg}</div>"
|
|
9
|
-
end
|
|
10
|
-
end
|
|
11
|
-
end
|
|
12
|
-
end
|