irwi 0.4.1 → 0.4.2
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.
- data/README.rdoc +4 -19
- data/app/views/base_wiki_pages/_wiki_page_actions.html.erb +1 -1
- data/app/views/base_wiki_pages/compare.html.erb +1 -1
- data/app/views/base_wiki_pages/edit.html.erb +11 -2
- data/app/views/base_wiki_pages/history.html.erb +1 -3
- data/app/views/base_wiki_pages/new.html.erb +3 -2
- data/app/views/base_wiki_pages/no.html.erb +1 -1
- data/app/views/base_wiki_pages/not_allowed.html.erb +1 -1
- data/lib/generators/irwi_wiki_views/irwi_wiki_views_generator.rb +1 -1
- data/lib/irwi.rb +2 -0
- data/lib/irwi/config.rb +39 -24
- data/lib/irwi/extensions/controllers/wiki_pages.rb +1 -1
- data/lib/irwi/extensions/models/wiki_page.rb +4 -1
- data/lib/irwi/extensions/models/wiki_page_version.rb +4 -2
- data/lib/irwi/formatters/simple_html.rb +10 -0
- data/lib/irwi/helpers/wiki_pages_helper.rb +14 -6
- data/lib/irwi/paginators/none.rb +1 -0
- data/lib/irwi/version.rb +1 -1
- metadata +39 -10
data/README.rdoc
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
= Irwi
|
2
2
|
|
3
|
-
Irwi is Ruby on Rails plugin which adds wiki functionality to your application.
|
3
|
+
Irwi is a Ruby on Rails 3 plugin which adds wiki functionality to your application.
|
4
4
|
|
5
5
|
== Installation
|
6
6
|
|
@@ -78,30 +78,15 @@ Irwi allows easy attachment integration in your wiki. There area several simple
|
|
78
78
|
* Append to initializer (or create a new one) something like <tt>Irwi.config.page_attachment_class_name = 'WikiPageAttachment'</tt>.
|
79
79
|
* Run <tt>rake db:migrate</tt> and start using attachments in your wiki!
|
80
80
|
|
81
|
-
== Localization
|
82
|
-
|
83
|
-
== Rails prior to 2.3
|
84
|
-
|
85
|
-
If you have Rails prior to 2.3 when you should also call:
|
86
|
-
|
87
|
-
script/generate irwi_wiki_views
|
88
|
-
|
89
|
-
To generate default wiki views.
|
90
|
-
|
91
|
-
== I18n Issues
|
92
|
-
|
93
|
-
If you get some weird errors like
|
94
|
-
|
95
|
-
missing interpolation argument in "%{count} %B %Y, %H:%M"
|
96
|
-
|
97
|
-
Please check your Rails and I18n versions, because of incompatibility issue between Rails prior to 2.3.6 and I18n 0.4.x (http://github.com/svenfuchs/i18n/issues/issue/20). If it's your case, consider upgrade of Rails or downgrade of I18n. Big thanks to Tomasz Stachewicz for information ;)
|
98
|
-
|
99
81
|
== Contributors
|
100
82
|
|
101
83
|
* Alexey Noskov (http://github.com/alno)
|
102
84
|
* Ravi Bhim (http://github.com/ravibhim)
|
103
85
|
* Pavel Valodzka (http://github.com/valodzka)
|
104
86
|
* Xavier Defrang (http://github.com/xavier)
|
87
|
+
* Tomáš Pospíšek (http://github.com/tpo)
|
88
|
+
* Evan Arnold (http://github.com/earnold)
|
89
|
+
* https://github.com/alno/irwi/contributors
|
105
90
|
|
106
91
|
Feel free to add yourself when you add new features.
|
107
92
|
|
@@ -1,5 +1,5 @@
|
|
1
1
|
<ul class="wiki_page_actions">
|
2
2
|
<%= content_tag('li', link_to( wt( 'History' ), wiki_page_history_path(@page) )) if history_allowed? %>
|
3
3
|
<%= content_tag('li', link_to( wt( 'Edit' ), wiki_page_edit_path(@page) )) if edit_allowed? %>
|
4
|
-
<%= content_tag('li', link_to( wt( 'Destroy' ), wiki_page_path(@page), :method => :delete, :confirm => wt( "Destroyed page
|
4
|
+
<%= content_tag('li', link_to( wt( 'Destroy' ), wiki_page_path(@page), :method => :delete, :confirm => wt( "Destroyed page can't be restored. Are you sure?" ) )) if destroy_allowed? %>
|
5
5
|
</ul>
|
@@ -8,11 +8,20 @@
|
|
8
8
|
</div>
|
9
9
|
<% end %>
|
10
10
|
|
11
|
-
|
11
|
+
<%= wiki_page_form do |f| %>
|
12
12
|
<%= f.hidden_field :previous_version_number, :value => f.object.last_version_number %>
|
13
|
+
<%= hidden_field_tag :path, @page.path %>
|
13
14
|
|
14
15
|
<p><%=wt 'Title:' %><br /><%= f.text_field :title %></p>
|
15
|
-
|
16
|
+
<%# If our 'content' contains newlines, Erubis will indent them (to make the
|
17
|
+
produced HTML look nicer). However those indenting spaces *will* appear
|
18
|
+
in the textarea in the user's browser and will get POSTed by the browser
|
19
|
+
when submitting the form and thus would get written to the wiki content
|
20
|
+
into the database. The gsub's below replace the linebreaks ('\r\n')
|
21
|
+
with UTF8 linefeeds (same way HAML solves this problem), which are
|
22
|
+
ignored by Erubis and should be correctly displayed as linebreaks by
|
23
|
+
modern browsers. %>
|
24
|
+
<p><%=wt 'Content:' %><br /><%= f.text_area(:content).gsub("\n", '
').gsub("\r",'') %></p>
|
16
25
|
<p><%=wt 'Comment on this change (optional):' %><br /><%= f.text_field :comment %></p>
|
17
26
|
|
18
27
|
<input type="submit" name="save" value="<%=wt 'Save page' %>" class="submit" />
|
@@ -2,12 +2,13 @@
|
|
2
2
|
|
3
3
|
<h1><%=wt 'Creating a new wiki page' %></h1>
|
4
4
|
|
5
|
-
|
5
|
+
<%= wiki_page_form do |f| %>
|
6
6
|
<%= f.hidden_field :previous_version_number, :value => f.object.last_version_number %>
|
7
7
|
|
8
8
|
<p><%=wt 'Title:' %><br /><%= f.text_field :title %></p>
|
9
9
|
<p><%=wt 'Content:' %><br /><%= f.text_area :content %></p>
|
10
10
|
<%= f.hidden_field :comment, :value => 'First Revision'%>
|
11
|
+
<%= hidden_field_tag :path, @page.path %>
|
11
12
|
|
12
13
|
<input type="submit" value="<%=wt 'Create page' %>" class="submit" />
|
13
|
-
<% end %>
|
14
|
+
<% end %>
|
@@ -1 +1 @@
|
|
1
|
-
<%=(wt 'There
|
1
|
+
<%=(wt 'There is no such page', :default => 'There is no such page. Do you want to <a href="%{new_url}">create it</a>?', :new_url => wiki_page_new_path ).html_safe %>
|
@@ -1 +1 @@
|
|
1
|
-
<%=wt 'You are not allowed to be here
|
1
|
+
<%=wt 'You are not allowed to be here; please go back.' %>
|
@@ -5,7 +5,7 @@ class IrwiWikiViewsGenerator < Rails::Generators::Base
|
|
5
5
|
def views
|
6
6
|
empty_directory 'app/views/base_wiki_pages'
|
7
7
|
|
8
|
-
Dir.foreach
|
8
|
+
Dir.foreach File.expand_path("../../../../app/views/base_wiki_pages", __FILE__) do |file| # Searching for files in app/views
|
9
9
|
copy_file( file, 'app/views/base_wiki_pages/' + file ) if file != '.' && file != '..'
|
10
10
|
end
|
11
11
|
end
|
data/lib/irwi.rb
CHANGED
@@ -1,10 +1,12 @@
|
|
1
1
|
require 'active_support/dependencies'
|
2
|
+
require 'rails_autolink' if defined?(Rails)
|
2
3
|
|
3
4
|
module Irwi
|
4
5
|
|
5
6
|
module Formatters
|
6
7
|
autoload :BlueCloth, 'irwi/formatters/blue_cloth'
|
7
8
|
autoload :RedCloth, 'irwi/formatters/red_cloth'
|
9
|
+
autoload :SimpleHtml, 'irwi/formatters/simple_html'
|
8
10
|
end
|
9
11
|
|
10
12
|
module Comparators
|
data/lib/irwi/config.rb
CHANGED
@@ -2,40 +2,55 @@ require 'active_support'
|
|
2
2
|
|
3
3
|
class Irwi::Config
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
attr_accessor_with_default :page_attachment_class_name do
|
12
|
-
# Can be for example 'WikiPageAttachment'
|
13
|
-
nil
|
14
|
-
end
|
15
|
-
|
16
|
-
attr_accessor_with_default :page_version_foreign_key, 'page_id'
|
5
|
+
attr_accessor :controller_name
|
6
|
+
attr_accessor :user_class_name
|
7
|
+
attr_accessor :page_class_name
|
8
|
+
attr_accessor :page_version_class_name
|
9
|
+
attr_accessor :page_attachment_class_name
|
10
|
+
attr_accessor :page_version_foreign_key
|
17
11
|
|
18
12
|
# Object using to format content
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
13
|
+
attr_writer :formatter
|
14
|
+
|
15
|
+
def formatter
|
16
|
+
@formatter ||= begin
|
17
|
+
require 'irwi/formatters/red_cloth'
|
18
|
+
|
19
|
+
self.formatter = Irwi::Formatters::RedCloth.new
|
20
|
+
end
|
23
21
|
end
|
24
22
|
|
25
23
|
# Object using to compare pages
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
24
|
+
attr_writer :comparator
|
25
|
+
|
26
|
+
def comparator
|
27
|
+
@comparator ||= begin
|
28
|
+
require 'irwi/comparators/diff_lcs'
|
29
|
+
|
30
|
+
self.comparator = Irwi::Comparators::DiffLcs.new
|
31
|
+
end
|
30
32
|
end
|
31
33
|
|
32
34
|
# Object using to paginate collections
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
35
|
+
attr_writer :paginator
|
36
|
+
|
37
|
+
def paginator
|
38
|
+
@paginator ||= begin
|
39
|
+
require 'irwi/paginators/none'
|
40
|
+
|
41
|
+
self.paginator = Irwi::Paginators::None.new
|
42
|
+
end
|
37
43
|
end
|
38
44
|
|
45
|
+
def initialize
|
46
|
+
@controller_name = 'wiki_pages'
|
47
|
+
@user_class_name = 'User'
|
48
|
+
@page_class_name = 'WikiPage'
|
49
|
+
@page_version_class_name = 'WikiPageVersion'
|
50
|
+
@page_attachment_class_name = nil
|
51
|
+
@page_version_foreign_key = 'page_id'
|
52
|
+
end
|
53
|
+
|
39
54
|
def page_class
|
40
55
|
page_class_name.constantize
|
41
56
|
end
|
@@ -106,7 +106,7 @@ module Irwi::Extensions::Controllers::WikiPages
|
|
106
106
|
|
107
107
|
# Renders user-specified or default template
|
108
108
|
def render_template( template )
|
109
|
-
render "#{template_dir template}/#{template}"
|
109
|
+
render "#{template_dir template}/#{template}", :status => (case template when 'no' then 404 when 'not_allowed' then 403 else 200 end)
|
110
110
|
end
|
111
111
|
|
112
112
|
# Initialize @current_user instance variable
|
@@ -3,7 +3,7 @@ module Irwi::Extensions::Models::WikiPage
|
|
3
3
|
module ClassMethods
|
4
4
|
|
5
5
|
def find_by_path_or_new( path )
|
6
|
-
self.find_by_path( path ) || self.new( :path => path, :title => path )
|
6
|
+
self.find_by_path( path ) || self.new( :path => path, :title => CGI::unescape(path) )
|
7
7
|
end
|
8
8
|
|
9
9
|
end
|
@@ -34,6 +34,8 @@ module Irwi::Extensions::Models::WikiPage
|
|
34
34
|
base.send :extend, Irwi::Extensions::Models::WikiPage::ClassMethods
|
35
35
|
base.send :include, Irwi::Extensions::Models::WikiPage::InstanceMethods
|
36
36
|
|
37
|
+
base.attr_protected :id
|
38
|
+
|
37
39
|
base.send :attr_accessor, :comment, :previous_version_number
|
38
40
|
|
39
41
|
base.belongs_to :creator, :class_name => Irwi.config.user_class_name
|
@@ -45,6 +47,7 @@ module Irwi::Extensions::Models::WikiPage
|
|
45
47
|
base.has_many :attachments, :class_name => Irwi.config.page_attachment_class_name, :foreign_key => Irwi.config.page_version_foreign_key
|
46
48
|
end
|
47
49
|
|
50
|
+
base.before_save {|record| record.content = '' if record.content.nil? }
|
48
51
|
base.after_save :create_new_version
|
49
52
|
end
|
50
53
|
|
@@ -17,7 +17,7 @@ module Irwi::Extensions::Models::WikiPageVersion
|
|
17
17
|
protected
|
18
18
|
|
19
19
|
def raise_on_update
|
20
|
-
raise ActiveRecordError.new "
|
20
|
+
raise ActiveRecordError.new "Can't modify existing version"
|
21
21
|
end
|
22
22
|
|
23
23
|
end
|
@@ -26,12 +26,14 @@ module Irwi::Extensions::Models::WikiPageVersion
|
|
26
26
|
base.send :extend, Irwi::Extensions::Models::WikiPageVersion::ClassMethods
|
27
27
|
base.send :include, Irwi::Extensions::Models::WikiPageVersion::InstanceMethods
|
28
28
|
|
29
|
+
base.attr_protected :id
|
30
|
+
|
29
31
|
base.belongs_to :page, :class_name => Irwi.config.page_class_name
|
30
32
|
base.belongs_to :updator, :class_name => Irwi.config.user_class_name
|
31
33
|
|
32
34
|
base.before_update :raise_on_update
|
33
35
|
|
34
|
-
base.
|
36
|
+
base.scope :between, lambda { | first, last |
|
35
37
|
first = first.to_i
|
36
38
|
last = last.to_i
|
37
39
|
first, last = last, first if last < first # Reordering if neeeded
|
@@ -5,10 +5,13 @@ module Irwi::Helpers::WikiPagesHelper
|
|
5
5
|
|
6
6
|
# Edit form for wiki page model
|
7
7
|
def wiki_page_form( config = {}, &block )
|
8
|
-
form_for(
|
8
|
+
form_for( @page, { :as => :page, :url => url_for( :action => :update ), :html=> { :class => 'wiki_form', :method => :post } }.merge!( config ), &block )
|
9
9
|
end
|
10
10
|
|
11
|
-
def wiki_page_new_path
|
11
|
+
def wiki_page_new_path
|
12
|
+
if params && params[:path].present?
|
13
|
+
page = CGI::escape(params[:path])
|
14
|
+
end
|
12
15
|
wiki_page_path( page, :new )
|
13
16
|
end
|
14
17
|
|
@@ -27,6 +30,7 @@ module Irwi::Helpers::WikiPagesHelper
|
|
27
30
|
def wiki_page_path( page = nil, action = :show )
|
28
31
|
if page
|
29
32
|
page = page.path if page.respond_to? :path
|
33
|
+
page = nil if page.empty?
|
30
34
|
|
31
35
|
url_for( :action => action, :path => page )
|
32
36
|
else
|
@@ -43,9 +47,13 @@ module Irwi::Helpers::WikiPagesHelper
|
|
43
47
|
end
|
44
48
|
|
45
49
|
def wiki_user( user )
|
46
|
-
return
|
50
|
+
return ("<" + wt("Unknown") + ">").html_safe unless user
|
47
51
|
|
48
|
-
|
52
|
+
if user.respond_to?(:name)
|
53
|
+
user.name
|
54
|
+
else
|
55
|
+
"User##{user.id}"
|
56
|
+
end
|
49
57
|
end
|
50
58
|
|
51
59
|
def wiki_linkify( str )
|
@@ -68,7 +76,7 @@ module Irwi::Helpers::WikiPagesHelper
|
|
68
76
|
if page = Irwi.config.page_class.find_by_title( title )
|
69
77
|
url_for( :controller => Irwi.config.controller_name, :action => :show, :path => page.path )
|
70
78
|
else
|
71
|
-
url_for( :controller => Irwi.config.controller_name, :action => :show, :path => title )
|
79
|
+
url_for( :controller => Irwi.config.controller_name, :action => :show, :path => CGI::escape(title) )
|
72
80
|
end
|
73
81
|
end
|
74
82
|
|
@@ -87,7 +95,7 @@ module Irwi::Helpers::WikiPagesHelper
|
|
87
95
|
#
|
88
96
|
def wt(msg, *args)
|
89
97
|
config = args.extract_options!
|
90
|
-
config[:default] = msg
|
98
|
+
config[:default] = msg if config[:default].blank?
|
91
99
|
config[:scope] = 'wiki'
|
92
100
|
I18n.t(msg, config)
|
93
101
|
end
|
data/lib/irwi/paginators/none.rb
CHANGED
data/lib/irwi/version.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: irwi
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
5
|
-
prerelease:
|
4
|
+
hash: 11
|
5
|
+
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 4
|
9
|
-
-
|
10
|
-
version: 0.4.
|
9
|
+
- 2
|
10
|
+
version: 0.4.2
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Alexey Noskov
|
@@ -16,8 +16,7 @@ autorequire:
|
|
16
16
|
bindir: bin
|
17
17
|
cert_chain: []
|
18
18
|
|
19
|
-
date:
|
20
|
-
default_executable:
|
19
|
+
date: 2012-03-22 00:00:00 Z
|
21
20
|
dependencies:
|
22
21
|
- !ruby/object:Gem::Dependency
|
23
22
|
name: diff-lcs
|
@@ -84,9 +83,24 @@ dependencies:
|
|
84
83
|
type: :runtime
|
85
84
|
version_requirements: *id004
|
86
85
|
- !ruby/object:Gem::Dependency
|
87
|
-
name:
|
86
|
+
name: rails_autolink
|
88
87
|
prerelease: false
|
89
88
|
requirement: &id005 !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
90
|
+
requirements:
|
91
|
+
- - ">="
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
hash: 15
|
94
|
+
segments:
|
95
|
+
- 1
|
96
|
+
- 0
|
97
|
+
version: "1.0"
|
98
|
+
type: :runtime
|
99
|
+
version_requirements: *id005
|
100
|
+
- !ruby/object:Gem::Dependency
|
101
|
+
name: rspec
|
102
|
+
prerelease: false
|
103
|
+
requirement: &id006 !ruby/object:Gem::Requirement
|
90
104
|
none: false
|
91
105
|
requirements:
|
92
106
|
- - ">="
|
@@ -97,7 +111,21 @@ dependencies:
|
|
97
111
|
- 0
|
98
112
|
version: "2.0"
|
99
113
|
type: :development
|
100
|
-
version_requirements: *
|
114
|
+
version_requirements: *id006
|
115
|
+
- !ruby/object:Gem::Dependency
|
116
|
+
name: sqlite3
|
117
|
+
prerelease: false
|
118
|
+
requirement: &id007 !ruby/object:Gem::Requirement
|
119
|
+
none: false
|
120
|
+
requirements:
|
121
|
+
- - ">="
|
122
|
+
- !ruby/object:Gem::Version
|
123
|
+
hash: 3
|
124
|
+
segments:
|
125
|
+
- 0
|
126
|
+
version: "0"
|
127
|
+
type: :development
|
128
|
+
version_requirements: *id007
|
101
129
|
description: Irwi is Ruby on Rails plugin which adds wiki functionality to your application.
|
102
130
|
email:
|
103
131
|
- alexey.noskov@gmail.com
|
@@ -143,6 +171,7 @@ files:
|
|
143
171
|
- lib/irwi/helpers/wiki_pages_helper.rb
|
144
172
|
- lib/irwi/formatters/red_cloth.rb
|
145
173
|
- lib/irwi/formatters/blue_cloth.rb
|
174
|
+
- lib/irwi/formatters/simple_html.rb
|
146
175
|
- lib/irwi/version.rb
|
147
176
|
- lib/irwi/config.rb
|
148
177
|
- lib/generators/irwi_wiki/templates/controllers/wiki_pages_controller.rb
|
@@ -157,7 +186,6 @@ files:
|
|
157
186
|
- lib/generators/irwi_wiki_attachments/irwi_wiki_attachments_generator.rb
|
158
187
|
- MIT-LICENSE
|
159
188
|
- README.rdoc
|
160
|
-
has_rdoc: true
|
161
189
|
homepage: http://github.com/alno/irwi
|
162
190
|
licenses: []
|
163
191
|
|
@@ -194,9 +222,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
194
222
|
requirements: []
|
195
223
|
|
196
224
|
rubyforge_project:
|
197
|
-
rubygems_version: 1.
|
225
|
+
rubygems_version: 1.8.11
|
198
226
|
signing_key:
|
199
227
|
specification_version: 3
|
200
228
|
summary: Irwi is Ruby on Rails plugin which adds wiki functionality to your application.
|
201
229
|
test_files: []
|
202
230
|
|
231
|
+
has_rdoc:
|