gollum-lib 5.2.4-java → 6.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 48b93e28c86be16f0f22a60841419bf01cca94c4bb965063aa0c60af3fe34d68
4
- data.tar.gz: cc9aac74db4af15d4943663ec1b3ab02dd451c77a728db20dcd87b4580736d39
3
+ metadata.gz: 9fde289b9c464179c9bbcacb39df9321ac5a239eb32833aba51cb90d94883216
4
+ data.tar.gz: 3e53a15b3388c14503c55d5b1368244508194a0d208680dc2daf5402822102dc
5
5
  SHA512:
6
- metadata.gz: b186da0a8c8af4e1b0306025f2634b3d07437b36a4e2afa0db5f5bed4f2a4f76eb6dc8af91de8e4790a3e0d18602426834d3226d87e5cf911c4cef940f06a924
7
- data.tar.gz: '029d5f5f42f759e8827871cc80ccb4d3308f794dd3d7bffe5c0c7286d1acd3fc40f6c644c57ca975c49c63d7085bfb14a5bef0887599db5bafc78978434ea622'
6
+ metadata.gz: 7216765bf26c315fb1c55ae8ce2bb863c8d769cbfe871dd8292c075b31a9e8091239465efb36083560f5d6b4d08b1cb03702cca7f301a83a4e79236785194211
7
+ data.tar.gz: 398193c6d8325d477fe8da6ffcc43f7a3c043bc969a0d83fca1f826a9e03c4deb113870ff28f932dc5f484d34644781829251312ae6d8d86e83f252f1d914ed3
data/Gemfile CHANGED
@@ -1,3 +1,9 @@
1
1
  source 'https://rubygems.org'
2
-
3
2
  gemspec :name => 'gollum-lib'
3
+ gem 'irb'
4
+
5
+ if RUBY_PLATFORM == 'java' then
6
+ group :development do
7
+ gem 'activesupport', '~> 6.0'
8
+ end
9
+ end
data/HISTORY.md CHANGED
@@ -1,8 +1,10 @@
1
- # 5.2.3 / 2023-03-13
1
+ # 5.2.4 / 2023-03-22
2
2
 
3
- * Bugfix release: update adapter dependencies for Ruby 3.2 support.
3
+ * Bugfix release: address XSS vulnerability ( @6661620a, @dometto)
4
4
 
5
+ # 5.2.3 / 2023-03-13
5
6
 
7
+ * Bugfix release: update adapter dependencies for Ruby 3.2 support.
6
8
 
7
9
  # 5.2.2 / 2023-01-18
8
10
 
data/LATEST_CHANGES.md CHANGED
@@ -1,3 +1,13 @@
1
- # 5.2.4 / 2023-03-22
1
+ # 6.0
2
2
 
3
- * Bugfix release: address XSS vulnerability ( @6661620a, @dometto)
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)
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', '~> 1.11'
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,7 +44,7 @@ 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.4'
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'
@@ -90,10 +89,11 @@ def specification(version, default_adapter, platform = nil)
90
89
  lib/gollum-lib/macro.rb
91
90
  lib/gollum-lib/macro/all_pages.rb
92
91
  lib/gollum-lib/macro/audio.rb
92
+ lib/gollum-lib/macro/flash.rb
93
93
  lib/gollum-lib/macro/global_toc.rb
94
+ lib/gollum-lib/macro/icon.rb
94
95
  lib/gollum-lib/macro/navigation.rb
95
96
  lib/gollum-lib/macro/note.rb
96
- lib/gollum-lib/macro/octicon.rb
97
97
  lib/gollum-lib/macro/series.rb
98
98
  lib/gollum-lib/macro/video.rb
99
99
  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', '~> 1.0']
6
+ default_adapter = ['gollum-rjgit_adapter', '~> 2.0']
7
7
  else
8
- default_adapter = ['gollum-rugged_adapter', '~> 2.0']
8
+ default_adapter = ['gollum-rugged_adapter', '~> 3.0']
9
9
  end
10
10
  Gem::Specification.new &specification(Gollum::Lib::VERSION, default_adapter)
@@ -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.6']
3
+ default_adapter = ['gollum-rjgit_adapter', '~> 2.0']
4
4
  Gem::Specification.new &specification(Gollum::Lib::VERSION, default_adapter, "java")
@@ -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
@@ -8,18 +8,21 @@ module Gollum
8
8
 
9
9
  class << self
10
10
 
11
- # For use with self.find: returns true if the given query corresponds to the in-repo path of the BlobEntry.
12
- #
13
- # query - The String path to match.
14
- # entry - The BlobEntry to check against.
15
- # global_match - (Not implemented for File, see Page.path_match)
16
- # hyphened_tags - If true, replace spaces in match_path with hyphens.
17
- # case_insensitive - If true, compare query and match_path case-insensitively
18
- def path_match(query, entry, global_match = false, hyphened_tags = false, case_insensitive = false)
19
- path_compare(query, ::File.join('/', entry.path), hyphened_tags, case_insensitive)
20
- end
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.path_match: returns true if 'query' and 'match_path' match, strictly or taking account of the following parameters:
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 it's directory (so anywhere in the repo)
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
- map = wiki.tree_map_for(version.to_s)
51
-
52
- query_path = Pathname.new(::File.join(['/', wiki.page_file_dir, path].compact)).cleanpath.to_s
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
- begin
56
- entry = map.detect do |entry|
57
- path_match(query_path, entry, global_match, wiki.hyphened_tag_lookup, wiki.case_insensitive_tag_lookup)
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 = "#{path}/#{blob.name}"[1..-1]
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
@@ -1,5 +1,5 @@
1
1
  # ~*~ encoding: utf-8 ~*~
2
- require 'octicons'
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
- if argument =~ /^([a-z0-9_]+)="(.*?)"/
27
- opts[Regexp.last_match[1]] = Regexp.last_match[2]
28
- elsif argument =~ /^"(.*)"$/
29
- args << Regexp.last_match[1].gsub("\\\"", "\"")
30
- else
31
- args << argument
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
- icon = Octicons::Octicon.new('zap', {width: 24, height: 24})
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
- sanitize(data)
61
+ data
59
62
  end
60
63
  end
@@ -37,7 +37,7 @@ require 'zlib'
37
37
  #
38
38
  class Gollum::Filter::PlantUML < Gollum::Filter
39
39
 
40
- DEFAULT_URL = "http://www.plantuml.com/plantuml/png"
40
+ DEFAULT_URL = "http://localhost:8080/plantuml/png"
41
41
 
42
42
  # Configuration class used to change the behaviour of the PlatnUML filter.
43
43
  #
@@ -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
- data = GitHub::Markup.render_s(@markup.format, data)
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."
@@ -231,7 +231,13 @@ class Gollum::Filter::Tags < Gollum::Filter
231
231
  name = page ? path_to_link_text(link) : link
232
232
  end
233
233
 
234
- link = page ? page.escaped_url_path : ERB::Util.url_encode(link).force_encoding('utf-8')
234
+ if page
235
+ link = page.escaped_url_path
236
+ else
237
+ link = Pathname.new(link).relative? ? "#{@markup.dir.to_s}/#{link}" : link
238
+ link = ERB::Util.url_encode(link).force_encoding('utf-8')
239
+ end
240
+
235
241
  generate_link(link, name, extra, presence)
236
242
  end
237
243
 
@@ -161,15 +161,11 @@ module Gollum
161
161
  items = []
162
162
  tree.each do |entry|
163
163
  if entry[:type] == 'blob'
164
- items << BlobEntry.new(entry[:sha], entry[:path], entry[:size], entry[:mode].to_i(8))
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
- if (dir = @page_file_dir)
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.
@@ -3,12 +3,12 @@
3
3
  module Gollum
4
4
  module Helpers
5
5
 
6
- # If url starts with a leading slash, trim down its number of leading slashes to 1. Else, return url unchanged.
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
- return '/' + url.gsub(/^\/+/, '') if url[0, 1] == '/'
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
@@ -0,0 +1,9 @@
1
+ module Gollum
2
+ class Macro
3
+ class Icon < Gollum::Macro
4
+ def render(icon)
5
+ %Q(<div class="gollum-icon" data-gollum-icon="#{icon}"></div>)
6
+ end
7
+ end
8
+ end
9
+ end
@@ -1,18 +1,8 @@
1
1
  module Gollum
2
2
  class Macro
3
3
  class Note < Gollum::Macro
4
- def render(notice, octicon = 'info')
5
- icon = ""
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
- icon = Octicons::Octicon.new('alert', {width: 24, height: 24})
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
@@ -38,7 +38,7 @@ module Gollum
38
38
  end
39
39
 
40
40
  def render(*_args)
41
- "!!!Unknown macro: #{@macro_name}!!!"
41
+ html_error("Unknown macro: #{@macro_name}")
42
42
  end
43
43
  end
44
44
  end
@@ -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)
@@ -6,22 +6,39 @@ module Gollum
6
6
  SUBPAGENAMES = [:header, :footer, :sidebar]
7
7
 
8
8
  class << self
9
- # For use with self.find: returns true if the given query corresponds to the in-repo path of the BlobEntry.
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
- # global_match - If true, find a File matching path's filename, but not its directory (so anywhere in the repo)
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
- entry_name = valid_extension?(query) ? entry.name : strip_filename(entry.name)
18
- match_path = ::File.join([
19
- '/',
20
- global_match ? nil : entry.dir,
21
- entry_name
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
@@ -1,5 +1,5 @@
1
1
  module Gollum
2
2
  module Lib
3
- VERSION = '5.2.4'
3
+ VERSION = '6.0'
4
4
  end
5
5
  end
@@ -7,7 +7,7 @@ module Gollum
7
7
 
8
8
  class << self
9
9
  # Sets the default ref for the wiki.
10
- attr_writer :default_ref
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 default_ref
23
- @default_ref || 'master'
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
@@ -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.default_ref
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
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: 5.2.4
4
+ version: '6.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: 2023-03-22 00:00:00.000000000 Z
12
+ date: 2023-08-01 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: gollum-rjgit_adapter
@@ -17,14 +17,14 @@ dependencies:
17
17
  requirements:
18
18
  - - "~>"
19
19
  - !ruby/object:Gem::Version
20
- version: '0.6'
20
+ version: '2.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: '0.6'
27
+ version: '2.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: '1.11'
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: '1.11'
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.4'
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.4'
321
+ version: '1.5'
336
322
  - !ruby/object:Gem::Dependency
337
323
  name: nokogiri-diff
338
324
  requirement: !ruby/object:Gem::Requirement
@@ -434,10 +420,11 @@ files:
434
420
  - lib/gollum-lib/macro.rb
435
421
  - lib/gollum-lib/macro/all_pages.rb
436
422
  - lib/gollum-lib/macro/audio.rb
423
+ - lib/gollum-lib/macro/flash.rb
437
424
  - lib/gollum-lib/macro/global_toc.rb
425
+ - lib/gollum-lib/macro/icon.rb
438
426
  - lib/gollum-lib/macro/navigation.rb
439
427
  - lib/gollum-lib/macro/note.rb
440
- - lib/gollum-lib/macro/octicon.rb
441
428
  - lib/gollum-lib/macro/series.rb
442
429
  - lib/gollum-lib/macro/video.rb
443
430
  - lib/gollum-lib/macro/warn.rb
@@ -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