Skip to content

Commit 878117a

Browse files
author
Stefano Verna
committed
First version
1 parent a9ef818 commit 878117a

File tree

13 files changed

+403
-0
lines changed

13 files changed

+403
-0
lines changed

Gemfile

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
source "http://rubygems.org"
2+
3+
# Declare your gem's dependencies in simple_form_fancy_uploads.gemspec.
4+
# Bundler will treat runtime dependencies like base dependencies, and
5+
# development dependencies will be added by default to the :development group.
6+
gemspec
7+
8+
group :development, :test do
9+
gem 'simplecov', require: false
10+
gem 'sqlite3'
11+
gem 'rspec-rails', '~> 2.8.1'
12+
gem 'webrat'
13+
end
14+

Gemfile.lock

Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
PATH
2+
remote: .
3+
specs:
4+
simple_form_fancy_uploads (0.0.2)
5+
carrierwave
6+
rails (~> 3.2.1)
7+
simple_form (~> 2.0.1)
8+
9+
GEM
10+
remote: http://rubygems.org/
11+
specs:
12+
actionmailer (3.2.1)
13+
actionpack (= 3.2.1)
14+
mail (~> 2.4.0)
15+
actionpack (3.2.1)
16+
activemodel (= 3.2.1)
17+
activesupport (= 3.2.1)
18+
builder (~> 3.0.0)
19+
erubis (~> 2.7.0)
20+
journey (~> 1.0.1)
21+
rack (~> 1.4.0)
22+
rack-cache (~> 1.1)
23+
rack-test (~> 0.6.1)
24+
sprockets (~> 2.1.2)
25+
activemodel (3.2.1)
26+
activesupport (= 3.2.1)
27+
builder (~> 3.0.0)
28+
activerecord (3.2.1)
29+
activemodel (= 3.2.1)
30+
activesupport (= 3.2.1)
31+
arel (~> 3.0.0)
32+
tzinfo (~> 0.3.29)
33+
activeresource (3.2.1)
34+
activemodel (= 3.2.1)
35+
activesupport (= 3.2.1)
36+
activesupport (3.2.1)
37+
i18n (~> 0.6)
38+
multi_json (~> 1.0)
39+
arel (3.0.2)
40+
builder (3.0.0)
41+
carrierwave (0.5.8)
42+
activesupport (~> 3.0)
43+
diff-lcs (1.1.3)
44+
erubis (2.7.0)
45+
hike (1.2.1)
46+
i18n (0.6.0)
47+
journey (1.0.1)
48+
json (1.6.5)
49+
mail (2.4.3)
50+
i18n (>= 0.4.0)
51+
mime-types (~> 1.16)
52+
treetop (~> 1.4.8)
53+
mime-types (1.17.2)
54+
multi_json (1.0.4)
55+
nokogiri (1.5.0)
56+
polyglot (0.3.3)
57+
rack (1.4.1)
58+
rack-cache (1.1)
59+
rack (>= 0.4)
60+
rack-ssl (1.3.2)
61+
rack
62+
rack-test (0.6.1)
63+
rack (>= 1.0)
64+
rails (3.2.1)
65+
actionmailer (= 3.2.1)
66+
actionpack (= 3.2.1)
67+
activerecord (= 3.2.1)
68+
activeresource (= 3.2.1)
69+
activesupport (= 3.2.1)
70+
bundler (~> 1.0)
71+
railties (= 3.2.1)
72+
railties (3.2.1)
73+
actionpack (= 3.2.1)
74+
activesupport (= 3.2.1)
75+
rack-ssl (~> 1.3.2)
76+
rake (>= 0.8.7)
77+
rdoc (~> 3.4)
78+
thor (~> 0.14.6)
79+
rake (0.9.2.2)
80+
rdoc (3.12)
81+
json (~> 1.4)
82+
rspec (2.8.0)
83+
rspec-core (~> 2.8.0)
84+
rspec-expectations (~> 2.8.0)
85+
rspec-mocks (~> 2.8.0)
86+
rspec-core (2.8.0)
87+
rspec-expectations (2.8.0)
88+
diff-lcs (~> 1.1.2)
89+
rspec-mocks (2.8.0)
90+
rspec-rails (2.8.1)
91+
actionpack (>= 3.0)
92+
activesupport (>= 3.0)
93+
railties (>= 3.0)
94+
rspec (~> 2.8.0)
95+
simple_form (2.0.1)
96+
actionpack (~> 3.0)
97+
activemodel (~> 3.0)
98+
simplecov (0.5.4)
99+
multi_json (~> 1.0.3)
100+
simplecov-html (~> 0.5.3)
101+
simplecov-html (0.5.3)
102+
sprockets (2.1.2)
103+
hike (~> 1.2)
104+
rack (~> 1.0)
105+
tilt (~> 1.1, != 1.3.0)
106+
sqlite3 (1.3.5)
107+
thor (0.14.6)
108+
tilt (1.3.3)
109+
treetop (1.4.10)
110+
polyglot
111+
polyglot (>= 0.3.1)
112+
tzinfo (0.3.32)
113+
webrat (0.7.3)
114+
nokogiri (>= 1.2.0)
115+
rack (>= 1.0)
116+
rack-test (>= 0.5.3)
117+
118+
PLATFORMS
119+
ruby
120+
121+
DEPENDENCIES
122+
rspec-rails (~> 2.8.1)
123+
simple_form_fancy_uploads!
124+
simplecov
125+
sqlite3
126+
webrat

MIT-LICENSE

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
Copyright (c) 2012 Andrea Pavoni http://andreapavoni.com
2+
3+
Permission is hereby granted, free of charge, to any person obtaining
4+
a copy of this software and associated documentation files (the
5+
"Software"), to deal in the Software without restriction, including
6+
without limitation the rights to use, copy, modify, merge, publish,
7+
distribute, sublicense, and/or sell copies of the Software, and to
8+
permit persons to whom the Software is furnished to do so, subject to
9+
the following conditions:
10+
11+
The above copyright notice and this permission notice shall be
12+
included in all copies or substantial portions of the Software.
13+
14+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

README.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
### Gemfile
2+
3+
```ruby
4+
gem 'activeadmin-dragonfly'
5+
```
6+
7+
### Model
8+
9+
```ruby
10+
class BlogPost < ActiveRecord::Base
11+
attr_accessible :image, :retained_image, :remove_image
12+
image_accessor :image
13+
end
14+
```
15+
16+
### Editor
17+
18+
```ruby
19+
ActiveAdmin.register BlogPost do
20+
form do |f|
21+
# ...
22+
f.input :image, as: :dragonfly
23+
f.input :image, as: :dragonfly, input_html: { components: [:preview, :upload, :url, :remove ] }
24+
# ...
25+
end
26+
end
27+
```

Rakefile

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#!/usr/bin/env rake
2+
begin
3+
require 'bundler/setup'
4+
rescue LoadError
5+
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
6+
end
7+
begin
8+
require 'rdoc/task'
9+
rescue LoadError
10+
require 'rdoc/rdoc'
11+
require 'rake/rdoctask'
12+
RDoc::Task = Rake::RDocTask
13+
end
14+
15+
RDoc::Task.new(:rdoc) do |rdoc|
16+
rdoc.rdoc_dir = 'rdoc'
17+
rdoc.title = 'SimpleFormDragonfly'
18+
rdoc.options << '--line-numbers'
19+
rdoc.rdoc_files.include('README.rdoc')
20+
rdoc.rdoc_files.include('lib/**/*.rb')
21+
end
22+
23+
Bundler::GemHelper.install_tasks
24+

activeadmin-dragonfly.gemspec

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
$:.push File.expand_path("../lib", __FILE__)
2+
3+
# Maintain your gem's version:
4+
require "active_admin/dragonfly/version"
5+
6+
# Describe your gem and declare its dependencies:
7+
Gem::Specification.new do |s|
8+
s.name = "activeadmin-dragonfly"
9+
s.version = ActiveAdmin::Dragonfly::VERSION
10+
s.authors = ["Stefano Verna"]
11+
s.email = ["stefano.verna@gmail.com"]
12+
s.homepage = "http://github.com/cantierecreativo/railsyard-dragonfly"
13+
s.summary = "Adds a new :dragonfly field type to ActiveAdmin"
14+
s.description = "Adds a new :dragonfly field type to ActiveAdmin"
15+
16+
s.files = Dir["{app,config,db,lib}/**/*"] + ["MIT-LICENSE", "Rakefile", "README.md"]
17+
18+
s.add_dependency "activeadmin"
19+
s.add_dependency "dragonfly"
20+
end
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
@import bourbon
2+
3+
div.input.dragonfly
4+
5+
.dragonfly-fields
6+
display: inline-block
7+
vertical-align: top
8+
position: relative
9+
width: 500px
10+
+clearfix
11+
12+
label
13+
width: auto
14+
15+
.dragonfly-field
16+
margin-bottom: 4px
17+
18+
.field-preview
19+
float: left
20+
width: 72px
21+
margin-right: 10px
22+
23+
.no-image
24+
text-align: center
25+
height: 72px
26+
display: table-cell
27+
vertical-align: middle
28+
color: #666
29+
text-shadow: rgba(white, 0.6) 0 1px 0
30+
font-size: 12px
31+
32+
.field-upload, .field-remove, .field-url
33+
float: right
34+
width: 500px - 72px - 10px

config/locales/en.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
en:
2+
formtastic:
3+
dragonfly:
4+
no_image: "No image present"
5+
upload: "Upload"
6+
url: "URL"
7+
remove: "Remove?"

config/locales/it.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
it:
2+
formtastic:
3+
dragonfly:
4+
no_image: "Nessuna immagine"
5+
upload: "Upload"
6+
url: "URL"
7+
remove: "Rimuovi?"
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
require 'dragonfly'
2+
3+
module ActiveAdmin
4+
module Dragonfly
5+
class Engine < ::Rails::Engine
6+
7+
initializer "Railsyard precompile hook" do |app|
8+
app.config.assets.precompile += [
9+
"active_admin/active_admin_dragonfly.js",
10+
"active_admin/active_admin_dragonfly.css"
11+
]
12+
end
13+
14+
config.to_prepare do
15+
ActiveAdmin.application.register_stylesheet "active_admin/active_admin_dragonfly.css", :media => :screen
16+
end
17+
18+
end
19+
end
20+
end

0 commit comments

Comments
 (0)