diff options
| -rw-r--r-- | app/controllers/nodes_controller.rb | 29 | ||||
| -rw-r--r-- | app/helpers/nodes_helper.rb | 2 | ||||
| -rw-r--r-- | app/views/layouts/admin.html.erb | 15 | ||||
| -rw-r--r-- | app/views/nodes/create.html.erb | 2 | ||||
| -rw-r--r-- | app/views/nodes/destroy.html.erb | 2 | ||||
| -rw-r--r-- | app/views/nodes/edit.html.erb | 34 | ||||
| -rw-r--r-- | app/views/nodes/index.html.erb | 7 | ||||
| -rw-r--r-- | app/views/nodes/new.html.erb | 2 | ||||
| -rw-r--r-- | app/views/nodes/show.html.erb | 10 | ||||
| -rw-r--r-- | app/views/nodes/update.html.erb | 2 | ||||
| -rw-r--r-- | app/views/pages/index.html.erb | 3 | ||||
| -rw-r--r-- | config/routes.rb | 1 | ||||
| -rw-r--r-- | test/functional/nodes_controller_test.rb | 8 | ||||
| -rw-r--r-- | test/unit/helpers/nodes_helper_test.rb | 4 |
14 files changed, 118 insertions, 3 deletions
diff --git a/app/controllers/nodes_controller.rb b/app/controllers/nodes_controller.rb new file mode 100644 index 0000000..90cf756 --- /dev/null +++ b/app/controllers/nodes_controller.rb | |||
| @@ -0,0 +1,29 @@ | |||
| 1 | class NodesController < ApplicationController | ||
| 2 | |||
| 3 | layout 'admin' | ||
| 4 | |||
| 5 | def index | ||
| 6 | @nodes = Node.root.children.all(:include => :head) | ||
| 7 | end | ||
| 8 | |||
| 9 | def new | ||
| 10 | end | ||
| 11 | |||
| 12 | def create | ||
| 13 | end | ||
| 14 | |||
| 15 | def show | ||
| 16 | @nodes = Node.find(params[:id]).children | ||
| 17 | end | ||
| 18 | |||
| 19 | def edit | ||
| 20 | @page = Node.find(params[:id]).draft | ||
| 21 | end | ||
| 22 | |||
| 23 | def update | ||
| 24 | end | ||
| 25 | |||
| 26 | def destroy | ||
| 27 | end | ||
| 28 | |||
| 29 | end | ||
diff --git a/app/helpers/nodes_helper.rb b/app/helpers/nodes_helper.rb new file mode 100644 index 0000000..673b561 --- /dev/null +++ b/app/helpers/nodes_helper.rb | |||
| @@ -0,0 +1,2 @@ | |||
| 1 | module NodesHelper | ||
| 2 | end | ||
diff --git a/app/views/layouts/admin.html.erb b/app/views/layouts/admin.html.erb new file mode 100644 index 0000000..95161a8 --- /dev/null +++ b/app/views/layouts/admin.html.erb | |||
| @@ -0,0 +1,15 @@ | |||
| 1 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" | ||
| 2 | "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> | ||
| 3 | |||
| 4 | <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> | ||
| 5 | <head> | ||
| 6 | <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> | ||
| 7 | |||
| 8 | <title>untitled</title> | ||
| 9 | |||
| 10 | </head> | ||
| 11 | |||
| 12 | <body> | ||
| 13 | <%= yield :layout %> | ||
| 14 | </body> | ||
| 15 | </html> | ||
diff --git a/app/views/nodes/create.html.erb b/app/views/nodes/create.html.erb new file mode 100644 index 0000000..05b6282 --- /dev/null +++ b/app/views/nodes/create.html.erb | |||
| @@ -0,0 +1,2 @@ | |||
| 1 | <h1>Nodes#create</h1> | ||
| 2 | <p>Find me in app/views/nodes/create.html.erb</p> | ||
diff --git a/app/views/nodes/destroy.html.erb b/app/views/nodes/destroy.html.erb new file mode 100644 index 0000000..065cf1d --- /dev/null +++ b/app/views/nodes/destroy.html.erb | |||
| @@ -0,0 +1,2 @@ | |||
| 1 | <h1>Nodes#destroy</h1> | ||
| 2 | <p>Find me in app/views/nodes/destroy.html.erb</p> | ||
diff --git a/app/views/nodes/edit.html.erb b/app/views/nodes/edit.html.erb new file mode 100644 index 0000000..a5668e2 --- /dev/null +++ b/app/views/nodes/edit.html.erb | |||
| @@ -0,0 +1,34 @@ | |||
| 1 | <h1>Nodes#edit</h1> | ||
| 2 | |||
| 3 | <h1>Editing page</h1> | ||
| 4 | |||
| 5 | <% form_for(@page) do |f| %> | ||
| 6 | <%= f.error_messages %> | ||
| 7 | |||
| 8 | <p> | ||
| 9 | <%= f.label :node_id %><br /> | ||
| 10 | <%= f.text_field :node_id %> | ||
| 11 | </p> | ||
| 12 | <p> | ||
| 13 | <%= f.label :title %><br /> | ||
| 14 | <%= f.text_field :title %> | ||
| 15 | </p> | ||
| 16 | <p> | ||
| 17 | <%= f.label :abstract %><br /> | ||
| 18 | <%= f.text_area :abstract %> | ||
| 19 | </p> | ||
| 20 | <p> | ||
| 21 | <%= f.label :body %><br /> | ||
| 22 | <%= f.text_area :body %> | ||
| 23 | </p> | ||
| 24 | <p> | ||
| 25 | <%= f.label :revision %><br /> | ||
| 26 | <%= f.text_field :revision %> | ||
| 27 | </p> | ||
| 28 | <p> | ||
| 29 | <%= f.submit "Update" %> | ||
| 30 | </p> | ||
| 31 | <% end %> | ||
| 32 | |||
| 33 | <%= link_to 'Show', @page %> | | ||
| 34 | <%= link_to 'Back', pages_path %> | ||
diff --git a/app/views/nodes/index.html.erb b/app/views/nodes/index.html.erb new file mode 100644 index 0000000..6cbf76d --- /dev/null +++ b/app/views/nodes/index.html.erb | |||
| @@ -0,0 +1,7 @@ | |||
| 1 | <h1>Nodes</h1> | ||
| 2 | |||
| 3 | <ul> | ||
| 4 | <% @nodes.each do |node| %> | ||
| 5 | <li><%= link_to node.unique_name, node_path(node) %></li> | ||
| 6 | <% end %> | ||
| 7 | </ul> \ No newline at end of file | ||
diff --git a/app/views/nodes/new.html.erb b/app/views/nodes/new.html.erb new file mode 100644 index 0000000..4258377 --- /dev/null +++ b/app/views/nodes/new.html.erb | |||
| @@ -0,0 +1,2 @@ | |||
| 1 | <h1>Nodes#new</h1> | ||
| 2 | <p>Find me in app/views/nodes/new.html.erb</p> | ||
diff --git a/app/views/nodes/show.html.erb b/app/views/nodes/show.html.erb new file mode 100644 index 0000000..bbf11c0 --- /dev/null +++ b/app/views/nodes/show.html.erb | |||
| @@ -0,0 +1,10 @@ | |||
| 1 | <h1>Nodes</h1> | ||
| 2 | |||
| 3 | <table> | ||
| 4 | <% @nodes.each do |node| %> | ||
| 5 | <tr> | ||
| 6 | <td><%= link_to node.unique_name, node_path(node) %></td> | ||
| 7 | <td><%= link_to 'Edit', edit_node_path(node) %></td> | ||
| 8 | </tr> | ||
| 9 | <% end %> | ||
| 10 | </table> \ No newline at end of file | ||
diff --git a/app/views/nodes/update.html.erb b/app/views/nodes/update.html.erb new file mode 100644 index 0000000..5c6caa8 --- /dev/null +++ b/app/views/nodes/update.html.erb | |||
| @@ -0,0 +1,2 @@ | |||
| 1 | <h1>Nodes#update</h1> | ||
| 2 | <p>Find me in app/views/nodes/update.html.erb</p> | ||
diff --git a/app/views/pages/index.html.erb b/app/views/pages/index.html.erb index f5918f0..16539da 100644 --- a/app/views/pages/index.html.erb +++ b/app/views/pages/index.html.erb | |||
| @@ -4,9 +4,6 @@ | |||
| 4 | <tr> | 4 | <tr> |
| 5 | <th>Node</th> | 5 | <th>Node</th> |
| 6 | <th>Title</th> | 6 | <th>Title</th> |
| 7 | <th>Abstract</th> | ||
| 8 | <th>Body</th> | ||
| 9 | <th>Revision</th> | ||
| 10 | </tr> | 7 | </tr> |
| 11 | 8 | ||
| 12 | <% for page in @pages %> | 9 | <% for page in @pages %> |
diff --git a/config/routes.rb b/config/routes.rb index 15ce385..c436b00 100644 --- a/config/routes.rb +++ b/config/routes.rb | |||
| @@ -1,5 +1,6 @@ | |||
| 1 | ActionController::Routing::Routes.draw do |map| | 1 | ActionController::Routing::Routes.draw do |map| |
| 2 | map.resources :pages | 2 | map.resources :pages |
| 3 | map.resources :nodes | ||
| 3 | 4 | ||
| 4 | 5 | ||
| 5 | map.connect ':language/*page_path', | 6 | map.connect ':language/*page_path', |
diff --git a/test/functional/nodes_controller_test.rb b/test/functional/nodes_controller_test.rb new file mode 100644 index 0000000..d6d579d --- /dev/null +++ b/test/functional/nodes_controller_test.rb | |||
| @@ -0,0 +1,8 @@ | |||
| 1 | require 'test_helper' | ||
| 2 | |||
| 3 | class NodesControllerTest < ActionController::TestCase | ||
| 4 | # Replace this with your real tests. | ||
| 5 | test "the truth" do | ||
| 6 | assert true | ||
| 7 | end | ||
| 8 | end | ||
diff --git a/test/unit/helpers/nodes_helper_test.rb b/test/unit/helpers/nodes_helper_test.rb new file mode 100644 index 0000000..13011de --- /dev/null +++ b/test/unit/helpers/nodes_helper_test.rb | |||
| @@ -0,0 +1,4 @@ | |||
| 1 | require 'test_helper' | ||
| 2 | |||
| 3 | class NodesHelperTest < ActionView::TestCase | ||
| 4 | end | ||
