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.
Files changed (38) hide show
  1. checksums.yaml +7 -0
  2. data/Gemfile +6 -4
  3. data/Gemfile.lock +151 -151
  4. data/HISTORY.md +43 -15
  5. data/LICENSE +661 -0
  6. data/README.md +75 -185
  7. data/Rakefile +170 -160
  8. data/examples/rails/initializer.rb +0 -0
  9. data/gollum_rails.gemspec +72 -57
  10. data/lib/gollum_rails.rb +35 -18
  11. data/lib/gollum_rails/adapters/activemodel.rb +46 -0
  12. data/lib/gollum_rails/adapters/activemodel/boolean.rb +15 -0
  13. data/lib/gollum_rails/adapters/activemodel/callback.rb +61 -0
  14. data/lib/gollum_rails/adapters/activemodel/error.rb +27 -0
  15. data/lib/gollum_rails/adapters/activemodel/naming.rb +42 -0
  16. data/lib/gollum_rails/adapters/activemodel/validation.rb +188 -0
  17. data/lib/gollum_rails/adapters/gollum.rb +61 -0
  18. data/lib/gollum_rails/adapters/gollum/.gitkeep +0 -0
  19. data/lib/gollum_rails/adapters/gollum/committer.rb +9 -0
  20. data/lib/gollum_rails/adapters/gollum/error.rb +19 -0
  21. data/lib/gollum_rails/adapters/gollum/page.rb +177 -0
  22. data/lib/gollum_rails/adapters/gollum/wiki.rb +43 -0
  23. data/lib/gollum_rails/initializer.rb +8 -0
  24. data/lib/gollum_rails/{hash.rb → modules/hash.rb} +33 -20
  25. data/lib/gollum_rails/modules/loader.rb +5 -0
  26. data/lib/gollum_rails/page.rb +283 -406
  27. data/lib/gollum_rails/setup.rb +68 -0
  28. metadata +56 -99
  29. data/LICENSE.md +0 -7
  30. data/lib/generators/gollum_rails/model/model_generator.rb +0 -10
  31. data/lib/gollum_rails/config.rb +0 -36
  32. data/lib/gollum_rails/dependency_injector.rb +0 -24
  33. data/lib/gollum_rails/engine.rb +0 -12
  34. data/lib/gollum_rails/file.rb +0 -9
  35. data/lib/gollum_rails/messages.yml +0 -8
  36. data/lib/gollum_rails/validations.rb +0 -10
  37. data/lib/gollum_rails/versions.rb +0 -79
  38. data/lib/gollum_rails/wiki.rb +0 -36
data/README.md CHANGED
@@ -1,185 +1,75 @@
1
- Gollum for Rails
2
- ================
3
- [![Build Status](https://travis-ci.org/nirnanaaa/gollum_rails.png?branch=master)](https://travis-ci.org/nirnanaaa/gollum_rails)
4
- [![Dependency Status](https://gemnasium.com/nirnanaaa/gollum_rails.png)](https://gemnasium.com/nirnanaaa/gollum_rails)
5
-
6
- Gollum for Rails combines the benefits from gollum with the flexibility of Rails.
7
-
8
- It improves the lightweight "gollum" experience which is quite awesome.
9
-
10
- You can:
11
-
12
- * Define your own views
13
- * Use your Rails layouts
14
- * Embed it without mounting something in your Rack app
15
- * Use own preprocession e.g. Sidekiq for Async Syntax highlightning
16
- * Use user Authentication e.g. Devise or Authlogic
17
-
18
- ## SYSTEM REQUIREMENTS
19
- - Python 2.5+ (2.7.3 recommended)
20
- - Ruby 1.8.7+ (1.9.3 recommended)
21
- - Unix like operating system (OS X, Ubuntu, Debian, and more)
22
- - Will not work on Windows (see [gollum](https://github.com/github/gollum/blob/master/README.md#system-requirements))
23
-
24
- ## INSTALLATION
25
-
26
- Put
27
-
28
- gem 'gollum_rails'
29
-
30
-
31
- in your `Gemfile`
32
-
33
- Then just run the [Bundler](http://gembundler.com/)
34
-
35
- $ bundle install
36
-
37
- If you want you can add an initializer into e.g. `config/initializers/gollum_rails.rb`
38
-
39
- GollumRails::Wiki.new(<location>)
40
-
41
- Now your gollum wiki is ready for use
42
-
43
- If you want you can add a model the same way as normal `ActiveRecord` / `ActiveModel`
44
-
45
- class Page < GollumRails::Page
46
-
47
- end
48
-
49
- ## API
50
-
51
- Accessible variables / methods are:
52
-
53
- For: `GollumRails::Page`
54
-
55
- Every action returns a `String`, containing the commit id of the current action
56
-
57
- First: For each action you write on a wiki page, a commit must be given. So lets do this. The commit MUST be a `Hash`
58
-
59
- commit_data = {
60
- :message => "test action on page",
61
- :name => 'Florian Kasper',
62
- :email => 'nirnanaaa@khnetworks.com'
63
- }
64
-
65
- **Create a new Page:**
66
-
67
- Example for existing model `Page`
68
-
69
- page = Page.new {:name => 'Example page',
70
- :content => 'some very very very very long content',
71
- :format => :markdown,
72
- :commit => commit_data
73
- }
74
- page.save
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
+ [![Build Status](https://travis-ci.org/nirnanaaa/gollum_rails.png?branch=master)](https://travis-ci.org/nirnanaaa/gollum_rails)
4
+ [![Dependency Status](https://gemnasium.com/nirnanaaa/gollum_rails.png)](https://gemnasium.com/nirnanaaa/gollum_rails)
5
+ [![Gem Version](https://badge.fury.io/rb/gollum_rails.png)](http://badge.fury.io/rb/gollum_rails)
6
+ [![Coverage Status](https://coveralls.io/repos/nirnanaaa/gollum_rails/badge.png?branch=master)](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
+ [![AGPLv3](http://www.gnu.org/graphics/agplv3-155x51.png)](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
- # Helper functions
8
- #
9
- #############################################################################
10
-
11
- def name
12
- @name ||= Dir['*.gemspec'].first.split('.').first
13
- end
14
-
15
- def version
16
- line = File.read("lib/#{name}.rb")[/^\s*VERSION\s*=\s*.*/]
17
- line.match(/.*VERSION\s*=\s*['"](.*)['"]/)[1]
18
- end
19
-
20
- # assumes x.y.z all digit version
21
- def next_version
22
- # x.y.z
23
- v = version.split '.'
24
- # bump z
25
- v[-1] = v[-1].to_i + 1
26
- v.join '.'
27
- end
28
-
29
- def bump_version
30
- old_file = File.read("lib/#{name}.rb")
31
- old_version_line = old_file[/^\s*VERSION\s*=\s*.*/]
32
- new_version = next_version
33
- # replace first match of old vesion with new version
34
- old_file.sub!(old_version_line, " VERSION = '#{new_version}'")
35
-
36
- File.write("lib/#{name}.rb", old_file)
37
-
38
- new_version
39
- end
40
-
41
- def date
42
- Date.today.to_s
43
- end
44
-
45
- def rubyforge_project
46
- name
47
- end
48
-
49
- def gemspec_file
50
- "#{name}.gemspec"
51
- end
52
-
53
- def gem_file
54
- "#{name}-#{version}.gem"
55
- end
56
-
57
- def replace_header(head, header_name)
58
- head.sub!(/(\.#{header_name}\s*= ').*'/) { "#{$1}#{send(header_name)}'"}
59
- end
60
-
61
- #############################################################################
62
- #
63
- # Standard tasks
64
- #
65
- #############################################################################
66
-
67
- task :default => :test
68
-
69
- require 'rake/testtask'
70
- Rake::TestTask.new(:test) do |test|
71
- test.libs << 'lib' << 'test' << '.'
72
- test.pattern = 'test/**/test_*.rb'
73
- test.verbose = true
74
- end
75
-
76
-
77
- desc "Open an irb session preloaded with this library"
78
- task :console do
79
- sh "irb -rubygems -r ./lib/#{name}.rb"
80
- end
81
-
82
- #############################################################################
83
- #
84
- # Custom tasks (add your own tasks here)
85
- #
86
- #############################################################################
87
-
88
- desc "Update version number and gemspec"
89
- task :bump do
90
- puts "Updated version to #{bump_version}"
91
- # Execute does not invoke dependencies.
92
- # Manually invoke gemspec then validate.
93
- Rake::Task[:gemspec].execute
94
- Rake::Task[:validate].execute
95
- end
96
-
97
- #############################################################################
98
- #
99
- # Packaging tasks
100
- #
101
- #############################################################################
102
-
103
- desc 'Create a release build'
104
- task :release => :build do
105
- unless `git branch` =~ /^\* master$/
106
- puts "You must be on the master branch to release!"
107
- exit!
108
- end
109
- sh "git commit --allow-empty -a -m 'Release #{version}'"
110
- sh "git pull"
111
- sh "git tag v#{version}"
112
- sh "git push origin master"
113
- sh "git push origin v#{version}"
114
- sh "gem push pkg/#{name}-#{version}.gem"
115
- end
116
-
117
- desc 'Build gem'
118
- task :build => :gemspec do
119
- sh "mkdir -p pkg"
120
- sh "gem build #{gemspec_file}"
121
- sh "mv #{gem_file} pkg"
122
- end
123
-
124
- desc 'Update gemspec'
125
- task :gemspec => :validate do
126
- # read spec file and split out manifest section
127
- spec = File.read(gemspec_file)
128
- head, manifest, tail = spec.split(" # = MANIFEST =\n")
129
- # replace name version and date
130
- replace_header(head, :name)
131
- replace_header(head, :version)
132
- replace_header(head, :date)
133
- #comment this out if your rubyforge_project has a different name
134
- replace_header(head, :rubyforge_project)
135
-
136
- # determine file list from git ls-files
137
- files = `git ls-files`.
138
- split("\n").
139
- sort.
140
- reject { |file| file =~ /^\./ }.
141
- reject { |file| file =~ /^(doc|pkg|test|Home\.md|\.gitattributes)/ }.
142
- map { |file| " #{file}" }.
143
- join("\n")
144
-
145
- # piece file back together and write
146
- manifest = " s.files = %w[\n#{files}\n ]\n"
147
- spec = [head, manifest, tail].join(" # = MANIFEST =\n")
148
- #File.open(gemspec_file, 'w') { |io| io.write(spec) }
149
- puts "Updated #{gemspec_file}"
150
- end
151
-
152
- desc 'Validate lib files and version file'
153
- task :validate do
154
- libfiles = Dir['lib/*'] - ["lib/#{name}.rb", "lib/#{name}", "lib/generators"]
155
- unless Dir['VERSION*'].empty?
156
- puts "A `VERSION` file at root level violates Gem best practices."
157
- exit!
158
- end
159
- end
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
+