summaryrefslogtreecommitdiff
path: root/app/controllers
diff options
context:
space:
mode:
authorerdgeist <erdgeist@erdgeist.org>2026-06-24 04:13:16 +0200
committererdgeist <erdgeist@erdgeist.org>2026-06-24 04:13:16 +0200
commite0a7e0fec760ba12c8067a37e10c96f1f05876e2 (patch)
treed0cf745592a46aee4d4913911fd34c7c24515220 /app/controllers
parent6424e10be5a89f175a74c71c55660412a169b8b8 (diff)
Stage 1 complete: Rails 2.3.5 to Rails 3.2.22.5 upgrade
- Converted plugins to gems (Gemfile) - Updated config structure (application.rb, boot.rb, environment.rb) - Converted routes to Rails 3 DSL - Converted named_scope to scope throughout models - Converted find(:all, :conditions) to where() chains - Fixed has_many :order to use ordering scope - Updated session store and secret token configuration - Fixed exception_notification middleware configuration - Patched Ruby 2.4 / Rails 3.2 incompatibilities: - Integer/Float duration arithmetic (ActiveSupport) - Arel visit_Integer for PostgreSQL adapter - create_database String/Integer coercion - ActionController consider_all_requests_local - Migrated taggings schema for acts-as-taggable-on - Replaced dynamic_form gem with custom form_error_messages helper - Fixed Rails 3 block helper syntax (form_for, form_tag, fields_for) - Fixed admin layout yield - Updated test suite for Rails 3 APIs
Diffstat (limited to 'app/controllers')
-rw-r--r--app/controllers/admin_controller.rb38
-rw-r--r--app/controllers/application_controller.rb18
-rw-r--r--app/controllers/content_controller.rb4
-rw-r--r--app/controllers/menu_items_controller.rb2
-rw-r--r--app/controllers/nodes_controller.rb9
-rw-r--r--app/controllers/revisions_controller.rb1
-rw-r--r--app/controllers/rss_controller.rb19
-rw-r--r--app/controllers/tags_controller.rb14
-rw-r--r--app/controllers/users_controller.rb2
9 files changed, 40 insertions, 67 deletions
diff --git a/app/controllers/admin_controller.rb b/app/controllers/admin_controller.rb
index f3cc221..18c4104 100644
--- a/app/controllers/admin_controller.rb
+++ b/app/controllers/admin_controller.rb
@@ -5,21 +5,15 @@ class AdminController < ApplicationController
5 before_filter :login_required 5 before_filter :login_required
6 6
7 def index 7 def index
8 @drafts = Node.all( 8 @drafts = Node.where("draft_id IS NOT NULL")
9 :limit => 50, 9 .limit(50).order("updated_at desc")
10 :order => "updated_at desc", 10
11 :conditions => ["draft_id IS NOT NULL"] 11 @drafts_count = Node.where("draft_id IS NOT NULL").count
12 ) 12
13 @drafts_count = Node.count( 13 @recent_changes = Node.where(
14 :conditions => ["draft_id IS NOT NULL"] 14 "updated_at < ? AND updated_at > ? AND parent_id IS NOT NULL",
15 ) 15 Time.now, Time.now - 14.days
16 @recent_changes = Node.all( 16 ).limit(50).order("updated_at desc")
17 :limit => 50,
18 :order => "updated_at desc",
19 :conditions => [
20 "updated_at < ? AND updated_at > ? AND parent_id IS NOT NULL", Time.now, Time.now-14.days
21 ]
22 )
23 17
24 all_nodes = Node.root.self_and_descendants 18 all_nodes = Node.root.self_and_descendants
25 @sitemap_depth = {} 19 @sitemap_depth = {}
@@ -28,16 +22,12 @@ class AdminController < ApplicationController
28 end 22 end
29 @sitemap = all_nodes.to_a.sort! { |node1,node2| node1.lft <=> node2.lft }.delete_if { |node| node.update? } 23 @sitemap = all_nodes.to_a.sort! { |node1,node2| node1.lft <=> node2.lft }.delete_if { |node| node.update? }
30 24
31 @mypages = Page.all( 25 @mypages = Page.where("user_id = ? or editor_id = ?", @current_user, @current_user)
32 :conditions => [ "user_id = ? or editor_id = ?", @current_user, @current_user]
33 )
34
35 @mynodes = Node.all(
36 :order => "updated_at desc",
37 :joins => :pages,
38 :conditions => [ "pages.user_id = ? or pages.editor_id = ?", @current_user, @current_user ]
39 ).uniq.first(50)
40 26
27 @mynodes = Node.joins(:pages)
28 .where("pages.user_id = ? or pages.editor_id = ?", @current_user, @current_user)
29 .order("updated_at desc")
30 .uniq.first(50)
41 end 31 end
42 32
43 def search 33 def search
diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb
index 89cd330..4d0ed2e 100644
--- a/app/controllers/application_controller.rb
+++ b/app/controllers/application_controller.rb
@@ -2,25 +2,19 @@
2# Likewise, all the methods added will be available for all controllers. 2# Likewise, all the methods added will be available for all controllers.
3 3
4class ApplicationController < ActionController::Base 4class ApplicationController < ActionController::Base
5
6 include ExceptionNotifiable
7 include AuthenticatedSystem 5 include AuthenticatedSystem
8 6
9 helper :all # include all helpers, all the time
10 protect_from_forgery # See ActionController::RequestForgeryProtection for details 7 protect_from_forgery # See ActionController::RequestForgeryProtection for details
11 8
12 # Scrub sensitive parameters from your log
13 filter_parameter_logging :password, :password_confirmation
14
15 before_filter :set_locale 9 before_filter :set_locale
16 10
17 protected 11 protected
18 12
19 def set_locale 13 def set_locale
20 if params[:locale] && I18n.available_locales.include?(params[:locale].to_sym) 14 if params[:locale] && I18n.available_locales.include?(params[:locale].to_sym)
21 I18n.locale = params[:locale].to_sym 15 I18n.locale = params[:locale].to_sym
22 else 16 else
23 params.delete(:locale) 17 params.delete(:locale)
24 end
25 end 18 end
19 end
26end 20end
diff --git a/app/controllers/content_controller.rb b/app/controllers/content_controller.rb
index c62b726..4248239 100644
--- a/app/controllers/content_controller.rb
+++ b/app/controllers/content_controller.rb
@@ -20,7 +20,7 @@ class ContentController < ApplicationController
20 ) 20 )
21 else 21 else
22 render( 22 render(
23 :file => File.join(RAILS_ROOT, 'public', '404.html'), 23 :file => Rails.root.join('public', '404.html'),
24 :status => 404 24 :status => 404
25 ) 25 )
26 end 26 end
@@ -38,7 +38,7 @@ class ContentController < ApplicationController
38 38
39 private 39 private
40 def find_page 40 def find_page
41 path = params[:page_path].join('/') 41 path = params[:page_path].is_a?(Array) ? params[:page_path].join('/') : params[:page_path]
42 if path =~ /^[a-zA-Z\:\/\/\.\-\d_]+$/ 42 if path =~ /^[a-zA-Z\:\/\/\.\-\d_]+$/
43 @page = Node.find_page(path) 43 @page = Node.find_page(path)
44 else 44 else
diff --git a/app/controllers/menu_items_controller.rb b/app/controllers/menu_items_controller.rb
index 808da15..24a3d5e 100644
--- a/app/controllers/menu_items_controller.rb
+++ b/app/controllers/menu_items_controller.rb
@@ -7,7 +7,7 @@ class MenuItemsController < ApplicationController
7 layout 'admin' 7 layout 'admin'
8 8
9 def index 9 def index
10 @menu_items = MenuItem.all(:order => "position ASC") 10 @menu_items = MenuItem.order("position ASC").all
11 end 11 end
12 12
13 def show 13 def show
diff --git a/app/controllers/nodes_controller.rb b/app/controllers/nodes_controller.rb
index 95aed48..7c082c4 100644
--- a/app/controllers/nodes_controller.rb
+++ b/app/controllers/nodes_controller.rb
@@ -15,12 +15,9 @@ class NodesController < ApplicationController
15 ] 15 ]
16 16
17 def index 17 def index
18 @nodes = Node.root.descendants.paginate( 18 @nodes = Node.root.descendants.includes(:head, :draft)
19 :include => [:head, :draft], 19 .order('id DESC')
20 :page => params[:page], 20 .paginate(:page => params[:page], :per_page => 25)
21 :per_page => 25,
22 :order => 'id DESC'
23 )
24 end 21 end
25 22
26 def new 23 def new
diff --git a/app/controllers/revisions_controller.rb b/app/controllers/revisions_controller.rb
index 05e8acc..8c16730 100644
--- a/app/controllers/revisions_controller.rb
+++ b/app/controllers/revisions_controller.rb
@@ -8,6 +8,7 @@ class RevisionsController < ApplicationController
8 8
9 def index 9 def index
10 @node = Node.find(params[:node_id]) 10 @node = Node.find(params[:node_id])
11 @pages = @node.pages.all
11 end 12 end
12 13
13 def diff 14 def diff
diff --git a/app/controllers/rss_controller.rb b/app/controllers/rss_controller.rb
index acffc0e..70a642c 100644
--- a/app/controllers/rss_controller.rb
+++ b/app/controllers/rss_controller.rb
@@ -7,12 +7,9 @@ class RssController < ApplicationController
7 expires_in 31.minutes, :public => true 7 expires_in 31.minutes, :public => true
8 8
9 I18n.locale = :de 9 I18n.locale = :de
10 10
11 @items = Page.heads.find_tagged_with( 11 @items = Page.heads.tagged_with("update")
12 "update", 12 .order("published_at DESC").limit(20)
13 :order => "published_at DESC",
14 :limit => 20
15 )
16 13
17 respond_to do |format| 14 respond_to do |format|
18 format.xml {} 15 format.xml {}
@@ -21,13 +18,9 @@ class RssController < ApplicationController
21 end 18 end
22 19
23 def recent_changes 20 def recent_changes
24 @items = Page.all( 21 @items = Page.where(
25 :limit => 20, 22 "updated_at < ? AND updated_at > ?", Time.now, Time.now - 14.days
26 :order => "updated_at desc", 23 ).limit(20).order("updated_at desc")
27 :conditions => [
28 "updated_at < ? AND updated_at > ?", Time.now, Time.now-14.days
29 ]
30 )
31 end 24 end
32 25
33 protected 26 protected
diff --git a/app/controllers/tags_controller.rb b/app/controllers/tags_controller.rb
index bf64b73..f09d560 100644
--- a/app/controllers/tags_controller.rb
+++ b/app/controllers/tags_controller.rb
@@ -5,7 +5,7 @@ class TagsController < ApplicationController
5 def index 5 def index
6 @page = Page.new :title => "Tags" 6 @page = Page.new :title => "Tags"
7 7
8 @tags = Tag.all(:limit => 500) 8 @tags = Tag.limit(500).all
9 end 9 end
10 10
11 def show 11 def show
@@ -16,14 +16,12 @@ class TagsController < ApplicationController
16 @tag = @tag ? @tag.name : tag_name 16 @tag = @tag ? @tag.name : tag_name
17 @page = Page.new 17 @page = Page.new
18 18
19 params[:page] = ( params[:page].is_a?(Fixnum) ? params[:page] : 1 ) 19 params[:page] = (params[:page].is_a?(Integer) ? params[:page] : 1)
20 20
21 @pages = Page.heads.paginate( 21 @pages = Page.heads.tagged_with(@tag).paginate(
22 Page.find_options_for_find_tagged_with(@tag).merge( 22 :order => 'published_at DESC',
23 :order => 'published_at DESC', 23 :page => params[:page],
24 :page=>params[:page], 24 :per_page => 23
25 :per_page => 23
26 )
27 ) 25 )
28 26
29 respond_to do |format| 27 respond_to do |format|
diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb
index 87df678..b7914c4 100644
--- a/app/controllers/users_controller.rb
+++ b/app/controllers/users_controller.rb
@@ -9,7 +9,7 @@ class UsersController < ApplicationController
9 layout 'admin' 9 layout 'admin'
10 10
11 def index 11 def index
12 @users = User.all(:order => "login ASC").group_by do |user| 12 @users = User.order("login ASC").all.group_by do |user|
13 user.admin? ? :admin : :user 13 user.admin? ? :admin : :user
14 end 14 end
15 end 15 end