Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* support image upload by Fleximage.
- Loading branch information
Showing
168 changed files
with
17,748 additions
and
3 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
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,88 @@ | ||
class ImagesController < ApplicationController | ||
# GET /images | ||
# GET /images.xml | ||
def index | ||
@images = Image.find(:all) | ||
|
||
respond_to do |format| | ||
format.html # index.html.erb | ||
format.xml { render :xml => @images } | ||
end | ||
end | ||
|
||
# GET /images/1 | ||
# GET /images/1.xml | ||
def show | ||
@image = Image.find(params[:id]) | ||
|
||
respond_to do |format| | ||
format.html # show.html.erb | ||
format.xml { render :xml => @image } | ||
format.png | ||
format.jpg | ||
format.gif | ||
end | ||
end | ||
|
||
# GET /images/new | ||
# GET /images/new.xml | ||
def new | ||
@image = Image.new | ||
|
||
respond_to do |format| | ||
format.html # new.html.erb | ||
format.xml { render :xml => @image } | ||
end | ||
end | ||
|
||
# GET /images/1/edit | ||
def edit | ||
@image = Image.find(params[:id]) | ||
end | ||
|
||
# POST /images | ||
# POST /images.xml | ||
def create | ||
@image = Image.new(params[:image]) | ||
|
||
respond_to do |format| | ||
if @image.save | ||
flash[:notice] = 'Image was successfully created.' | ||
format.html { redirect_to(@image) } | ||
format.xml { render :xml => @image, :status => :created, :location => @image } | ||
else | ||
format.html { render :action => "new" } | ||
format.xml { render :xml => @image.errors, :status => :unprocessable_entity } | ||
end | ||
end | ||
end | ||
|
||
# PUT /images/1 | ||
# PUT /images/1.xml | ||
def update | ||
@image = Image.find(params[:id]) | ||
|
||
respond_to do |format| | ||
if @image.update_attributes(params[:image]) | ||
flash[:notice] = 'Image was successfully updated.' | ||
format.html { redirect_to(@image) } | ||
format.xml { head :ok } | ||
else | ||
format.html { render :action => "edit" } | ||
format.xml { render :xml => @image.errors, :status => :unprocessable_entity } | ||
end | ||
end | ||
end | ||
|
||
# DELETE /images/1 | ||
# DELETE /images/1.xml | ||
def destroy | ||
@image = Image.find(params[:id]) | ||
@image.destroy | ||
|
||
respond_to do |format| | ||
format.html { redirect_to(images_url) } | ||
format.xml { head :ok } | ||
end | ||
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,2 @@ | ||
module ImagesHelper | ||
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,15 @@ | ||
class Image < ActiveRecord::Base | ||
acts_as_fleximage :image_directory => File.join("images", "uploaded") | ||
|
||
def image_filename=(filename) | ||
self.filename = filename | ||
end | ||
|
||
def image_width=(width) | ||
self.width = width | ||
end | ||
|
||
def image_height=(height) | ||
self.height = height | ||
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
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,24 @@ | ||
<h1>Editing image</h1> | ||
|
||
<% form_for(@image) do |f| %> | ||
<%= f.error_messages %> | ||
|
||
<p> | ||
<%= f.label :filename %><br /> | ||
<%= f.text_field :filename %> | ||
</p> | ||
<p> | ||
<%= f.label :width %><br /> | ||
<%= f.text_field :width %> | ||
</p> | ||
<p> | ||
<%= f.label :height %><br /> | ||
<%= f.text_field :height %> | ||
</p> | ||
<p> | ||
<%= f.submit "Update" %> | ||
</p> | ||
<% end %> | ||
<%= link_to 'Show', @image %> | | ||
<%= link_to 'Back', images_path %> |
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,24 @@ | ||
<h1>Listing images</h1> | ||
|
||
<table> | ||
<tr> | ||
<th>Filename</th> | ||
<th>Width</th> | ||
<th>Height</th> | ||
</tr> | ||
|
||
<% for image in @images %> | ||
<tr> | ||
<td><%=h image.filename %></td> | ||
<td><%=h image.width %></td> | ||
<td><%=h image.height %></td> | ||
<td><%= link_to 'Show', image %></td> | ||
<td><%= link_to 'Edit', edit_image_path(image) %></td> | ||
<td><%= link_to 'Destroy', image, :confirm => 'Are you sure?', :method => :delete %></td> | ||
</tr> | ||
<% end %> | ||
</table> | ||
|
||
<br /> | ||
|
||
<%= link_to 'New image', new_image_path %> |
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,15 @@ | ||
<h1>New image</h1> | ||
|
||
<% form_for(@image, :html => {:multipart => true}) do |f| %> | ||
<%= f.error_messages %> | ||
|
||
<p> | ||
<%= f.file_field :image_file %><br /> | ||
or URL: <%= f.text_field :image_file_url %> | ||
</p> | ||
<p> | ||
<%= f.submit "Create" %> | ||
</p> | ||
<% end %> | ||
<%= link_to 'Back', images_path %> |
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,3 @@ | ||
@image.operate do |image| | ||
image.resize '320x240' | ||
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,23 @@ | ||
<p> | ||
<b>Image:</b> | ||
<%= image_tag(image_path(@image, :format => :png)) %> | ||
</p> | ||
|
||
<p> | ||
<b>Filename:</b> | ||
<%=h @image.filename %> | ||
</p> | ||
|
||
<p> | ||
<b>Width:</b> | ||
<%=h @image.width %> | ||
</p> | ||
|
||
<p> | ||
<b>Height:</b> | ||
<%=h @image.height %> | ||
</p> | ||
|
||
|
||
<%= link_to 'Edit', edit_image_path(@image) %> | | ||
<%= link_to 'Back', images_path %> |
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,3 @@ | ||
@image.operate do |image| | ||
image.resize '320x240' | ||
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,3 @@ | ||
@image.operate do |image| | ||
image.resize '320x240' | ||
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,17 @@ | ||
<!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>Images: <%= controller.action_name %></title> | ||
<%= stylesheet_link_tag('base') %> | ||
</head> | ||
<body> | ||
|
||
<p style="color: green"><%= flash[:notice] %></p> | ||
|
||
<%= yield %> | ||
|
||
</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
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,15 @@ | ||
class CreateImages < ActiveRecord::Migration | ||
def self.up | ||
create_table :images do |t| | ||
t.string :filename | ||
t.integer :width | ||
t.integer :height | ||
|
||
t.timestamps | ||
end | ||
end | ||
|
||
def self.down | ||
drop_table :images | ||
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 @@ | ||
/uploaded |
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 @@ | ||
# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html | ||
|
||
one: | ||
filename: MyString | ||
width: 1 | ||
height: | ||
|
||
two: | ||
filename: MyString | ||
width: 1 | ||
height: |
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,45 @@ | ||
require 'test_helper' | ||
|
||
class ImagesControllerTest < ActionController::TestCase | ||
test "should get index" do | ||
get :index | ||
assert_response :success | ||
assert_not_nil assigns(:images) | ||
end | ||
|
||
test "should get new" do | ||
get :new | ||
assert_response :success | ||
end | ||
|
||
test "should create image" do | ||
assert_difference('Image.count') do | ||
post :create, :image => { } | ||
end | ||
|
||
assert_redirected_to image_path(assigns(:image)) | ||
end | ||
|
||
test "should show image" do | ||
get :show, :id => images(:one).id | ||
assert_response :success | ||
end | ||
|
||
test "should get edit" do | ||
get :edit, :id => images(:one).id | ||
assert_response :success | ||
end | ||
|
||
test "should update image" do | ||
put :update, :id => images(:one).id, :image => { } | ||
assert_redirected_to image_path(assigns(:image)) | ||
end | ||
|
||
test "should destroy image" do | ||
assert_difference('Image.count', -1) do | ||
delete :destroy, :id => images(:one).id | ||
end | ||
|
||
assert_redirected_to images_path | ||
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,8 @@ | ||
require 'test_helper' | ||
|
||
class ImageTest < ActiveSupport::TestCase | ||
# Replace this with your real tests. | ||
test "the truth" do | ||
assert true | ||
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,5 @@ | ||
test/rails_root/log/* | ||
test/rails_root/public/uploads/* | ||
test/rails_root/tmp/**/* | ||
.DS_Store | ||
*.sqlite3 |
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,20 @@ | ||
Copyright (c) 2008 [name of plugin creator] | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining | ||
a copy of this software and associated documentation files (the | ||
"Software"), to deal in the Software without restriction, including | ||
without limitation the rights to use, copy, modify, merge, publish, | ||
distribute, sublicense, and/or sell copies of the Software, and to | ||
permit persons to whom the Software is furnished to do so, subject to | ||
the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be | ||
included in all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | ||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE | ||
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION | ||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION | ||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
Oops, something went wrong.