mirror of
https://github.com/danbee/danbarberphoto
synced 2025-03-04 08:49:07 +00:00
Refactor controllers to make more sense.
This commit is contained in:
parent
525fda2911
commit
3dd213e140
@ -1,5 +1,4 @@
|
|||||||
class CategoriesController < ApplicationController
|
class CategoriesController < ApplicationController
|
||||||
layout "photos"
|
|
||||||
# GET /categories
|
# GET /categories
|
||||||
# GET /categories.xml
|
# GET /categories.xml
|
||||||
def index
|
def index
|
||||||
|
|||||||
@ -1,6 +1,4 @@
|
|||||||
class ContactsController < ApplicationController
|
class ContactsController < ApplicationController
|
||||||
layout "photos"
|
|
||||||
|
|
||||||
def new
|
def new
|
||||||
@contact = Contact.new(:id => 1)
|
@contact = Contact.new(:id => 1)
|
||||||
@page_title = 'Contact'
|
@page_title = 'Contact'
|
||||||
|
|||||||
@ -1,4 +1,5 @@
|
|||||||
class HomeController < ApplicationController
|
class HomeController < ApplicationController
|
||||||
def index
|
def index
|
||||||
|
@photo = Photo.featured.order('RANDOM()').first
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -1,13 +1,6 @@
|
|||||||
class PagesController < ApplicationController
|
class PagesController < ApplicationController
|
||||||
layout "photos"
|
def show
|
||||||
|
@page = Page.find_by_name(params[:name])
|
||||||
def index
|
@page_title = @page.title
|
||||||
@photo = Photo.featured.order('RANDOM()').first
|
|
||||||
end
|
|
||||||
|
|
||||||
def about
|
|
||||||
@page = Page.find_by_name('about')
|
|
||||||
@content = @page.content
|
|
||||||
@page_title = 'About'
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
<div class="sg-5 about">
|
<div class="sg-5 about">
|
||||||
<%= link_to raw('<span>about</span>'), about_path %>
|
<%= link_to raw('<span>about</span>'), page_path(:about) %>
|
||||||
</div>
|
</div>
|
||||||
<div class="sg-5 portfolio">
|
<div class="sg-5 portfolio">
|
||||||
<%= link_to raw('<span>portfolio</span>'), :controller => 'categories' %>
|
<%= link_to raw('<span>portfolio</span>'), :controller => 'categories' %>
|
||||||
@ -1 +0,0 @@
|
|||||||
%h1= APP_CONFIG['name']
|
|
||||||
@ -1,9 +0,0 @@
|
|||||||
!!!
|
|
||||||
%html
|
|
||||||
%head
|
|
||||||
%title= APP_CONFIG['name']
|
|
||||||
= stylesheet_link_tag "application"
|
|
||||||
= javascript_include_tag "application"
|
|
||||||
= csrf_meta_tags
|
|
||||||
%body
|
|
||||||
= yield
|
|
||||||
@ -1,17 +0,0 @@
|
|||||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
|
||||||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
|
||||||
|
|
||||||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
|
||||||
<head>
|
|
||||||
<meta http-equiv="content-type" content="text/html;charset=UTF-8" />
|
|
||||||
<title>Categories: <%= controller.action_name %></title>
|
|
||||||
<%= stylesheet_link_tag 'scaffold' %>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
|
|
||||||
<p style="color: green"><%= notice %></p>
|
|
||||||
|
|
||||||
<%= yield %>
|
|
||||||
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
@ -9,7 +9,7 @@
|
|||||||
|
|
||||||
<div class="sg-11 about-content">
|
<div class="sg-11 about-content">
|
||||||
<div>
|
<div>
|
||||||
<%= raw(@content.to_html) %>
|
<%= raw(@page.content.to_html) %>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@ -86,23 +86,24 @@ DanBarberPhoto::Application.routes.draw do
|
|||||||
get :log_view
|
get :log_view
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
resources :photos do
|
resources :photos do
|
||||||
member do
|
member do
|
||||||
get :log_view
|
get :log_view
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
match 'about' => 'pages#about', :as => :about
|
|
||||||
#match 'contact' => 'pages#contact', :as => :contact
|
#match 'contact' => 'pages#contact', :as => :contact
|
||||||
resources :contacts, :only => [:new, :create]
|
resources :contacts, :only => [:new, :create]
|
||||||
|
|
||||||
|
match '/:name' => 'pages#show', :as => :page
|
||||||
|
|
||||||
# This is a legacy wild controller route that's not recommended for RESTful applications.
|
# This is a legacy wild controller route that's not recommended for RESTful applications.
|
||||||
# Note: This route will make all actions in every controller accessible via GET requests.
|
# Note: This route will make all actions in every controller accessible via GET requests.
|
||||||
# match ':controller(/:action(/:id(.:format)))'
|
# match ':controller(/:action(/:id(.:format)))'
|
||||||
|
|
||||||
# root :to => 'welcome#index'
|
# root :to => 'welcome#index'
|
||||||
root :to => 'pages#index'
|
root :to => 'home#index'
|
||||||
|
|
||||||
# See how all your routes lay out with "rake routes"
|
# See how all your routes lay out with "rake routes"
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user