summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhukl <contact@smyck.org>2009-02-19 22:40:27 +0100
committerhukl <contact@smyck.org>2009-02-19 22:40:27 +0100
commit111829573d1c048d4c4c4e4d98b114eba9c28196 (patch)
tree6f9d40764b0fd5a0587827f373db167be13f9ac2
parent632b3a03d732ae735b2efd1999e14c649bf35b77 (diff)
adding the admin controller and his friends
-rw-r--r--app/controllers/admin_controller.rb12
-rw-r--r--app/helpers/admin_helper.rb11
-rw-r--r--app/views/admin/index.html.erb5
-rw-r--r--app/views/layouts/admin.html.erb8
-rw-r--r--test/functional/admin_controller_test.rb8
-rw-r--r--test/unit/helpers/admin_helper_test.rb4
6 files changed, 47 insertions, 1 deletions
diff --git a/app/controllers/admin_controller.rb b/app/controllers/admin_controller.rb
new file mode 100644
index 0000000..e672e3b
--- /dev/null
+++ b/app/controllers/admin_controller.rb
@@ -0,0 +1,12 @@
1class AdminController < ApplicationController
2
3 def index
4 end
5
6 def switch_locale
7 I18n.locale = params[:id].to_sym
8
9 render :controller => 'nodes', :action => 'index'
10 end
11
12end
diff --git a/app/helpers/admin_helper.rb b/app/helpers/admin_helper.rb
new file mode 100644
index 0000000..7122584
--- /dev/null
+++ b/app/helpers/admin_helper.rb
@@ -0,0 +1,11 @@
1module AdminHelper
2
3 def language_selector
4 case I18n.locale
5 when :de
6 link_to 'Deutsch', edit_node_path(@node, :locale => :en)
7 when :en
8 link_to 'Deutsch', :locale => :de, :controller => params[:controller], :action => params[:action]
9 end
10 end
11end \ No newline at end of file
diff --git a/app/views/admin/index.html.erb b/app/views/admin/index.html.erb
new file mode 100644
index 0000000..0a9874f
--- /dev/null
+++ b/app/views/admin/index.html.erb
@@ -0,0 +1,5 @@
1<h1>Admin#index</h1>
2<p>Find me in app/views/admin/index.html.erb</p>
3
4
5<%= link_to 'nodes', :controller => :nodes, :action => :index %> \ No newline at end of file
diff --git a/app/views/layouts/admin.html.erb b/app/views/layouts/admin.html.erb
index df5b014..deebc66 100644
--- a/app/views/layouts/admin.html.erb
+++ b/app/views/layouts/admin.html.erb
@@ -24,6 +24,12 @@
24 </head> 24 </head>
25 25
26 <body> 26 <body>
27 <%= yield :layout %> 27 <div id="navigation">
28 <p><%= I18n.locale %></p>
29 <%= language_selector %>
30 </div>
31 <div id="content">
32 <%= yield :layout %>
33 </div>
28 </body> 34 </body>
29</html> 35</html>
diff --git a/test/functional/admin_controller_test.rb b/test/functional/admin_controller_test.rb
new file mode 100644
index 0000000..9bbf29b
--- /dev/null
+++ b/test/functional/admin_controller_test.rb
@@ -0,0 +1,8 @@
1require 'test_helper'
2
3class AdminControllerTest < ActionController::TestCase
4 # Replace this with your real tests.
5 test "the truth" do
6 assert true
7 end
8end
diff --git a/test/unit/helpers/admin_helper_test.rb b/test/unit/helpers/admin_helper_test.rb
new file mode 100644
index 0000000..23d9f40
--- /dev/null
+++ b/test/unit/helpers/admin_helper_test.rb
@@ -0,0 +1,4 @@
1require 'test_helper'
2
3class AdminHelperTest < ActionView::TestCase
4end