gollum_rails 0.0.6 → 0.0.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.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +1 -0
- data/gollum_rails.gemspec +1 -1
- data/lib/generators/gollum_rails/install/install_generator.rb +5 -0
- data/lib/gollum_rails/adapters/gollum/wiki.rb +3 -0
- data/lib/gollum_rails/adapters/gollum.rb +9 -0
- data/lib/gollum_rails/page.rb +29 -9
- data/lib/gollum_rails/setup.rb +1 -0
- data/lib/gollum_rails.rb +1 -1
- 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: e28f59903e3501a35a990311a3289ffb7fabf8de
|
4
|
+
data.tar.gz: 6554db1a2ad83743510b428e527a12980e6eaa23
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6b69256e1cec596b51086ee56dfc83df954d4a15563ad3b476ec155d325620ed081fb4963941cfe2f3833d6dc92bd53ddb24157d6a7cb30868ee7fc108423c2b
|
7
|
+
data.tar.gz: 90f3315569e2cfc5d070e6424de6b24ccc4dc780e4e8fed8e55a1227cde3bb5a5495af1419301e66a4f2986de3fe3ae82d30e244267b1eedd366c784e49ae817
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -23,6 +23,7 @@ with gollum_rails you can:
|
|
23
23
|
- Unix like operating system (OS X, Ubuntu, Debian, and more)
|
24
24
|
- Will not work on Windows (see [gollum](https://github.com/github/gollum/blob/master/README.md#system-requirements))
|
25
25
|
|
26
|
+
## [RUBY >= 2.0 READ THIS](https://github.com/nirnanaaa/gollum_rails/wiki/Ruby#ruby-2.0)
|
26
27
|
## [Installation](https://github.com/nirnanaaa/gollum_rails/wiki/Installation)
|
27
28
|
|
28
29
|
## [Usage](https://github.com/nirnanaaa/gollum_rails/wiki/Usage)
|
data/gollum_rails.gemspec
CHANGED
@@ -4,7 +4,7 @@ Gem::Specification.new do |s|
|
|
4
4
|
s.name = 'gollum_rails'
|
5
5
|
s.rubyforge_project = s.name
|
6
6
|
|
7
|
-
s.version = '0.0.
|
7
|
+
s.version = '0.0.7'
|
8
8
|
|
9
9
|
s.summary = 'Combines the benefits from Gollum and Rails'
|
10
10
|
s.description= 'Use all the benefits from Rails and combine them with the awesome Gollum wiki'
|
@@ -1,11 +1,16 @@
|
|
1
1
|
require 'rails/generators'
|
2
2
|
|
3
3
|
module GollumRails
|
4
|
+
|
5
|
+
# Generators for GollumRails
|
4
6
|
module Generators
|
7
|
+
|
8
|
+
# Installation generator
|
5
9
|
class InstallGenerator < ::Rails::Generators::Base
|
6
10
|
source_root File.expand_path("../templates", __FILE__)
|
7
11
|
desc "This generator will install gollum_rails"
|
8
12
|
|
13
|
+
# Installs the necessary files
|
9
14
|
def install_application
|
10
15
|
if File.exist? 'config/initializers/gollum.rb'
|
11
16
|
puts <<-EOM
|
@@ -26,6 +26,15 @@ module GollumRails
|
|
26
26
|
# Sets the committer
|
27
27
|
attr_writer :committer_class
|
28
28
|
|
29
|
+
# Sets the applications status
|
30
|
+
attr_writer :enabled
|
31
|
+
|
32
|
+
# Gets the enabled status
|
33
|
+
#
|
34
|
+
# Returns a boolean value
|
35
|
+
def enabled
|
36
|
+
@enabled || false
|
37
|
+
end
|
29
38
|
# Gets the Globally used Page class or use a new one if not defined
|
30
39
|
#
|
31
40
|
#
|
data/lib/gollum_rails/page.rb
CHANGED
@@ -12,11 +12,21 @@ module GollumRails
|
|
12
12
|
# * delete
|
13
13
|
# * find_or_initialize_by_naname
|
14
14
|
#
|
15
|
-
class Page
|
15
|
+
class Page
|
16
|
+
extend ::ActiveModel::Callbacks
|
16
17
|
include ::ActiveModel::Conversion
|
17
18
|
extend ::ActiveModel::Naming
|
18
19
|
|
19
20
|
|
21
|
+
# Callback for save
|
22
|
+
define_model_callbacks :save
|
23
|
+
|
24
|
+
# Callback for update
|
25
|
+
define_model_callbacks :update
|
26
|
+
|
27
|
+
# Callback for delete
|
28
|
+
define_model_callbacks :delete
|
29
|
+
|
20
30
|
# static
|
21
31
|
class << self
|
22
32
|
# Gets / Sets the gollum page
|
@@ -33,8 +43,12 @@ module GollumRails
|
|
33
43
|
#
|
34
44
|
# commit must be given to perform any page action!
|
35
45
|
def initialize(attrs = {})
|
36
|
-
|
37
|
-
|
46
|
+
if Adapters::Gollum::Connector.enabled
|
47
|
+
attrs.each{|k,v| self.instance_variable_set("@#{k}", v)}
|
48
|
+
attrs.each{|k,v| self.class.validator.instance_variable_set("@#{k}", v)}
|
49
|
+
else
|
50
|
+
raise GollumInternalError, 'gollum_rails is not enabled!'
|
51
|
+
end
|
38
52
|
end
|
39
53
|
|
40
54
|
#########
|
@@ -132,10 +146,12 @@ module GollumRails
|
|
132
146
|
#
|
133
147
|
# Returns an instance of Gollum::Page or false
|
134
148
|
def save
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
149
|
+
run_callbacks :save do
|
150
|
+
begin
|
151
|
+
page.new_page(name,content,format,commit)
|
152
|
+
rescue ::Gollum::DuplicatePageError => e
|
153
|
+
page.instance_variable_set "@page",page.find_page(name)
|
154
|
+
end
|
139
155
|
end
|
140
156
|
return page.page
|
141
157
|
end
|
@@ -182,7 +198,9 @@ module GollumRails
|
|
182
198
|
#
|
183
199
|
# Returns an instance of Gollum::Page
|
184
200
|
def update_attributes(hash, commit=nil)
|
185
|
-
|
201
|
+
run_callbacks :update do
|
202
|
+
page.update_page hash, get_right_commit(commit)
|
203
|
+
end
|
186
204
|
end
|
187
205
|
|
188
206
|
# Deletes current page (also available static. See below)
|
@@ -192,7 +210,9 @@ module GollumRails
|
|
192
210
|
#
|
193
211
|
# Returns the commit id of the current action as String
|
194
212
|
def delete(commit=nil)
|
195
|
-
|
213
|
+
run_callbacks :delete do
|
214
|
+
page.delete_page get_right_commit(commit)
|
215
|
+
end
|
196
216
|
end
|
197
217
|
|
198
218
|
# Previews the page - Mostly used if you want to see what you do before saving
|
data/lib/gollum_rails/setup.rb
CHANGED
data/lib/gollum_rails.rb
CHANGED
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: 0.0.
|
4
|
+
version: 0.0.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Florian Kasper
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-
|
11
|
+
date: 2013-04-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activemodel
|