mirror of
https://github.com/danbee/danbarberphoto
synced 2025-03-04 08:49:07 +00:00
Added "enabled" for photos so I can disable them without deleting.
This commit is contained in:
parent
9ac87c80a9
commit
6b26a58497
@ -4,10 +4,10 @@ class CategoriesController < ApplicationController
|
|||||||
# GET /categories.xml
|
# GET /categories.xml
|
||||||
def index
|
def index
|
||||||
@categories = Category.paginate :all, :page => params[:page], :per_page => 4
|
@categories = Category.paginate :all, :page => params[:page], :per_page => 4
|
||||||
|
|
||||||
@num_categories = @categories.count
|
@num_categories = @categories.count
|
||||||
|
|
||||||
@photos = Photo.all(:limit => 2, :order => 'RANDOM()', :conditions => { :featured => true })
|
@photos = Photo.all(:limit => 2, :order => 'RANDOM()', :conditions => { :featured => true, :enabled => true })
|
||||||
|
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.html # index.html.erb
|
format.html # index.html.erb
|
||||||
@ -26,63 +26,4 @@ class CategoriesController < ApplicationController
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# GET /categories/new
|
|
||||||
# GET /categories/new.xml
|
|
||||||
def new
|
|
||||||
@category = Category.new
|
|
||||||
|
|
||||||
respond_to do |format|
|
|
||||||
format.html # new.html.erb
|
|
||||||
format.xml { render :xml => @category }
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
# GET /categories/1/edit
|
|
||||||
def edit
|
|
||||||
@category = Category.find(params[:id])
|
|
||||||
end
|
|
||||||
|
|
||||||
# POST /categories
|
|
||||||
# POST /categories.xml
|
|
||||||
def create
|
|
||||||
@category = Category.new(params[:category])
|
|
||||||
|
|
||||||
respond_to do |format|
|
|
||||||
if @category.save
|
|
||||||
format.html { redirect_to(@category, :notice => 'Category was successfully created.') }
|
|
||||||
format.xml { render :xml => @category, :status => :created, :location => @category }
|
|
||||||
else
|
|
||||||
format.html { render :action => "new" }
|
|
||||||
format.xml { render :xml => @category.errors, :status => :unprocessable_entity }
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
# PUT /categories/1
|
|
||||||
# PUT /categories/1.xml
|
|
||||||
def update
|
|
||||||
@category = Category.find(params[:id])
|
|
||||||
|
|
||||||
respond_to do |format|
|
|
||||||
if @category.update_attributes(params[:category])
|
|
||||||
format.html { redirect_to(@category, :notice => 'Category was successfully updated.') }
|
|
||||||
format.xml { head :ok }
|
|
||||||
else
|
|
||||||
format.html { render :action => "edit" }
|
|
||||||
format.xml { render :xml => @category.errors, :status => :unprocessable_entity }
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
# DELETE /categories/1
|
|
||||||
# DELETE /categories/1.xml
|
|
||||||
def destroy
|
|
||||||
@category = Category.find(params[:id])
|
|
||||||
@category.destroy
|
|
||||||
|
|
||||||
respond_to do |format|
|
|
||||||
format.html { redirect_to(categories_url) }
|
|
||||||
format.xml { head :ok }
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|||||||
@ -1,10 +1,10 @@
|
|||||||
class ContactsController < ApplicationController
|
class ContactsController < ApplicationController
|
||||||
layout "photos"
|
layout "photos"
|
||||||
|
|
||||||
def new
|
def new
|
||||||
@contact = Contact.new(:id => 1)
|
@contact = Contact.new(:id => 1)
|
||||||
end
|
end
|
||||||
|
|
||||||
def create
|
def create
|
||||||
@contact = Contact.new(params[:contact])
|
@contact = Contact.new(params[:contact])
|
||||||
if @contact.save
|
if @contact.save
|
||||||
|
|||||||
@ -2,7 +2,7 @@ class PagesController < ApplicationController
|
|||||||
layout "photos"
|
layout "photos"
|
||||||
|
|
||||||
def index
|
def index
|
||||||
@photo = Photo.first(:order => 'RANDOM()', :conditions => { :featured => true })
|
@photo = Photo.first(:order => 'RANDOM()', :conditions => { :featured => true, :enabled => true })
|
||||||
end
|
end
|
||||||
|
|
||||||
def about
|
def about
|
||||||
|
|||||||
@ -7,7 +7,7 @@ class PhotosController < ApplicationController
|
|||||||
def index
|
def index
|
||||||
if params[:category_id]
|
if params[:category_id]
|
||||||
@category = Category.find_by_id(params[:category_id])
|
@category = Category.find_by_id(params[:category_id])
|
||||||
@photos = @category.photos.paginate :page => params[:page], :per_page => 11
|
@photos = @category.photos.paginate :page => params[:page], :conditions => { :enabled => true }, :per_page => 11
|
||||||
@num_photos = @photos.count
|
@num_photos = @photos.count
|
||||||
else
|
else
|
||||||
@photos = Photo.paginate :all, :page => params[:page], :per_page => 11
|
@photos = Photo.paginate :all, :page => params[:page], :per_page => 11
|
||||||
@ -17,16 +17,6 @@ class PhotosController < ApplicationController
|
|||||||
format.html
|
format.html
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def create
|
|
||||||
@photo = Photo.new(params[:photo])
|
|
||||||
if @photo.save
|
|
||||||
flash[:notice] = 'Photo was successfully saved'
|
|
||||||
redirect_to photo_url(@photo)
|
|
||||||
else
|
|
||||||
render :action => :new
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def show
|
def show
|
||||||
@photo = Photo.find(params[:id])
|
@photo = Photo.find(params[:id])
|
||||||
|
|||||||
@ -10,6 +10,7 @@
|
|||||||
<%= stylesheet_link_tag "squaregrid", :media => "all" %>
|
<%= stylesheet_link_tag "squaregrid", :media => "all" %>
|
||||||
<%= stylesheet_link_tag "photos", :media => "all" %>
|
<%= stylesheet_link_tag "photos", :media => "all" %>
|
||||||
<%= stylesheet_link_tag "fancybox", :media => "all" %>
|
<%= stylesheet_link_tag "fancybox", :media => "all" %>
|
||||||
|
<%= stylesheet_link_tag "scrollbars", :media => "screen" %>
|
||||||
<%= javascript_include_tag 'jquery', 'jquery.validate', 'jrails', 'fancybox', 'photos' %>
|
<%= javascript_include_tag 'jquery', 'jquery.validate', 'jrails', 'fancybox', 'photos' %>
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
|
|||||||
@ -14,8 +14,8 @@ Category:
|
|||||||
|
|
||||||
Photo:
|
Photo:
|
||||||
fields:
|
fields:
|
||||||
default: title, sort, featured
|
default: title, sort, enabled, featured
|
||||||
form: photo, title, description, flickr_url, featured, sort
|
form: photo, title, description, flickr_url, enabled, featured, sort
|
||||||
order_by:
|
order_by:
|
||||||
relationships: categories
|
relationships: categories
|
||||||
filters:
|
filters:
|
||||||
|
|||||||
9
db/migrate/20101202155552_add_enabled_to_photos.rb
Normal file
9
db/migrate/20101202155552_add_enabled_to_photos.rb
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
class AddEnabledToPhotos < ActiveRecord::Migration
|
||||||
|
def self.up
|
||||||
|
add_column :photos, :enabled, :boolean, :default => true
|
||||||
|
end
|
||||||
|
|
||||||
|
def self.down
|
||||||
|
remove_column :photos, :enabled
|
||||||
|
end
|
||||||
|
end
|
||||||
@ -10,7 +10,7 @@
|
|||||||
#
|
#
|
||||||
# It's strongly recommended to check this file into your version control system.
|
# It's strongly recommended to check this file into your version control system.
|
||||||
|
|
||||||
ActiveRecord::Schema.define(:version => 20101013165208) do
|
ActiveRecord::Schema.define(:version => 20101202155552) do
|
||||||
|
|
||||||
create_table "admin_users", :force => true do |t|
|
create_table "admin_users", :force => true do |t|
|
||||||
t.string "first_name", :default => "", :null => false
|
t.string "first_name", :default => "", :null => false
|
||||||
@ -61,6 +61,7 @@ ActiveRecord::Schema.define(:version => 20101013165208) do
|
|||||||
t.text "description"
|
t.text "description"
|
||||||
t.integer "sort"
|
t.integer "sort"
|
||||||
t.boolean "featured", :default => false
|
t.boolean "featured", :default => false
|
||||||
|
t.boolean "enabled", :default => true
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@ -183,13 +183,14 @@ img {
|
|||||||
.about-content {
|
.about-content {
|
||||||
background: #444;
|
background: #444;
|
||||||
color: #ccc;
|
color: #ccc;
|
||||||
|
overflow: auto;
|
||||||
}
|
}
|
||||||
.about-content div {
|
.about-content div {
|
||||||
padding: 15px 20px;
|
padding: 15px 20px;
|
||||||
}
|
}
|
||||||
.about-content div p {
|
.about-content div p {
|
||||||
margin-bottom: 0.6em;
|
margin-bottom: 0.6em;
|
||||||
line-height: 1.4em;
|
line-height: 1.35em;
|
||||||
}
|
}
|
||||||
/* FORM */
|
/* FORM */
|
||||||
.contact-form {
|
.contact-form {
|
||||||
|
|||||||
71
public/stylesheets/scrollbars.css
Normal file
71
public/stylesheets/scrollbars.css
Normal file
@ -0,0 +1,71 @@
|
|||||||
|
/* Shamelessly stolen from elliottkember.com, which in turn was shamelessly stolen from maxvoltar.com, which in turn was shamelessly stolen from chatrboxapp.com. */
|
||||||
|
|
||||||
|
::-webkit-scrollbar {
|
||||||
|
width: 6px;
|
||||||
|
height: 6px;
|
||||||
|
}
|
||||||
|
|
||||||
|
::-webkit-scrollbar-button:start:decrement,
|
||||||
|
::-webkit-scrollbar-button:end:increment {
|
||||||
|
display: block;
|
||||||
|
height: 4px;
|
||||||
|
}
|
||||||
|
|
||||||
|
::-webkit-scrollbar-button:vertical:increment {
|
||||||
|
background-color: #fff;
|
||||||
|
background: transparent;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
::-webkit-scrollbar-track {
|
||||||
|
-webkit-border-radius: 3px;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
::-webkit-scrollbar-track-piece {
|
||||||
|
-webkit-border-radius: 3px;
|
||||||
|
}
|
||||||
|
|
||||||
|
::-webkit-scrollbar-thumb:vertical {
|
||||||
|
height: 50px;
|
||||||
|
background-color: #666;
|
||||||
|
opacity: 0.5;
|
||||||
|
-webkit-border-radius: 3px;
|
||||||
|
position: relative;
|
||||||
|
}
|
||||||
|
|
||||||
|
::-webkit-scrollbar-thumb:horizontal {
|
||||||
|
width: 50px;
|
||||||
|
background-color: #999;
|
||||||
|
-webkit-border-radius: 3px;
|
||||||
|
}
|
||||||
|
|
||||||
|
::-webkit-scrollbar-thumb:vertical:hover {
|
||||||
|
background-color: #999;
|
||||||
|
}
|
||||||
|
::-webkit-scrollbar-thumb:vertical:active, ::-webkit-scrollbar-thumb:vertical:focus{
|
||||||
|
background-color: #ddd;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
html {
|
||||||
|
/*overflow-y: scroll;*/
|
||||||
|
overflow: auto;
|
||||||
|
/*width: 100% !important;*/
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* @group default */
|
||||||
|
|
||||||
|
#wrapper {
|
||||||
|
margin: 0 auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
html {
|
||||||
|
overflow-x: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
#turn_wrapper {
|
||||||
|
left: 10px !important;
|
||||||
|
}
|
||||||
|
|
||||||
Loading…
Reference in New Issue
Block a user