gollum_rails 1.5.5 → 1.5.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/gollum_rails.gemspec +1 -1
- data/lib/gollum_rails.rb +1 -1
- data/lib/gollum_rails/core.rb +37 -5
- data/lib/gollum_rails/finders.rb +3 -3
- data/spec/gollum_rails/page_spec.rb +37 -0
- 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: 5997873b85103d1d0ed0f94b46693a365d0529db
|
4
|
+
data.tar.gz: 57fee5ae386f2c24af584d033d562b6dd9f7eddc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d7d17cd47c838ba9a212ab1f9bc8d8c551fc4a16c4ec35ab7706a4fe47f65ddce80ac9546f5ed60a830841c34a30c78a625870583c1e31d26e072b74fe12125c
|
7
|
+
data.tar.gz: 21f43bad70858c468995c3b6b2e5189cb0a7d330b8ed4dcbddedfa84004c6b0cc1e6772ec670850912f68bb5ea3b2a56c4a8fede411ba8b87afa73af46bd44d9
|
data/Gemfile.lock
CHANGED
data/gollum_rails.gemspec
CHANGED
data/lib/gollum_rails.rb
CHANGED
data/lib/gollum_rails/core.rb
CHANGED
@@ -13,14 +13,20 @@ module GollumRails
|
|
13
13
|
Gollum::Markup.formats.include?(format.to_sym)
|
14
14
|
end
|
15
15
|
|
16
|
+
# Resets the folder to /
|
17
|
+
def reset_folder
|
18
|
+
set_folder(nil)
|
19
|
+
end
|
20
|
+
|
21
|
+
# Sets the folder
|
16
22
|
def set_folder(options)
|
17
|
-
if options.
|
18
|
-
|
23
|
+
if options.is_a? Hash
|
19
24
|
return if options.empty?
|
20
25
|
options = options[:folder]
|
21
26
|
end
|
22
27
|
Setup.wiki_options ||= {}
|
23
28
|
Setup.wiki_options[:page_file_dir] = options
|
29
|
+
Setup.wiki_options[:base_path] = options
|
24
30
|
end
|
25
31
|
alias_method :folder=, :set_folder
|
26
32
|
end
|
@@ -40,14 +46,40 @@ module GollumRails
|
|
40
46
|
end
|
41
47
|
|
42
48
|
|
43
|
-
|
49
|
+
# Gets the pathname for current file
|
44
50
|
def path_name
|
45
|
-
f =
|
51
|
+
f = full_path.first
|
46
52
|
return '/' if f == '.'
|
47
53
|
f
|
48
54
|
end
|
55
|
+
|
56
|
+
def full_path
|
57
|
+
File.split(name)
|
58
|
+
end
|
59
|
+
|
60
|
+
def file_name
|
61
|
+
full_path.last
|
62
|
+
end
|
63
|
+
|
64
|
+
# Gets the next subfolder for current pathname
|
65
|
+
def next_folder(previous)
|
66
|
+
path = path_name
|
67
|
+
previous = File.split(previous).join
|
68
|
+
path.gsub!(/#{previous}/i, '')
|
69
|
+
ngxpath = File.split(path).first #use path only cuz we want the next folder not file
|
70
|
+
new_path = ngxpath.split('/').reject { |c| c.empty? }
|
71
|
+
px = new_path.join
|
72
|
+
if px == '.' || px.empty?
|
73
|
+
return nil
|
74
|
+
end
|
75
|
+
px
|
76
|
+
|
77
|
+
end
|
49
78
|
|
50
|
-
|
79
|
+
def cname
|
80
|
+
Gollum::Page.cname(self.name)
|
81
|
+
end
|
82
|
+
# Gets a canonicalized filename of the page
|
51
83
|
def canonicalized_filename
|
52
84
|
Gollum::Page.canonicalize_filename(name)
|
53
85
|
end
|
data/lib/gollum_rails/finders.rb
CHANGED
@@ -22,13 +22,13 @@ module GollumRails
|
|
22
22
|
#
|
23
23
|
# name - the name of the page
|
24
24
|
# version - optional - The pages version
|
25
|
-
#
|
25
|
+
# folder_reset - optional - resets the folder to / before performing the search
|
26
26
|
# exact - optional - perform an exact match
|
27
27
|
#
|
28
28
|
# Return an instance of Gollum::Page
|
29
|
-
def find(name, version=nil,
|
29
|
+
def find(name, version=nil, folder_reset=false, exact=true)
|
30
30
|
name = name[:name] if name.kind_of?(Hash) && name.has_key?(:name)
|
31
|
-
Page.
|
31
|
+
Page.reset_folder if folder_reset
|
32
32
|
wiki.clear_cache
|
33
33
|
path = File.split(name)
|
34
34
|
if path.first == '/' || path.first == '.'
|
@@ -67,6 +67,43 @@ describe "Gollum Page" do
|
|
67
67
|
expect(RailsModel.find('test-page')).not_to be_nil
|
68
68
|
@rr.destroy
|
69
69
|
end
|
70
|
+
it "has a cname" do
|
71
|
+
@rr.name = 'test page'
|
72
|
+
@rr.save
|
73
|
+
expect(@rr.cname).to match('test-page')
|
74
|
+
@rr.destroy
|
75
|
+
end
|
76
|
+
it "has a filename " do
|
77
|
+
@rr.name = '/home/page/test/page'
|
78
|
+
@rr.save
|
79
|
+
expect(@rr.file_name).to match 'page'
|
80
|
+
@rr.destroy
|
81
|
+
end
|
82
|
+
it "has a path name" do
|
83
|
+
@rr.name = '/home/page/test/page'
|
84
|
+
@rr.save
|
85
|
+
|
86
|
+
expect(@rr.path_name).to match 'home/page/test'
|
87
|
+
@rr.destroy
|
88
|
+
end
|
89
|
+
it "can get the next subfolder" do
|
90
|
+
@rr.name = '/home/page/test/page'
|
91
|
+
@rr.save
|
92
|
+
expect(@rr.next_folder('/home')).to match 'page'
|
93
|
+
@rr.destroy
|
94
|
+
end
|
95
|
+
it "can get the next subfolder again" do
|
96
|
+
@rr.name = '/home/page'
|
97
|
+
@rr.save
|
98
|
+
expect(@rr.next_folder("/home")).to be_nil
|
99
|
+
@rr.destroy
|
100
|
+
end
|
101
|
+
it "cannot get the next subfolder" do
|
102
|
+
@rr.name = 'page'
|
103
|
+
@rr.save
|
104
|
+
expect(@rr.next_folder("/")).to be_nil
|
105
|
+
@rr.destroy
|
106
|
+
end
|
70
107
|
it "was last changed by me" do
|
71
108
|
@rr.save
|
72
109
|
@rr.last_changed_by.should == 'flo <mosny@zyg.li>'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gollum_rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.5.
|
4
|
+
version: 1.5.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Florian Kasper
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-02-
|
11
|
+
date: 2014-02-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activemodel
|