gollum_rails 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +102 -0
- data/gollum_rails.gemspec +5 -3
- data/lib/gollum/rails/config.rb +2 -2
- data/lib/gollum/rails/hash.rb +7 -0
- data/lib/gollum/rails/messages.yml +7 -2
- data/lib/gollum/rails/page.rb +28 -9
- metadata +5 -4
data/README.md
CHANGED
@@ -0,0 +1,102 @@
|
|
1
|
+
Gollum for Rails
|
2
|
+
================
|
3
|
+
|
4
|
+
Gollum for Rails combines the benefits from gollum with the flexibility of Rails.
|
5
|
+
|
6
|
+
It improves the lightweight "gollum" experience which is quite awesome.
|
7
|
+
|
8
|
+
You can:
|
9
|
+
|
10
|
+
* Define your own views
|
11
|
+
* Use your Rails layouts
|
12
|
+
* Embed it without mounting something in your Rack app
|
13
|
+
* Use own preprocession e.g. Sidekiq for Async Syntax highlightning
|
14
|
+
* Use user Authentication e.g. Devise or Authlogic
|
15
|
+
|
16
|
+
## SYSTEM REQUIREMENTS
|
17
|
+
- Python 2.5+ (2.7.3 recommended)
|
18
|
+
- Ruby 1.8.7+ (1.9.3 recommended)
|
19
|
+
- Unix like operating system (OS X, Ubuntu, Debian, and more)
|
20
|
+
- Will not work on Windows (see [gollum](https://github.com/github/gollum/blob/master/README.md#system-requirements))
|
21
|
+
|
22
|
+
## INSTALLATION
|
23
|
+
|
24
|
+
Put
|
25
|
+
|
26
|
+
gem 'gollum_rails'
|
27
|
+
|
28
|
+
|
29
|
+
in your `Gemfile`
|
30
|
+
|
31
|
+
Then just run the [Bundler](http://gembundler.com/)
|
32
|
+
|
33
|
+
$ bundle install
|
34
|
+
|
35
|
+
If you want you can add an initializer into e.g. `config/initializers/gollum_rails.rb`
|
36
|
+
|
37
|
+
Gollum::Rails::Wiki.new(<location>)
|
38
|
+
|
39
|
+
Now your gollum is ready for use
|
40
|
+
|
41
|
+
If you want you can add a model the same way as normal `ActiveRecord` / `ActiveModel`
|
42
|
+
|
43
|
+
class Page < Gollum::Rails::Page
|
44
|
+
|
45
|
+
end
|
46
|
+
|
47
|
+
## Validating
|
48
|
+
|
49
|
+
Works like `ActiveRecord` / `ActiveModel` validation
|
50
|
+
|
51
|
+
some examples:
|
52
|
+
|
53
|
+
|
54
|
+
## API
|
55
|
+
|
56
|
+
|
57
|
+
## TODO
|
58
|
+
* List all pages
|
59
|
+
* Search pages
|
60
|
+
* embed gollum :markdown editor
|
61
|
+
|
62
|
+
## DEVELOPER
|
63
|
+
|
64
|
+
Very cool. Just fork this repository and send pull requests ;)
|
65
|
+
|
66
|
+
### QUICK START
|
67
|
+
|
68
|
+
Clone the repository:
|
69
|
+
|
70
|
+
$ git clone git://github.com/nirnanaaa/gollum_rails.git
|
71
|
+
|
72
|
+
Run the [Bundler](http://gembundler.com/):
|
73
|
+
|
74
|
+
$ bundle install
|
75
|
+
|
76
|
+
|
77
|
+
### TESTING
|
78
|
+
|
79
|
+
First use the Quick Start to install all dependencys.
|
80
|
+
All tests are stored under the `test/` directory.
|
81
|
+
|
82
|
+
First you must create a `wiki` repository.
|
83
|
+
|
84
|
+
$ git init test/wiki
|
85
|
+
|
86
|
+
To run tests just use the `rake` command:
|
87
|
+
|
88
|
+
$ bundle exec rake
|
89
|
+
|
90
|
+
BE CAREFUL! THE FIRST TEST WILL FAIL BECAUSE THE NECESSARY STATIC FILES ARE NOT EXISTING
|
91
|
+
|
92
|
+
|
93
|
+
## EXAMPLE
|
94
|
+
## LICENSE
|
95
|
+
Copyright � 2013 Florian Kasper
|
96
|
+
|
97
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the �Software�), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
98
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
99
|
+
|
100
|
+
THE SOFTWARE IS PROVIDED �AS IS�, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
101
|
+
|
102
|
+
|
data/gollum_rails.gemspec
CHANGED
@@ -1,9 +1,10 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = 'gollum_rails'
|
3
|
-
s.version = '0.0.
|
3
|
+
s.version = '0.0.2'
|
4
4
|
|
5
|
-
s.summary = 'Combines Gollum
|
6
|
-
s.description=
|
5
|
+
s.summary = 'Combines the benefits from Gollum with Rails'
|
6
|
+
s.description= 'use templating, authentication and so on'
|
7
|
+
#File.read(File.join(File.dirname(__FILE__), 'README.md'))
|
7
8
|
|
8
9
|
s.add_dependency('activemodel', '~> 3.2.11')
|
9
10
|
s.add_dependency('gollum', '~> 2.4.11')
|
@@ -37,6 +38,7 @@ Gem::Specification.new do |s|
|
|
37
38
|
lib/gollum/rails/engine.rb
|
38
39
|
lib/gollum/rails/config.rb
|
39
40
|
lib/gollum/rails/messages.yml
|
41
|
+
lib/gollum/rails/hash.rb
|
40
42
|
]
|
41
43
|
s.require_paths = %w[lib]
|
42
44
|
s.has_rdoc = false
|
data/lib/gollum/rails/config.rb
CHANGED
@@ -1,2 +1,7 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
messages:
|
2
|
+
name_not_set_or_nil: The name is not set or is NIL
|
3
|
+
commit_not_empty_and_content_not_empty: The commit must be set and also the content
|
4
|
+
commit_must_be_given: Commit must not be empty or nil
|
5
|
+
no_page_fetched: No page was fetched
|
6
|
+
no_page_found: The page was not found
|
7
|
+
format_not_set: The format was not set
|
data/lib/gollum/rails/page.rb
CHANGED
@@ -1,8 +1,10 @@
|
|
1
1
|
# ~*~ encoding: utf-8 ~*~
|
2
|
+
require "gollum/rails/hash"
|
2
3
|
module Gollum
|
3
4
|
module Rails
|
4
|
-
class Page
|
5
|
+
class Page
|
5
6
|
include ActiveModel::Conversion
|
7
|
+
include ActiveModel::Validations
|
6
8
|
extend ActiveModel::Naming
|
7
9
|
|
8
10
|
#the filename
|
@@ -27,7 +29,7 @@ module Gollum
|
|
27
29
|
# the commit Hash
|
28
30
|
attr_accessor :commit
|
29
31
|
|
30
|
-
#
|
32
|
+
# Holds a ::Hash of config options
|
31
33
|
attr_accessor :options
|
32
34
|
|
33
35
|
# a boolean variable that holds the status of save() and update()
|
@@ -38,6 +40,10 @@ module Gollum
|
|
38
40
|
|
39
41
|
# holds an instance of Gollum::Wiki
|
40
42
|
attr_reader :wiki
|
43
|
+
|
44
|
+
# class names
|
45
|
+
attr_reader :class
|
46
|
+
|
41
47
|
# attributes needs to be a hash
|
42
48
|
# example:
|
43
49
|
# Gollum::Rails::Page.new({name: '', content: '', format: '', commit: {}})
|
@@ -55,8 +61,16 @@ module Gollum
|
|
55
61
|
# }
|
56
62
|
def initialize(attributes = {}, options = {})
|
57
63
|
wiki = DependencyInjector.get('wiki')
|
64
|
+
config = DependencyInjector.get('config')
|
58
65
|
if wiki && wiki.is_a?(Wiki)
|
59
66
|
@wiki = wiki
|
67
|
+
else
|
68
|
+
raise RuntimeError
|
69
|
+
end
|
70
|
+
if config && config.is_a?(Hash)
|
71
|
+
@options = config
|
72
|
+
else
|
73
|
+
raise RuntimeError
|
60
74
|
end
|
61
75
|
if !Validations.is_boolean?(@persisted)
|
62
76
|
@persisted = false
|
@@ -118,7 +132,7 @@ module Gollum
|
|
118
132
|
@format = format
|
119
133
|
end
|
120
134
|
if commit.nil? || content.nil?
|
121
|
-
@error =
|
135
|
+
@error = @options.messages.commit_not_empty_and_content_not_empty
|
122
136
|
return false
|
123
137
|
end
|
124
138
|
return @wiki.wiki.update_page(@page, @name, @format, content, commit)
|
@@ -127,7 +141,7 @@ module Gollum
|
|
127
141
|
# Deletes page fetched by find()
|
128
142
|
def delete(commit)
|
129
143
|
if commit.nil?
|
130
|
-
@error =
|
144
|
+
@error = @options.messages.commit_must_be_given
|
131
145
|
return false
|
132
146
|
end
|
133
147
|
return @wiki.wiki.delete_page(@page, commit)
|
@@ -137,7 +151,7 @@ module Gollum
|
|
137
151
|
if @page
|
138
152
|
@page.raw_data
|
139
153
|
else
|
140
|
-
@error =
|
154
|
+
@error = @options.messages.no_page_fetched
|
141
155
|
return false
|
142
156
|
end
|
143
157
|
end
|
@@ -147,7 +161,7 @@ module Gollum
|
|
147
161
|
if @page
|
148
162
|
@page.formatted_data
|
149
163
|
else
|
150
|
-
@error =
|
164
|
+
@error = @options.messages.no_page_fetched
|
151
165
|
return false
|
152
166
|
end
|
153
167
|
end
|
@@ -162,7 +176,7 @@ module Gollum
|
|
162
176
|
if @page
|
163
177
|
@page.versions
|
164
178
|
else
|
165
|
-
@error =
|
179
|
+
@error = @options.messages.no_page_fetched
|
166
180
|
return false
|
167
181
|
end
|
168
182
|
end
|
@@ -178,16 +192,21 @@ module Gollum
|
|
178
192
|
# format must be set
|
179
193
|
def valid?
|
180
194
|
if !@name || @name.nil?
|
195
|
+
@error = @options.messages.name_not_set_or_nil
|
181
196
|
return false
|
182
197
|
end
|
183
198
|
if !@commit || !@commit.is_a?(Hash)
|
199
|
+
@error = @options.messages.commit_must_be_given
|
184
200
|
return false
|
185
201
|
end
|
186
202
|
if !@format
|
203
|
+
@error = @options.messages.format_not_set
|
187
204
|
return false
|
188
205
|
end
|
206
|
+
|
207
|
+
super
|
208
|
+
|
189
209
|
return true
|
190
|
-
|
191
210
|
end
|
192
211
|
|
193
212
|
#gets an Instance of Gollum::Wiki fetched by find() method
|
@@ -198,7 +217,7 @@ module Gollum
|
|
198
217
|
if !name.nil?
|
199
218
|
page = @wiki.wiki.page(name)
|
200
219
|
if page.nil?
|
201
|
-
@error =
|
220
|
+
@error = @options.messages.no_page_found
|
202
221
|
return nil
|
203
222
|
end
|
204
223
|
|
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.
|
4
|
+
version: 0.0.2
|
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-27 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activemodel
|
@@ -171,7 +171,7 @@ dependencies:
|
|
171
171
|
- - ~>
|
172
172
|
- !ruby/object:Gem::Version
|
173
173
|
version: 3.2.11
|
174
|
-
description:
|
174
|
+
description: use templating, authentication and so on
|
175
175
|
email: nirnanaaa@khnetworks.com
|
176
176
|
executables: []
|
177
177
|
extensions: []
|
@@ -192,6 +192,7 @@ files:
|
|
192
192
|
- lib/gollum/rails/engine.rb
|
193
193
|
- lib/gollum/rails/config.rb
|
194
194
|
- lib/gollum/rails/messages.yml
|
195
|
+
- lib/gollum/rails/hash.rb
|
195
196
|
homepage: https://github.com/nirnanaaa/gollum_rails
|
196
197
|
licenses: []
|
197
198
|
post_install_message:
|
@@ -215,5 +216,5 @@ rubyforge_project:
|
|
215
216
|
rubygems_version: 1.8.23
|
216
217
|
signing_key:
|
217
218
|
specification_version: 3
|
218
|
-
summary: Combines Gollum
|
219
|
+
summary: Combines the benefits from Gollum with Rails
|
219
220
|
test_files: []
|