gollum-lib 4.2.1-java → 4.2.2-java
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/gemspec.rb +6 -4
- data/lib/gollum-lib.rb +1 -1
- data/lib/gollum-lib/file_view.rb +10 -4
- data/lib/gollum-lib/filter/emoji.rb +39 -0
- data/lib/gollum-lib/filter/tags.rb +9 -3
- data/lib/gollum-lib/markup.rb +1 -1
- data/lib/gollum-lib/page.rb +22 -8
- data/lib/gollum-lib/version.rb +1 -1
- data/lib/gollum-lib/wiki.rb +42 -2
- metadata +23 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d251ccb17ef08c54c7619aff450d52fee60afd1a
|
4
|
+
data.tar.gz: 94929bd617697704de1c9be1b1e5fe643b1a11e3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 46672d43228533de53ac6b584b1207bdf5e92d0efb90117a68d8f9ec0ce283007bef43b7d46854273abaa53d4e80fd0a7b7f32ded2a38a5c7503d38e71857dd9
|
7
|
+
data.tar.gz: e0eeea8a09af09489d7b7790ef73a9488f4a8aeba797fd092ff5703ef66db87ef1af4ac78b68f24ce52ed8e768bcbf1a33c2215dd728618ea8c241d821553370
|
data/gemspec.rb
CHANGED
@@ -8,7 +8,7 @@ def specification(version, default_adapter, platform = nil)
|
|
8
8
|
s.name = 'gollum-lib'
|
9
9
|
s.version = version
|
10
10
|
s.platform = platform if platform
|
11
|
-
s.date = '2016-
|
11
|
+
s.date = '2016-11-18'
|
12
12
|
s.rubyforge_project = 'gollum-lib'
|
13
13
|
s.license = 'MIT'
|
14
14
|
|
@@ -27,9 +27,10 @@ def specification(version, default_adapter, platform = nil)
|
|
27
27
|
s.add_dependency *default_adapter
|
28
28
|
s.add_dependency 'rouge', '~> 2.0'
|
29
29
|
s.add_dependency 'nokogiri', '~> 1.6.4'
|
30
|
-
s.add_dependency 'stringex', '~> 2.
|
31
|
-
s.add_dependency 'sanitize', '~> 2.1
|
32
|
-
s.add_dependency 'github-markup', '~> 1.4
|
30
|
+
s.add_dependency 'stringex', '~> 2.6'
|
31
|
+
s.add_dependency 'sanitize', '~> 2.1'
|
32
|
+
s.add_dependency 'github-markup', '~> 1.4'
|
33
|
+
s.add_dependency 'gemojione', '~> 2.2'
|
33
34
|
|
34
35
|
s.add_development_dependency 'org-ruby', '~> 0.9.9'
|
35
36
|
s.add_development_dependency 'kramdown', '~> 1.6.0'
|
@@ -70,6 +71,7 @@ def specification(version, default_adapter, platform = nil)
|
|
70
71
|
lib/gollum-lib/file_view.rb
|
71
72
|
lib/gollum-lib/filter.rb
|
72
73
|
lib/gollum-lib/filter/code.rb
|
74
|
+
lib/gollum-lib/filter/emoji.rb
|
73
75
|
lib/gollum-lib/filter/macro.rb
|
74
76
|
lib/gollum-lib/filter/metadata.rb
|
75
77
|
lib/gollum-lib/filter/plain_text.rb
|
data/lib/gollum-lib.rb
CHANGED
@@ -16,6 +16,7 @@ end
|
|
16
16
|
# external
|
17
17
|
require 'github/markup'
|
18
18
|
require 'sanitize'
|
19
|
+
require 'gemojione'
|
19
20
|
|
20
21
|
# internal
|
21
22
|
require File.expand_path('../gollum-lib/git_access', __FILE__)
|
@@ -62,4 +63,3 @@ module Gollum
|
|
62
63
|
class NoSuchPathError < StandardError; end
|
63
64
|
|
64
65
|
end
|
65
|
-
|
data/lib/gollum-lib/file_view.rb
CHANGED
@@ -20,8 +20,12 @@ module Gollum
|
|
20
20
|
|
21
21
|
def new_page(page)
|
22
22
|
name = page.name
|
23
|
-
url = url_for_page page
|
24
|
-
%Q( <li class="file"><a href="#{url}"><span class="icon"></span>#{name}</a
|
23
|
+
url, valid_page = url_for_page page
|
24
|
+
%Q( <li class="file"><a href="#{url}"><span class="icon"></span>#{name}</a>#{valid_page ? "" : delete_file(url, valid_page)}</li>)
|
25
|
+
end
|
26
|
+
|
27
|
+
def delete_file(url, valid_page)
|
28
|
+
%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>)
|
25
29
|
end
|
26
30
|
|
27
31
|
def new_folder(folder_path)
|
@@ -42,17 +46,19 @@ module Gollum
|
|
42
46
|
|
43
47
|
def url_for_page(page)
|
44
48
|
url = ''
|
49
|
+
valid_page_name = false
|
45
50
|
if @show_all
|
46
51
|
# Remove ext for valid pages.
|
47
52
|
filename = page.filename
|
48
|
-
|
53
|
+
valid_page_name = Page::valid_page_name?(filename)
|
54
|
+
filename = valid_page_name ? filename.chomp(::File.extname(filename)) : filename
|
49
55
|
|
50
56
|
url = ::File.join(::File.dirname(page.path), filename)
|
51
57
|
else
|
52
58
|
url = ::File.join(::File.dirname(page.path), page.filename_stripped)
|
53
59
|
end
|
54
60
|
url = url[2..-1] if url[0, 2] == './'
|
55
|
-
url
|
61
|
+
return url, valid_page_name
|
56
62
|
end
|
57
63
|
|
58
64
|
def render_files
|
@@ -0,0 +1,39 @@
|
|
1
|
+
# ~*~ encoding: utf-8 ~*~
|
2
|
+
|
3
|
+
# Emoji
|
4
|
+
#
|
5
|
+
# Render emoji such as :smile:
|
6
|
+
class Gollum::Filter::Emoji < Gollum::Filter
|
7
|
+
|
8
|
+
EXTRACT_PATTERN = %r{
|
9
|
+
(?<!\[{2})
|
10
|
+
:(?<name>[\w-]+):
|
11
|
+
(?!\]{^2})
|
12
|
+
}ix
|
13
|
+
|
14
|
+
PROCESS_PATTERN = %r{
|
15
|
+
=EEMMOOJJII=
|
16
|
+
(?<name>[\w-]+)
|
17
|
+
=IIJJOOMMEE=
|
18
|
+
}ix
|
19
|
+
|
20
|
+
def extract(data)
|
21
|
+
data.gsub! EXTRACT_PATTERN do
|
22
|
+
emoji_exists?($~[:name]) ? "=EEMMOOJJII=#{$~[:name]}=IIJJOOMMEE=" : $&
|
23
|
+
end
|
24
|
+
data
|
25
|
+
end
|
26
|
+
|
27
|
+
def process(data)
|
28
|
+
data.gsub! PROCESS_PATTERN, %q(<img src="/emoji/\k<name>" alt="\k<name>" class="emoji">)
|
29
|
+
data
|
30
|
+
end
|
31
|
+
|
32
|
+
private
|
33
|
+
|
34
|
+
def emoji_exists?(name)
|
35
|
+
@index ||= Gemojione::Index.new
|
36
|
+
!!@index.find_by_name(name)
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
@@ -129,6 +129,10 @@ class Gollum::Filter::Tags < Gollum::Filter
|
|
129
129
|
path = ::File.join @markup.wiki.base_path, file.path
|
130
130
|
elsif name =~ /^https?:\/\/.+(jpg|png|gif|svg|bmp)$/i
|
131
131
|
path = name
|
132
|
+
elsif name =~ /.+(jpg|png|gif|svg|bmp)$/i
|
133
|
+
# If is image, file not found and no link, then populate with empty String
|
134
|
+
# We can than add an image not found alt attribute for this later
|
135
|
+
path = ""
|
132
136
|
end
|
133
137
|
|
134
138
|
if path
|
@@ -167,8 +171,10 @@ class Gollum::Filter::Tags < Gollum::Filter
|
|
167
171
|
end
|
168
172
|
end
|
169
173
|
|
170
|
-
if (alt = opts['alt'])
|
174
|
+
if path != "" && (alt = opts['alt'])
|
171
175
|
attrs << %{alt="#{alt}"}
|
176
|
+
elsif path == ""
|
177
|
+
attrs << %{alt="Image not found"}
|
172
178
|
end
|
173
179
|
|
174
180
|
attr_string = attrs.size > 0 ? attrs.join(' ') + ' ' : ''
|
@@ -212,7 +218,7 @@ class Gollum::Filter::Tags < Gollum::Filter
|
|
212
218
|
if parts.size == 1
|
213
219
|
url = parts[0].strip
|
214
220
|
else
|
215
|
-
name, url = *parts.compact.map(&:strip)
|
221
|
+
name, url = *parts.compact.map(&:strip)
|
216
222
|
end
|
217
223
|
accepted_protocols = @markup.wiki.sanitization.protocols['a']['href'].dup
|
218
224
|
if accepted_protocols.include?(:relative)
|
@@ -230,7 +236,7 @@ class Gollum::Filter::Tags < Gollum::Filter
|
|
230
236
|
else
|
231
237
|
nil
|
232
238
|
end
|
233
|
-
|
239
|
+
|
234
240
|
end
|
235
241
|
|
236
242
|
# Attempt to process the tag as a file link tag.
|
data/lib/gollum-lib/markup.rb
CHANGED
@@ -99,7 +99,7 @@ module Gollum
|
|
99
99
|
@format = format
|
100
100
|
@name = name
|
101
101
|
|
102
|
-
chain = [:Metadata, :PlainText, :TOC, :RemoteCode, :Code, :Sanitize, :WSD, :Tags, :Render]
|
102
|
+
chain = [:Metadata, :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)
|
data/lib/gollum-lib/page.rb
CHANGED
@@ -477,17 +477,31 @@ module Gollum
|
|
477
477
|
|
478
478
|
map ||= @wiki.tree_map_for(@wiki.ref, true)
|
479
479
|
valid_names = subpagenames.map(&:capitalize).join("|")
|
480
|
-
|
481
|
-
|
482
|
-
|
483
|
-
|
484
|
-
|
485
|
-
|
486
|
-
|
480
|
+
# From Ruby 2.2 onwards map.select! could be used
|
481
|
+
map = map.select{|entry| entry.name =~ /^_(#{valid_names})/ }
|
482
|
+
return if map.empty?
|
483
|
+
|
484
|
+
subpagenames.each do |subpagename|
|
485
|
+
dir = ::Pathname.new(self.path)
|
486
|
+
while dir = dir.parent do
|
487
|
+
subpageblob = map.find do |blob_entry|
|
488
|
+
|
489
|
+
filename = "_#{subpagename.to_s.capitalize}"
|
490
|
+
searchpath = dir == Pathname.new('.') ? Pathname.new(filename) : dir + filename
|
491
|
+
entrypath = ::Pathname.new(blob_entry.path)
|
492
|
+
# Ignore extentions
|
493
|
+
entrypath = entrypath.dirname + entrypath.basename(entrypath.extname)
|
494
|
+
entrypath == searchpath
|
495
|
+
end
|
496
|
+
|
497
|
+
if subpageblob
|
498
|
+
instance_variable_set("@#{subpagename}", subpageblob.page(@wiki, @version) )
|
487
499
|
break
|
488
500
|
end
|
501
|
+
|
502
|
+
break if dir == Pathname.new('.')
|
489
503
|
end
|
490
|
-
end
|
504
|
+
end
|
491
505
|
end
|
492
506
|
|
493
507
|
def inspect
|
data/lib/gollum-lib/version.rb
CHANGED
data/lib/gollum-lib/wiki.rb
CHANGED
@@ -194,6 +194,7 @@ module Gollum
|
|
194
194
|
# Default: false
|
195
195
|
# :collapse_tree - Start with collapsed file view. Default: false
|
196
196
|
# :css - Include the custom.css file from the repo.
|
197
|
+
# :emoji - Parse and interpret emoji tags (e.g. :heart:).
|
197
198
|
# :h1_title - Concatenate all h1's on a page to form the
|
198
199
|
# page title.
|
199
200
|
# :index_page - The default page to retrieve or create if the
|
@@ -240,6 +241,7 @@ module Gollum
|
|
240
241
|
@show_all = options.fetch :show_all, false
|
241
242
|
@collapse_tree = options.fetch :collapse_tree, false
|
242
243
|
@css = options.fetch :css, false
|
244
|
+
@emoji = options.fetch :emoji, false
|
243
245
|
@h1_title = options.fetch :h1_title, false
|
244
246
|
@index_page = options.fetch :index_page, 'Home'
|
245
247
|
@bar_side = options.fetch :sidebar, :right
|
@@ -248,7 +250,8 @@ module Gollum
|
|
248
250
|
@allow_uploads = options.fetch :allow_uploads, false
|
249
251
|
@per_page_uploads = options.fetch :per_page_uploads, false
|
250
252
|
@filter_chain = options.fetch :filter_chain,
|
251
|
-
[:Metadata, :PlainText, :TOC, :RemoteCode, :Code, :Macro, :Sanitize, :WSD, :PlantUML, :Tags, :Render]
|
253
|
+
[:Metadata, :PlainText, :TOC, :RemoteCode, :Code, :Macro, :Emoji, :Sanitize, :WSD, :PlantUML, :Tags, :Render]
|
254
|
+
@filter_chain.delete(:Emoji) unless options.fetch :emoji, false
|
252
255
|
end
|
253
256
|
|
254
257
|
# Public: check whether the wiki's git repo exists on the filesystem.
|
@@ -488,6 +491,43 @@ module Gollum
|
|
488
491
|
multi_commit ? committer : committer.commit
|
489
492
|
end
|
490
493
|
|
494
|
+
# Public: Delete a file.
|
495
|
+
#
|
496
|
+
# path - The path to the file to delete
|
497
|
+
# commit - The commit Hash details:
|
498
|
+
# :message - The String commit message.
|
499
|
+
# :name - The String author full name.
|
500
|
+
# :email - The String email address.
|
501
|
+
# :parent - Optional Gollum::Git::Commit parent to this update.
|
502
|
+
# :tree - Optional String SHA of the tree to create the
|
503
|
+
# index from.
|
504
|
+
# :committer - Optional Gollum::Committer instance. If provided,
|
505
|
+
# assume that this operation is part of batch of
|
506
|
+
# updates and the commit happens later.
|
507
|
+
#
|
508
|
+
# Returns the String SHA1 of the newly written version, or the
|
509
|
+
# Gollum::Committer instance if this is part of a batch update.
|
510
|
+
def delete_file(path, commit)
|
511
|
+
dir = ::File.dirname(path)
|
512
|
+
ext = ::File.extname(path)
|
513
|
+
format = ext.split('.').last || 'txt'
|
514
|
+
filename = ::File.basename(path, ext)
|
515
|
+
|
516
|
+
multi_commit = !!commit[:committer]
|
517
|
+
committer = multi_commit ? commit[:committer] : Committer.new(self, commit)
|
518
|
+
|
519
|
+
committer.delete(path)
|
520
|
+
|
521
|
+
committer.after_commit do |index, _sha|
|
522
|
+
dir = '' if dir == '.'
|
523
|
+
|
524
|
+
@access.refresh
|
525
|
+
index.update_working_dir(dir, filename, format)
|
526
|
+
end
|
527
|
+
|
528
|
+
multi_commit ? committer : committer.commit
|
529
|
+
end
|
530
|
+
|
491
531
|
# Public: Applies a reverse diff for a given page. If only 1 SHA is given,
|
492
532
|
# the reverse diff will be taken from its parent (^SHA...SHA). If two SHAs
|
493
533
|
# are given, the reverse diff is taken from SHA1...SHA2.
|
@@ -647,7 +687,7 @@ module Gollum
|
|
647
687
|
options[:max_count] = 10 unless options[:max_count]
|
648
688
|
@repo.log(@ref, nil, options)
|
649
689
|
end
|
650
|
-
|
690
|
+
|
651
691
|
# Public: Refreshes just the cached Git reference data. This should
|
652
692
|
# be called after every Gollum update.
|
653
693
|
#
|
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.
|
4
|
+
version: 4.2.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: 2016-
|
12
|
+
date: 2016-11-18 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: gollum-rjgit_adapter
|
@@ -59,42 +59,56 @@ dependencies:
|
|
59
59
|
requirements:
|
60
60
|
- - ~>
|
61
61
|
- !ruby/object:Gem::Version
|
62
|
-
version: 2.
|
62
|
+
version: '2.6'
|
63
63
|
type: :runtime
|
64
64
|
prerelease: false
|
65
65
|
version_requirements: !ruby/object:Gem::Requirement
|
66
66
|
requirements:
|
67
67
|
- - ~>
|
68
68
|
- !ruby/object:Gem::Version
|
69
|
-
version: 2.
|
69
|
+
version: '2.6'
|
70
70
|
- !ruby/object:Gem::Dependency
|
71
71
|
name: sanitize
|
72
72
|
requirement: !ruby/object:Gem::Requirement
|
73
73
|
requirements:
|
74
74
|
- - ~>
|
75
75
|
- !ruby/object:Gem::Version
|
76
|
-
version: 2.1
|
76
|
+
version: '2.1'
|
77
77
|
type: :runtime
|
78
78
|
prerelease: false
|
79
79
|
version_requirements: !ruby/object:Gem::Requirement
|
80
80
|
requirements:
|
81
81
|
- - ~>
|
82
82
|
- !ruby/object:Gem::Version
|
83
|
-
version: 2.1
|
83
|
+
version: '2.1'
|
84
84
|
- !ruby/object:Gem::Dependency
|
85
85
|
name: github-markup
|
86
86
|
requirement: !ruby/object:Gem::Requirement
|
87
87
|
requirements:
|
88
88
|
- - ~>
|
89
89
|
- !ruby/object:Gem::Version
|
90
|
-
version: 1.4
|
90
|
+
version: '1.4'
|
91
91
|
type: :runtime
|
92
92
|
prerelease: false
|
93
93
|
version_requirements: !ruby/object:Gem::Requirement
|
94
94
|
requirements:
|
95
95
|
- - ~>
|
96
96
|
- !ruby/object:Gem::Version
|
97
|
-
version: 1.4
|
97
|
+
version: '1.4'
|
98
|
+
- !ruby/object:Gem::Dependency
|
99
|
+
name: gemojione
|
100
|
+
requirement: !ruby/object:Gem::Requirement
|
101
|
+
requirements:
|
102
|
+
- - ~>
|
103
|
+
- !ruby/object:Gem::Version
|
104
|
+
version: '2.2'
|
105
|
+
type: :runtime
|
106
|
+
prerelease: false
|
107
|
+
version_requirements: !ruby/object:Gem::Requirement
|
108
|
+
requirements:
|
109
|
+
- - ~>
|
110
|
+
- !ruby/object:Gem::Version
|
111
|
+
version: '2.2'
|
98
112
|
- !ruby/object:Gem::Dependency
|
99
113
|
name: org-ruby
|
100
114
|
requirement: !ruby/object:Gem::Requirement
|
@@ -371,6 +385,7 @@ files:
|
|
371
385
|
- lib/gollum-lib/file_view.rb
|
372
386
|
- lib/gollum-lib/filter.rb
|
373
387
|
- lib/gollum-lib/filter/code.rb
|
388
|
+
- lib/gollum-lib/filter/emoji.rb
|
374
389
|
- lib/gollum-lib/filter/macro.rb
|
375
390
|
- lib/gollum-lib/filter/metadata.rb
|
376
391
|
- lib/gollum-lib/filter/plain_text.rb
|