Skip to content

Commit

Permalink
Crop image
Browse files Browse the repository at this point in the history
  • Loading branch information
strikeroff committed Sep 28, 2009
1 parent 0ace8ac commit b3770a7
Show file tree
Hide file tree
Showing 6 changed files with 107 additions and 0 deletions.
2 changes: 2 additions & 0 deletions app/models/product.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
class Product < ActiveRecord::Base
end
42 changes: 42 additions & 0 deletions app/views/upload_images/show.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<div style="padding-top:100px;padding-left:100px;">
<%= image_tag @inplace_image.data :default %>

<div>
<%= link_to "Кропать?", test_crop_image_url(@inplace_image) %>
</div>
<div style="padding-top:100px;">
Перезагрузить фотку
<% form_for @inplace_image, :inplace_image, :url=> reupload_image_url(:id=>@inplace_image.id), :html=>{:multipart=>true} do |form| %>
<div>
<%= form.error_messages %>
</div>
<div>
Укажите alias
</div>
<div>

<input type="text" name="alias" value="<%= @inplace_image.alias %>">
</div>

<!--<div>-->
<!--Укажите тип геометрии(например mainpage)-->
<!--</div>-->

<!--<div>-->
<!--<%= form.text_field :geometry_type %>-->
<!--</div>-->

<div>
Выберете картинку
</div>
<div>
<%= form.file_field :data %>
</div>
<div style="padding-top:20px;">
<%= submit_tag "Сохранить файл" %>
</div>
<% end %>

</div>
</div>

29 changes: 29 additions & 0 deletions app/views/upload_images/test_crop.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<div style="padding-top:100px;padding-left:50px; padding-bottom:100px;">
<%= image_tag @inplace_image.data :original %>


<div style="padding-top:100px;">

<% form_for @inplace_image, :inplace_image, :url=> crop_image_url(:id=>@inplace_image.id) do |form| %>
<div>
<%= form.error_messages %>
</div>
<div>
ВВедите конфигурацию
<input type="text" name="inplace_image[crop_geometry]" value="[100,100,80,80]">
</div>

<div>
sub_type_name - (например default)
<input type="text" name="inplace_image[sub_type_name]" value="">
</div>


<div style="padding-top:20px;">
<%= submit_tag "Кропить" %>
</div>
<% end %>

</div>
</div>

15 changes: 15 additions & 0 deletions db/migrate/20090928094528_create_products.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
class CreateProducts < ActiveRecord::Migration
def self.up
create_table :products do |t|
t.string :name
t.text :description
t.integer :inplace_image_id

t.timestamps
end
end

def self.down
drop_table :products
end
end
11 changes: 11 additions & 0 deletions test/fixtures/products.yml
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:
name: MyString
description: MyText
inplace_image_id: 1

two:
name: MyString
description: MyText
inplace_image_id: 1
8 changes: 8 additions & 0 deletions test/unit/product_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
require 'test_helper'

class ProductTest < ActiveSupport::TestCase
# Replace this with your real tests.
test "the truth" do
assert true
end
end

0 comments on commit b3770a7

Please sign in to comment.