gollum_rails 0.0.2.8 → 0.0.5
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 +7 -0
- data/Gemfile +6 -4
- data/Gemfile.lock +151 -151
- data/HISTORY.md +43 -15
- data/LICENSE +661 -0
- data/README.md +75 -185
- data/Rakefile +170 -160
- data/examples/rails/initializer.rb +0 -0
- data/gollum_rails.gemspec +72 -57
- data/lib/gollum_rails.rb +35 -18
- data/lib/gollum_rails/adapters/activemodel.rb +46 -0
- data/lib/gollum_rails/adapters/activemodel/boolean.rb +15 -0
- data/lib/gollum_rails/adapters/activemodel/callback.rb +61 -0
- data/lib/gollum_rails/adapters/activemodel/error.rb +27 -0
- data/lib/gollum_rails/adapters/activemodel/naming.rb +42 -0
- data/lib/gollum_rails/adapters/activemodel/validation.rb +188 -0
- data/lib/gollum_rails/adapters/gollum.rb +61 -0
- data/lib/gollum_rails/adapters/gollum/.gitkeep +0 -0
- data/lib/gollum_rails/adapters/gollum/committer.rb +9 -0
- data/lib/gollum_rails/adapters/gollum/error.rb +19 -0
- data/lib/gollum_rails/adapters/gollum/page.rb +177 -0
- data/lib/gollum_rails/adapters/gollum/wiki.rb +43 -0
- data/lib/gollum_rails/initializer.rb +8 -0
- data/lib/gollum_rails/{hash.rb → modules/hash.rb} +33 -20
- data/lib/gollum_rails/modules/loader.rb +5 -0
- data/lib/gollum_rails/page.rb +283 -406
- data/lib/gollum_rails/setup.rb +68 -0
- metadata +56 -99
- data/LICENSE.md +0 -7
- data/lib/generators/gollum_rails/model/model_generator.rb +0 -10
- data/lib/gollum_rails/config.rb +0 -36
- data/lib/gollum_rails/dependency_injector.rb +0 -24
- data/lib/gollum_rails/engine.rb +0 -12
- data/lib/gollum_rails/file.rb +0 -9
- data/lib/gollum_rails/messages.yml +0 -8
- data/lib/gollum_rails/validations.rb +0 -10
- data/lib/gollum_rails/versions.rb +0 -79
- data/lib/gollum_rails/wiki.rb +0 -36
data/README.md
CHANGED
@@ -1,185 +1,75 @@
|
|
1
|
-
Gollum for Rails
|
2
|
-
================
|
3
|
-
[](https://travis-ci.org/nirnanaaa/gollum_rails)
|
4
|
-
[](https://gemnasium.com/nirnanaaa/gollum_rails)
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
*
|
15
|
-
* Use
|
16
|
-
*
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
-
|
22
|
-
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
Thats it. Very easy. You can use also `page.save!` method.
|
77
|
-
|
78
|
-
|
79
|
-
**Update an existing page**
|
80
|
-
|
81
|
-
page = Page.new
|
82
|
-
page.find('Example page')
|
83
|
-
page.update('some very long content', commit_data)
|
84
|
-
|
85
|
-
# you can also change the name
|
86
|
-
|
87
|
-
page.update('some very long content', commit_data, 'new-name')
|
88
|
-
|
89
|
-
# and the format (page will be recreated)
|
90
|
-
|
91
|
-
page.update('some very long content', commit_data, nil, :wiki)
|
92
|
-
|
93
|
-
|
94
|
-
**Delete a page**
|
95
|
-
|
96
|
-
page = Page.new
|
97
|
-
page.find('Example page')
|
98
|
-
page.delete
|
99
|
-
|
100
|
-
# or
|
101
|
-
|
102
|
-
page.delete!
|
103
|
-
|
104
|
-
# for getting errors instead of `NIL`
|
105
|
-
|
106
|
-
**Set data manually**
|
107
|
-
|
108
|
-
page = Page.new
|
109
|
-
|
110
|
-
page.name = "testpage"
|
111
|
-
page.content = "content"
|
112
|
-
page.format = :markdown
|
113
|
-
page.commit = {
|
114
|
-
:message => "test action on page",
|
115
|
-
:name => 'Florian Kasper',
|
116
|
-
:email => 'nirnanaaa@khnetworks.com'
|
117
|
-
}
|
118
|
-
|
119
|
-
**Preview a page (AJAX/or not)**
|
120
|
-
|
121
|
-
page = Page.new
|
122
|
-
preview = page.preview("testpage", "content") # or page.preview("testpage", "content", :format)
|
123
|
-
|
124
|
-
# preview contains the HTML rendered data!
|
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
|
-
|
149
|
-
## TODO
|
150
|
-
* List all pages
|
151
|
-
* Search pages
|
152
|
-
* embed gollum :markdown editor
|
153
|
-
|
154
|
-
## DEVELOPER
|
155
|
-
|
156
|
-
Very cool. Just fork this repository and send pull requests ;)
|
157
|
-
|
158
|
-
### QUICK START
|
159
|
-
|
160
|
-
Clone the repository:
|
161
|
-
|
162
|
-
$ git clone git://github.com/nirnanaaa/gollum_rails.git
|
163
|
-
|
164
|
-
Run the [Bundler](http://gembundler.com/):
|
165
|
-
|
166
|
-
$ bundle install
|
167
|
-
|
168
|
-
|
169
|
-
### TESTING
|
170
|
-
|
171
|
-
First use the Quick Start to install all dependencys.
|
172
|
-
All tests are stored under the `test/` directory.
|
173
|
-
|
174
|
-
First you must create a `wiki` repository.
|
175
|
-
|
176
|
-
$ git init test/wiki
|
177
|
-
|
178
|
-
To run tests just use the `rake` command:
|
179
|
-
|
180
|
-
$ bundle exec rake
|
181
|
-
|
182
|
-
BE CAREFUL! THE FIRST TEST WILL FAIL BECAUSE THE NECESSARY STATIC FILES ARE NOT EXISTING
|
183
|
-
|
184
|
-
|
185
|
-
## EXAMPLE
|
1
|
+
Gollum for Rails
|
2
|
+
================
|
3
|
+
[](https://travis-ci.org/nirnanaaa/gollum_rails)
|
4
|
+
[](https://gemnasium.com/nirnanaaa/gollum_rails)
|
5
|
+
[](http://badge.fury.io/rb/gollum_rails)
|
6
|
+
[](https://coveralls.io/r/nirnanaaa/gollum_rails)
|
7
|
+
|
8
|
+
|
9
|
+
gollum_rails combines the git-powered wiki software gollum with the extremely popular webframework rails.
|
10
|
+
It improves the lightweight "gollum" experience which is quite awesome.
|
11
|
+
|
12
|
+
with gollum_rails you can:
|
13
|
+
|
14
|
+
* Define your own views
|
15
|
+
* Use your Rails layouts
|
16
|
+
* Embed gollum it without mounting any rack application
|
17
|
+
* Use own preprocession e.g. background workers for data procession
|
18
|
+
* Use user authentication e.g. Devise or Authlogic
|
19
|
+
|
20
|
+
## SYSTEM REQUIREMENTS
|
21
|
+
- Python 2.5+ (2.7.3 recommended)
|
22
|
+
- Ruby 1.9.3+ (2.0.0 recommended)
|
23
|
+
- Unix like operating system (OS X, Ubuntu, Debian, and more)
|
24
|
+
- Will not work on Windows (see [gollum](https://github.com/github/gollum/blob/master/README.md#system-requirements))
|
25
|
+
|
26
|
+
## [Installation](https://github.com/nirnanaaa/gollum_rails/wiki/Installation)
|
27
|
+
|
28
|
+
## [Usage](https://github.com/nirnanaaa/gollum_rails/wiki/Usage)
|
29
|
+
|
30
|
+
|
31
|
+
## DEVELOPER
|
32
|
+
|
33
|
+
Very cool. Just fork this repository and send me pull requests.
|
34
|
+
|
35
|
+
### QUICK START
|
36
|
+
|
37
|
+
Clone the repository:
|
38
|
+
|
39
|
+
$ git clone git://github.com/nirnanaaa/gollum_rails.git
|
40
|
+
|
41
|
+
Run the [Bundler](http://gembundler.com/):
|
42
|
+
|
43
|
+
$ bundle install
|
44
|
+
|
45
|
+
|
46
|
+
### TESTING
|
47
|
+
|
48
|
+
First use the Quick Start to install all dependencies.
|
49
|
+
All tests are stored under the `spec/` directory.
|
50
|
+
|
51
|
+
To run tests just use the `rspec` command:
|
52
|
+
|
53
|
+
$ bundle exec rspec
|
54
|
+
|
55
|
+
## LICENSE
|
56
|
+
|
57
|
+
[](http://www.gnu.org/licenses/agpl-3.0.en.html)
|
58
|
+
|
59
|
+
gollum_rails is licensed under the AGPL license.
|
60
|
+
|
61
|
+
Copyright (C) 2013 Florian Kasper
|
62
|
+
|
63
|
+
This program is free software: you can redistribute it and/or modify
|
64
|
+
it under the terms of the GNU Affero General Public License as published by
|
65
|
+
the Free Software Foundation, either version 3 of the License, or
|
66
|
+
(at your option) any later version.
|
67
|
+
|
68
|
+
This program is distributed in the hope that it will be useful,
|
69
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
70
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
71
|
+
GNU Affero General Public License for more details.
|
72
|
+
|
73
|
+
You should have received a copy of the GNU Affero General Public License
|
74
|
+
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
75
|
+
|
data/Rakefile
CHANGED
@@ -1,160 +1,170 @@
|
|
1
|
-
require 'rubygems'
|
2
|
-
require 'rake'
|
3
|
-
require 'date'
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
#
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
#
|
25
|
-
v
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
#
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
end
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
#
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
sh "
|
120
|
-
sh "
|
121
|
-
sh "
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
#
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake'
|
3
|
+
require 'date'
|
4
|
+
require 'rspec/core/rake_task'
|
5
|
+
|
6
|
+
|
7
|
+
#############################################################################
|
8
|
+
#
|
9
|
+
# Helper functions
|
10
|
+
#
|
11
|
+
#############################################################################
|
12
|
+
|
13
|
+
def name
|
14
|
+
@name ||= Dir['*.gemspec'].first.split('.').first
|
15
|
+
end
|
16
|
+
|
17
|
+
def version
|
18
|
+
line = File.read("lib/#{name}.rb")[/^\s*VERSION\s*=\s*.*/]
|
19
|
+
line.match(/.*VERSION\s*=\s*['"](.*)['"]/)[1]
|
20
|
+
end
|
21
|
+
|
22
|
+
# assumes x.y.z all digit version
|
23
|
+
def next_version
|
24
|
+
# x.y.z
|
25
|
+
v = version.split '.'
|
26
|
+
# bump z
|
27
|
+
v[-1] = v[-1].to_i + 1
|
28
|
+
v.join '.'
|
29
|
+
end
|
30
|
+
|
31
|
+
def bump_version
|
32
|
+
old_file = File.read("lib/#{name}.rb")
|
33
|
+
old_version_line = old_file[/^\s*VERSION\s*=\s*.*/]
|
34
|
+
new_version = next_version
|
35
|
+
# replace first match of old vesion with new version
|
36
|
+
old_file.sub!(old_version_line, " VERSION = '#{new_version}'")
|
37
|
+
|
38
|
+
File.write("lib/#{name}.rb", old_file)
|
39
|
+
|
40
|
+
new_version
|
41
|
+
end
|
42
|
+
|
43
|
+
def date
|
44
|
+
Date.today.to_s
|
45
|
+
end
|
46
|
+
|
47
|
+
def rubyforge_project
|
48
|
+
name
|
49
|
+
end
|
50
|
+
|
51
|
+
def gemspec_file
|
52
|
+
"#{name}.gemspec"
|
53
|
+
end
|
54
|
+
|
55
|
+
def gem_file
|
56
|
+
"#{name}-#{version}.gem"
|
57
|
+
end
|
58
|
+
|
59
|
+
def replace_header(head, header_name)
|
60
|
+
head.sub!(/(\.#{header_name}\s*= ').*'/) { "#{$1}#{send(header_name)}'"}
|
61
|
+
end
|
62
|
+
|
63
|
+
#############################################################################
|
64
|
+
#
|
65
|
+
# Standard tasks
|
66
|
+
#
|
67
|
+
#############################################################################
|
68
|
+
|
69
|
+
task :default => :spec_run
|
70
|
+
|
71
|
+
desc "Run RSpec"
|
72
|
+
RSpec::Core::RakeTask.new do |t|
|
73
|
+
t.verbose = false
|
74
|
+
end
|
75
|
+
|
76
|
+
desc "Run specs"
|
77
|
+
task :spec_run do
|
78
|
+
begin
|
79
|
+
sh "rake spec"
|
80
|
+
rescue RuntimeError => e
|
81
|
+
puts e.message
|
82
|
+
exit(1)
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
|
87
|
+
desc "Open an irb session preloaded with this library"
|
88
|
+
task :console do
|
89
|
+
sh "irb -rubygems -r ./lib/#{name}.rb"
|
90
|
+
end
|
91
|
+
|
92
|
+
#############################################################################
|
93
|
+
#
|
94
|
+
# Custom tasks (add your own tasks here)
|
95
|
+
#
|
96
|
+
#############################################################################
|
97
|
+
|
98
|
+
desc "Update version number and gemspec"
|
99
|
+
task :bump do
|
100
|
+
puts "Updated version to #{bump_version}"
|
101
|
+
# Execute does not invoke dependencies.
|
102
|
+
# Manually invoke gemspec then validate.
|
103
|
+
Rake::Task[:gemspec].execute
|
104
|
+
Rake::Task[:validate].execute
|
105
|
+
end
|
106
|
+
|
107
|
+
#############################################################################
|
108
|
+
#
|
109
|
+
# Packaging tasks
|
110
|
+
#
|
111
|
+
#############################################################################
|
112
|
+
|
113
|
+
desc 'Create a release build'
|
114
|
+
task :release => :build do
|
115
|
+
unless `git branch` =~ /^\* master$/
|
116
|
+
puts "You must be on the master branch to release!"
|
117
|
+
exit!
|
118
|
+
end
|
119
|
+
sh "git commit --allow-empty -a -m 'Release #{version}'"
|
120
|
+
sh "git pull"
|
121
|
+
sh "git tag v#{version}"
|
122
|
+
sh "git push origin master"
|
123
|
+
sh "git push origin v#{version}"
|
124
|
+
sh "gem push pkg/#{name}-#{version}.gem"
|
125
|
+
end
|
126
|
+
|
127
|
+
desc 'Build gem'
|
128
|
+
task :build => :gemspec do
|
129
|
+
sh "mkdir -p pkg"
|
130
|
+
sh "gem build #{gemspec_file}"
|
131
|
+
sh "mv #{gem_file} pkg"
|
132
|
+
end
|
133
|
+
|
134
|
+
desc 'Update gemspec'
|
135
|
+
task :gemspec => :validate do
|
136
|
+
# read spec file and split out manifest section
|
137
|
+
spec = File.read(gemspec_file)
|
138
|
+
head, manifest, tail = spec.split(" # = MANIFEST =\n")
|
139
|
+
# replace name version and date
|
140
|
+
replace_header(head, :name)
|
141
|
+
replace_header(head, :version)
|
142
|
+
replace_header(head, :date)
|
143
|
+
#comment this out if your rubyforge_project has a different name
|
144
|
+
replace_header(head, :rubyforge_project)
|
145
|
+
|
146
|
+
# determine file list from git ls-files
|
147
|
+
files = `git ls-files`.
|
148
|
+
split("\n").
|
149
|
+
sort.
|
150
|
+
reject { |file| file =~ /^\./ }.
|
151
|
+
reject { |file| file =~ /^(doc|pkg|spec|Home\.md|\.gitattributes)/ }.
|
152
|
+
map { |file| " #{file}" }.
|
153
|
+
join("\n")
|
154
|
+
|
155
|
+
# piece file back together and write
|
156
|
+
manifest = " s.files = %w[\n#{files}\n ]\n"
|
157
|
+
spec = [head, manifest, tail].join(" # = MANIFEST =\n")
|
158
|
+
File.open(gemspec_file, 'w') { |io| io.write(spec) }
|
159
|
+
puts "Updated #{gemspec_file}"
|
160
|
+
end
|
161
|
+
|
162
|
+
desc 'Validate lib files and version file'
|
163
|
+
task :validate do
|
164
|
+
libfiles = Dir['lib/*'] - ["lib/#{name}.rb", "lib/#{name}", "lib/generators"]
|
165
|
+
unless Dir['VERSION*'].empty?
|
166
|
+
puts "A `VERSION` file at root level violates Gem best practices."
|
167
|
+
exit!
|
168
|
+
end
|
169
|
+
end
|
170
|
+
|