irwi 0.4.2 → 0.5.0

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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 22090f82507fef1269d7f8ad01a63c5764feb374
4
+ data.tar.gz: c1b7c604fe635ad3d3f62e3a4cf69d9ec87276a1
5
+ SHA512:
6
+ metadata.gz: 5928f78b1c8135f0fdf529cb000ef518896f6751927b7caf14367ffdf5111beb6b40f45b4920f25fa3531c12b4a039c8b0a70ee8a110a3674464eff9151d3a6d
7
+ data.tar.gz: b14e6ac0a0c9352400921a35f841384819a937391dda472188c181594a047db1db17a605d92e1a807e8a6aa54c1b3926729f53aac1fba11041a9b80547391614
@@ -1,31 +1,22 @@
1
- = Irwi
2
-
3
- Irwi is a Ruby on Rails 3 plugin which adds wiki functionality to your application.
4
-
5
- == Installation
6
-
7
- Setup gemcutter as gem source:
8
-
9
- sudo gem install gemcutter
10
- gem tumble
1
+ *WARNING: It's unstable branch for migration to Rails 4*
11
2
 
12
- And install irwi gem (recommended):
3
+ = Irwi
13
4
 
14
- sudo gem install irwi
5
+ Irwi is a Ruby on Rails 4 plugin which adds wiki functionality to your application.
15
6
 
16
- And add to your environment.rb:
7
+ == Status
17
8
 
18
- config.gem "irwi", :source => "http://gemcutter.org"
9
+ {<img src="https://secure.travis-ci.org/alno/irwi.png?branch=master" alt="Build Status" />}[http://travis-ci.org/alno/irwi]
19
10
 
20
- Or in your application directory call:
11
+ == Installation
21
12
 
22
- script/plugin install git://github.com/alno/irwi
13
+ Add to your Gemfile:
23
14
 
24
- == Usage
15
+ gem 'irwi', :git => 'git://github.com/alno/irwi.git'
25
16
 
26
- In your application directory call:
17
+ Then in your application directory call:
27
18
 
28
- script/generate irwi_wiki
19
+ rails g irwi_wiki
29
20
 
30
21
  It will generate:
31
22
  * WikiPageController to serve wiki pages
@@ -34,7 +25,7 @@ It will generate:
34
25
 
35
26
  Also it will add to your <tt>routes.rb</tt> something like:
36
27
 
37
- map.wiki_root '/wiki'
28
+ wiki_root '/wiki'
38
29
 
39
30
  == Wiki syntax (links to other pages)
40
31
 
@@ -57,6 +48,10 @@ Following helpers are defined by default and you may replace them with you own:
57
48
 
58
49
  Configuration options are acessed via <tt>Irwi.config</tt> object. Currently supported options:
59
50
  * <tt>user_class_name</tt> - Name of user model class. By default - 'User'
51
+
52
+ Define a method named 'current_user' method on WikiPagesController that returns the object for the current user
53
+
54
+
60
55
  * <tt>formatter</tt> - Formatter instance, which process wiki content before output. It should have method <tt>format</tt>, which gets a string and returns it formatted. By default instance of <tt>Irwi::Formatters::RedCloth</tt> is used (requires RedCloth gem). Other built-in formatter is <tt>Irwi::Formatters::BlueCloth</tt> (requires BlueCloth gem). Option accepts formatter instance, not class, so correct usage is:
61
56
 
62
57
  Irwi.config.formatter = Irwi::Formatters::BlueCloth.new
@@ -1,4 +1,5 @@
1
1
  <ul class="wiki_page_actions">
2
+ <%= content_tag('li', link_to( wt( 'List pages' ), wiki_all_path)) %>
2
3
  <%= content_tag('li', link_to( wt( 'History' ), wiki_page_history_path(@page) )) if history_allowed? %>
3
4
  <%= content_tag('li', link_to( wt( 'Edit' ), wiki_page_edit_path(@page) )) if edit_allowed? %>
4
5
  <%= 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? %>
@@ -1,5 +1,5 @@
1
1
  <% if with_form %>
2
- <form action="<%=wiki_page_compare_path%>" method="get">
2
+ <form action="<%=wiki_page_compare_path(@page)%>" method="get">
3
3
  <% end %>
4
4
 
5
5
  <table class="wiki_history">
@@ -3,9 +3,9 @@
3
3
  <h1><%=wt 'All pages' %></h1>
4
4
 
5
5
  <ul>
6
- <% wiki_paginate @pages do -%>
6
+ <%= wiki_paginate @pages do -%>
7
7
  <% @pages.each do |page| -%>
8
8
  <li><%= link_to page.title, wiki_page_path( page ) %></li>
9
9
  <% end -%>
10
10
  <% end -%>
11
- </ul>
11
+ </ul>
@@ -2,6 +2,8 @@
2
2
 
3
3
  <h1><%=wt '%{page_title} - Comparing versions %{old_version} and %{new_version}', :page_title => h( @page.title ), :old_version => @old_version.number, :new_version => @new_version.number %></h1>
4
4
 
5
+ <%= link_to "Back to history", history_wiki_page_path(@page.path) %><br />
6
+
5
7
  <%=wt 'Changes list:' %>
6
8
 
7
9
  <%= wiki_paginate @versions do%>
@@ -11,8 +11,9 @@
11
11
  <%= wiki_page_form do |f| %>
12
12
  <%= f.hidden_field :previous_version_number, :value => f.object.last_version_number %>
13
13
  <%= hidden_field_tag :path, @page.path %>
14
-
14
+
15
15
  <p><%=wt 'Title:' %><br /><%= f.text_field :title %></p>
16
+
16
17
  <%# If our 'content' contains newlines, Erubis will indent them (to make the
17
18
  produced HTML look nicer). However those indenting spaces *will* appear
18
19
  in the textarea in the user's browser and will get POSTed by the browser
@@ -21,9 +22,9 @@
21
22
  with UTF8 linefeeds (same way HAML solves this problem), which are
22
23
  ignored by Erubis and should be correctly displayed as linebreaks by
23
24
  modern browsers. %>
24
- <p><%=wt 'Content:' %><br /><%= f.text_area(:content).gsub("\n", '&#x000A;').gsub("\r",'') %></p>
25
+ <p><%=wt "Content: #{link_to('(Textile Markup', 'http://redcloth.org/hobix.com/textile/', target: '_blank')}".html_safe %> allowed)<br /><%= f.text_area(:content) %> </p>
26
+ <%#<p><%#=wt 'Content:' %><br /><%#= f.text_area(:content, :value => f.object.content.gsub("\n", '&#x000A;').gsub("\r",'')).html_safe %#></p>%>
25
27
  <p><%=wt 'Comment on this change (optional):' %><br /><%= f.text_field :comment %></p>
26
-
27
28
  <input type="submit" name="save" value="<%=wt 'Save page' %>" class="submit" />
28
29
  <input type="submit" name="preview" value="<%=wt 'Preview' %>" class="submit" />
29
30
  <input type="submit" name="cancel" value="<%=wt 'Cancel' %>" class="submit" />
@@ -6,3 +6,5 @@
6
6
  <%= wiki_page_actions %>
7
7
 
8
8
  <%= wiki_page_history %>
9
+
10
+ <%= link_to "Back to page", wiki_page_path(@page) %>
@@ -1,9 +1,8 @@
1
- require 'rails/generators/active_record/migration'
1
+ require 'rails/generators/active_record'
2
2
 
3
3
  class IrwiWikiGenerator < Rails::Generators::Base
4
4
 
5
5
  include Rails::Generators::Migration
6
- extend ActiveRecord::Generators::Migration
7
6
 
8
7
  source_root File.expand_path("../templates", __FILE__)
9
8
 
@@ -20,10 +19,14 @@ class IrwiWikiGenerator < Rails::Generators::Base
20
19
  copy_file 'models/wiki_page_version.rb', 'app/models/wiki_page_version.rb'
21
20
 
22
21
  # Migrations
23
- migration_template 'migrate/create_wiki_pages.rb', 'db/migrate/create_wiki_pages'
22
+ migration_template 'migrate/create_wiki_pages.rb', 'db/migrate/create_wiki_pages.rb'
24
23
 
25
24
  # Routes
26
25
  route "wiki_root '/wiki'"
27
26
  end
28
27
 
28
+ def self.next_migration_number dirname
29
+ ActiveRecord::Generators::Base.next_migration_number dirname
30
+ end
31
+
29
32
  end
@@ -1,4 +1,4 @@
1
- require 'rails/generators/active_record/migration'
1
+ require 'rails/generators/active_record'
2
2
 
3
3
  class IrwiWikiAttachmentsGenerator < Rails::Generators::Base
4
4
 
@@ -10,7 +10,7 @@ class IrwiWikiAttachmentsGenerator < Rails::Generators::Base
10
10
  def generate_attachments
11
11
  %w[create_wiki_page_attachments].each do |mig|
12
12
  unless Dir.entries(File.join(Rails.root,'db','migrate')).grep(/#{mig}/).present?
13
- migration_template "migrate/#{mig}.rb", "db/migrate/#{mig}"
13
+ migration_template "migrate/#{mig}.rb", "db/migrate/#{mig}.rb"
14
14
  sleep(1) # To avoid migration file version collision.
15
15
  end
16
16
  end
@@ -19,4 +19,8 @@ class IrwiWikiAttachmentsGenerator < Rails::Generators::Base
19
19
  copy_file 'models/wiki_page_attachment.rb', 'app/models/wiki_page_attachment.rb'
20
20
  end
21
21
 
22
+ def self.next_migration_number dirname
23
+ ActiveRecord::Generators::Base.next_migration_number dirname
24
+ end
25
+
22
26
  end
@@ -7,6 +7,8 @@ module Irwi
7
7
  autoload :BlueCloth, 'irwi/formatters/blue_cloth'
8
8
  autoload :RedCloth, 'irwi/formatters/red_cloth'
9
9
  autoload :SimpleHtml, 'irwi/formatters/simple_html'
10
+ autoload :WikiCloth, 'irwi/formatters/wiki_cloth'
11
+ autoload :RedCarpet, 'irwi/formatters/red_carpet'
10
12
  end
11
13
 
12
14
  module Comparators
@@ -23,6 +25,8 @@ module Irwi
23
25
  module Paginators
24
26
  autoload :None, 'irwi/paginators/none'
25
27
  autoload :WillPaginate, 'irwi/paginators/will_paginate'
28
+ # TODO Implement Kaminari paginator
29
+ # TODO Autodetect paginator
26
30
  end
27
31
 
28
32
  module Support
@@ -1,8 +1,8 @@
1
1
  module Irwi::Extensions::Controllers::WikiPageAttachments
2
2
 
3
3
  def add_attachment
4
- attachment = page_attachment_class.new(params[:wiki_page_attachment])
5
- attachment.save
4
+ attachment = page_attachment_class.new(permitted_page_attachment_params)
5
+ attachment.save!
6
6
  redirect_to url_for(:path => attachment.page.path, :action => :edit)
7
7
  end
8
8
 
@@ -12,10 +12,14 @@ module Irwi::Extensions::Controllers::WikiPageAttachments
12
12
  redirect_to url_for(:path => attachment.page.path, :action => :edit)
13
13
  end
14
14
 
15
- protected
15
+ private
16
16
 
17
17
  def page_attachment_class
18
18
  Irwi.config.page_attachment_class
19
19
  end
20
20
 
21
+ def permitted_page_attachment_params
22
+ params.require(:wiki_page_attachment).permit(:page_id, :wiki_page_attachment)
23
+ end
24
+
21
25
  end
@@ -1,4 +1,5 @@
1
1
  module Irwi::Extensions::Controllers::WikiPages
2
+ extend ActiveSupport::Concern
2
3
 
3
4
  module ClassMethods
4
5
 
@@ -12,148 +13,145 @@ module Irwi::Extensions::Controllers::WikiPages
12
13
 
13
14
  end
14
15
 
15
- module InstanceMethods
16
+ include Irwi::Extensions::Controllers::WikiPageAttachments
17
+ include Irwi::Support::TemplateFinder
16
18
 
17
- include Irwi::Extensions::Controllers::WikiPageAttachments
18
- include Irwi::Support::TemplateFinder
19
+ def show
20
+ return not_allowed unless show_allowed?
19
21
 
20
- def show
21
- return not_allowed unless show_allowed?
22
-
23
- render_template( @page.new_record? ? 'no' : 'show' )
24
- end
22
+ render_template( @page.new_record? ? 'no' : 'show' )
23
+ end
25
24
 
26
- def history
27
- return not_allowed unless history_allowed?
25
+ def history
26
+ return not_allowed unless history_allowed?
28
27
 
29
- @versions = Irwi.config.paginator.paginate( @page.versions, :page => params[:page] ) # Paginating them
28
+ @versions = Irwi.config.paginator.paginate( @page.versions, :page => params[:page] ) # Paginating them
30
29
 
31
- render_template( @page.new_record? ? 'no' : 'history' )
32
- end
30
+ render_template( @page.new_record? ? 'no' : 'history' )
31
+ end
33
32
 
34
- def compare
35
- return not_allowed unless history_allowed?
33
+ def compare
34
+ return not_allowed unless history_allowed?
36
35
 
37
- if @page.new_record?
38
- render_template 'no'
39
- else
40
- new_num = params[:new].to_i || @page.last_version_number # Last version number
41
- old_num = params[:old].to_i || 1 # First version number
36
+ if @page.new_record?
37
+ render_template 'no'
38
+ else
39
+ new_num = params[:new].to_i || @page.last_version_number # Last version number
40
+ old_num = params[:old].to_i || 1 # First version number
42
41
 
43
- old_num, new_num = new_num, old_num if new_num < old_num # Swapping them if last < first
42
+ old_num, new_num = new_num, old_num if new_num < old_num # Swapping them if last < first
44
43
 
45
- versions = @page.versions.between( old_num, new_num ) # Loading all versions between first and last
44
+ versions = @page.versions.between( old_num, new_num ) # Loading all versions between first and last
46
45
 
47
- @versions = Irwi.config.paginator.paginate( versions, :page => params[:page] ) # Paginating them
46
+ @versions = Irwi.config.paginator.paginate( versions, :page => params[:page] ) # Paginating them
48
47
 
49
- @new_version = @versions.first.number == new_num ? @versions.first : versions.first # Loading next version
50
- @old_version = @versions.last.number == old_num ? @versions.last : versions.last # Loading previous version
48
+ @new_version = @versions.first.number == new_num ? @versions.first : versions.first # Loading next version
49
+ @old_version = @versions.last.number == old_num ? @versions.last : versions.last # Loading previous version
51
50
 
52
- render_template 'compare'
53
- end
51
+ render_template 'compare'
54
52
  end
53
+ end
55
54
 
56
- def new
57
- return not_allowed unless show_allowed? && edit_allowed?
55
+ def new
56
+ return not_allowed unless show_allowed? && edit_allowed?
58
57
 
59
- render_template 'new'
60
- end
58
+ render_template 'new'
59
+ end
61
60
 
62
- def edit
63
- return not_allowed unless show_allowed? && edit_allowed?
61
+ def edit
62
+ return not_allowed unless show_allowed? && edit_allowed?
64
63
 
65
- render_template 'edit'
66
- end
64
+ render_template 'edit'
65
+ end
67
66
 
68
- def update
69
- return not_allowed unless params[:page] && (@page.new_record? || edit_allowed?) # Check for rights (but not for new record, for it we will use second check only)
67
+ def update
68
+ return not_allowed unless params[:page] && (@page.new_record? || edit_allowed?) # Check for rights (but not for new record, for it we will use second check only)
70
69
 
71
- @page.attributes = params[:page] # Assign new attributes
72
- @page.comment = params[:page][:comment]
70
+ @page.attributes = permitted_page_params
73
71
 
74
- return not_allowed unless edit_allowed? # Double check: used beacause action may become invalid after attributes update
72
+ return not_allowed unless edit_allowed? # Double check: used beacause action may become invalid after attributes update
75
73
 
76
- @page.updator = @current_user # Assing user, which updated page
77
- @page.creator = @current_user if @page.new_record? # Assign it's creator if it's new page
74
+ @page.updator = @current_user # Assing user, which updated page
75
+ @page.creator = @current_user if @page.new_record? # Assign it's creator if it's new page
78
76
 
79
- if !params[:preview] && (params[:cancel] || @page.save)
80
- redirect_to url_for( :action => :show, :path => @page.path.split('/') ) # redirect to new page's path (if it changed)
81
- else
82
- render_template 'edit'
83
- end
77
+ if !params[:preview] && (params[:cancel] || @page.save)
78
+ redirect_to url_for( :action => :show, :path => @page.path.split('/') ) # redirect to new page's path (if it changed)
79
+ else
80
+ render_template 'edit'
84
81
  end
82
+ end
85
83
 
86
- def destroy
87
- return not_allowed unless destroy_allowed?
84
+ def destroy
85
+ return not_allowed unless destroy_allowed?
88
86
 
89
- @page.destroy
87
+ @page.destroy
90
88
 
91
- redirect_to url_for( :action => :show )
92
- end
89
+ redirect_to url_for( :action => :show )
90
+ end
93
91
 
94
- def all
95
- @pages = Irwi.config.paginator.paginate( page_class, :page => params[:page] ) # Loading and paginating all pages
92
+ def all
93
+ @pages = Irwi.config.paginator.paginate( page_class, :page => params[:page] ) # Loading and paginating all pages
96
94
 
97
- render_template 'all'
98
- end
95
+ render_template 'all'
96
+ end
99
97
 
100
- protected
98
+ private
101
99
 
102
- # Retrieves wiki_page_class for this controller
103
- def page_class
104
- self.class.page_class
105
- end
100
+ def permitted_page_params
101
+ params.require(:page).permit(:title, :content, :comment)
102
+ end
106
103
 
107
- # Renders user-specified or default template
108
- def render_template( template )
109
- render "#{template_dir template}/#{template}", :status => (case template when 'no' then 404 when 'not_allowed' then 403 else 200 end)
110
- end
104
+ # Retrieves wiki_page_class for this controller
105
+ def page_class
106
+ self.class.page_class
107
+ end
111
108
 
112
- # Initialize @current_user instance variable
113
- def setup_current_user
114
- @current_user = respond_to?( :current_user, true ) ? current_user : nil # Find user by current_user method or return nil
115
- end
109
+ # Renders user-specified or default template
110
+ def render_template( template )
111
+ render "#{template_dir template}/#{template}", :status => (case template when 'no' then 404 when 'not_allowed' then 403 else 200 end)
112
+ end
116
113
 
117
- # Initialize @page instance variable
118
- def setup_page
119
- @page = page_class.find_by_path_or_new( params[:path] || '' ) # Find existing page by path or create new
120
- end
114
+ # Initialize @current_user instance variable
115
+ def setup_current_user
116
+ @current_user = respond_to?( :current_user, true ) ? current_user : nil # Find user by current_user method or return nil
117
+ end
121
118
 
122
- # Method, which called when user tries to visit
123
- def not_allowed
124
- render_template 'not_allowed'
125
- end
119
+ # Initialize @page instance variable
120
+ def setup_page
121
+ @page = page_class.find_by_path_or_new( params[:path] || '' ) # Find existing page by path or create new
122
+ end
126
123
 
127
- # Check is it allowed for current user to see current page. Designed to be redefined by application programmer
128
- def show_allowed?
129
- true
130
- end
124
+ # Method, which called when user tries to visit
125
+ def not_allowed
126
+ render_template 'not_allowed'
127
+ end
131
128
 
132
- # Check is it allowed for current user see current page history. Designed to be redefined by application programmer
133
- def history_allowed?
134
- show_allowed?
135
- end
129
+ # Check is it allowed for current user to see current page. Designed to be redefined by application programmer
130
+ def show_allowed?
131
+ true
132
+ end
136
133
 
137
- # Check is it allowed for current user edit current page. Designed to be redefined by application programmer
138
- def edit_allowed?
139
- show_allowed?
140
- end
134
+ # Check is it allowed for current user see current page history. Designed to be redefined by application programmer
135
+ def history_allowed?
136
+ show_allowed?
137
+ end
141
138
 
142
- # Check is it allowed for current user destroy current page. Designed to be redefined by application programmer
143
- def destroy_allowed?
144
- edit_allowed?
145
- end
139
+ # Check is it allowed for current user edit current page. Designed to be redefined by application programmer
140
+ def edit_allowed?
141
+ show_allowed?
142
+ end
146
143
 
144
+ # Check is it allowed for current user destroy current page. Designed to be redefined by application programmer
145
+ def destroy_allowed?
146
+ edit_allowed?
147
147
  end
148
148
 
149
- def self.included( base )
150
- base.send :extend, Irwi::Extensions::Controllers::WikiPages::ClassMethods
151
- base.send :include, Irwi::Extensions::Controllers::WikiPages::InstanceMethods
149
+ included do
150
+ before_action :setup_current_user # Setup @current_user instance variable before each action
152
151
 
153
- base.before_filter :setup_current_user # Setup @current_user instance variable before each action
154
152
  # Setup @page instance variable before each action
155
- base.before_filter :setup_page, :only => [ :show, :history, :compare, :new, :edit, :update, :destroy, :add_attachment ]
156
- base.helper_method :show_allowed?, :edit_allowed?, :history_allowed?, :destroy_allowed? # Access control methods are avaliable in views
153
+ before_action :setup_page, :only => [ :show, :history, :compare, :new, :edit, :update, :destroy, :add_attachment ]
154
+ helper_method :show_allowed?, :edit_allowed?, :history_allowed?, :destroy_allowed? # Access control methods are avaliable in views
157
155
  end
158
156
 
159
157
  end
@@ -1,4 +1,5 @@
1
1
  module Irwi::Extensions::Models::WikiPage
2
+ extend ActiveSupport::Concern
2
3
 
3
4
  module ClassMethods
4
5
 
@@ -8,47 +9,38 @@ module Irwi::Extensions::Models::WikiPage
8
9
 
9
10
  end
10
11
 
11
- module InstanceMethods
12
-
13
- # Retrieve number of last version
14
- def last_version_number
15
- last = versions.first
16
- last ? last.number : 0
17
- end
12
+ # Retrieve number of last version
13
+ def last_version_number
14
+ last = versions.first
15
+ last ? last.number : 0
16
+ end
18
17
 
19
- protected
18
+ protected
20
19
 
21
- def create_new_version
22
- n = last_version_number
23
-
24
- v = versions.build
25
- v.attributes = attributes.slice( *v.attribute_names )
26
- v.comment = comment
27
- v.number = n + 1
28
- v.save!
29
- end
20
+ def create_new_version
21
+ n = last_version_number
30
22
 
23
+ v = versions.build
24
+ v.attributes = attributes.slice( *(v.attribute_names - ['id']) )
25
+ v.comment = comment
26
+ v.number = n + 1
27
+ v.save!
31
28
  end
32
29
 
33
- def self.included( base )
34
- base.send :extend, Irwi::Extensions::Models::WikiPage::ClassMethods
35
- base.send :include, Irwi::Extensions::Models::WikiPage::InstanceMethods
36
-
37
- base.attr_protected :id
38
-
39
- base.send :attr_accessor, :comment, :previous_version_number
30
+ included do
31
+ attr_accessor :comment, :previous_version_number
40
32
 
41
- base.belongs_to :creator, :class_name => Irwi.config.user_class_name
42
- base.belongs_to :updator, :class_name => Irwi.config.user_class_name
33
+ belongs_to :creator, class_name: Irwi.config.user_class_name
34
+ belongs_to :updator, class_name: Irwi.config.user_class_name
43
35
 
44
- base.has_many :versions, :class_name => Irwi.config.page_version_class_name, :foreign_key => Irwi.config.page_version_foreign_key, :order => 'id DESC'
36
+ has_many :versions, ->{ order('id DESC') }, class_name: Irwi.config.page_version_class_name, foreign_key: Irwi.config.page_version_foreign_key
45
37
 
46
38
  if Irwi::config.page_attachment_class_name
47
- base.has_many :attachments, :class_name => Irwi.config.page_attachment_class_name, :foreign_key => Irwi.config.page_version_foreign_key
39
+ has_many :attachments, class_name: Irwi.config.page_attachment_class_name, foreign_key: Irwi.config.page_version_foreign_key
48
40
  end
49
41
 
50
- base.before_save {|record| record.content = '' if record.content.nil? }
51
- base.after_save :create_new_version
42
+ before_save { |record| record.content = '' if record.content.nil? }
43
+ after_save :create_new_version
52
44
  end
53
45
 
54
46
  end
@@ -1,9 +1,10 @@
1
1
  module Irwi::Extensions::Models::WikiPageAttachment
2
+ extend ActiveSupport::Concern
2
3
 
3
4
  DEFAULT_PAPERCLIP_OPTIONS = {:styles => { :medium => "300x300>", :thumb => "100x100>" }}
4
5
 
5
- def self.included( base )
6
- base.belongs_to :page, :class_name => Irwi.config.page_class_name
6
+ included do
7
+ belongs_to :page, class_name: Irwi.config.page_class_name
7
8
  end
8
9
 
9
10
  end
@@ -1,43 +1,32 @@
1
1
  module Irwi::Extensions::Models::WikiPageVersion
2
+ extend ActiveSupport::Concern
2
3
 
3
- module ClassMethods
4
-
4
+ def next
5
+ self.class.first :conditions => ["id > ? AND page_id = ?", id, page_id], :order => 'id ASC'
5
6
  end
6
7
 
7
- module InstanceMethods
8
-
9
- def next
10
- self.class.first :conditions => ["id > ? AND page_id = ?", id, page_id], :order => 'id ASC'
11
- end
12
-
13
- def previous
14
- self.class.first :conditions => ["id < ? AND page_id = ?", id, page_id], :order => 'id DESC'
15
- end
16
-
17
- protected
18
-
19
- def raise_on_update
20
- raise ActiveRecordError.new "Can't modify existing version"
21
- end
22
-
8
+ def previous
9
+ self.class.first :conditions => ["id < ? AND page_id = ?", id, page_id], :order => 'id DESC'
23
10
  end
24
11
 
25
- def self.included( base )
26
- base.send :extend, Irwi::Extensions::Models::WikiPageVersion::ClassMethods
27
- base.send :include, Irwi::Extensions::Models::WikiPageVersion::InstanceMethods
12
+ private
28
13
 
29
- base.attr_protected :id
14
+ def raise_on_update
15
+ raise ActiveRecordError.new "Can't modify existing version"
16
+ end
30
17
 
31
- base.belongs_to :page, :class_name => Irwi.config.page_class_name
32
- base.belongs_to :updator, :class_name => Irwi.config.user_class_name
18
+ included do
19
+ belongs_to :page, class_name: Irwi.config.page_class_name
20
+ belongs_to :updator, class_name: Irwi.config.user_class_name
33
21
 
34
- base.before_update :raise_on_update
22
+ before_update :raise_on_update
35
23
 
36
- base.scope :between, lambda { | first, last |
24
+ scope :between, lambda { |first, last|
37
25
  first = first.to_i
38
26
  last = last.to_i
39
27
  first, last = last, first if last < first # Reordering if neeeded
40
- { :conditions => [ 'number >= ? AND number <= ?', first, last ] }
28
+
29
+ where('number >= ? AND number <= ?', first, last)
41
30
  }
42
31
  end
43
32
 
@@ -0,0 +1,12 @@
1
+ class Irwi::Formatters::RedCarpet
2
+
3
+ def initialize
4
+ require 'redcarpet'
5
+ end
6
+
7
+ def format( text )
8
+ markdown = Redcarpet::Markdown.new(Redcarpet::Render::HTML, :autolink => true, :space_after_headers => true, :tables => true)
9
+ markdown.render(text)
10
+ end
11
+
12
+ end
@@ -0,0 +1,11 @@
1
+ class Irwi::Formatters::WikiCloth
2
+
3
+ def initialize
4
+ require 'wikicloth'
5
+ end
6
+
7
+ def format( text )
8
+ WikiCloth::Parser.new({:data => text}).to_html
9
+ end
10
+
11
+ end
@@ -39,7 +39,7 @@ module Irwi::Helpers::WikiPagesHelper
39
39
  end
40
40
 
41
41
  def wiki_content( text )
42
- sanitize( auto_link( Irwi.config.formatter.format( wiki_linkify( wiki_show_attachments(text) ) ) ) )
42
+ sanitize( auto_link( Irwi.config.formatter.format( wiki_linkify( wiki_show_attachments(text) ) ).html_safe))
43
43
  end
44
44
 
45
45
  def wiki_diff( old_text, new_text )
@@ -123,7 +123,7 @@ module Irwi::Helpers::WikiPagesHelper
123
123
  render :partial => "#{template_dir '_wiki_page_history'}/wiki_page_history", :locals => { :page => page, :versions => versions, :with_form => (versions.size > 1) }
124
124
  end
125
125
 
126
- def wiki_page_attachments(page)
126
+ def wiki_page_attachments(page = @page)
127
127
  return unless Irwi::config.page_attachment_class_name
128
128
 
129
129
  page.attachments.each do |attachment|
@@ -132,12 +132,12 @@ module Irwi::Helpers::WikiPagesHelper
132
132
  concat link_to(wt('Remove'), wiki_remove_page_attachment_path(attachment.id), :method => :delete)
133
133
  end
134
134
 
135
- form_for(:wiki_page_attachment,
136
- Irwi.config.page_attachment_class.new,
137
- :url => wiki_add_page_attachment_path(@page),
135
+ form_for(Irwi.config.page_attachment_class.new,
136
+ :as => :wiki_page_attachment,
137
+ :url => wiki_add_page_attachment_path(page),
138
138
  :html => { :multipart => true }) do |form|
139
139
  concat form.file_field :wiki_page_attachment
140
- concat form.hidden_field :page_id, :value => @page.id
140
+ concat form.hidden_field :page_id, :value => page.id
141
141
  concat form.submit 'Add Attachment'
142
142
  end
143
143
  end
@@ -3,9 +3,7 @@ require 'active_support/core_ext/hash'
3
3
  class Irwi::Paginators::None
4
4
 
5
5
  def paginate( collection, options = {} )
6
- find_options = options.except :page, :per_page, :total_entries, :finder
7
-
8
- collection.find( :all, find_options )
6
+ collection.all
9
7
  end
10
8
 
11
9
  def paginated_section( view, collection, &block )
@@ -10,7 +10,7 @@ module Irwi::Support::RouteMapper
10
10
  }.merge(config)
11
11
 
12
12
  Irwi.config.system_pages.each do |page_action, page_path| # Adding routes for system pages
13
- get( "#{root}/#{page_path}", opts.merge({ :action => page_action }) )
13
+ get( "#{root}/#{page_path}", opts.merge({ :action => page_action.dup }) )
14
14
  end
15
15
 
16
16
  get( "#{root}/compare/(*path)", opts.merge({ :action => 'compare', :as => 'compare_wiki_page' }) ) # Comparing two versions of page
@@ -1,7 +1,5 @@
1
1
  module Irwi::Support::TemplateFinder
2
2
 
3
- protected
4
-
5
3
  def template_dir(template)
6
4
  dir = respond_to?( :controller_path ) ? controller_path : controller.controller_path
7
5
  dir = 'base_wiki_pages' if Dir.glob( "app/views/#{dir}/#{template}.html.*" ).empty? # Select default if there are no template in resource directory
@@ -1,8 +1,8 @@
1
1
  module Irwi
2
2
  module VERSION #:nodoc:
3
3
  MAJOR = 0
4
- MINOR = 4
5
- TINY = 2
4
+ MINOR = 5
5
+ TINY = 0
6
6
 
7
7
  STRING = [MAJOR, MINOR, TINY].join('.')
8
8
  end
metadata CHANGED
@@ -1,231 +1,215 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: irwi
3
- version: !ruby/object:Gem::Version
4
- hash: 11
5
- prerelease:
6
- segments:
7
- - 0
8
- - 4
9
- - 2
10
- version: 0.4.2
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.5.0
11
5
  platform: ruby
12
- authors:
6
+ authors:
13
7
  - Alexey Noskov
14
8
  - Ravi Bhim
15
9
  autorequire:
16
10
  bindir: bin
17
11
  cert_chain: []
18
-
19
- date: 2012-03-22 00:00:00 Z
20
- dependencies:
21
- - !ruby/object:Gem::Dependency
12
+ date: 2016-02-15 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
22
15
  name: diff-lcs
23
- prerelease: false
24
- requirement: &id001 !ruby/object:Gem::Requirement
25
- none: false
26
- requirements:
27
- - - ">="
28
- - !ruby/object:Gem::Version
29
- hash: 23
30
- segments:
31
- - 1
32
- - 1
33
- - 2
16
+ requirement: !ruby/object:Gem::Requirement
17
+ requirements:
18
+ - - ">="
19
+ - !ruby/object:Gem::Version
34
20
  version: 1.1.2
35
21
  type: :runtime
36
- version_requirements: *id001
37
- - !ruby/object:Gem::Dependency
38
- name: activerecord
39
22
  prerelease: false
40
- requirement: &id002 !ruby/object:Gem::Requirement
41
- none: false
42
- requirements:
43
- - - ">="
44
- - !ruby/object:Gem::Version
45
- hash: 7
46
- segments:
47
- - 3
48
- - 0
49
- - 0
50
- version: 3.0.0
23
+ version_requirements: !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - ">="
26
+ - !ruby/object:Gem::Version
27
+ version: 1.1.2
28
+ - !ruby/object:Gem::Dependency
29
+ name: activerecord
30
+ requirement: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - ">="
33
+ - !ruby/object:Gem::Version
34
+ version: '4.0'
51
35
  type: :runtime
52
- version_requirements: *id002
53
- - !ruby/object:Gem::Dependency
54
- name: activesupport
55
36
  prerelease: false
56
- requirement: &id003 !ruby/object:Gem::Requirement
57
- none: false
58
- requirements:
59
- - - ">="
60
- - !ruby/object:Gem::Version
61
- hash: 7
62
- segments:
63
- - 3
64
- - 0
65
- - 0
66
- version: 3.0.0
37
+ version_requirements: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - ">="
40
+ - !ruby/object:Gem::Version
41
+ version: '4.0'
42
+ - !ruby/object:Gem::Dependency
43
+ name: activesupport
44
+ requirement: !ruby/object:Gem::Requirement
45
+ requirements:
46
+ - - ">="
47
+ - !ruby/object:Gem::Version
48
+ version: '4.0'
67
49
  type: :runtime
68
- version_requirements: *id003
69
- - !ruby/object:Gem::Dependency
70
- name: actionpack
71
50
  prerelease: false
72
- requirement: &id004 !ruby/object:Gem::Requirement
73
- none: false
74
- requirements:
75
- - - ">="
76
- - !ruby/object:Gem::Version
77
- hash: 7
78
- segments:
79
- - 3
80
- - 0
81
- - 0
82
- version: 3.0.0
51
+ version_requirements: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - ">="
54
+ - !ruby/object:Gem::Version
55
+ version: '4.0'
56
+ - !ruby/object:Gem::Dependency
57
+ name: actionpack
58
+ requirement: !ruby/object:Gem::Requirement
59
+ requirements:
60
+ - - ">="
61
+ - !ruby/object:Gem::Version
62
+ version: '4.0'
83
63
  type: :runtime
84
- version_requirements: *id004
85
- - !ruby/object:Gem::Dependency
86
- name: rails_autolink
87
64
  prerelease: false
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"
65
+ version_requirements: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - ">="
68
+ - !ruby/object:Gem::Version
69
+ version: '4.0'
70
+ - !ruby/object:Gem::Dependency
71
+ name: rails_autolink
72
+ requirement: !ruby/object:Gem::Requirement
73
+ requirements:
74
+ - - ">="
75
+ - !ruby/object:Gem::Version
76
+ version: '1.0'
98
77
  type: :runtime
99
- version_requirements: *id005
100
- - !ruby/object:Gem::Dependency
101
- name: rspec
102
78
  prerelease: false
103
- requirement: &id006 !ruby/object:Gem::Requirement
104
- none: false
105
- requirements:
106
- - - ">="
107
- - !ruby/object:Gem::Version
108
- hash: 3
109
- segments:
110
- - 2
111
- - 0
112
- version: "2.0"
79
+ version_requirements: !ruby/object:Gem::Requirement
80
+ requirements:
81
+ - - ">="
82
+ - !ruby/object:Gem::Version
83
+ version: '1.0'
84
+ - !ruby/object:Gem::Dependency
85
+ name: rspec
86
+ requirement: !ruby/object:Gem::Requirement
87
+ requirements:
88
+ - - ">="
89
+ - !ruby/object:Gem::Version
90
+ version: '2.0'
113
91
  type: :development
114
- version_requirements: *id006
115
- - !ruby/object:Gem::Dependency
92
+ prerelease: false
93
+ version_requirements: !ruby/object:Gem::Requirement
94
+ requirements:
95
+ - - ">="
96
+ - !ruby/object:Gem::Version
97
+ version: '2.0'
98
+ - !ruby/object:Gem::Dependency
116
99
  name: sqlite3
100
+ requirement: !ruby/object:Gem::Requirement
101
+ requirements:
102
+ - - ">="
103
+ - !ruby/object:Gem::Version
104
+ version: '0'
105
+ type: :development
117
106
  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"
107
+ version_requirements: !ruby/object:Gem::Requirement
108
+ requirements:
109
+ - - ">="
110
+ - !ruby/object:Gem::Version
111
+ version: '0'
112
+ - !ruby/object:Gem::Dependency
113
+ name: RedCloth
114
+ requirement: !ruby/object:Gem::Requirement
115
+ requirements:
116
+ - - ">="
117
+ - !ruby/object:Gem::Version
118
+ version: '0'
127
119
  type: :development
128
- version_requirements: *id007
120
+ prerelease: false
121
+ version_requirements: !ruby/object:Gem::Requirement
122
+ requirements:
123
+ - - ">="
124
+ - !ruby/object:Gem::Version
125
+ version: '0'
129
126
  description: Irwi is Ruby on Rails plugin which adds wiki functionality to your application.
130
- email:
127
+ email:
131
128
  - alexey.noskov@gmail.com
132
129
  - ravi.bhim@yahoo.com
133
130
  executables: []
134
-
135
131
  extensions: []
136
-
137
- extra_rdoc_files:
132
+ extra_rdoc_files:
138
133
  - README.rdoc
139
134
  - MIT-LICENSE
140
- files:
141
- - app/views/base_wiki_pages/no.html.erb
142
- - app/views/base_wiki_pages/_wiki_page_info.html.erb
143
- - app/views/base_wiki_pages/all.html.erb
144
- - app/views/base_wiki_pages/show.html.erb
145
- - app/views/base_wiki_pages/not_allowed.html.erb
146
- - app/views/base_wiki_pages/history.html.erb
135
+ files:
136
+ - MIT-LICENSE
137
+ - README.rdoc
147
138
  - app/views/base_wiki_pages/_wiki_page_actions.html.erb
148
139
  - app/views/base_wiki_pages/_wiki_page_history.html.erb
149
- - app/views/base_wiki_pages/new.html.erb
150
- - app/views/base_wiki_pages/edit.html.erb
140
+ - app/views/base_wiki_pages/_wiki_page_info.html.erb
151
141
  - app/views/base_wiki_pages/_wiki_page_style.html.erb
142
+ - app/views/base_wiki_pages/all.html.erb
152
143
  - app/views/base_wiki_pages/compare.html.erb
144
+ - app/views/base_wiki_pages/edit.html.erb
145
+ - app/views/base_wiki_pages/history.html.erb
146
+ - app/views/base_wiki_pages/new.html.erb
147
+ - app/views/base_wiki_pages/no.html.erb
148
+ - app/views/base_wiki_pages/not_allowed.html.erb
149
+ - app/views/base_wiki_pages/show.html.erb
150
+ - lib/generators/irwi_wiki/irwi_wiki_generator.rb
151
+ - lib/generators/irwi_wiki/templates/controllers/wiki_pages_controller.rb
152
+ - lib/generators/irwi_wiki/templates/helpers/wiki_pages_helper.rb
153
+ - lib/generators/irwi_wiki/templates/migrate/create_wiki_pages.rb
154
+ - lib/generators/irwi_wiki/templates/models/wiki_page.rb
155
+ - lib/generators/irwi_wiki/templates/models/wiki_page_version.rb
156
+ - lib/generators/irwi_wiki_attachments/irwi_wiki_attachments_generator.rb
157
+ - lib/generators/irwi_wiki_attachments/templates/migrate/create_wiki_page_attachments.rb
158
+ - lib/generators/irwi_wiki_attachments/templates/models/wiki_page_attachment.rb
159
+ - lib/generators/irwi_wiki_views/irwi_wiki_views_generator.rb
153
160
  - lib/irwi.rb
154
- - lib/irwi/support/template_finder.rb
155
- - lib/irwi/support/route_mapper.rb
156
161
  - lib/irwi/comparators/base.rb
157
- - lib/irwi/comparators/spans/not_changed_span.rb
158
- - lib/irwi/comparators/spans/changed_span.rb
159
162
  - lib/irwi/comparators/diff_lcs.rb
160
- - lib/irwi/extensions/models.rb
161
- - lib/irwi/extensions/controllers/wiki_pages.rb
162
- - lib/irwi/extensions/controllers/wiki_page_attachments.rb
163
+ - lib/irwi/comparators/spans/changed_span.rb
164
+ - lib/irwi/comparators/spans/not_changed_span.rb
165
+ - lib/irwi/config.rb
163
166
  - lib/irwi/extensions/controllers.rb
167
+ - lib/irwi/extensions/controllers/wiki_page_attachments.rb
168
+ - lib/irwi/extensions/controllers/wiki_pages.rb
169
+ - lib/irwi/extensions/models.rb
164
170
  - lib/irwi/extensions/models/wiki_page.rb
165
- - lib/irwi/extensions/models/wiki_page_version.rb
166
171
  - lib/irwi/extensions/models/wiki_page_attachment.rb
172
+ - lib/irwi/extensions/models/wiki_page_version.rb
173
+ - lib/irwi/formatters/blue_cloth.rb
174
+ - lib/irwi/formatters/red_carpet.rb
175
+ - lib/irwi/formatters/red_cloth.rb
176
+ - lib/irwi/formatters/simple_html.rb
177
+ - lib/irwi/formatters/wiki_cloth.rb
167
178
  - lib/irwi/helpers.rb
168
- - lib/irwi/paginators/will_paginate.rb
169
- - lib/irwi/paginators/none.rb
170
179
  - lib/irwi/helpers/wiki_page_attachments_helper.rb
171
180
  - lib/irwi/helpers/wiki_pages_helper.rb
172
- - lib/irwi/formatters/red_cloth.rb
173
- - lib/irwi/formatters/blue_cloth.rb
174
- - lib/irwi/formatters/simple_html.rb
181
+ - lib/irwi/paginators/none.rb
182
+ - lib/irwi/paginators/will_paginate.rb
183
+ - lib/irwi/support/route_mapper.rb
184
+ - lib/irwi/support/template_finder.rb
175
185
  - lib/irwi/version.rb
176
- - lib/irwi/config.rb
177
- - lib/generators/irwi_wiki/templates/controllers/wiki_pages_controller.rb
178
- - lib/generators/irwi_wiki/templates/migrate/create_wiki_pages.rb
179
- - lib/generators/irwi_wiki/templates/helpers/wiki_pages_helper.rb
180
- - lib/generators/irwi_wiki/templates/models/wiki_page.rb
181
- - lib/generators/irwi_wiki/templates/models/wiki_page_version.rb
182
- - lib/generators/irwi_wiki/irwi_wiki_generator.rb
183
- - lib/generators/irwi_wiki_views/irwi_wiki_views_generator.rb
184
- - lib/generators/irwi_wiki_attachments/templates/migrate/create_wiki_page_attachments.rb
185
- - lib/generators/irwi_wiki_attachments/templates/models/wiki_page_attachment.rb
186
- - lib/generators/irwi_wiki_attachments/irwi_wiki_attachments_generator.rb
187
- - MIT-LICENSE
188
- - README.rdoc
189
186
  homepage: http://github.com/alno/irwi
190
187
  licenses: []
191
-
188
+ metadata: {}
192
189
  post_install_message:
193
- rdoc_options:
194
- - --line-numbers
195
- - --inline-source
196
- - --title
197
- - Rayo CMS
198
- - --main
190
+ rdoc_options:
191
+ - "--line-numbers"
192
+ - "--inline-source"
193
+ - "--title"
194
+ - Irwi
195
+ - "--main"
199
196
  - README.rdoc
200
- require_paths:
197
+ require_paths:
201
198
  - lib
202
- required_ruby_version: !ruby/object:Gem::Requirement
203
- none: false
204
- requirements:
199
+ required_ruby_version: !ruby/object:Gem::Requirement
200
+ requirements:
205
201
  - - ">="
206
- - !ruby/object:Gem::Version
207
- hash: 3
208
- segments:
209
- - 0
210
- version: "0"
211
- required_rubygems_version: !ruby/object:Gem::Requirement
212
- none: false
213
- requirements:
202
+ - !ruby/object:Gem::Version
203
+ version: '0'
204
+ required_rubygems_version: !ruby/object:Gem::Requirement
205
+ requirements:
214
206
  - - ">="
215
- - !ruby/object:Gem::Version
216
- hash: 23
217
- segments:
218
- - 1
219
- - 3
220
- - 6
207
+ - !ruby/object:Gem::Version
221
208
  version: 1.3.6
222
209
  requirements: []
223
-
224
210
  rubyforge_project:
225
- rubygems_version: 1.8.11
211
+ rubygems_version: 2.4.5
226
212
  signing_key:
227
- specification_version: 3
213
+ specification_version: 4
228
214
  summary: Irwi is Ruby on Rails plugin which adds wiki functionality to your application.
229
215
  test_files: []
230
-
231
- has_rdoc: