gollum-lib 5.0.a.1-java → 5.0.a.2-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/gemspec.rb +1 -1
- data/lib/gollum-lib/committer.rb +2 -4
- data/lib/gollum-lib/macro/global_toc.rb +1 -1
- data/lib/gollum-lib/macro/navigation.rb +1 -1
- data/lib/gollum-lib/markup.rb +18 -4
- data/lib/gollum-lib/markups.rb +53 -12
- data/lib/gollum-lib/page.rb +24 -40
- data/lib/gollum-lib/version.rb +2 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: eafda74f78c96ad24495b806bbb508b17b079bf9
|
4
|
+
data.tar.gz: 6f8d3e18f17d31d204d562b72b3f79e2dde9b9d3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ee2d771bd18e399272e8a1b2f00cd13d50a2e64c49e198d980bc2851db17e6f8ea278fcd3fb731a7017110f6d7481f5e9818d0f0f55cc3490f99d46d3ddcd09a
|
7
|
+
data.tar.gz: d4ba9285af6a115a10f4bd1438070c0d76dcf0cc7aaea0b76a7b5540a3b6753130f6875171c66f7d3ac9aa2b7d53e8e3f0edab66d84b4a21be9179fd935166d7
|
data/gemspec.rb
CHANGED
data/lib/gollum-lib/committer.rb
CHANGED
@@ -78,14 +78,12 @@ module Gollum
|
|
78
78
|
# name - The String Gollum::Page filename_stripped.
|
79
79
|
# format - The Symbol Gollum::Page format.
|
80
80
|
# data - The String wiki data to store in the tree map.
|
81
|
-
# allow_same_ext - A Boolean determining if the tree map allows the same
|
82
|
-
# filename with the same extension.
|
83
81
|
#
|
84
82
|
# Raises Gollum::DuplicatePageError if a matching filename already exists.
|
85
83
|
# This way, pages are not inadvertently overwritten.
|
86
84
|
#
|
87
85
|
# Returns nothing (modifies the Index in place).
|
88
|
-
def add_to_index(dir, name, format, data
|
86
|
+
def add_to_index(dir, name, format, data)
|
89
87
|
path = @wiki.page_file_name(name, format)
|
90
88
|
|
91
89
|
dir = '/' if dir.strip.empty?
|
@@ -108,7 +106,7 @@ module Gollum
|
|
108
106
|
|
109
107
|
new_file_ext = ::File.extname(path).sub(/^\./, '')
|
110
108
|
|
111
|
-
if downpath == existing_file &&
|
109
|
+
if downpath == existing_file && (new_file_ext == existing_file_ext)
|
112
110
|
raise DuplicatePageError.new(dir, blob.name, path)
|
113
111
|
end
|
114
112
|
end
|
@@ -3,7 +3,7 @@ module Gollum
|
|
3
3
|
class GlobalTOC < Gollum::Macro
|
4
4
|
def render(title = "Global Table of Contents")
|
5
5
|
if @wiki.pages.size > 0
|
6
|
-
result = '<ul>' + @wiki.pages.map { |p| "<li><a href=\"/#{p.url_path}\">#{p.
|
6
|
+
result = '<ul>' + @wiki.pages.map { |p| "<li><a href=\"/#{p.url_path}\">#{p.url_path}</a></li>" }.join + '</ul>'
|
7
7
|
end
|
8
8
|
"<div class=\"toc\"><div class=\"toc-title\">#{title}</div>#{result}</div>"
|
9
9
|
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.
|
9
|
+
path_display = full_path ? page.url_path_display : page.url_path.sub(toc_root_path,"").sub(/^\//,'')
|
10
10
|
"<li><a href=\"/#{page.url_path}\">#{path_display}</a></li>"
|
11
11
|
end
|
12
12
|
end
|
data/lib/gollum-lib/markup.rb
CHANGED
@@ -19,6 +19,7 @@ module Gollum
|
|
19
19
|
include Helpers
|
20
20
|
|
21
21
|
@formats = {}
|
22
|
+
@extensions = []
|
22
23
|
|
23
24
|
class << self
|
24
25
|
|
@@ -31,20 +32,33 @@ module Gollum
|
|
31
32
|
end
|
32
33
|
end
|
33
34
|
|
35
|
+
def extensions
|
36
|
+
@extensions
|
37
|
+
end
|
38
|
+
|
34
39
|
# Register a file format
|
35
40
|
#
|
36
41
|
# ext - The file extension
|
37
42
|
# name - The name of the markup type
|
38
43
|
# options - Hash of options:
|
39
|
-
#
|
40
|
-
#
|
44
|
+
# extensions - Array of valid file extensions, for instance ['md']
|
45
|
+
# enabled - Whether the markup is enabled
|
41
46
|
#
|
42
47
|
# If given a block, that block will be registered with GitHub::Markup to
|
43
48
|
# render any matching pages
|
44
49
|
def register(ext, name, options = {}, &block)
|
50
|
+
if options[:regexp] then
|
51
|
+
STDERR.puts <<-EOS
|
52
|
+
Warning: attempted to register a markup (name: #{name.to_s}) by passing the deprecated :regexp option.
|
53
|
+
Please pass an Array of valid file extensions (:extensions => ['ext1', 'ext2']) instead.
|
54
|
+
EOS
|
55
|
+
end
|
56
|
+
new_extension = options.fetch(:extensions, [ext.to_s])
|
45
57
|
@formats[ext] = { :name => name,
|
46
|
-
:
|
47
|
-
:reverse_links => options.fetch(:reverse_links, false)
|
58
|
+
:extensions => new_extension,
|
59
|
+
:reverse_links => options.fetch(:reverse_links, false),
|
60
|
+
:enabled => options.fetch(:enabled, true) }
|
61
|
+
@extensions.concat(new_extension)
|
48
62
|
end
|
49
63
|
end
|
50
64
|
|
data/lib/gollum-lib/markups.rb
CHANGED
@@ -1,20 +1,61 @@
|
|
1
1
|
# ~*~ encoding: utf-8 ~*~
|
2
|
+
|
3
|
+
require "pathname"
|
4
|
+
|
5
|
+
module Gollum
|
6
|
+
module MarkupRegisterUtils
|
7
|
+
# Check if a gem exists. This implementation requires Gem::Specificaton to
|
8
|
+
# be filled.
|
9
|
+
def gem_exists?(name)
|
10
|
+
Gem::Specification.find {|spec| spec.name == name} != nil
|
11
|
+
end
|
12
|
+
|
13
|
+
# Check if an executable exists. This implementation comes from
|
14
|
+
# stackoverflow question 2108727.
|
15
|
+
def executable_exists?(name)
|
16
|
+
exts = ENV["PATHEXT"] ? ENV["PATHEXT"].split(";") : [""]
|
17
|
+
paths = ENV["PATH"].split(::File::PATH_SEPARATOR)
|
18
|
+
paths.each do |path|
|
19
|
+
exts.each do |ext|
|
20
|
+
exe = Pathname(path) + "#{name}#{ext}"
|
21
|
+
return true if exe.executable?
|
22
|
+
end
|
23
|
+
end
|
24
|
+
return false
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
include Gollum::MarkupRegisterUtils
|
30
|
+
|
2
31
|
module Gollum
|
3
32
|
class Markup
|
4
|
-
|
5
33
|
GitHub::Markup::Markdown::MARKDOWN_GEMS['kramdown'] = proc { |content|
|
6
34
|
Kramdown::Document.new(content, :auto_ids => false, :smart_quotes => ["'", "'", '"', '"'].map{|char| char.codepoints.first}).to_html
|
7
35
|
}
|
8
36
|
|
9
|
-
|
10
|
-
register(:
|
11
|
-
register(:rdoc,
|
12
|
-
register(:
|
13
|
-
|
14
|
-
|
15
|
-
register(:
|
16
|
-
|
17
|
-
register(:
|
18
|
-
|
37
|
+
# markdown, rdoc, and plain text are always supported.
|
38
|
+
register(:markdown, "Markdown", :extensions => ['md','mkd','mkdn','mdown','markdown'])
|
39
|
+
register(:rdoc, "RDoc")
|
40
|
+
register(:txt, "Plain Text")
|
41
|
+
# the following formats are available only when certain gem is installed
|
42
|
+
# or certain program exists.
|
43
|
+
register(:textile, "Textile",
|
44
|
+
:enabled => MarkupRegisterUtils::gem_exists?("RedCloth"))
|
45
|
+
register(:org, "Org-mode",
|
46
|
+
:enabled => MarkupRegisterUtils::gem_exists?("org-ruby"))
|
47
|
+
register(:creole, "Creole",
|
48
|
+
:enabled => MarkupRegisterUtils::gem_exists?("creole"),
|
49
|
+
:reverse_links => true)
|
50
|
+
register(:rest, "reStructuredText",
|
51
|
+
:enabled => MarkupRegisterUtils::executable_exists?("python2"),
|
52
|
+
:extensions => ['rest', 'rst', 'rst.txt', 'rest.txt'])
|
53
|
+
register(:asciidoc, "AsciiDoc",
|
54
|
+
:enabled => MarkupRegisterUtils::gem_exists?("asciidoctor"))
|
55
|
+
register(:mediawiki, "MediaWiki",
|
56
|
+
:enabled => MarkupRegisterUtils::gem_exists?("wikicloth"),
|
57
|
+
:extensions => ['mediawiki','wiki'], :reverse_links => true)
|
58
|
+
register(:pod, "Pod",
|
59
|
+
:enabled => MarkupRegisterUtils::executable_exists?("perl"))
|
19
60
|
end
|
20
|
-
end
|
61
|
+
end
|
data/lib/gollum-lib/page.rb
CHANGED
@@ -17,25 +17,13 @@ module Gollum
|
|
17
17
|
# Returns a Page
|
18
18
|
attr_accessor :parent_page
|
19
19
|
|
20
|
-
# Find the Symbol format for the file extension
|
21
|
-
#
|
22
|
-
# ext - String file extension, like ".md"
|
23
|
-
#
|
24
|
-
# Returns the Symbol format associated with ext
|
25
|
-
def self.parse_extension(ext)
|
26
|
-
Gollum::Markup.formats.each_pair do |name, format|
|
27
|
-
return name if ext =~ format[:regexp]
|
28
|
-
end
|
29
|
-
nil
|
30
|
-
end
|
31
|
-
|
32
20
|
# Checks if a filename has a valid, registered extension
|
33
21
|
#
|
34
22
|
# filename - String filename, like "Home.md".
|
35
23
|
#
|
36
24
|
# Returns true or false.
|
37
25
|
def self.valid_extension?(filename)
|
38
|
-
|
26
|
+
Gollum::Markup.extensions.include?(::File.extname(filename.to_s).sub(/^\./,''))
|
39
27
|
end
|
40
28
|
|
41
29
|
# Checks if a filename has a valid extension understood by GitHub::Markup.
|
@@ -55,15 +43,11 @@ module Gollum
|
|
55
43
|
#
|
56
44
|
# Returns the Symbol format of the page; one of the registered format types
|
57
45
|
def self.format_for(filename)
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
#
|
64
|
-
# Returns the filtered String.
|
65
|
-
def self.canonicalize_filename(filename)
|
66
|
-
self.strip_filename(filename.to_s)
|
46
|
+
ext = ::File.extname(filename.to_s).sub(/^\./,'')
|
47
|
+
Gollum::Markup.formats.each_pair do |name, format|
|
48
|
+
return name if format[:extensions].include?(ext)
|
49
|
+
end
|
50
|
+
nil
|
67
51
|
end
|
68
52
|
|
69
53
|
# Reusable filter to strip extension and path from filename
|
@@ -72,7 +56,7 @@ module Gollum
|
|
72
56
|
#
|
73
57
|
# Returns the stripped String.
|
74
58
|
def self.strip_filename(filename)
|
75
|
-
::File.basename(filename, ::File.extname(filename))
|
59
|
+
::File.basename(filename.to_s, ::File.extname(filename.to_s))
|
76
60
|
end
|
77
61
|
|
78
62
|
# Public: Initialize a page.
|
@@ -88,6 +72,13 @@ module Gollum
|
|
88
72
|
@parent_page = nil
|
89
73
|
end
|
90
74
|
|
75
|
+
# Public: The SHA hash identifying this page
|
76
|
+
#
|
77
|
+
# Returns the String SHA.
|
78
|
+
def sha
|
79
|
+
@blob && @blob.id
|
80
|
+
end
|
81
|
+
|
91
82
|
# Public: The on-disk filename of the page including extension.
|
92
83
|
#
|
93
84
|
# Returns the String name.
|
@@ -106,7 +97,7 @@ module Gollum
|
|
106
97
|
#
|
107
98
|
# Returns the String name.
|
108
99
|
def name
|
109
|
-
self.class.
|
100
|
+
self.class.strip_filename(filename)
|
110
101
|
end
|
111
102
|
|
112
103
|
# Public: The title will be constructed from the
|
@@ -140,17 +131,10 @@ module Gollum
|
|
140
131
|
''
|
141
132
|
end
|
142
133
|
|
143
|
-
path << self.
|
134
|
+
path << self.filename
|
144
135
|
path
|
145
136
|
end
|
146
137
|
|
147
|
-
# Public: The display form of the url path required to reach this page within the repo.
|
148
|
-
#
|
149
|
-
# Returns the String url_path
|
150
|
-
def url_path_display
|
151
|
-
url_path
|
152
|
-
end
|
153
|
-
|
154
138
|
# Public: Defines title for page.rb
|
155
139
|
#
|
156
140
|
# Returns the String title
|
@@ -158,6 +142,13 @@ module Gollum
|
|
158
142
|
metadata_title || url_path
|
159
143
|
end
|
160
144
|
|
145
|
+
# Public: The url_path, but CGI escaped.
|
146
|
+
#
|
147
|
+
# Returns the String url_path
|
148
|
+
def escaped_url_path
|
149
|
+
CGI.escape(self.url_path).gsub('%2F', '/')
|
150
|
+
end
|
151
|
+
|
161
152
|
# Public: Metadata title
|
162
153
|
#
|
163
154
|
# Set with <!-- --- title: New Title --> in page content
|
@@ -179,13 +170,6 @@ module Gollum
|
|
179
170
|
@wiki.display_metadata
|
180
171
|
end
|
181
172
|
|
182
|
-
# Public: The url_path, but CGI escaped.
|
183
|
-
#
|
184
|
-
# Returns the String url_path
|
185
|
-
def escaped_url_path
|
186
|
-
CGI.escape(self.url_path).gsub('%2F', '/')
|
187
|
-
end
|
188
|
-
|
189
173
|
# Public: The raw contents of the page.
|
190
174
|
#
|
191
175
|
# Returns the String data.
|
@@ -390,7 +374,7 @@ module Gollum
|
|
390
374
|
|
391
375
|
map.each do |entry|
|
392
376
|
next if entry.name.to_s.empty? || !self.class.valid_extension?(entry.name)
|
393
|
-
entry_name = ::File.extname(name).empty? ? Page.
|
377
|
+
entry_name = ::File.extname(name).empty? ? ::Gollum::Page.strip_filename(entry.name) : entry.name
|
394
378
|
path = checked_dir ? ::File.join(entry.dir, entry_name) : entry_name
|
395
379
|
next unless query.downcase == path.downcase
|
396
380
|
return entry.page(@wiki, @version)
|
data/lib/gollum-lib/version.rb
CHANGED
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.0.a.
|
4
|
+
version: 5.0.a.2
|
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: 2017-04-
|
12
|
+
date: 2017-04-12 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: gollum-rjgit_adapter
|