gollum-lib 4.2.10-java → 5.0.a.1-java

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA256:
3
- metadata.gz: '082172479f673ebbd6eacedeb7f2edb540f312dac8307ea68b347b9eca14b961'
4
- data.tar.gz: 48b46d753206cb6cb9650d3d9e398e726fd5451340b27b09c860847e1542504e
2
+ SHA1:
3
+ metadata.gz: ae72c5766cef3dfac6331528aa1bbae51b168dd9
4
+ data.tar.gz: 3ef52f1eea546e5204ae4ba48ab0a07d36e7c206
5
5
  SHA512:
6
- metadata.gz: 6e5dfec01055468484d7c0dd582c56c566dce3fe1435d189e31b4207d3f20a4d05533a709c4218600cdb2524c788a43b59e45fcc59fd820b1048d4da2d690fe5
7
- data.tar.gz: 8e2ff18cf89c7b933acf162797b88e973aa9c5d68b4d3b3234de0cd52aeed53b0512e86bf1a26df7a5e7fa73c3f56dc53a014403788ddebebcda50e7f9ccc426
6
+ metadata.gz: 653feadd2f5ab77be231fc6b1c749e035b28dc610e80ab513ef62c70176f149767eb4638fc7143dfeadb1e0d668d7daa4967850191b8f57c2d1db0de9edb668d
7
+ data.tar.gz: e72ae4b5f112ad0d15a7001b651ead4ebec0b7b691ef7ab408dc0895fb405b7d64c71366050cf5bd7761ae468b1dd294c0b576f34a3a1695528e85c92f142551
data/Gemfile CHANGED
@@ -1,2 +1,2 @@
1
1
  source 'https://rubygems.org'
2
- gemspec :name => 'gollum-lib'
2
+ gemspec :name => 'gollum-lib'
data/README.md CHANGED
@@ -19,7 +19,8 @@ Gollum-lib follows the rules of [Semantic Versioning](http://semver.org/) and us
19
19
 
20
20
  ## SYSTEM REQUIREMENTS
21
21
 
22
- - Ruby 1.9.3+ (>2.0 recommended)
22
+ - Python 2.5+ (2.7.3 recommended)
23
+ - Ruby 2.1.0+ (>= 2.3.3 recommended)
23
24
  - Unix like operating system (OS X, Ubuntu, Debian, and more)
24
25
  - Will not work on Windows with the default [grit](https://github.com/github/grit) adapter, but might work via JRuby (please let us know!)
25
26
 
data/ROADMAP ADDED
@@ -0,0 +1,6 @@
1
+ # Roadmap to 5.x
2
+
3
+ * Unicode everywhere
4
+ * Reduce whitespace substitution array to a single character to reduce lookup times
5
+ * Benchmarking
6
+ *
data/Rakefile CHANGED
@@ -118,14 +118,14 @@ end
118
118
 
119
119
  desc 'Create a release build'
120
120
  task :release => :build do
121
- unless `git branch` =~ /^\* master$/
122
- puts "You must be on the master branch to release!"
121
+ unless `git branch` =~ /gollum-lib-5.x/
122
+ puts "You must be on the gollum-lib-5.x branch to release!"
123
123
  exit!
124
124
  end
125
125
  sh "git commit --allow-empty -a -m 'Release #{version}'"
126
- sh "git pull --rebase origin master"
126
+ sh "git pull --rebase origin gollum-lib-5.x"
127
127
  sh "git tag v#{version}"
128
- sh "git push origin master"
128
+ sh "git push origin gollum-lib-5.x"
129
129
  sh "git push origin v#{version}"
130
130
  sh "gem push pkg/#{name}-#{version}.gem"
131
131
  sh "gem push pkg/#{name}-#{version}-java.gem"
data/gemspec.rb CHANGED
@@ -3,12 +3,12 @@ def specification(version, default_adapter, platform = nil)
3
3
  s.specification_version = 2 if s.respond_to? :specification_version=
4
4
  s.required_rubygems_version = Gem::Requirement.new('>= 0') if s.respond_to? :required_rubygems_version=
5
5
  s.rubygems_version = '0.0.1'
6
- s.required_ruby_version = '>= 1.9'
6
+ s.required_ruby_version = '>= 2.1'
7
7
 
8
8
  s.name = 'gollum-lib'
9
9
  s.version = version
10
10
  s.platform = platform if platform
11
- s.date = '2018-10-01'
11
+ s.date = '2017-04-08'
12
12
  s.rubyforge_project = 'gollum-lib'
13
13
  s.license = 'MIT'
14
14
 
@@ -25,20 +25,15 @@ def specification(version, default_adapter, platform = nil)
25
25
  s.extra_rdoc_files = %w(README.md LICENSE)
26
26
 
27
27
  s.add_dependency *default_adapter
28
- s.add_dependency 'rouge', '~> 2.1'
29
- if RUBY_VERSION < '2.1'
30
- s.add_dependency 'nokogiri', '~> 1.6.1'
31
- else
32
- s.add_dependency 'nokogiri', '>= 1.6.1', '< 2.0'
33
- end
28
+ s.add_dependency 'rouge', '~> 2.0'
29
+ s.add_dependency 'nokogiri', '~> 1.7', '>= 1.7.1'
34
30
  s.add_dependency 'stringex', '~> 2.6'
35
- s.add_dependency 'sanitize', '~> 2.1.1', '>= 2.1.1'
31
+ s.add_dependency 'sanitize', '~> 2.1'
36
32
  s.add_dependency 'github-markup', '~> 1.6'
37
33
  s.add_dependency 'gemojione', '~> 3.2'
38
- s.add_dependency 'twitter-text', '1.14.7'
39
34
 
40
35
  s.add_development_dependency 'org-ruby', '~> 0.9.9'
41
- s.add_development_dependency 'kramdown', '~> 1.6.0'
36
+ s.add_development_dependency 'kramdown', '~> 1.13'
42
37
  s.add_development_dependency 'RedCloth', '~> 4.2.9'
43
38
  s.add_development_dependency 'mocha', '~> 1.1.0'
44
39
  s.add_development_dependency 'shoulda', '~> 3.5.0'
@@ -64,6 +59,7 @@ def specification(version, default_adapter, platform = nil)
64
59
  HISTORY.md
65
60
  LICENSE
66
61
  README.md
62
+ ROADMAP
67
63
  Rakefile
68
64
  docs/sanitization.md
69
65
  gemspec.rb
@@ -78,7 +74,6 @@ def specification(version, default_adapter, platform = nil)
78
74
  lib/gollum-lib/filter/code.rb
79
75
  lib/gollum-lib/filter/emoji.rb
80
76
  lib/gollum-lib/filter/macro.rb
81
- lib/gollum-lib/filter/metadata.rb
82
77
  lib/gollum-lib/filter/plain_text.rb
83
78
  lib/gollum-lib/filter/plantuml.rb
84
79
  lib/gollum-lib/filter/remote_code.rb
@@ -87,8 +82,8 @@ def specification(version, default_adapter, platform = nil)
87
82
  lib/gollum-lib/filter/tags.rb
88
83
  lib/gollum-lib/filter/toc.rb
89
84
  lib/gollum-lib/filter/wsd.rb
85
+ lib/gollum-lib/filter/yaml.rb
90
86
  lib/gollum-lib/git_access.rb
91
- lib/gollum-lib/gitcode.rb
92
87
  lib/gollum-lib/helpers.rb
93
88
  lib/gollum-lib/hook.rb
94
89
  lib/gollum-lib/macro.rb
@@ -34,10 +34,6 @@ require File.expand_path('../gollum-lib/markups', __FILE__)
34
34
  require File.expand_path('../gollum-lib/sanitization', __FILE__)
35
35
  require File.expand_path('../gollum-lib/filter', __FILE__)
36
36
 
37
- # Set ruby to UTF-8 mode
38
- # This is required for Ruby 1.8.7 which gollum still supports.
39
- $KCODE = 'U' if RUBY_VERSION[0, 3] == '1.8'
40
-
41
37
  module Gollum
42
38
 
43
39
  def self.assets_path
@@ -86,10 +86,6 @@ module Gollum
86
86
  #
87
87
  # Returns nothing (modifies the Index in place).
88
88
  def add_to_index(dir, name, format, data, allow_same_ext = false)
89
- # spaces must be dashes
90
- dir.gsub!(' ', '-')
91
- name.gsub!(' ', '-')
92
-
93
89
  path = @wiki.page_file_name(name, format)
94
90
 
95
91
  dir = '/' if dir.strip.empty?
@@ -10,13 +10,12 @@ module Gollum
10
10
  # set pages to wiki.pages + wiki.files and show_all to true
11
11
  def initialize(pages, options = {})
12
12
  @pages = pages
13
- @wiki = @pages.first ? @pages.first.wiki : nil
14
13
  @show_all = options[:show_all] || false
15
14
  @checked = options[:collapse_tree] ? '' : "checked"
16
15
  end
17
16
 
18
17
  def enclose_tree(string)
19
- sanitize_html(%Q(<ol class="tree">\n) + string + %Q(</ol>))
18
+ %Q(<ol class="tree">\n) + string + %Q(</ol>)
20
19
  end
21
20
 
22
21
  def new_page(page)
@@ -97,7 +96,7 @@ module Gollum
97
96
  </li>
98
97
  HTML
99
98
 
100
- return enclose_tree(html)
99
+ return enclose_tree html
101
100
  end
102
101
 
103
102
  sorted_folders = []
@@ -154,11 +153,8 @@ module Gollum
154
153
  changed = false
155
154
  end
156
155
 
157
- enclose_tree(html)
156
+ # return the completed html
157
+ enclose_tree html
158
158
  end # end render_files
159
-
160
- def sanitize_html(data)
161
- @wiki ? @wiki.sanitizer.clean(data) : data
162
- end
163
159
  end # end FileView class
164
160
  end # end Gollum module
@@ -5,7 +5,7 @@ class Gollum::Filter::Tags < Gollum::Filter
5
5
  # Extract all tags into the tagmap and replace with placeholders.
6
6
  def extract(data)
7
7
  return data if @markup.format == :txt || @markup.format == :asciidoc
8
- data.gsub!(/(.?)\[\[(.+?)\]\]([^\[]?)/m) do
8
+ data.gsub!(/(.?)\[\[(.+?)\]\]([^\[]?)/) do
9
9
  if Regexp.last_match[1] == "'" && Regexp.last_match[3] != "'"
10
10
  "[[#{Regexp.last_match[2]}]]#{Regexp.last_match[3]}"
11
11
  elsif Regexp.last_match[2].include?('][')
@@ -279,13 +279,13 @@ class Gollum::Filter::Tags < Gollum::Filter
279
279
  parts.reverse! if @markup.reverse_links?
280
280
 
281
281
  name, page_name = *parts.compact.map(&:strip)
282
- cname = @markup.wiki.page_class.cname(page_name || name)
282
+ cname = page_name ? page_name : name.to_s
283
283
 
284
284
  presence = "absent"
285
285
  link_name = cname
286
286
  page, extra = find_page_from_name(cname)
287
287
  if page
288
- link_name = @markup.wiki.page_class.cname(page.name)
288
+ link_name = page.name
289
289
  presence = "present"
290
290
  end
291
291
  link = ::File.join(@markup.wiki.base_path, page ? page.escaped_url_path : CGI.escape(link_name))
@@ -0,0 +1,27 @@
1
+ require 'yaml'
2
+ # Extract YAML frontmatter from data and build metadata table.
3
+
4
+ class Gollum::Filter::YAML < Gollum::Filter
5
+
6
+ # Regexp thanks to jekyll
7
+ YAML_FRONT_MATTER_REGEXP = %r!\A(---\s*\n.*?\n?)^((---|\.\.\.)\s*$\n?)!m
8
+
9
+ def extract(data)
10
+ data.gsub!(YAML_FRONT_MATTER_REGEXP) do
11
+ @markup.metadata ||= {}
12
+ begin
13
+ frontmatter = ::YAML.safe_load(@markup.sanitize.clean(Regexp.last_match[1]))
14
+ @markup.metadata.merge!(frontmatter) if frontmatter.respond_to?(:keys) && frontmatter.respond_to?(:values)
15
+ rescue ::Psych::SyntaxError, ::Psych::DisallowedClass, ::Psych::BadAlias => error
16
+ @markup.metadata['errors'] ||= []
17
+ @markup.metadata['errors'] << "Failed to load YAML frontmater: #{error.message}"
18
+ end
19
+ ''
20
+ end
21
+ data
22
+ end
23
+
24
+ def process(data)
25
+ data
26
+ end
27
+ end
@@ -6,7 +6,7 @@ module Gollum
6
6
  if @wiki.pages.size > 0
7
7
  list_items = @wiki.pages.map do |page|
8
8
  if page.url_path.start_with?(toc_root_path)
9
- path_display = full_path ? page.url_path_display : page.url_path_display.sub(toc_root_path.gsub("-", " "), "").sub(/^\//,'')
9
+ path_display = full_path ? page.url_path_display : page.url_path_display.sub(toc_root_path,"").sub(/^\//,'')
10
10
  "<li><a href=\"/#{page.url_path}\">#{path_display}</a></li>"
11
11
  end
12
12
  end
@@ -31,7 +31,7 @@ module Gollum
31
31
  end
32
32
  end
33
33
 
34
- # Register a file extension and associated markup type
34
+ # Register a file format
35
35
  #
36
36
  # ext - The file extension
37
37
  # name - The name of the markup type
@@ -99,7 +99,7 @@ module Gollum
99
99
  @format = format
100
100
  @name = name
101
101
 
102
- chain = [:Metadata, :PlainText, :Emoji, :TOC, :RemoteCode, :Code, :Sanitize, :WSD, :Tags, :Render]
102
+ chain = [:YAML, :PlainText, :Emoji, :TOC, :RemoteCode, :Code, :Sanitize, :WSD, :Tags, :Render]
103
103
 
104
104
  filter_chain = chain.map do |r|
105
105
  Gollum::Filter.const_get(r).new(self)
@@ -3,7 +3,7 @@ module Gollum
3
3
  class Markup
4
4
 
5
5
  GitHub::Markup::Markdown::MARKDOWN_GEMS['kramdown'] = proc { |content|
6
- Kramdown::Document.new(content, :auto_ids => false, :input => "markdown").to_html
6
+ Kramdown::Document.new(content, :auto_ids => false, :smart_quotes => ["'", "'", '"', '"'].map{|char| char.codepoints.first}).to_html
7
7
  }
8
8
 
9
9
  register(:markdown, "Markdown", :regexp => /md|mkdn?|mdown|markdown/)
@@ -17,29 +17,25 @@ module Gollum
17
17
  # Returns a Page
18
18
  attr_accessor :parent_page
19
19
 
20
-
21
- # Checks a filename against the registered markup extensions
20
+ # Find the Symbol format for the file extension
22
21
  #
23
- # filename - String filename, like "Home.md"
22
+ # ext - String file extension, like ".md"
24
23
  #
25
- # Returns e.g. ["Home", :markdown], or [] if the extension is unregistered
26
- def self.parse_filename(filename)
27
- return [] unless filename =~ /^(.+)\.([a-zA-Z]\w*)$/i
28
- pref, ext = Regexp.last_match[1], Regexp.last_match[2]
29
-
24
+ # Returns the Symbol format associated with ext
25
+ def self.parse_extension(ext)
30
26
  Gollum::Markup.formats.each_pair do |name, format|
31
- return [pref, name] if ext =~ format[:regexp]
27
+ return name if ext =~ format[:regexp]
32
28
  end
33
- []
29
+ nil
34
30
  end
35
31
 
36
32
  # Checks if a filename has a valid, registered extension
37
33
  #
38
34
  # filename - String filename, like "Home.md".
39
35
  #
40
- # Returns the matching String basename of the file without the extension.
41
- def self.valid_filename?(filename)
42
- self.parse_filename(filename).first
36
+ # Returns true or false.
37
+ def self.valid_extension?(filename)
38
+ !!self.parse_extension(::File.extname(filename))
43
39
  end
44
40
 
45
41
  # Checks if a filename has a valid extension understood by GitHub::Markup.
@@ -48,10 +44,9 @@ module Gollum
48
44
  #
49
45
  # filename - String filename, like "Home.md".
50
46
  #
51
- # Returns the matching String basename of the file without the extension.
47
+ # Returns true or false.
52
48
  def self.valid_page_name?(filename)
53
- match = valid_filename?(filename)
54
- filename =~ /^_/ ? false : match
49
+ !(filename =~ /^_/) && self.valid_extension?(filename)
55
50
  end
56
51
 
57
52
  # Public: The format of a given filename.
@@ -60,15 +55,15 @@ module Gollum
60
55
  #
61
56
  # Returns the Symbol format of the page; one of the registered format types
62
57
  def self.format_for(filename)
63
- self.parse_filename(filename).last
58
+ self.parse_extension(::File.extname(filename))
64
59
  end
65
60
 
66
61
  # Reusable filter to turn a filename (without path) into a canonical name.
67
- # Strips extension, converts dashes to spaces.
62
+ # Strips extension, convert to string if possible.
68
63
  #
69
64
  # Returns the filtered String.
70
65
  def self.canonicalize_filename(filename)
71
- strip_filename(filename).gsub('-', ' ')
66
+ self.strip_filename(filename.to_s)
72
67
  end
73
68
 
74
69
  # Reusable filter to strip extension and path from filename
@@ -107,8 +102,7 @@ module Gollum
107
102
  self.class.strip_filename(filename)
108
103
  end
109
104
 
110
- # Public: The canonical page name without extension, and dashes converted
111
- # to spaces.
105
+ # Public: The canonical page name without extension.
112
106
  #
113
107
  # Returns the String name.
114
108
  def name
@@ -116,8 +110,7 @@ module Gollum
116
110
  end
117
111
 
118
112
  # Public: The title will be constructed from the
119
- # filename by stripping the extension and replacing any dashes with
120
- # spaces.
113
+ # filename by stripping the extension.
121
114
  #
122
115
  # Returns the fully sanitized String title.
123
116
  def title
@@ -147,7 +140,7 @@ module Gollum
147
140
  ''
148
141
  end
149
142
 
150
- path << Page.cname(self.name, '-', '-')
143
+ path << self.name
151
144
  path
152
145
  end
153
146
 
@@ -155,14 +148,14 @@ module Gollum
155
148
  #
156
149
  # Returns the String url_path
157
150
  def url_path_display
158
- url_path.gsub("-", " ")
151
+ url_path
159
152
  end
160
153
 
161
154
  # Public: Defines title for page.rb
162
155
  #
163
156
  # Returns the String title
164
157
  def url_path_title
165
- metadata_title || url_path_display
158
+ metadata_title || url_path
166
159
  end
167
160
 
168
161
  # Public: Metadata title
@@ -179,6 +172,13 @@ module Gollum
179
172
  nil
180
173
  end
181
174
 
175
+ # Public: Whether or not to display the metadata
176
+ def display_metadata?
177
+ return false if metadata.empty? || (metadata.size == 1 && metadata['title'])
178
+ return false if metadata['display_metadata'] == false
179
+ @wiki.display_metadata
180
+ end
181
+
182
182
  # Public: The url_path, but CGI escaped.
183
183
  #
184
184
  # Returns the String url_path
@@ -224,7 +224,7 @@ module Gollum
224
224
  if @formatted_data && @doc then
225
225
  yield @doc if block_given?
226
226
  else
227
- @formatted_data = markup_class.render(historical?, encoding, include_levels) do |doc|
227
+ @formatted_data = markup.render(historical?, encoding, include_levels) do |doc|
228
228
  @doc = doc
229
229
  yield doc if block_given?
230
230
  end
@@ -240,16 +240,16 @@ module Gollum
240
240
  # Returns the String data.
241
241
  def toc_data
242
242
  return @parent_page.toc_data if @parent_page and @sub_page
243
- formatted_data if markup_class.toc == nil
244
- markup_class.toc
243
+ formatted_data if markup.toc == nil
244
+ markup.toc
245
245
  end
246
246
 
247
247
  # Public: Embedded metadata.
248
248
  #
249
249
  # Returns Hash of metadata.
250
250
  def metadata
251
- formatted_data if markup_class.metadata == nil
252
- markup_class.metadata
251
+ formatted_data if markup.metadata == nil
252
+ markup.metadata || {}
253
253
  end
254
254
 
255
255
  # Public: The format of the page.
@@ -262,8 +262,8 @@ module Gollum
262
262
  # Gets the Gollum::Markup instance that will render this page's content.
263
263
  #
264
264
  # Returns a Gollum::Markup instance.
265
- def markup_class
266
- @markup_class ||= @wiki.markup_classes[format].new(self)
265
+ def markup
266
+ @markup ||= @wiki.markup_classes[format].new(self)
267
267
  end
268
268
 
269
269
  # Public: The current version of the page.
@@ -331,33 +331,6 @@ module Gollum
331
331
  !!@historical
332
332
  end
333
333
 
334
- #########################################################################
335
- #
336
- # Class Methods
337
- #
338
- #########################################################################
339
-
340
- # Convert a human page name into a canonical page name.
341
- #
342
- # name - The String human page name.
343
- # char_white_sub - Substitution for whitespace
344
- # char_other_sub - Substitution for other special chars
345
- #
346
- # Examples
347
- #
348
- # Page.cname("Bilbo Baggins")
349
- # # => 'Bilbo-Baggins'
350
- #
351
- # Page.cname("Bilbo Baggins",'_')
352
- # # => 'Bilbo_Baggins'
353
- #
354
- # Returns the String canonical name.
355
- def self.cname(name, char_white_sub = '-', char_other_sub = '-')
356
- name.respond_to?(:gsub) ?
357
- name.gsub(%r(\s), char_white_sub).gsub(%r([<>+]), char_other_sub) :
358
- ''
359
- end
360
-
361
334
  # Convert a format Symbol into an extension String.
362
335
  #
363
336
  # format - The format Symbol.
@@ -413,12 +386,13 @@ module Gollum
413
386
 
414
387
  checked_dir = BlobEntry.normalize_dir(checked_dir)
415
388
  checked_dir = '' if exact && checked_dir.nil?
416
- name = ::File.join(checked_dir, name) if checked_dir
389
+ query = checked_dir ? ::File.join(checked_dir, name) : name
417
390
 
418
391
  map.each do |entry|
419
- next if entry.name.to_s.empty?
420
- path = checked_dir ? ::File.join(entry.dir, entry.name) : entry.name
421
- next unless page_match(name, path)
392
+ next if entry.name.to_s.empty? || !self.class.valid_extension?(entry.name)
393
+ entry_name = ::File.extname(name).empty? ? Page.canonicalize_filename(entry.name) : entry.name
394
+ path = checked_dir ? ::File.join(entry.dir, entry_name) : entry_name
395
+ next unless query.downcase == path.downcase
422
396
  return entry.page(@wiki, @version)
423
397
  end
424
398
 
@@ -451,22 +425,6 @@ module Gollum
451
425
  end
452
426
  end
453
427
 
454
- # Compare the canonicalized versions of the two names.
455
- #
456
- # name - The human or canonical String page name.
457
- # path - the String path on disk (including file extension).
458
- #
459
- # Returns a Boolean.
460
- def page_match(name, path)
461
- if (match = self.class.valid_filename?(path))
462
- @wiki.ws_subs.each do |sub|
463
- return true if Page.cname(name).downcase == Page.cname(match, sub).downcase
464
- end
465
- end
466
- false
467
- end
468
-
469
-
470
428
  # Loads sub pages. Sub page names (footers, headers, sidebars) are prefixed with
471
429
  # an underscore to distinguish them from other Pages. If there is not one within
472
430
  # the current directory, starts walking up the directory tree to try and find one
@@ -495,9 +453,7 @@ module Gollum
495
453
  end
496
454
 
497
455
  if subpageblob
498
- subpage = subpageblob.page(@wiki, @version)
499
- subpage.parent_page = self
500
- instance_variable_set("@#{subpagename}", subpage)
456
+ instance_variable_set("@#{subpagename}", subpageblob.page(@wiki, @version) )
501
457
  break
502
458
  end
503
459
 
@@ -1,5 +1,5 @@
1
1
  module Gollum
2
2
  module Lib
3
- VERSION = '4.2.10'
3
+ VERSION = '5.0.a.1'
4
4
  end
5
- end
5
+ end
@@ -22,9 +22,6 @@ module Gollum
22
22
  # Sets the default email for commits.
23
23
  attr_writer :default_committer_email
24
24
 
25
- # Array of chars to substitute whitespace for when trying to locate file in git repo.
26
- attr_writer :default_ws_subs
27
-
28
25
  # Sets sanitization options. Set to false to deactivate
29
26
  # sanitization altogether.
30
27
  attr_writer :sanitization
@@ -118,10 +115,6 @@ module Gollum
118
115
  @default_committer_email || 'anon@anon.com'
119
116
  end
120
117
 
121
- def default_ws_subs
122
- @default_ws_subs || ['_', '-']
123
- end
124
-
125
118
  def default_options
126
119
  @default_options || {}
127
120
  end
@@ -144,9 +137,6 @@ module Gollum
144
137
  # Gets the String directory in which all page files reside.
145
138
  attr_reader :page_file_dir
146
139
 
147
- # Gets the Array of chars to sub for ws in filenames.
148
- attr_reader :ws_subs
149
-
150
140
  # Gets the boolean live preview value.
151
141
  attr_reader :live_preview
152
142
 
@@ -158,6 +148,10 @@ module Gollum
158
148
  # Defaults to false
159
149
  attr_reader :h1_title
160
150
 
151
+ # Whether or not to render a page's metadata on the page
152
+ # Defaults to true
153
+ attr_reader :display_metadata
154
+
161
155
  # Gets the custom index page for / and subdirs (e.g. foo/)
162
156
  attr_reader :index_page
163
157
 
@@ -186,7 +180,6 @@ module Gollum
186
180
  # :sanitization - An instance of Sanitization.
187
181
  # :page_file_dir - String the directory in which all page files reside
188
182
  # :ref - String the repository ref to retrieve pages from
189
- # :ws_subs - Array of chars to sub for ws in filenames.
190
183
  # :mathjax - Set to false to disable mathjax.
191
184
  # :user_icons - Enable user icons on the history page. [gravatar, identicon, none].
192
185
  # Default: none
@@ -197,6 +190,7 @@ module Gollum
197
190
  # :emoji - Parse and interpret emoji tags (e.g. :heart:).
198
191
  # :h1_title - Concatenate all h1's on a page to form the
199
192
  # page title.
193
+ # :display_metadata - Whether or not to render a page's metadata on the page. Default: true
200
194
  # :index_page - The default page to retrieve or create if the
201
195
  # a directory is accessed.
202
196
  # :bar_side - Where the sidebar should be displayed, may be:
@@ -233,7 +227,6 @@ module Gollum
233
227
  @repo = @access.repo
234
228
  @ref = options.fetch :ref, self.class.default_ref
235
229
  @sanitization = options.fetch :sanitization, self.class.sanitization
236
- @ws_subs = options.fetch :ws_subs, self.class.default_ws_subs
237
230
  @history_sanitization = options.fetch :history_sanitization, self.class.history_sanitization
238
231
  @live_preview = options.fetch :live_preview, true
239
232
  @universal_toc = options.fetch :universal_toc, false
@@ -243,6 +236,7 @@ module Gollum
243
236
  @css = options.fetch :css, false
244
237
  @emoji = options.fetch :emoji, false
245
238
  @h1_title = options.fetch :h1_title, false
239
+ @display_metadata = options.fetch :display_metadata, true
246
240
  @index_page = options.fetch :index_page, 'Home'
247
241
  @bar_side = options.fetch :sidebar, :right
248
242
  @user_icons = ['gravatar', 'identicon'].include?(options[:user_icons]) ?
@@ -250,7 +244,7 @@ module Gollum
250
244
  @allow_uploads = options.fetch :allow_uploads, false
251
245
  @per_page_uploads = options.fetch :per_page_uploads, false
252
246
  @filter_chain = options.fetch :filter_chain,
253
- [:Metadata, :PlainText, :TOC, :RemoteCode, :Code, :Macro, :Emoji, :Sanitize, :WSD, :PlantUML, :Tags, :Render]
247
+ [:YAML, :PlainText, :TOC, :RemoteCode, :Code, :Macro, :Emoji, :Sanitize, :WSD, :PlantUML, :Tags, :Render]
254
248
  @filter_chain.delete(:Emoji) unless options.fetch :emoji, false
255
249
  end
256
250
 
@@ -310,8 +304,8 @@ module Gollum
310
304
  def preview_page(name, data, format)
311
305
  page = @page_class.new(self)
312
306
  ext = @page_class.format_to_ext(format.to_sym)
313
- name = @page_class.cname(name) + '.' + ext
314
- blob = OpenStruct.new(:name => name, :data => data, :is_symlink => false)
307
+ filename = "#{name}.#{ext}"
308
+ blob = OpenStruct.new(:name => filename, :data => data, :is_symlink => false)
315
309
  page.populate(blob)
316
310
  page.version = @access.commit(@ref)
317
311
  page
@@ -337,21 +331,15 @@ module Gollum
337
331
  # Returns the String SHA1 of the newly written version, or the
338
332
  # Gollum::Committer instance if this is part of a batch update.
339
333
  def write_page(name, format, data, commit = {}, dir = '')
340
- # spaces must be dashes
341
- sanitized_name = name.gsub(' ', '-')
342
- sanitized_dir = dir.gsub(' ', '-')
343
- sanitized_dir = ::File.join([@page_file_dir, sanitized_dir].compact)
334
+ sanitized_dir = ::File.join([@page_file_dir, dir].compact)
344
335
 
345
336
  multi_commit = !!commit[:committer]
346
337
  committer = multi_commit ? commit[:committer] : Committer.new(self, commit)
347
-
348
- filename = Gollum::Page.cname(sanitized_name)
349
-
350
- committer.add_to_index(sanitized_dir, filename, format, data)
338
+ committer.add_to_index(sanitized_dir, name, format, data)
351
339
 
352
340
  committer.after_commit do |index, _sha|
353
341
  @access.refresh
354
- index.update_working_dir(sanitized_dir, filename, format)
342
+ index.update_working_dir(sanitized_dir, name, format)
355
343
  end
356
344
 
357
345
  multi_commit ? committer : committer.commit
@@ -436,7 +424,7 @@ module Gollum
436
424
  dir = ::File.dirname(page.path)
437
425
  dir = '' if dir == '.'
438
426
  filename = (rename = page.name != name) ?
439
- Gollum::Page.cname(name) : page.filename_stripped
427
+ name : page.filename_stripped
440
428
 
441
429
  multi_commit = !!commit[:committer]
442
430
  committer = multi_commit ? commit[:committer] : Committer.new(self, commit)
@@ -651,9 +639,9 @@ module Gollum
651
639
  results[file_name] = count.to_i
652
640
  end
653
641
 
654
- # Use git ls-files '*query*' to search for file names. Grep only searches file content.
642
+ # Use ls_files '*query*' to search for file names. Grep only searches file content.
655
643
  # Spaces are converted to dashes when saving pages to disk.
656
- @repo.git.ls_files(query.gsub(' ','-'), options).each do |path|
644
+ @repo.git.ls_files(query, options).each do |path|
657
645
  # Remove ext only from known extensions.
658
646
  file_name = Page::valid_page_name?(path) ? path.chomp(::File.extname(path)) : path
659
647
  # If there's not already a result for file_name then
@@ -848,7 +836,7 @@ module Gollum
848
836
  #
849
837
  # Returns the String filename.
850
838
  def page_file_name(name, format)
851
- name + '.' + @page_class.format_to_ext(format)
839
+ "#{name}.#{@page_class.format_to_ext(format)}"
852
840
  end
853
841
 
854
842
  # Fill an array with a list of pages.
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.2.10
4
+ version: 5.0.a.1
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: 2018-10-01 00:00:00.000000000 Z
12
+ date: 2017-04-08 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: gollum-rjgit_adapter
@@ -31,34 +31,34 @@ dependencies:
31
31
  requirements:
32
32
  - - "~>"
33
33
  - !ruby/object:Gem::Version
34
- version: '2.1'
34
+ version: '2.0'
35
35
  type: :runtime
36
36
  prerelease: false
37
37
  version_requirements: !ruby/object:Gem::Requirement
38
38
  requirements:
39
39
  - - "~>"
40
40
  - !ruby/object:Gem::Version
41
- version: '2.1'
41
+ version: '2.0'
42
42
  - !ruby/object:Gem::Dependency
43
43
  name: nokogiri
44
44
  requirement: !ruby/object:Gem::Requirement
45
45
  requirements:
46
- - - ">="
46
+ - - "~>"
47
47
  - !ruby/object:Gem::Version
48
- version: 1.6.1
49
- - - "<"
48
+ version: '1.7'
49
+ - - ">="
50
50
  - !ruby/object:Gem::Version
51
- version: '2.0'
51
+ version: 1.7.1
52
52
  type: :runtime
53
53
  prerelease: false
54
54
  version_requirements: !ruby/object:Gem::Requirement
55
55
  requirements:
56
- - - ">="
56
+ - - "~>"
57
57
  - !ruby/object:Gem::Version
58
- version: 1.6.1
59
- - - "<"
58
+ version: '1.7'
59
+ - - ">="
60
60
  - !ruby/object:Gem::Version
61
- version: '2.0'
61
+ version: 1.7.1
62
62
  - !ruby/object:Gem::Dependency
63
63
  name: stringex
64
64
  requirement: !ruby/object:Gem::Requirement
@@ -79,20 +79,14 @@ dependencies:
79
79
  requirements:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
- version: 2.1.1
83
- - - ">="
84
- - !ruby/object:Gem::Version
85
- version: 2.1.1
82
+ version: '2.1'
86
83
  type: :runtime
87
84
  prerelease: false
88
85
  version_requirements: !ruby/object:Gem::Requirement
89
86
  requirements:
90
87
  - - "~>"
91
88
  - !ruby/object:Gem::Version
92
- version: 2.1.1
93
- - - ">="
94
- - !ruby/object:Gem::Version
95
- version: 2.1.1
89
+ version: '2.1'
96
90
  - !ruby/object:Gem::Dependency
97
91
  name: github-markup
98
92
  requirement: !ruby/object:Gem::Requirement
@@ -121,20 +115,6 @@ dependencies:
121
115
  - - "~>"
122
116
  - !ruby/object:Gem::Version
123
117
  version: '3.2'
124
- - !ruby/object:Gem::Dependency
125
- name: twitter-text
126
- requirement: !ruby/object:Gem::Requirement
127
- requirements:
128
- - - '='
129
- - !ruby/object:Gem::Version
130
- version: 1.14.7
131
- type: :runtime
132
- prerelease: false
133
- version_requirements: !ruby/object:Gem::Requirement
134
- requirements:
135
- - - '='
136
- - !ruby/object:Gem::Version
137
- version: 1.14.7
138
118
  - !ruby/object:Gem::Dependency
139
119
  name: org-ruby
140
120
  requirement: !ruby/object:Gem::Requirement
@@ -155,14 +135,14 @@ dependencies:
155
135
  requirements:
156
136
  - - "~>"
157
137
  - !ruby/object:Gem::Version
158
- version: 1.6.0
138
+ version: '1.13'
159
139
  type: :development
160
140
  prerelease: false
161
141
  version_requirements: !ruby/object:Gem::Requirement
162
142
  requirements:
163
143
  - - "~>"
164
144
  - !ruby/object:Gem::Version
165
- version: 1.6.0
145
+ version: '1.13'
166
146
  - !ruby/object:Gem::Dependency
167
147
  name: RedCloth
168
148
  requirement: !ruby/object:Gem::Requirement
@@ -399,6 +379,7 @@ files:
399
379
  - HISTORY.md
400
380
  - LICENSE
401
381
  - README.md
382
+ - ROADMAP
402
383
  - Rakefile
403
384
  - docs/sanitization.md
404
385
  - gemspec.rb
@@ -413,7 +394,6 @@ files:
413
394
  - lib/gollum-lib/filter/code.rb
414
395
  - lib/gollum-lib/filter/emoji.rb
415
396
  - lib/gollum-lib/filter/macro.rb
416
- - lib/gollum-lib/filter/metadata.rb
417
397
  - lib/gollum-lib/filter/plain_text.rb
418
398
  - lib/gollum-lib/filter/plantuml.rb
419
399
  - lib/gollum-lib/filter/remote_code.rb
@@ -422,8 +402,8 @@ files:
422
402
  - lib/gollum-lib/filter/tags.rb
423
403
  - lib/gollum-lib/filter/toc.rb
424
404
  - lib/gollum-lib/filter/wsd.rb
405
+ - lib/gollum-lib/filter/yaml.rb
425
406
  - lib/gollum-lib/git_access.rb
426
- - lib/gollum-lib/gitcode.rb
427
407
  - lib/gollum-lib/helpers.rb
428
408
  - lib/gollum-lib/hook.rb
429
409
  - lib/gollum-lib/macro.rb
@@ -452,15 +432,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
452
432
  requirements:
453
433
  - - ">="
454
434
  - !ruby/object:Gem::Version
455
- version: '1.9'
435
+ version: '2.1'
456
436
  required_rubygems_version: !ruby/object:Gem::Requirement
457
437
  requirements:
458
- - - ">="
438
+ - - ">"
459
439
  - !ruby/object:Gem::Version
460
- version: '0'
440
+ version: 1.3.1
461
441
  requirements: []
462
442
  rubyforge_project: gollum-lib
463
- rubygems_version: 2.7.7
443
+ rubygems_version: 2.6.11
464
444
  signing_key:
465
445
  specification_version: 2
466
446
  summary: A simple, Git-powered wiki.
@@ -1,29 +0,0 @@
1
- # Extract metadata for data and build metadata table. Metadata consists of
2
- # key/value pairs in "key:value" format found between markers. Each
3
- # key/value pair must be on its own line. Internal whitespace in keys and
4
- # values is preserved, but external whitespace is ignored.
5
- #
6
- # Because ri and ruby 1.8.7 are awesome, the markers can't
7
- # be included in this documentation without triggering
8
- # `Unhandled special: Special: type=17`
9
- # Please read the source code for the exact markers
10
- class Gollum::Filter::Metadata < Gollum::Filter
11
- def extract(data)
12
- # The markers are `<!-- ---` and `-->`
13
- data.gsub(/\<\!--+\s+---(.*?)--+\>/m) do
14
- @markup.metadata ||= {}
15
- # Split untrusted input on newlines, then remove bits that look like
16
- # HTML elements before parsing each line.
17
- Regexp.last_match[1].split("\n").each do |line|
18
- line.gsub!(/<[^>]*>/, '')
19
- k, v = line.split(':', 2)
20
- @markup.metadata[k.strip] = (v ? v.strip : '') if k
21
- end
22
- ''
23
- end
24
- end
25
-
26
- def process(data)
27
- data
28
- end
29
- end
@@ -1,48 +0,0 @@
1
- # ~*~ encoding: utf-8 ~*~
2
- require 'net/http'
3
- require 'net/https' # ruby 1.8.7 fix, remove at upgrade
4
- require 'uri'
5
- require 'open-uri'
6
-
7
- module Gollum
8
- class Gitcode
9
- def initialize(path)
10
- raise(ArgumentError, 'path is nil or empty') if path.nil? or path.empty?
11
-
12
- @uri = URI::HTTP.build({
13
- :path => self.unchomp(path),
14
- :host => 'raw.github.com',
15
- :scheme => 'https',
16
- :port => 443 })
17
- end
18
-
19
- def contents
20
- @contents ||= self.req @uri
21
- end
22
-
23
- def unchomp(p)
24
- return p if p.nil?
25
- p[0] == '/' ? p : ('/' + p)
26
- end
27
-
28
- def req(uri, cut = 1)
29
- return "Too many redirects or retries" if cut >= 10
30
- http = Net::HTTP.new uri.host, uri.port
31
- http.use_ssl = true
32
- resp = http.get uri.path, {
33
- 'Accept' => 'text/plain',
34
- 'Cache-Control' => 'no-cache',
35
- 'Connection' => 'keep-alive',
36
- 'Host' => uri.host,
37
- 'User-Agent' => 'Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:15.0) Gecko/20100101 Firefox/15.0'
38
- }
39
- code = resp.code.to_i
40
- return resp.body if code == 200
41
- return "Not Found" if code == 404
42
- return "Unhandled Response Code #{code}" unless code == 304 or not resp.header['location'].nil?
43
- loc = URI.parse resp.header['location']
44
- uri2 = loc.relative?() ? (uri + loc) : loc # overloads (+)
45
- return req uri2, (cut + 1)
46
- end
47
- end
48
- end