1
0
mirror of https://github.com/danbee/danbarberphoto synced 2025-03-04 08:49:07 +00:00

Finished up admin interface. Tweaks to site stylesheets.

This commit is contained in:
Dan Barber 2011-10-31 17:34:48 +00:00
parent 08170ec5e0
commit 3162853285
35 changed files with 389 additions and 19 deletions

View File

@ -45,6 +45,7 @@ gem 'sass-rails', "~> 3.1.0"
gem "exception_notification", :git => "git://github.com/rails/exception_notification", :require => 'exception_notifier' gem "exception_notification", :git => "git://github.com/rails/exception_notification", :require => 'exception_notifier'
gem 'pg' gem 'pg'
gem 'devise' gem 'devise'
gem 'formtastic'
gem 'squeel' gem 'squeel'
gem 'mini_exiftool' gem 'mini_exiftool'
gem 'will_paginate' gem 'will_paginate'
@ -52,3 +53,4 @@ gem 'rdiscount'
gem 'paperclip' gem 'paperclip'
gem 'acts_as_markup' gem 'acts_as_markup'
gem 'yaml_db' gem 'yaml_db'
gem 'haml'

View File

@ -64,6 +64,9 @@ GEM
erubis (2.7.0) erubis (2.7.0)
execjs (1.2.9) execjs (1.2.9)
multi_json (~> 1.0) multi_json (~> 1.0)
formtastic (2.0.2)
rails (~> 3.0)
haml (3.1.3)
hike (1.2.1) hike (1.2.1)
hpricot (0.8.4) hpricot (0.8.4)
i18n (0.6.0) i18n (0.6.0)
@ -164,6 +167,8 @@ DEPENDENCIES
coffee-rails (~> 3.1.0) coffee-rails (~> 3.1.0)
devise devise
exception_notification! exception_notification!
formtastic
haml
hpricot hpricot
jquery-rails jquery-rails
mini_exiftool mini_exiftool

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.0 KiB

After

Width:  |  Height:  |  Size: 3.9 KiB

View File

@ -6,4 +6,5 @@
// //
//= require jquery //= require jquery
//= require jquery_ujs //= require jquery_ujs
//= require fancybox
//= require_directory ./admin //= require_directory ./admin

View File

@ -0,0 +1,2 @@
$ ->
$(".photos .photo a").not(".actions a").fancybox()

View File

@ -4,5 +4,6 @@
* the top of the compiled file, but it's generally better to create a new file per style scope. * the top of the compiled file, but it's generally better to create a new file per style scope.
*= require_self *= require_self
*= require formtastic *= require formtastic
*= require fancybox
*= require_directory ./admin *= require_directory ./admin
*/ */

View File

@ -109,6 +109,9 @@ table
background: #ddd !important background: #ddd !important
border-bottom: 0 border-bottom: 0
.pagination
margin: 0.5em 0
#error_explanation #error_explanation
width: 450px width: 450px
border: 2px solid red border: 2px solid red

View File

@ -50,6 +50,13 @@ form.formtastic
-webkit-appearance: none -webkit-appearance: none
margin: 0 margin: 0
.fragments
.label label
width: 13em
.fragments-group
padding-left: 14em
input[type=submit], a.button input[type=submit], a.button
@include button @include button
&[name=commit] &[name=commit]
@ -61,6 +68,11 @@ form.formtastic
&:hover, &:focus &:hover, &:focus
background-color: #8B6 background-color: #8B6
.boolean
label
padding-left: 14em
text-align: left
.error input .error input
border-width: 1px border-width: 1px
border-style: solid border-style: solid

View File

@ -0,0 +1,21 @@
@import "../includes/round_corners"
@import "../includes/box_shadow"
.photos
.photo
float: left
margin-right: 1em
margin-top: 1em
&:after
content: ""
display: block
clear: both
ul.categories
border: 1px solid #ccc
@include round-corners(3px)
@include box-shadow("inset 2px 2px 4px rgba(0, 0, 0, 0.1)")
margin-top: 1em
padding: 1em
width: 25%
float: right

View File

@ -1,10 +1,13 @@
@import "includes/box_shadow" @import "includes/box_shadow"
html
-webkit-text-size-adjust: 100%
body body
background: #101010 background: #101010
color: white color: white
font-family: "Helvetica Neue", "Arial", "Helvatica", sans-serif font-family: freight-sans-pro, "Helvetica Neue", "Arial", sans-serif
font-size: 14px font-size: 100%
overflow: hidden overflow: hidden
a a
@ -151,7 +154,7 @@ p a
text-align: right text-align: right
margin: 0 20px margin: 0 20px
font-weight: normal font-weight: normal
font-size: 1.1em font-size: 1em
line-height: 1em line-height: 1em
img img
@ -183,9 +186,9 @@ img
color: #ccc color: #ccc
overflow: auto overflow: auto
div div
padding: 15px 20px padding: 2px 12px
p p
margin-bottom: 0.6em margin-top: 0.6em
line-height: 1.35em line-height: 1.35em
/* FORM /* FORM
@ -206,6 +209,7 @@ form
display: block display: block
width: 75px width: 75px
float: left float: left
margin-top: 6px
&.error &.error
float: none float: none
display: inline display: inline
@ -214,9 +218,9 @@ form
textarea textarea
height: 150px height: 150px
width: 335px width: 335px
font-family: "Helvetica Neue","Arial","Helvatica",sans-serif font-family: freight-sans-pro, "Helvetica Neue", "Arial", sans-serif
font-size: 14px font-size: 1em
padding: 3px padding: 5px
color: #333 color: #333
border: 2px solid #999 border: 2px solid #999
-moz-border-radius: 3px -moz-border-radius: 3px
@ -224,9 +228,9 @@ form
border-radius: 3px border-radius: 3px
input input
&[type='text'] &[type='text']
font-family: "Helvetica Neue","Arial","Helvatica",sans-serif font-family: freight-sans-pro, "Helvetica Neue", "Arial", sans-serif
font-size: 14px font-size: 1em
padding: 3px padding: 5px
color: #333 color: #333
border: 2px solid #999 border: 2px solid #999
-moz-border-radius: 3px -moz-border-radius: 3px
@ -266,9 +270,9 @@ input.error, textarea.error
form input[type='submit'] form input[type='submit']
background: #666 background: #666
font-family: "Helvetica Neue","Arial","Helvatica",sans-serif font-family: freight-sans-pro, "Helvetica Neue", "Arial", sans-serif
font-size: 14px font-size: 1em
padding: 3px padding: 3px 8px
color: white color: white
border: 2px solid #333 border: 2px solid #333
-moz-border-radius: 3px -moz-border-radius: 3px

View File

@ -5,6 +5,9 @@ class Admin::AdminController < ApplicationController
def admin_menu def admin_menu
@admin_menu = { :dashboard => '', @admin_menu = { :dashboard => '',
:admin_users => '' } :admin_users => '',
:categories => '',
:photos => '',
:pages => '' }
end end
end end

View File

@ -1,2 +1,53 @@
class Admin::CategoriesController < Admin::ResourcesController class Admin::CategoriesController < Admin::AdminController
def index
@categories = Category.all
end
def new
@category = Category.new
end
def edit
@category = Category.find(params[:id])
end
def update
@category = Category.find(params[:id])
respond_to do |format|
if @category.update_attributes(params[:category])
format.html { redirect_to(admin_categories_path, :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
def create
@category = Category.new(params[:category])
respond_to do |format|
if @category.save
format.html { redirect_to(admin_categories_path, :notice => 'Category was successfully added.') }
format.xml { head :ok }
else
format.html { render :action => "edit" }
format.xml { render :xml => @category.errors, :status => :unprocessable_entity }
end
end
end
def destroy
@category = Category.find(params[:id])
@category.destroy
respond_to do |format|
format.html { redirect_to(admin_categories_path, :notice => 'Category was deleted.') }
format.xml { head :ok }
end
end
end end

View File

@ -1,2 +1,53 @@
class Admin::PagesController < Admin::ResourcesController class Admin::PagesController < Admin::AdminController
def index
@pages = Page.all
end
def new
@page = Page.new
end
def edit
@page = Page.find(params[:id])
end
def update
@page = Page.find(params[:id])
respond_to do |format|
if @page.update_attributes(params[:page])
format.html { redirect_to(admin_pages_path, :notice => 'Page was successfully updated.') }
format.xml { head :ok }
else
format.html { render :action => "edit" }
format.xml { render :xml => @page.errors, :status => :unprocessable_entity }
end
end
end
def create
@page = Page.new(params[:page])
respond_to do |format|
if @page.save
format.html { redirect_to(admin_pages_path, :notice => 'Page was successfully added.') }
format.xml { head :ok }
else
format.html { render :action => "edit" }
format.xml { render :xml => @page.errors, :status => :unprocessable_entity }
end
end
end
def destroy
@page = Page.find(params[:id])
@page.destroy
respond_to do |format|
format.html { redirect_to(admin_pages_path, :notice => 'Page was deleted.') }
format.xml { head :ok }
end
end
end end

View File

@ -1,2 +1,60 @@
class Admin::PhotosController < Admin::ResourcesController class Admin::PhotosController < Admin::AdminController
before_filter :get_categories
def index
@photos = Photo.paginate(:page => params[:page])
end
def new
@photo = Photo.new
end
def edit
@photo = Photo.find(params[:id])
end
def update
@photo = Photo.find(params[:id])
respond_to do |format|
if @photo.update_attributes(params[:photo])
format.html { redirect_to(admin_photos_path, :notice => 'Photo was successfully updated.') }
format.xml { head :ok }
else
format.html { render :action => "edit" }
format.xml { render :xml => @photo.errors, :status => :unprocessable_entity }
end
end
end
def create
@photo = Photo.new(params[:photo])
respond_to do |format|
if @photo.save
format.html { redirect_to(admin_photos_path, :notice => 'Photo was successfully added.') }
format.xml { head :ok }
else
format.html { render :action => "edit" }
format.xml { render :xml => @photo.errors, :status => :unprocessable_entity }
end
end
end
def destroy
@photo = Photo.find(params[:id])
@photo.destroy
respond_to do |format|
format.html { redirect_to(admin_photos_path, :notice => 'Photo was deleted.') }
format.xml { head :ok }
end
end
private
def get_categories
@categories = Category.all
end
end end

View File

@ -0,0 +1,7 @@
%tr
%td= category.name
%td= category.base_colour
%td{ :class => :actions }
= link_to 'Show', [:admin, category]
= link_to 'Edit', edit_admin_category_path(category)
= link_to 'Destroy', [:admin, category], confirm: 'Are you sure?', method: :delete

View File

@ -0,0 +1,3 @@
= semantic_form_for [:admin, category] do |f|
= f.inputs :name, :description, :base_colour, :sort
= f.buttons

View File

@ -0,0 +1,2 @@
%h2 Edit Category
= render :partial => "form", :locals => { :category => @category }

View File

@ -0,0 +1,15 @@
%h2 Categories
%table
%thead
%tr
%th Name
%th Base Colour
%th
%tbody
= render :partial => "category", :collection => @categories
%tfoot
%tr
%td{:colspan => 4}
%br/
= link_to 'New Category', new_admin_category_path, :class => [:button, :new]

View File

@ -0,0 +1,2 @@
%h2 New Category
= render :partial => "form", :locals => { :category => @category }

View File

@ -0,0 +1,3 @@
= semantic_form_for [:admin, page] do |f|
= f.inputs :name, :title, :content
= f.buttons

View File

@ -0,0 +1,7 @@
%tr
%td= page.name
%td= page.title
%td{ :class => :actions }
= link_to 'Show', [:admin, page]
= link_to 'Edit', edit_admin_page_path(page)
= link_to 'Destroy', [:admin, page], confirm: 'Are you sure?', method: :delete

View File

@ -0,0 +1,2 @@
%h2 Edit Page
= render :partial => "form", :locals => { :page => @page }

View File

@ -0,0 +1,15 @@
%h2 Pages
%table
%thead
%tr
%th Name
%th Title
%th
%tbody
= render :partial => "page", :collection => @pages
%tfoot
%tr
%td{:colspan => 4}
%br/
= link_to 'New Category', new_admin_page_path, :class => [:button, :new]

View File

@ -0,0 +1,2 @@
%h2 New Page
= render :partial => "form", :locals => { :page => @page }

View File

@ -0,0 +1,8 @@
= semantic_form_for [:admin, photo] do |f|
%ul.categories
- @categories.each do |photo_category|
%li
= check_box_tag "photo[category_ids][]", photo_category.id, @photo.categories.include?(photo_category), :id => "photo_category_ids_#{photo_category.id}"
= label_tag "photo_category_ids_#{photo_category.id}", photo_category.name
= f.inputs :photo, :title, :description, :flickr_url, :featured, :enabled, :taken_at
= f.buttons

View File

@ -0,0 +1,6 @@
.photo
= link_to image_tag(photo.photo.url(:size5), :title => photo.title), photo.photo.url
.actions
= link_to 'Show', [:admin, photo]
= link_to 'Edit', edit_admin_photo_path(photo)
= link_to 'Destroy', [:admin, photo], confirm: 'Are you sure?', method: :delete

View File

@ -0,0 +1,2 @@
%h2 Edit Photo
= render :partial => "form", :locals => { :photo => @photo }

View File

@ -0,0 +1,11 @@
%h2 Photos
= will_paginate @photos, :remote => true
.photos
= render :partial => "photo", :collection => @photos
= will_paginate @products, :remote => true
%br/
= link_to 'New Photo', new_admin_photo_path, :class => [:button, :new]

View File

@ -0,0 +1,2 @@
%h2 New Photo
= render :partial => "form", :locals => { :photo => @photo }

View File

@ -12,6 +12,7 @@
<%= stylesheet_link_tag "fancybox", :media => "all" %> <%= stylesheet_link_tag "fancybox", :media => "all" %>
<%= stylesheet_link_tag "scrollbars", :media => "screen" %> <%= stylesheet_link_tag "scrollbars", :media => "screen" %>
<%= javascript_include_tag 'application' %> <%= javascript_include_tag 'application' %>
<%= render :partial => "shared/typekit" %>
</head> </head>
<body> <body>

View File

@ -0,0 +1,3 @@
= javascript_include_tag "http://use.typekit.com/bvi1xdc.js"
:javascript
try{Typekit.load();}catch(e){}

View File

@ -22,6 +22,9 @@ DanBarberPhoto::Application.routes.draw do
put :update_password put :update_password
end end
end end
resources :categories
resources :photos
resources :pages
end end
# The priority is based upon order of creation: # The priority is based upon order of creation:

View File

@ -0,0 +1,20 @@
class RemoveAdminUsers < ActiveRecord::Migration
def self.up
drop_table :admin_users
end
def self.down
create_table :admin_users do |t|
t.string :first_name, :default => "", :null => false
t.string :last_name, :default => "", :null => false
t.string :role, :null => false
t.string :email, :null => false
t.boolean :status, :default => false
t.string :token, :null => false
t.string :salt, :null => false
t.string :crypted_password, :null => false
t.string :preferences
t.timestamps
end
end
end

View File

@ -0,0 +1,27 @@
class CreateDeviseAdminUsers < ActiveRecord::Migration
def up
create_table(:admin_users) do |t|
t.database_authenticatable :null => false
t.recoverable
t.rememberable
t.trackable
# t.encryptable
t.confirmable
t.lockable :lock_strategy => :failed_attempts, :unlock_strategy => :both
# t.token_authenticatable
t.timestamps
end
add_index :admin_users, :email, :unique => true
add_index :admin_users, :reset_password_token, :unique => true
add_index :admin_users, :confirmation_token, :unique => true
add_index :admin_users, :unlock_token, :unique => true
# add_index :admin_users, :authentication_token, :unique => true
end
def down
drop_table :admin_users
end
end

View File

@ -11,7 +11,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 => 20111013085444) do ActiveRecord::Schema.define(:version => 20111030164012) do
create_table "admin_users", :force => true do |t| create_table "admin_users", :force => true do |t|
t.string "email", :default => "", :null => false t.string "email", :default => "", :null => false
@ -34,6 +34,11 @@ ActiveRecord::Schema.define(:version => 20111013085444) do
t.datetime "updated_at" t.datetime "updated_at"
end end
add_index "admin_users", ["confirmation_token"], :name => "index_admin_users_on_confirmation_token", :unique => true
add_index "admin_users", ["email"], :name => "index_admin_users_on_email", :unique => true
add_index "admin_users", ["reset_password_token"], :name => "index_admin_users_on_reset_password_token", :unique => true
add_index "admin_users", ["unlock_token"], :name => "index_admin_users_on_unlock_token", :unique => true
create_table "categories", :force => true do |t| create_table "categories", :force => true do |t|
t.string "name" t.string "name"
t.text "description" t.text "description"
@ -74,4 +79,14 @@ ActiveRecord::Schema.define(:version => 20111013085444) do
t.integer "views", :default => 0 t.integer "views", :default => 0
end end
create_table "sessions", :force => true do |t|
t.string "session_id", :null => false
t.text "data"
t.datetime "created_at"
t.datetime "updated_at"
end
add_index "sessions", ["session_id"], :name => "index_sessions_on_session_id"
add_index "sessions", ["updated_at"], :name => "index_sessions_on_updated_at"
end end