gollum_rails 0.0.2 → 0.0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +27 -2
- data/gollum_rails.gemspec +1 -1
- data/lib/gollum/rails/page.rb +9 -0
- metadata +1 -1
data/README.md
CHANGED
@@ -36,7 +36,7 @@ If you want you can add an initializer into e.g. `config/initializers/gollum_rai
|
|
36
36
|
|
37
37
|
Gollum::Rails::Wiki.new(<location>)
|
38
38
|
|
39
|
-
Now your gollum is ready for use
|
39
|
+
Now your gollum wiki is ready for use
|
40
40
|
|
41
41
|
If you want you can add a model the same way as normal `ActiveRecord` / `ActiveModel`
|
42
42
|
|
@@ -50,9 +50,34 @@ Works like `ActiveRecord` / `ActiveModel` validation
|
|
50
50
|
|
51
51
|
some examples:
|
52
52
|
|
53
|
-
|
53
|
+
# validates the presence of the Name (already embedded into to gem)
|
54
|
+
validates_presence_of :name
|
55
|
+
|
56
|
+
# forces the name to have a given format e.g. only 0-9 a-z and A-Z
|
57
|
+
validates_format_of :name, :with => /^[a-zA-Z0-9_]+$/i
|
58
|
+
|
59
|
+
# checks if the lenght of the content fit
|
60
|
+
validates_length_of :content, :maximum => 500
|
61
|
+
|
54
62
|
## API
|
55
63
|
|
64
|
+
Accessible variables / methods are:
|
65
|
+
|
66
|
+
`Gollum::Rails::Page`
|
67
|
+
|
68
|
+
**Create a new Page:**
|
69
|
+
|
70
|
+
Example for existing model `Page`
|
71
|
+
|
72
|
+
page = Page.new {:name => 'Example page',
|
73
|
+
:content => 'some very very very very long content',
|
74
|
+
:format => :markdown,
|
75
|
+
:commit => commit_data
|
76
|
+
}
|
77
|
+
page.save
|
78
|
+
|
79
|
+
Thats it. Very easy. You can use also `page.save!` method.
|
80
|
+
|
56
81
|
|
57
82
|
## TODO
|
58
83
|
* List all pages
|
data/gollum_rails.gemspec
CHANGED
data/lib/gollum/rails/page.rb
CHANGED
@@ -108,6 +108,15 @@ module Gollum
|
|
108
108
|
return true
|
109
109
|
end
|
110
110
|
|
111
|
+
#rewrite for save() method with raising exceptions as well
|
112
|
+
def save!
|
113
|
+
if @error
|
114
|
+
raise RuntimeError, @error
|
115
|
+
else
|
116
|
+
return save
|
117
|
+
end
|
118
|
+
|
119
|
+
end
|
111
120
|
# Updates an existing page
|
112
121
|
# usage:
|
113
122
|
#
|