irwi 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +14 -1
- data/VERSION +1 -1
- data/app/views/base_wiki_pages/_wiki_page_actions.html.erb +2 -1
- data/irwi.gemspec +2 -2
- data/lib/irwi/extensions/controllers/wiki_pages.rb +20 -7
- data/lib/irwi/helpers/wiki_pages_helper.rb +1 -1
- data/lib/irwi/support/route_mapper.rb +2 -0
- data/spec/extensions/controllers/wiki_pages_spec.rb +1 -0
- metadata +2 -2
data/README.rdoc
CHANGED
@@ -4,7 +4,20 @@ Irwi is Ruby on Rails plugin which adds wiki functionality to your application.
|
|
4
4
|
|
5
5
|
== Installation
|
6
6
|
|
7
|
-
|
7
|
+
Setup gemcutter as gem source:
|
8
|
+
|
9
|
+
sudo gem install gemcutter
|
10
|
+
gem tumble
|
11
|
+
|
12
|
+
And install irwi gem (recommended):
|
13
|
+
|
14
|
+
sudo gem install irwi
|
15
|
+
|
16
|
+
And add to your environment.rb:
|
17
|
+
|
18
|
+
config.gem "irwi", :source => "http://gemcutter.org"
|
19
|
+
|
20
|
+
Or in your application directory call:
|
8
21
|
|
9
22
|
script/plugin install git://github.com/alno/irwi
|
10
23
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.1
|
@@ -1,4 +1,5 @@
|
|
1
1
|
<ul class="wiki_page_actions">
|
2
|
-
<%= '<li>' + link_to( wt( 'Edit' ), wiki_page_edit_path ) + '</li>' if edit_allowed? %>
|
3
2
|
<%= '<li>' + link_to( wt( 'History' ), wiki_page_history_path ) + '</li>' if history_allowed? %>
|
3
|
+
<%= '<li>' + link_to( wt( 'Edit' ), wiki_page_edit_path ) + '</li>' if edit_allowed? %>
|
4
|
+
<%= '<li>' + link_to( wt( 'Destroy' ), wiki_page_path, :method => :delete, :confirm => wt( "Destroyed page cann't be restored. Are you ready for it?" ) ) + '</li>' if destroy_allowed? %>
|
4
5
|
</ul>
|
data/irwi.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{irwi}
|
8
|
-
s.version = "0.1.
|
8
|
+
s.version = "0.1.1"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Alexey Noskov"]
|
12
|
-
s.date = %q{2009-10-
|
12
|
+
s.date = %q{2009-10-26}
|
13
13
|
s.description = %q{Irwi is Ruby on Rails plugin which adds wiki functionality to your application. }
|
14
14
|
s.email = %q{alexey.noskov@gmail.com}
|
15
15
|
s.extra_rdoc_files = [
|
@@ -23,13 +23,13 @@ module Irwi::Extensions::Controllers::WikiPages
|
|
23
23
|
end
|
24
24
|
|
25
25
|
def history
|
26
|
-
return not_allowed unless
|
26
|
+
return not_allowed unless history_allowed?
|
27
27
|
|
28
28
|
render_template( @page.new_record? ? 'no' : 'history' )
|
29
29
|
end
|
30
30
|
|
31
31
|
def compare
|
32
|
-
return not_allowed unless
|
32
|
+
return not_allowed unless history_allowed?
|
33
33
|
|
34
34
|
if @page.new_record?
|
35
35
|
render_template 'no'
|
@@ -50,11 +50,11 @@ module Irwi::Extensions::Controllers::WikiPages
|
|
50
50
|
end
|
51
51
|
|
52
52
|
def update
|
53
|
-
return not_allowed unless @page.new_record? ||
|
53
|
+
return not_allowed unless @page.new_record? || edit_allowed? # Check for rights (but not for new record, for it we will use second check only)
|
54
54
|
|
55
55
|
@page.attributes = params[:page] # Assign new attributes
|
56
56
|
|
57
|
-
return not_allowed unless
|
57
|
+
return not_allowed unless edit_allowed? # Double check: used beacause action may become invalid after attributes update
|
58
58
|
|
59
59
|
@page.updator = @current_user # Assing user, which updated page
|
60
60
|
@page.creator = @current_user if @page.new_record? # Assign it's creator if it's new page
|
@@ -66,6 +66,14 @@ module Irwi::Extensions::Controllers::WikiPages
|
|
66
66
|
end
|
67
67
|
end
|
68
68
|
|
69
|
+
def destroy
|
70
|
+
return not_allowed unless destroy_allowed?
|
71
|
+
|
72
|
+
@page.destroy
|
73
|
+
|
74
|
+
redirect_to url_for( :action => :show )
|
75
|
+
end
|
76
|
+
|
69
77
|
protected
|
70
78
|
|
71
79
|
# Retrieves wiki_page_class for this controller
|
@@ -100,12 +108,17 @@ module Irwi::Extensions::Controllers::WikiPages
|
|
100
108
|
|
101
109
|
# Check is it allowed for current user see current page history. Designed to be redefined by application programmer
|
102
110
|
def history_allowed?
|
103
|
-
|
111
|
+
show_allowed?
|
104
112
|
end
|
105
113
|
|
106
114
|
# Check is it allowed for current user edit current page. Designed to be redefined by application programmer
|
107
115
|
def edit_allowed?
|
108
|
-
|
116
|
+
show_allowed?
|
117
|
+
end
|
118
|
+
|
119
|
+
# Check is it allowed for current user destroy current page. Designed to be redefined by application programmer
|
120
|
+
def destroy_allowed?
|
121
|
+
edit_allowed?
|
109
122
|
end
|
110
123
|
|
111
124
|
end
|
@@ -117,7 +130,7 @@ module Irwi::Extensions::Controllers::WikiPages
|
|
117
130
|
base.before_filter :setup_current_user # Setup @current_user instance variable before each action
|
118
131
|
base.before_filter :setup_page # Setup @page instance variable before each action
|
119
132
|
|
120
|
-
base.helper_method :show_allowed?, :edit_allowed?, :history_allowed? # Access control methods are avaliable in views
|
133
|
+
base.helper_method :show_allowed?, :edit_allowed?, :history_allowed?, :destroy_allowed? # Access control methods are avaliable in views
|
121
134
|
end
|
122
135
|
|
123
136
|
end
|
@@ -10,6 +10,8 @@ module Irwi::Support::RouteMapper
|
|
10
10
|
connect( "#{path}/compare/*path", opts.merge({ :action => 'compare' }) ) # Comparing two versions of page
|
11
11
|
connect( "#{path}/edit/*path", opts.merge({ :action => 'edit' }) ) # Wiki edit route
|
12
12
|
connect( "#{path}/history/*path", opts.merge({ :action => 'history' }) ) # Wiki history route
|
13
|
+
|
14
|
+
connect( "#{path}/*path", opts.merge({ :action => 'destroy', :conditions => { :method => :delete } }) ) # Wiki destroy route
|
13
15
|
connect( "#{path}/*path", opts.merge({ :action => 'update', :conditions => { :method => :post } }) ) # Save wiki pages route
|
14
16
|
connect( "#{path}/*path", opts.merge({ :action => 'show', :conditions => { :method => :get } }) ) # Wiki pages route
|
15
17
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: irwi
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alexey Noskov
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-10-
|
12
|
+
date: 2009-10-26 00:00:00 +03:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|