Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

implement rest of rails actions for this iteration; rename /public/in…

…dex.html
  • Loading branch information...
commit 36ab99d48c4dca90743a748d15fa1c8b22552ae9 1 parent 33513f4
@wizardwerdna authored
View
21 z_rails/app/controllers/pages_controller.rb
@@ -4,4 +4,25 @@ def index
@pages = ::Pages::All[].pages
end
+ def show
+ @page = ::Pages::Get[name: params[:id]].page
+ raise ActiveRecord::RecordNotFound if @page == ::Repository::NoRecord
+ redirect_to @page.locator
+ end
+
+ def update
+ locator = params[:locator] + dot_format_or_empty_string
+ ::Pages::Set[name: params[:id], locator: locator]
+ redirect_to root_url
+ end
+
+ private
+
+ def dot_format_or_empty_string
+ if params[:format].present?
+ '.' + params[:format]
+ else
+ ''
+ end
+ end
end
View
7 z_rails/config/routes.rb
@@ -1,6 +1,11 @@
ZRails::Application.routes.draw do
- resources :pages
+ root :to => "pages#index"
+
+ match ':id' => "pages#show"
+
+ match 'set/:id/*locator' => "pages#update", :constraints => {:url => /.*/}
+
# The priority is based upon order of creation:
# first created -> highest priority.
View
0  z_rails/public/index.html → z_rails/public/old_index.html
File renamed without changes
Please sign in to comment.
Something went wrong with that request. Please try again.