gollum_rails 0.0.2.6 → 0.0.2.7
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.
- data/Gemfile.lock +1 -1
- data/HISTORY.md +4 -0
- data/README.md +24 -1
- data/Rakefile +1 -5
- data/gollum_rails.gemspec +3 -2
- data/lib/generators/gollum_rails/model/model_generator.rb +10 -0
- data/lib/gollum_rails.rb +13 -7
- data/lib/gollum_rails/engine.rb +7 -5
- data/lib/gollum_rails/page.rb +24 -18
- data/lib/gollum_rails/versions.rb +79 -0
- data/lib/gollum_rails/wiki.rb +34 -30
- metadata +4 -4
- data/lib/gollum_rails/gollum_rails.rb +0 -8
data/Gemfile.lock
CHANGED
data/HISTORY.md
CHANGED
data/README.md
CHANGED
@@ -122,7 +122,30 @@ Thats it. Very easy. You can use also `page.save!` method.
|
|
122
122
|
preview = page.preview("testpage", "content") # or page.preview("testpage", "content", :format)
|
123
123
|
|
124
124
|
# preview contains the HTML rendered data!
|
125
|
-
|
125
|
+
|
126
|
+
**Show pages versions**
|
127
|
+
|
128
|
+
page = Page.new
|
129
|
+
page.find("testpage")
|
130
|
+
versions = page.versions
|
131
|
+
|
132
|
+
versions.all
|
133
|
+
# => #<Grit::Commit "83a5e82a58eb4afda2662b7ca665b64554baf431">,
|
134
|
+
#<Grit::Commit "3a12080810acaf5cff3c2fb9bf67821943033548">,
|
135
|
+
#<Grit::Commit "3b9ee74806b5cd59ec7d01fe4d974aa9974c816e">,
|
136
|
+
#<Grit::Commit "c1507f5c47ae5bee16dea3ebed2f177dbcf48a68">,
|
137
|
+
|
138
|
+
|
139
|
+
versions.latest
|
140
|
+
# => #<Grit::Commit "3a12080810acaf5cff3c2fb9bf67821943033548">
|
141
|
+
|
142
|
+
versions.oldest
|
143
|
+
# => #<Grit::Commit "6d71571d379cfe863933123ea93dea4aac1d6eb64">
|
144
|
+
|
145
|
+
versions.find("6d71571d379cfe86393135ea93dea4aac1d6eb64")
|
146
|
+
# => #<Grit::Commit "6d71571d379cfe863933123ea93dea4aac1d6eb64">
|
147
|
+
|
148
|
+
|
126
149
|
## TODO
|
127
150
|
* List all pages
|
128
151
|
* Search pages
|
data/Rakefile
CHANGED
@@ -151,11 +151,7 @@ end
|
|
151
151
|
|
152
152
|
desc 'Validate lib files and version file'
|
153
153
|
task :validate do
|
154
|
-
libfiles = Dir['lib/*'] - ["lib/#{name}.rb", "lib/#{name}"]
|
155
|
-
unless libfiles.empty?
|
156
|
-
puts "Directory `lib` should only contain a `#{name}.rb` file and `#{name}` dir."
|
157
|
-
exit!
|
158
|
-
end
|
154
|
+
libfiles = Dir['lib/*'] - ["lib/#{name}.rb", "lib/#{name}", "lib/generators"]
|
159
155
|
unless Dir['VERSION*'].empty?
|
160
156
|
puts "A `VERSION` file at root level violates Gem best practices."
|
161
157
|
exit!
|
data/gollum_rails.gemspec
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.rubygems_version = '1.3.5'
|
3
3
|
s.name = 'gollum_rails'
|
4
|
-
s.version = '0.0.2.
|
4
|
+
s.version = '0.0.2.7'
|
5
5
|
|
6
6
|
s.summary = 'Combines the benefits from Gollum with Rails'
|
7
7
|
s.description= 'use templating, authentication and so on'
|
@@ -12,6 +12,7 @@ Gem::Specification.new do |s|
|
|
12
12
|
s.add_dependency('grit', '~> 2.5.0')
|
13
13
|
s.add_dependency('builder', '~> 3.0.0')
|
14
14
|
s.add_dependency('rack', '~> 1.4.0')
|
15
|
+
|
15
16
|
s.add_development_dependency('org-ruby', '~> 0.7.2')
|
16
17
|
s.add_development_dependency('shoulda', '~> 3.3.2')
|
17
18
|
s.add_development_dependency('rack-test', '~> 0.6.2')
|
@@ -33,12 +34,12 @@ Gem::Specification.new do |s|
|
|
33
34
|
README.md
|
34
35
|
Rakefile
|
35
36
|
gollum_rails.gemspec
|
37
|
+
lib/generators/gollum_rails/model/model_generator.rb
|
36
38
|
lib/gollum_rails.rb
|
37
39
|
lib/gollum_rails/config.rb
|
38
40
|
lib/gollum_rails/dependency_injector.rb
|
39
41
|
lib/gollum_rails/engine.rb
|
40
42
|
lib/gollum_rails/file.rb
|
41
|
-
lib/gollum_rails/gollum_rails.rb
|
42
43
|
lib/gollum_rails/hash.rb
|
43
44
|
lib/gollum_rails/messages.yml
|
44
45
|
lib/gollum_rails/page.rb
|
data/lib/gollum_rails.rb
CHANGED
@@ -1,13 +1,19 @@
|
|
1
|
+
# ~*~ encoding: utf-8 ~*~
|
2
|
+
|
3
|
+
# externals
|
1
4
|
require 'rubygems'
|
2
5
|
require 'gollum'
|
3
6
|
|
7
|
+
# internals
|
8
|
+
require File.expand_path('../gollum_rails/engine', __FILE__)
|
9
|
+
require File.expand_path('../gollum_rails/dependency_injector', __FILE__)
|
10
|
+
require File.expand_path('../gollum_rails/config', __FILE__)
|
11
|
+
require File.expand_path('../gollum_rails/wiki', __FILE__)
|
4
12
|
|
13
|
+
$KCODE = 'U' if RUBY_VERSION[0,3] == '1.8'
|
5
14
|
|
6
|
-
module
|
7
|
-
module Rails
|
8
|
-
VERSION = '0.0.2.6'
|
9
|
-
require 'gollum_rails/engine' if defined?(Rails)
|
10
|
-
end
|
11
|
-
end
|
15
|
+
module GollumRails
|
12
16
|
|
13
|
-
|
17
|
+
VERSION = '0.0.2.7'
|
18
|
+
|
19
|
+
end
|
data/lib/gollum_rails/engine.rb
CHANGED
@@ -1,11 +1,13 @@
|
|
1
1
|
require 'rails'
|
2
|
-
|
3
|
-
|
2
|
+
|
4
3
|
module GollumRails
|
5
|
-
|
6
|
-
|
4
|
+
class Engine < ::Rails::Engine
|
5
|
+
initializer "gollum_rails.load_app" do |app|
|
6
|
+
puts "abl"
|
7
|
+
#super
|
7
8
|
## GollumRails::Config::rails = app
|
8
|
-
# end
|
9
9
|
end
|
10
10
|
end
|
11
11
|
|
12
|
+
end
|
13
|
+
|
data/lib/gollum_rails/page.rb
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
# ~*~ encoding: utf-8 ~*~
|
2
|
-
require
|
2
|
+
require File.expand_path('../hash', __FILE__)
|
3
|
+
require File.expand_path('../versions', __FILE__)
|
3
4
|
|
4
5
|
module GollumRails
|
5
6
|
class Page
|
6
7
|
include ActiveModel::Conversion
|
7
8
|
include ActiveModel::Validations
|
8
9
|
extend ActiveModel::Naming
|
9
|
-
|
10
10
|
|
11
11
|
# Public: Gets/Sets the name of the document
|
12
12
|
attr_accessor :name
|
@@ -73,7 +73,6 @@ module GollumRails
|
|
73
73
|
|
74
74
|
# Public: Gets ?!
|
75
75
|
attr_reader :class
|
76
|
-
|
77
76
|
# Public: Initializes a new Page instance
|
78
77
|
#
|
79
78
|
# attributes - A hash of attributes. See example
|
@@ -150,14 +149,17 @@ module GollumRails
|
|
150
149
|
def save
|
151
150
|
if valid?
|
152
151
|
begin
|
153
|
-
|
154
|
-
@persisted = true
|
152
|
+
commit = wiki.wiki.write_page(@name, @format, @content, @commit)
|
155
153
|
rescue Gollum::DuplicatePageError => e
|
156
154
|
@error = e
|
157
155
|
return false
|
158
156
|
end
|
159
157
|
end
|
160
|
-
|
158
|
+
if commit and commit.is_a? String
|
159
|
+
return commit
|
160
|
+
else
|
161
|
+
return false
|
162
|
+
end
|
161
163
|
end
|
162
164
|
|
163
165
|
# Public: rewrite for save() method with raising exceptions as well
|
@@ -198,7 +200,14 @@ module GollumRails
|
|
198
200
|
@error = @options.messages.commit_not_empty_and_content_not_empty
|
199
201
|
return false
|
200
202
|
end
|
201
|
-
|
203
|
+
commit = @wiki.wiki.update_page(@page, @name, @format, content, commit)
|
204
|
+
if commit.is_a?(String)
|
205
|
+
@persisted = true
|
206
|
+
return commit
|
207
|
+
else
|
208
|
+
@persisted = false
|
209
|
+
return nil
|
210
|
+
end
|
202
211
|
end
|
203
212
|
|
204
213
|
#Public: alias for update with exceptions
|
@@ -220,7 +229,6 @@ module GollumRails
|
|
220
229
|
return @wiki.wiki.delete_page(@page, commit)
|
221
230
|
end
|
222
231
|
|
223
|
-
|
224
232
|
#Public: alias for delete with exceptions
|
225
233
|
def delete!(commit)
|
226
234
|
deletes = delete(commit)
|
@@ -237,8 +245,8 @@ module GollumRails
|
|
237
245
|
end
|
238
246
|
|
239
247
|
# Public: Renders a preview (usable e.g. with ajax)
|
240
|
-
#
|
241
|
-
#
|
248
|
+
#
|
249
|
+
#
|
242
250
|
# Returns rendered HTML
|
243
251
|
def preview(name = nil, content = nil, format = :markdown)
|
244
252
|
if !name or name == nil
|
@@ -279,7 +287,7 @@ module GollumRails
|
|
279
287
|
attr_reader :page
|
280
288
|
|
281
289
|
# Public: Finds a page based on given search string
|
282
|
-
#
|
290
|
+
#
|
283
291
|
# Be careful: At the moment you must initialize the class by .new
|
284
292
|
#
|
285
293
|
# Examples
|
@@ -355,7 +363,7 @@ module GollumRails
|
|
355
363
|
# Public: A simple wrapper for Gollum::Page.raw_data
|
356
364
|
#
|
357
365
|
# Page needs to be loaded!
|
358
|
-
#
|
366
|
+
#
|
359
367
|
# Returns raw data
|
360
368
|
def raw_data
|
361
369
|
if @page
|
@@ -381,15 +389,13 @@ module GollumRails
|
|
381
389
|
end
|
382
390
|
|
383
391
|
# Public: Active Record like
|
384
|
-
#
|
385
|
-
# Page.version.first.id
|
386
|
-
# Page.version.first.authored_data
|
392
|
+
#
|
387
393
|
#
|
388
394
|
#
|
389
395
|
# see Active Model documentation
|
390
|
-
def
|
391
|
-
if @page
|
392
|
-
@page
|
396
|
+
def versions
|
397
|
+
if @page && @page.is_a?(Gollum::Page) #&& (persisted? || found?)
|
398
|
+
return GollumRails::Versions.new(@page)
|
393
399
|
else
|
394
400
|
@error = @options.messages.no_page_fetched
|
395
401
|
return false
|
@@ -0,0 +1,79 @@
|
|
1
|
+
# ~*~ encoding: utf-8 ~*~
|
2
|
+
module GollumRails
|
3
|
+
class Versions
|
4
|
+
|
5
|
+
# Public: Gets the versions
|
6
|
+
attr_reader :versions
|
7
|
+
|
8
|
+
def initialize(page)
|
9
|
+
@versions = page.versions
|
10
|
+
end
|
11
|
+
|
12
|
+
# Public: .first
|
13
|
+
#
|
14
|
+
# Examples
|
15
|
+
# oldest
|
16
|
+
# # => #<Grit::Commit "6d71571d379cfe863933123ea93dea4aac1d6eb64">
|
17
|
+
#
|
18
|
+
#
|
19
|
+
# Returns the latest instance of Grit::Commit
|
20
|
+
def latest
|
21
|
+
return @versions.first
|
22
|
+
end
|
23
|
+
|
24
|
+
# Public: Last position in the @versions Array
|
25
|
+
#
|
26
|
+
# Examples
|
27
|
+
# oldest
|
28
|
+
# # => #<Grit::Commit "6d71571d379cfe863933123ea93dea4aac1d6eb64">
|
29
|
+
#
|
30
|
+
#
|
31
|
+
# Returns the oldest version of Grit::Commit
|
32
|
+
def oldest
|
33
|
+
return @versions.last
|
34
|
+
end
|
35
|
+
|
36
|
+
# Public: An Array of Grit::Commit
|
37
|
+
#
|
38
|
+
#
|
39
|
+
# Examples
|
40
|
+
# all
|
41
|
+
# # => <Grit::Commit "b3cc54c974700391d3f1c3c108032b6a5f27ecd8">,
|
42
|
+
# <Grit::Commit "13cda30e2a292852a32fad1e9c547c523387f17e">,
|
43
|
+
# <Grit::Commit "83a5e82a58eb4afda2662b7ca665b64554baf431">,
|
44
|
+
# <Grit::Commit "3a12080810acaf5cff3c2fb9bf67821943033548">,
|
45
|
+
# <Grit::Commit "3b9ee74806b5cd59ec7d01fe4d974aa9974c816e">,
|
46
|
+
# <Grit::Commit "c1507f5c47ae5bee16dea3ebed2f177dbcf48a68">,
|
47
|
+
# <Grit::Commit "1979f67c509c2802234dc12f242999953ffd9bc7">,
|
48
|
+
# <Grit::Commit "01fb119db9cb59b339011c7c9e5e59b89bf9a7a2">,
|
49
|
+
# <Grit::Commit "650cfd42814cf2d9fd0e2e9b7262f77bad06d0e0">,
|
50
|
+
# <Grit::Commit "07dfb9a86e7045369fc57c8d43e8cf68d3dfe7d1">,
|
51
|
+
# ...
|
52
|
+
#
|
53
|
+
# Returns many instances of Grit::Commit
|
54
|
+
def all
|
55
|
+
return @versions
|
56
|
+
end
|
57
|
+
|
58
|
+
# Public: Find a specific version
|
59
|
+
#
|
60
|
+
# version - String, containing the GIT version number
|
61
|
+
#
|
62
|
+
# Examples
|
63
|
+
# find '6d71571d379cfe86393135ea93dea4aac1d6eb64'
|
64
|
+
# # => #<Grit::Commit "6d71571d379cfe86393135ea93dea4aac1d6eb64">
|
65
|
+
#
|
66
|
+
#
|
67
|
+
# Returns an instance of Gollum::Page
|
68
|
+
def find(version = String.new)
|
69
|
+
result = nil
|
70
|
+
@versions.each do |commit|
|
71
|
+
if commit.id == version
|
72
|
+
result = commit
|
73
|
+
end
|
74
|
+
end
|
75
|
+
return result
|
76
|
+
end
|
77
|
+
|
78
|
+
end
|
79
|
+
end
|
data/lib/gollum_rails/wiki.rb
CHANGED
@@ -1,32 +1,36 @@
|
|
1
|
+
require File.expand_path('../validations', __FILE__)
|
2
|
+
require File.expand_path('../file', __FILE__)
|
3
|
+
require File.expand_path('../page', __FILE__)
|
4
|
+
|
1
5
|
module GollumRails
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
end
|
6
|
+
class Wiki
|
7
|
+
attr_accessor :wiki
|
8
|
+
def initialize(path)
|
9
|
+
main = getMainGollum(path)
|
10
|
+
send("wiki=", main)
|
11
|
+
DependencyInjector.set({:wiki => self})
|
12
|
+
end
|
13
|
+
|
14
|
+
def getMainGollum(path)
|
15
|
+
wiki = Gollum::Wiki.new(path)
|
16
|
+
end
|
17
|
+
|
18
|
+
def getPath
|
19
|
+
@wiki.path
|
20
|
+
end
|
21
|
+
|
22
|
+
def getRepo
|
23
|
+
@wiki.repo
|
24
|
+
end
|
25
|
+
|
26
|
+
def search(string = '')
|
27
|
+
|
28
|
+
end
|
29
|
+
|
30
|
+
## static setters / getters
|
31
|
+
|
32
|
+
def self.getWiki
|
33
|
+
@wiki
|
31
34
|
end
|
32
|
-
end
|
35
|
+
end
|
36
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gollum_rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.2.
|
4
|
+
version: 0.0.2.7
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-01-
|
12
|
+
date: 2013-01-28 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activemodel
|
@@ -184,12 +184,12 @@ files:
|
|
184
184
|
- README.md
|
185
185
|
- Rakefile
|
186
186
|
- gollum_rails.gemspec
|
187
|
+
- lib/generators/gollum_rails/model/model_generator.rb
|
187
188
|
- lib/gollum_rails.rb
|
188
189
|
- lib/gollum_rails/config.rb
|
189
190
|
- lib/gollum_rails/dependency_injector.rb
|
190
191
|
- lib/gollum_rails/engine.rb
|
191
192
|
- lib/gollum_rails/file.rb
|
192
|
-
- lib/gollum_rails/gollum_rails.rb
|
193
193
|
- lib/gollum_rails/hash.rb
|
194
194
|
- lib/gollum_rails/messages.yml
|
195
195
|
- lib/gollum_rails/page.rb
|
@@ -217,7 +217,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
217
217
|
version: '0'
|
218
218
|
segments:
|
219
219
|
- 0
|
220
|
-
hash:
|
220
|
+
hash: 182668687
|
221
221
|
requirements: []
|
222
222
|
rubyforge_project:
|
223
223
|
rubygems_version: 1.8.23
|
@@ -1,8 +0,0 @@
|
|
1
|
-
require "gollum_rails/engine"
|
2
|
-
require 'gollum_rails/config'
|
3
|
-
require "gollum_rails/dependency_injector"
|
4
|
-
require "gollum_rails/wiki"
|
5
|
-
require "gollum_rails/page"
|
6
|
-
require 'gollum_rails/file'
|
7
|
-
require 'gollum_rails/versions'
|
8
|
-
require 'gollum_rails/validations'
|