gollum-lib 6.0-java → 6.1.0-java
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/HISTORY.md +15 -1
- data/LATEST_CHANGES.md +12 -10
- data/Rakefile +4 -4
- data/gemspec.rb +1 -2
- data/lib/gollum-lib/filter/code.rb +1 -1
- data/lib/gollum-lib/filter/plantuml.rb +21 -16
- data/lib/gollum-lib/filter/tags.rb +3 -2
- data/lib/gollum-lib/filter/yaml.rb +20 -1
- data/lib/gollum-lib/version.rb +1 -1
- data/lib/gollum-lib/wiki.rb +1 -1
- data/lib/gollum-lib.rb +0 -1
- metadata +3 -4
- data/lib/gollum-lib/file_view.rb +0 -164
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: fd82e77d612672eac386d7946f577227dc169cfbc5ad9455affa310cede0289b
|
|
4
|
+
data.tar.gz: 236d3fe12527b806ee2131de0339c99ea7df55f01399895d469034e1dae7d655
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 497e39ae3c21df758b60d57b80fa3d683ad376f70d4da1be67f3d871ecbede28acf8882f19e5f6a57afdb9ec73207c382e927c58d2efd39c14c0897211e89441
|
|
7
|
+
data.tar.gz: 91d14006c4a1a923156ba49177d10fb954f0f8e74761704e513fdd74bfe5726373a43078fd4e21604897356d01a6b79f117d76870d4a7b38e441719d025c391c
|
data/HISTORY.md
CHANGED
|
@@ -1,3 +1,17 @@
|
|
|
1
|
+
# 6.0 / 2023-08-01
|
|
2
|
+
|
|
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)
|
|
14
|
+
|
|
1
15
|
# 5.2.4 / 2023-03-22
|
|
2
16
|
|
|
3
17
|
* Bugfix release: address XSS vulnerability ( @6661620a, @dometto)
|
|
@@ -50,7 +64,7 @@ For a detailed overview of changes in 5.0 and a guide to migrating your wiki, se
|
|
|
50
64
|
** Dependency updates
|
|
51
65
|
** Bugfixes
|
|
52
66
|
** New Macro for listing contents of (sub)directories: `Navigation()`
|
|
53
|
-
** Table of Contents now supports setting max heading level
|
|
67
|
+
** Table of Contents now supports setting max heading level
|
|
54
68
|
|
|
55
69
|
# v4.0.2 / 2015-01-19
|
|
56
70
|
|
data/LATEST_CHANGES.md
CHANGED
|
@@ -1,13 +1,15 @@
|
|
|
1
|
-
# 6.0
|
|
1
|
+
# 6.1.0
|
|
2
2
|
|
|
3
|
-
|
|
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)
|
|
3
|
+
This is largely a bugfix release.
|
|
9
4
|
|
|
10
|
-
|
|
5
|
+
New features:
|
|
11
6
|
|
|
12
|
-
|
|
13
|
-
|
|
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
|
@@ -49,7 +49,7 @@ def specification(version, default_adapter, platform = nil)
|
|
|
49
49
|
s.add_development_dependency 'guard', '~> 2.16'
|
|
50
50
|
s.add_development_dependency 'guard-minitest', '~> 2.4'
|
|
51
51
|
s.add_development_dependency 'twitter_cldr', '~> 6.4'
|
|
52
|
-
|
|
52
|
+
|
|
53
53
|
# = MANIFEST =
|
|
54
54
|
s.files = %w[
|
|
55
55
|
Gemfile
|
|
@@ -67,7 +67,6 @@ def specification(version, default_adapter, platform = nil)
|
|
|
67
67
|
lib/gollum-lib/blob_entry.rb
|
|
68
68
|
lib/gollum-lib/committer.rb
|
|
69
69
|
lib/gollum-lib/file.rb
|
|
70
|
-
lib/gollum-lib/file_view.rb
|
|
71
70
|
lib/gollum-lib/filter.rb
|
|
72
71
|
lib/gollum-lib/filter/bibtex.rb
|
|
73
72
|
lib/gollum-lib/filter/code.rb
|
|
@@ -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
|
|
@@ -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
|
+
}
|
|
@@ -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
|
|
@@ -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
|
data/lib/gollum-lib/version.rb
CHANGED
data/lib/gollum-lib/wiki.rb
CHANGED
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: java
|
|
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-rjgit_adapter
|
|
@@ -398,7 +398,6 @@ files:
|
|
|
398
398
|
- lib/gollum-lib/blob_entry.rb
|
|
399
399
|
- lib/gollum-lib/committer.rb
|
|
400
400
|
- lib/gollum-lib/file.rb
|
|
401
|
-
- lib/gollum-lib/file_view.rb
|
|
402
401
|
- lib/gollum-lib/filter.rb
|
|
403
402
|
- lib/gollum-lib/filter/bibtex.rb
|
|
404
403
|
- lib/gollum-lib/filter/code.rb
|
|
@@ -457,7 +456,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
457
456
|
- !ruby/object:Gem::Version
|
|
458
457
|
version: '0'
|
|
459
458
|
requirements: []
|
|
460
|
-
rubygems_version: 3.
|
|
459
|
+
rubygems_version: 3.5.22
|
|
461
460
|
signing_key:
|
|
462
461
|
specification_version: 4
|
|
463
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
|