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

Mostly finished, still got the contact for to do. Switched to mini_exiftool for exif reading and fixed problem with setting title and description on upload! Finished portfolio page.

This commit is contained in:
Dan Barber 2010-10-10 11:45:23 -04:00
parent 023a119160
commit f49870b61b
19 changed files with 6968 additions and 26 deletions

View File

@ -3,7 +3,11 @@ class CategoriesController < ApplicationController
# GET /categories
# GET /categories.xml
def index
@categories = Category.all
@categories = Category.paginate :all, :page => params[:page], :per_page => 4
@num_categories = @categories.count
@photos = Photo.all(:limit => 2, :order => 'RANDOM()')
respond_to do |format|
format.html # index.html.erb

View File

@ -0,0 +1,7 @@
class PagesController < ApplicationController
layout "photos"
def index
@photo = Photo.first(:order => 'RANDOM()')
end
end

View File

@ -13,6 +13,9 @@ class PhotosController < ApplicationController
@photos = Photo.paginate :all, :page => params[:page], :per_page => 11
@num_photos = @photos.count
end
respond_to do |format|
format.html
end
end
def create

View File

@ -0,0 +1,2 @@
module PagesHelper
end

View File

@ -1,9 +1,10 @@
require 'exifr'
require 'mini_exiftool'
class Photo < ActiveRecord::Base
has_and_belongs_to_many :categories
has_attached_file :photo, :styles => { :original => "1024x1024>",
:size17 => "476x476#",
:size11 => "308x308#",
:size8 => "224x224#",
:size5 => "140x140#",
@ -16,7 +17,9 @@ class Photo < ActiveRecord::Base
private
def get_exif
exif = EXIFR::JPEG.new(photo.queued_for_write[:original].path)
self.description = exif.image_description
exif = MiniExiftool.new photo.queued_for_write[:original].path
self.title = exif.title
self.description = exif.description
self.save
end
end

View File

@ -1,6 +1,26 @@
<div class="sg-5 page-links">
<% if @categories.previous_page -%>
<%= link_to '<div>&larr;</div>', { :page => @categories.previous_page }, :class => 'prev-link' %>
<% end %>
</div>
<div class="sg-5 page-links">
<% if @categories.next_page -%>
<%= link_to '<div>&rarr;</div>', { :page => @categories.next_page }, :class => 'next-link' %>
<% end %>
</div>
</div>
<% @num_blank = 4 - @num_categories -%>
<div class="sg-24 sgParent">
<% @photos.each do |photo| %>
<div class="sg-11 photo" style="background: url('<%= photo.photo.url(:size11) %>')">
<%= link_to '&nbsp;', photo.photo.url, :rel => 'photo', :class => 'fancy' %>
</div>
<% end %>
<% @categories.each do |category| %>
<div class="category sg-5" style="background: <%= category.base_colour %>">
@ -8,4 +28,19 @@
</div>
<% end %>
<% @num_blank.times do %>
<div class="sg-5 photo blank-photo">
</div>
<% end %>
<!--<div class="sg-5" style="background: #222;">
</div>
<div class="sg-5" style="background: #333;">
</div>
<div class="sg-5" style="background: #555;">
</div>
<div class="sg-5 contact">
<%= link_to '<div>contact</div>', :action => 'contact' %>
</div>-->
</div>

View File

@ -10,18 +10,28 @@
</head>
<body>
<div id="page">
<div id="wrapper">
<div id="container">
<div id="wrapper">
<div id="container">
<div class="sgParent sg-12">
<div class="sgParent sg-12">
<div id="header" class="sg-11"><h1><%= image_tag('title.png') %></h1></div>
<div id="header" class="sg-11">
<%= link_to '<h1>'+image_tag('title.png')+'</h1>', '/' %>
</div>
<%= yield %>
<%= yield %>
<div id="footer" class="sg-35">
<p>&copy;2010 dan barber</p>
</div>
</div>
</div>
</div>
</div>
</div>
</body>

View File

@ -0,0 +1,26 @@
<div class="sg-5 about">
</div>
<div class="sg-5 portfolio">
<%= link_to '<div>portfolio</div>', :controller => 'categories' %>
</div>
</div>
<div class="sg-24 sgParent">
<div class="sg-11 about" style="background: white;">
</div>
<div class="sg-11 about" style="background: url(/images/me.jpg);">
</div>
<div class="sg-5" style="background: #222;">
</div>
<div class="sg-5" style="background: #333;">
</div>
<div class="sg-5" style="background: #555;">
</div>
<div class="sg-5 contact">
<%= link_to '<div>contact</div>', :action => 'contact' %>
</div>
</div>

View File

@ -0,0 +1,18 @@
<div class="sg-5 about">
<%= link_to '<div>about</div>', :action => 'about' %>
</div>
<div class="sg-5 portfolio">
<%= link_to '<div>portfolio</div>', :controller => 'categories' %>
</div>
</div>
<div class="sg-17" style="background: url('<%= @photo.photo.url(:size17) %>')">
</div>
<div class="sg-5" style="background: #333;">
</div>
<div class="sg-5" style="background: #555;">
</div>
<div class="sg-5 contact">
<%= link_to '<div>contact</div>', :action => 'contact' %>
</div>

View File

@ -1,9 +1,9 @@
<div class="sg-5">
</div>
<div class="sg-5 page-links">
<% if @photos.previous_page -%>
<%= link_to '<div>&larr;</div>', { :page => @photos.previous_page }, :class => 'prev-link' %>
<% end %>
</div>
<div class="sg-5 page-links">
<% if @photos.next_page -%>
<%= link_to '<div>&rarr;</div>', { :page => @photos.next_page }, :class => 'next-link' %>
<% end %>

View File

@ -19,7 +19,7 @@ Rails::Initializer.run do |config|
# config.gem "hpricot", :version => '0.6', :source => "http://code.whytheluckystiff.net"
# config.gem "sqlite3-ruby", :lib => "sqlite3"
# config.gem "aws-s3", :lib => "aws/s3"
config.gem "exifr"
config.gem "mini_exiftool"
config.gem "will_paginate"
# Only load the plugins named here, in the order given (default is alphabetical).

View File

@ -42,6 +42,11 @@ ActionController::Routing::Routes.draw do |map|
map.resources :categories, :has_many => :photos
map.resources :photos
map.root :controller => "pages"
map.pages ':action', :controller => 'pages'
map.connect ':controller/:action/:id'
map.connect ':controller/:action/:id.:format'
end

Binary file not shown.

File diff suppressed because it is too large Load Diff

BIN
public/images/me.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 63 KiB

275
public/index.html_ Normal file
View File

@ -0,0 +1,275 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<title>Ruby on Rails: Welcome aboard</title>
<style type="text/css" media="screen">
body {
margin: 0;
margin-bottom: 25px;
padding: 0;
background-color: #f0f0f0;
font-family: "Lucida Grande", "Bitstream Vera Sans", "Verdana";
font-size: 13px;
color: #333;
}
h1 {
font-size: 28px;
color: #000;
}
a {color: #03c}
a:hover {
background-color: #03c;
color: white;
text-decoration: none;
}
#page {
background-color: #f0f0f0;
width: 750px;
margin: 0;
margin-left: auto;
margin-right: auto;
}
#content {
float: left;
background-color: white;
border: 3px solid #aaa;
border-top: none;
padding: 25px;
width: 500px;
}
#sidebar {
float: right;
width: 175px;
}
#footer {
clear: both;
}
#header, #about, #getting-started {
padding-left: 75px;
padding-right: 30px;
}
#header {
background-image: url("images/rails.png");
background-repeat: no-repeat;
background-position: top left;
height: 64px;
}
#header h1, #header h2 {margin: 0}
#header h2 {
color: #888;
font-weight: normal;
font-size: 16px;
}
#about h3 {
margin: 0;
margin-bottom: 10px;
font-size: 14px;
}
#about-content {
background-color: #ffd;
border: 1px solid #fc0;
margin-left: -11px;
}
#about-content table {
margin-top: 10px;
margin-bottom: 10px;
font-size: 11px;
border-collapse: collapse;
}
#about-content td {
padding: 10px;
padding-top: 3px;
padding-bottom: 3px;
}
#about-content td.name {color: #555}
#about-content td.value {color: #000}
#about-content.failure {
background-color: #fcc;
border: 1px solid #f00;
}
#about-content.failure p {
margin: 0;
padding: 10px;
}
#getting-started {
border-top: 1px solid #ccc;
margin-top: 25px;
padding-top: 15px;
}
#getting-started h1 {
margin: 0;
font-size: 20px;
}
#getting-started h2 {
margin: 0;
font-size: 14px;
font-weight: normal;
color: #333;
margin-bottom: 25px;
}
#getting-started ol {
margin-left: 0;
padding-left: 0;
}
#getting-started li {
font-size: 18px;
color: #888;
margin-bottom: 25px;
}
#getting-started li h2 {
margin: 0;
font-weight: normal;
font-size: 18px;
color: #333;
}
#getting-started li p {
color: #555;
font-size: 13px;
}
#search {
margin: 0;
padding-top: 10px;
padding-bottom: 10px;
font-size: 11px;
}
#search input {
font-size: 11px;
margin: 2px;
}
#search-text {width: 170px}
#sidebar ul {
margin-left: 0;
padding-left: 0;
}
#sidebar ul h3 {
margin-top: 25px;
font-size: 16px;
padding-bottom: 10px;
border-bottom: 1px solid #ccc;
}
#sidebar li {
list-style-type: none;
}
#sidebar ul.links li {
margin-bottom: 5px;
}
</style>
<script type="text/javascript" src="javascripts/prototype.js"></script>
<script type="text/javascript" src="javascripts/effects.js"></script>
<script type="text/javascript">
function about() {
if (Element.empty('about-content')) {
new Ajax.Updater('about-content', 'rails/info/properties', {
method: 'get',
onFailure: function() {Element.classNames('about-content').add('failure')},
onComplete: function() {new Effect.BlindDown('about-content', {duration: 0.25})}
});
} else {
new Effect[Element.visible('about-content') ?
'BlindUp' : 'BlindDown']('about-content', {duration: 0.25});
}
}
window.onload = function() {
$('search-text').value = '';
$('search').onsubmit = function() {
$('search-text').value = 'site:rubyonrails.org ' + $F('search-text');
}
}
</script>
</head>
<body>
<div id="page">
<div id="sidebar">
<ul id="sidebar-items">
<li>
<form id="search" action="http://www.google.com/search" method="get">
<input type="hidden" name="hl" value="en" />
<input type="text" id="search-text" name="q" value="site:rubyonrails.org " />
<input type="submit" value="Search" /> the Rails site
</form>
</li>
<li>
<h3>Join the community</h3>
<ul class="links">
<li><a href="http://www.rubyonrails.org/">Ruby on Rails</a></li>
<li><a href="http://weblog.rubyonrails.org/">Official weblog</a></li>
<li><a href="http://wiki.rubyonrails.org/">Wiki</a></li>
</ul>
</li>
<li>
<h3>Browse the documentation</h3>
<ul class="links">
<li><a href="http://api.rubyonrails.org/">Rails API</a></li>
<li><a href="http://stdlib.rubyonrails.org/">Ruby standard library</a></li>
<li><a href="http://corelib.rubyonrails.org/">Ruby core</a></li>
<li><a href="http://guides.rubyonrails.org/">Rails Guides</a></li>
</ul>
</li>
</ul>
</div>
<div id="content">
<div id="header">
<h1>Welcome aboard</h1>
<h2>You&rsquo;re riding Ruby on Rails!</h2>
</div>
<div id="about">
<h3><a href="rails/info/properties" onclick="about(); return false">About your application&rsquo;s environment</a></h3>
<div id="about-content" style="display: none"></div>
</div>
<div id="getting-started">
<h1>Getting started</h1>
<h2>Here&rsquo;s how to get rolling:</h2>
<ol>
<li>
<h2>Use <tt>script/generate</tt> to create your models and controllers</h2>
<p>To see all available options, run it without parameters.</p>
</li>
<li>
<h2>Set up a default route and remove or rename this file</h2>
<p>Routes are set up in config/routes.rb.</p>
</li>
<li>
<h2>Create your database</h2>
<p>Run <tt>rake db:migrate</tt> to create your database. If you're not using SQLite (the default), edit <tt>config/database.yml</tt> with your username and password.</p>
</li>
</ol>
</div>
</div>
<div id="footer">&nbsp;</div>
</div>
</body>
</html>

View File

@ -1,23 +1,38 @@
body {
background: black;
background: #101010;
color: white;
font-family: "Helvetica Neue", "Arial", "Helvatica", sans-serif;
font-size: 14px;
overflow: hidden;
}
a {
text-decoration: none;
}
#page {
position: absolute;
top: 40%;
margin-top: -230px;
width: 100%;
}
#container {
padding-top: 20px;
}
#wrapper {
background: black;
background: #101010;
}
#header {
position: relative;
background: #0082bf;
height: 308px;
}
#header a {
display: block;
height: 308px;
width: 308px;
}
#header a:hover {
background: rgba(255,255,255,0.1);
}
#header h1 {
padding: 0;
margin: 0;
@ -25,10 +40,27 @@ a {
bottom: 15px;
right: 20px;
}
#footer {
background: #333;
color: black;
text-align: right;
height: 28px;
}
#footer p {
margin: 0 10px;
}
.sg-5, .sg-7, .sg-11, .sg-17, .sg-35 {
-moz-border-radius: 2px;
-webkit-border-radius: 2px;
border-radius: 2px;
}
.sg-5 {
height: 140px;
}
.sg-5 a {
position: relative;
display: block;
color: white;
height: 140px;
width: 140px;
}
@ -36,9 +68,38 @@ a {
height: 196px;
}
.sg-7 a {
position: relative;
display: block;
color: white;
height: 196px;
width: 196px;
}
.sg-11 {
height: 308px;
}
.sg-17 {
height: 476px;
}
.about {
background-color: #99BF00;
}
.portfolio {
background-color: #C03232;
}
.contact {
background-color: #777;
}
.about a:focus, .portfolio a:focus, .contact a:focus {
background: rgba(255,255,255,0.1);
}
.about a:hover, .portfolio a:hover, .contact a:hover {
background: rgba(255,255,255,0.2);
}
.about a div, .portfolio a div, .contact a div {
position: absolute;
top: 10px;
right: 20px;
}
.category {
position: relative;
}
@ -49,7 +110,8 @@ a {
}
.category a .arrow {
position: absolute;
bottom: 10px;
font-size: 2em;
bottom: 20px;
left: 20px;
}
.category a:focus, .photo a:focus {
@ -75,23 +137,17 @@ a {
img {
}
.page-links {
background: #c03232;
background: #666;
}
.prev-link, .next-link {
color: white;
font-size: 2em;
position: relative;
display: block;
width: 70px !important;
}
.prev-link {
float: left;
}
.next-link {
float: right;
}
.prev-link div, .next-link div {
position: absolute;
bottom: 10px;
bottom: 15px;
}
.prev-link div {
left: 20px;

View File

@ -0,0 +1,8 @@
require 'test_helper'
class PagesControllerTest < ActionController::TestCase
# Replace this with your real tests.
test "the truth" do
assert true
end
end

View File

@ -0,0 +1,4 @@
require 'test_helper'
class PagesHelperTest < ActionView::TestCase
end