-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
universaL
committed
May 2, 2008
1 parent
45139d0
commit ff38962
Showing
72 changed files
with
9,060 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
class PicturesController < ApplicationController | ||
# GET /pictures | ||
def index | ||
@pictures = Picture.find(:all, :order => "id DESC", :conditions => "parent_id is NULL") | ||
end | ||
|
||
# GET /pictures/new | ||
def new | ||
@picture = Picture.new | ||
end | ||
|
||
def create | ||
@picture = Picture.new(params[:picture]) | ||
if @picture.save | ||
flash[:notice] = 'Picture was successfully created.' | ||
redirect_to pictures_url | ||
else | ||
render :action => :new | ||
end | ||
end | ||
|
||
# DELETE /pictures/1 | ||
def destroy | ||
@picture = Picture.find(params[:id]) | ||
@picture.destroy | ||
redirect_to(pictures_url) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
module PicturesHelper | ||
|
||
def pictures_to_trs(pictures, cols) | ||
html = "" | ||
i = 0 | ||
while i < pictures.length | ||
links = "<tr class=\"odd\">\n" | ||
html << "<tr>\n" | ||
i.upto i+cols-1 do |j| | ||
if picture = pictures[j] | ||
html << " <td>" | ||
html << link_to(image_tag(picture.public_filename(:thumb)), picture.public_filename) | ||
html << "</td>\n" | ||
links << " <td>" | ||
links << link_to('Delete', picture, :confirm => 'Are you sure?', :method => :delete) | ||
links << "</td>\n" | ||
else | ||
html << " <td></td>" | ||
links << " <td></td>" | ||
end | ||
end | ||
html << "</tr>\n" | ||
links << "</tr>\n" | ||
html << links | ||
i += cols | ||
end | ||
html | ||
end | ||
alias_method :p2trs, :pictures_to_trs | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
class Picture < ActiveRecord::Base | ||
has_attachment :content_type => :image, | ||
:storage => :file_system, | ||
:max_size => 2.megabytes, | ||
:thumbnails => { :thumb => '150x150>' } | ||
validates_as_attachment | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<!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><%= controller.controller_name %>: <%= controller.action_name %></title> | ||
<%= stylesheet_link_tag 'scaffold' %> | ||
<%- %w{active4d all_hallows_eve amy blackboard brilliance_black brilliance_dull cobalt dawn eiffel espresso_libre idle iplastic lazy mac_classic magicwb_amiga pastels_on_dark spacecadet sunburst twilight zenburnesque}.each do |theme| -%> | ||
<%= require_syntax_css theme%> | ||
<%- end -%> | ||
<%= javascript_include_tag :defaults %> | ||
</head> | ||
<body> | ||
|
||
<p style="color: green"><%= flash[:notice] %></p> | ||
<%= yield %> | ||
<table> | ||
<tfoot> | ||
<tr> | ||
<td><%= link_to_unless_current 'Pastes', pastes_path %></td> | ||
<td><%= link_to_unless_current 'Pictures', pictures_path %></td> | ||
</tr> | ||
</tfoot> | ||
</table> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<table> | ||
<thead> | ||
<tr> | ||
<th colspan="4"><h1>Pictures</h1></th> | ||
<th><%= link_to 'New picture', new_picture_path %></th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
<%= p2trs @pictures, 5 %> | ||
</tbody> | ||
</table> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<table> | ||
<thead> | ||
<tr> | ||
<th><h1>New Picture</h1></th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
<%- unless @picture.errors.empty? -%> | ||
<tr><td><%= error_messages_for :picture %></td></tr> | ||
<%- end -%> | ||
<tr> | ||
<td> | ||
<% form_for(:picture, :url => pictures_path, | ||
:html => { :multipart => true }) do |f| -%> | ||
<%= f.label :uploaded_data, "Upload A picture" %><br/> | ||
<%= f.file_field :uploaded_data %><br/> | ||
<%= submit_tag 'Create' %> | ||
<% end -%> | ||
</td> | ||
</tr> | ||
</tbody> | ||
</table> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
development: | ||
bucket_name: appname_development | ||
access_key_id: | ||
secret_access_key: | ||
|
||
test: | ||
bucket_name: appname_test | ||
access_key_id: | ||
secret_access_key: | ||
|
||
production: | ||
bucket_name: appname | ||
access_key_id: | ||
secret_access_key: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
class CreatePictures < ActiveRecord::Migration | ||
def self.up | ||
create_table :pictures do |t| | ||
t.column :parent_id, :integer | ||
t.column :content_type, :string | ||
t.column :filename, :string | ||
t.column :thumbnail, :string | ||
t.column :size, :integer | ||
t.column :width, :integer | ||
t.column :height, :integer | ||
t.timestamps | ||
end | ||
end | ||
|
||
def self.down | ||
drop_table :pictures | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Oops, something went wrong.