summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorhukl <contact@smyck.org>2009-02-22 12:52:58 +0100
committerhukl <contact@smyck.org>2009-02-22 12:52:58 +0100
commitc39eb1e9839664deb68b50b2a9db16770d42852c (patch)
treee1c6b0ceb1309074e6018ac1a61adb218552154b /app
parente0d5557a9e7f88050da2ccb42e02397952cded0d (diff)
another round of view updates
Diffstat (limited to 'app')
-rw-r--r--app/controllers/nodes_controller.rb14
-rw-r--r--app/models/node.rb3
-rw-r--r--app/views/admin/_menu.html.erb5
-rw-r--r--app/views/layouts/admin.html.erb7
-rw-r--r--app/views/nodes/edit.html.erb11
-rw-r--r--app/views/nodes/index.html.erb3
-rw-r--r--app/views/nodes/new.html.erb5
7 files changed, 30 insertions, 18 deletions
diff --git a/app/controllers/nodes_controller.rb b/app/controllers/nodes_controller.rb
index baf023f..829e26f 100644
--- a/app/controllers/nodes_controller.rb
+++ b/app/controllers/nodes_controller.rb
@@ -3,7 +3,6 @@ class NodesController < ApplicationController
3 layout 'admin' 3 layout 'admin'
4 before_filter :login_required 4 before_filter :login_required
5 before_filter :find_node, :only => [ 5 before_filter :find_node, :only => [
6 :create,
7 :show, 6 :show,
8 :edit, 7 :edit,
9 :update, 8 :update,
@@ -21,15 +20,18 @@ class NodesController < ApplicationController
21 end 20 end
22 21
23 def new 22 def new
24 @node = Node.new 23 @node = Node.new params[:node]
25 end 24 end
26 25
27 def create 26 def create
28 tmp_node = Node.new( params[:node] ) 27 parent = Node.find_by_unique_name(params[:parent_unique_name])
28 parent ||= Node.root
29 29
30 if request.post? and tmp_node.save 30 @node = Node.new( params[:node] )
31 tmp_node.move_to_child_of @node 31
32 redirect_to(tmp_node) 32 if request.post? and @node.save
33 @node.move_to_child_of parent
34 redirect_to(@node)
33 else 35 else
34 render :action => :new 36 render :action => :new
35 end 37 end
diff --git a/app/models/node.rb b/app/models/node.rb
index 170ca1c..a6e3867 100644
--- a/app/models/node.rb
+++ b/app/models/node.rb
@@ -10,6 +10,9 @@ class Node < ActiveRecord::Base
10 # Callbacks 10 # Callbacks
11 after_create :initialize_empty_page 11 after_create :initialize_empty_page
12 12
13 # Validations
14 validates_length_of :slug, :within => 3..40
15
13 # Class methods 16 # Class methods
14 17
15 # Returns a page for a given node. If no revision is supplied, it returns 18 # Returns a page for a given node. If no revision is supplied, it returns
diff --git a/app/views/admin/_menu.html.erb b/app/views/admin/_menu.html.erb
new file mode 100644
index 0000000..fa616df
--- /dev/null
+++ b/app/views/admin/_menu.html.erb
@@ -0,0 +1,5 @@
1<%= language_selector %> |
2
3<%= link_to 'Overview', :controller => :admin, :action => 'index' %> |
4<%= link_to 'Nodes', nodes_path %> |
5<%= link_to 'User', users_path %> \ No newline at end of file
diff --git a/app/views/layouts/admin.html.erb b/app/views/layouts/admin.html.erb
index 73e3b02..d5b1e6f 100644
--- a/app/views/layouts/admin.html.erb
+++ b/app/views/layouts/admin.html.erb
@@ -25,12 +25,7 @@
25 25
26 <body> 26 <body>
27 <div id="navigation"> 27 <div id="navigation">
28 <%= language_selector %> | 28 <%= render :partial => 'admin/menu' if current_user %>
29
30 <%= link_to 'Overview', :controller => :admin, :action => 'index' %> |
31 <%= link_to 'Nodes', nodes_path %> |
32 <%= link_to 'User', users_path %> | Actions:
33 <%= yield :menu %>
34 </div> 29 </div>
35 <div id="flash"> 30 <div id="flash">
36 <%= flash[:notice] %> 31 <%= flash[:notice] %>
diff --git a/app/views/nodes/edit.html.erb b/app/views/nodes/edit.html.erb
index f6513a7..7ec3be0 100644
--- a/app/views/nodes/edit.html.erb
+++ b/app/views/nodes/edit.html.erb
@@ -1,3 +1,9 @@
1<div id='subnavigation'>
2 <%= link_to 'Show', @node %>
3 <%= link_to 'Back', nodes_path %>
4 <%= link_to 'Publish', publish_node_path, :method => :put %>
5</div>
6
1<h1>Editing page</h1> 7<h1>Editing page</h1>
2 8
3<strong>Sprache:</strong> <%= I18n.locale %> <strong>Pfad:</strong> <%= @node.unique_name %> 9<strong>Sprache:</strong> <%= I18n.locale %> <strong>Pfad:</strong> <%= @node.unique_name %>
@@ -27,9 +33,4 @@
27 <%= f.submit "Update" %> 33 <%= f.submit "Update" %>
28 </p> 34 </p>
29 <% end %> 35 <% end %>
30
31
32 <%= link_to 'Show', @node %> |
33 <%= link_to 'Back', nodes_path %> |
34 <%= link_to 'Publish', publish_node_path, :method => :put %>
35</div> 36</div>
diff --git a/app/views/nodes/index.html.erb b/app/views/nodes/index.html.erb
index 533204d..da69125 100644
--- a/app/views/nodes/index.html.erb
+++ b/app/views/nodes/index.html.erb
@@ -1,3 +1,6 @@
1<div id="subnavigation">
2 <%= link_to 'Create', new_node_path %>
3</div>
1<h1>Nodes</h1> 4<h1>Nodes</h1>
2 5
3<%= will_paginate @nodes %> 6<%= will_paginate @nodes %>
diff --git a/app/views/nodes/new.html.erb b/app/views/nodes/new.html.erb
index 1207413..d657eb3 100644
--- a/app/views/nodes/new.html.erb
+++ b/app/views/nodes/new.html.erb
@@ -1,12 +1,15 @@
1<h1>Create new node</h1> 1<h1>Create new node</h1>
2 2
3<%= error_messages_for :node %>
4
3<% form_for @node do |f| %> 5<% form_for @node do |f| %>
4 <p> 6 <p>
5 <%= f.label 'Parent node' %><br /> 7 <%= f.label 'Parent node - Leave empty for top level' %><br />
6 <%= text_field_tag :parent_unique_name %> 8 <%= text_field_tag :parent_unique_name %>
7 </p> 9 </p>
8 <p> 10 <p>
9 <%= f.label :slug %><br /> 11 <%= f.label :slug %><br />
10 <%= f.text_field :slug %> 12 <%= f.text_field :slug %>
11 </p> 13 </p>
14 <p><%= f.submit 'Create node' %></p>
12<% end %> \ No newline at end of file 15<% end %> \ No newline at end of file