inline_forms 1.3.48 → 1.3.49
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +22 -6
- data/bin/inline_forms +35 -8
- data/lib/app/helpers/form_elements/image_field.rb +10 -6
- data/lib/inline_forms/version.rb +1 -1
- metadata +1 -1
data/README.rdoc
CHANGED
@@ -5,21 +5,37 @@ Inline Forms is almost a complete admin application. You can try it out easily.
|
|
5
5
|
= Usage
|
6
6
|
|
7
7
|
gem install inline_forms
|
8
|
-
|
9
|
-
|
8
|
+
|
9
|
+
If you want to just start a new app called MyApp:
|
10
|
+
|
11
|
+
inline_forms create MyApp
|
12
|
+
|
13
|
+
If you want to use mysql instead of sqlite as development database:
|
14
|
+
|
15
|
+
inline_forms create MyApp --database mysql
|
16
|
+
|
17
|
+
If you want to install the example application:
|
18
|
+
|
19
|
+
inline_forms create MyApp --example
|
20
|
+
|
21
|
+
You can install the example application manually if you like:
|
22
|
+
|
23
|
+
inline_forms create MyApp
|
24
|
+
cd MyApp
|
10
25
|
rails g inline_forms Picture name:string caption:string image:image_field description:text apartment:belongs_to _presentation:'#{name}'
|
11
26
|
rails generate uploader Image
|
12
27
|
rails g inline_forms Apartment name:string title:string description:text pictures:has_many pictures:associated _enabled:yes _presentation:'#{name}'
|
13
28
|
bundle exec rake db:migrate
|
14
29
|
rails s
|
15
30
|
|
16
|
-
point your browser to http://localhost:3000/apartments
|
31
|
+
Now point your browser to http://localhost:3000/apartments and make sure JavaScript is enabled.
|
32
|
+
|
33
|
+
== Disclaimer
|
17
34
|
|
18
|
-
It's work in progress.
|
35
|
+
It's work in progress. Until I learn to use git branch, new releases break as easy as Elijah Price's bones.
|
19
36
|
|
20
37
|
|
21
38
|
== Copyright
|
22
39
|
|
23
|
-
Copyright (c) 2011 Ace Suares. See LICENSE.txt for
|
24
|
-
further details.
|
40
|
+
Copyright (c) 2011-2012 Ace Suares. See LICENSE.txt for further details.
|
25
41
|
|
data/bin/inline_forms
CHANGED
@@ -32,17 +32,33 @@ module InlineForms
|
|
32
32
|
DATABASE_OPTIONS = %w(sqlite mysql)
|
33
33
|
method_option :database, :aliases => "-d", :default => DATABASE_OPTIONS.first, :banner => DATABASE_OPTIONS.join('|'), :desc => 'specify development database'
|
34
34
|
method_option :dry, :type => :boolean, :desc => 'dry run. Do not do most things. Only useful for development of inline_forms'
|
35
|
+
method_option :example, :type => :boolean, :desc => 'install the example app. incompatible with --dry and uses sqlite as development database'
|
35
36
|
|
36
37
|
def create(app_name)
|
37
38
|
|
38
|
-
def dry_run?
|
39
|
+
def self.dry_run?
|
39
40
|
options[:dry]
|
40
41
|
end
|
41
42
|
|
42
|
-
|
43
|
+
def self.install_example?
|
44
|
+
options[:example]
|
45
|
+
end
|
46
|
+
|
47
|
+
database = DATABASE_OPTIONS.include?(options[:database]) ? options[:database] : DATABASE_OPTIONS.first
|
48
|
+
|
49
|
+
if install_example? && dry_run?
|
50
|
+
say "--example and --dry-run can not be used together", :red
|
51
|
+
exit 1
|
52
|
+
end
|
53
|
+
|
54
|
+
if install_example? && (database != 'sqlite')
|
55
|
+
say "--example can only be used with an sqlite development database", :red
|
56
|
+
exit 1
|
57
|
+
end
|
43
58
|
|
44
59
|
say "This is a dry run. I hope you know what you are doing...", :red if dry_run?
|
45
|
-
|
60
|
+
|
61
|
+
say "Creating #{app_name} with inline_forms v#{VERSION} and development database #{database}...", :green
|
46
62
|
|
47
63
|
regex = /\A[0-9a-zA-Z][0-9a-zA-Z_-]+[0-9a-zA-Z]\Z/
|
48
64
|
if ! regex.match(app_name)
|
@@ -62,7 +78,7 @@ module InlineForms
|
|
62
78
|
say "- Creating and trusting .rvmrc..."
|
63
79
|
ruby_version = %x[rvm current]
|
64
80
|
create_file "#{app_name}/.rvmrc", "rvm use #{ruby_version.chop}@#{app_name} --create"
|
65
|
-
say ("- " + %x[cd #{app_name} && rvm rvmrc trust .rvmrc]).chop
|
81
|
+
say ("- " + %x[cd #{app_name} && rvm rvmrc trust .rvmrc]).chop
|
66
82
|
|
67
83
|
say "- Changing to '#{app_name}' with RVM..."
|
68
84
|
RVM.chdir(app_name) do
|
@@ -123,9 +139,9 @@ module InlineForms
|
|
123
139
|
say "- Running bundle..."
|
124
140
|
system "bundle install" unless dry_run?
|
125
141
|
|
126
|
-
say "- Database setup: creating config/database.yml with development database #{
|
142
|
+
say "- Database setup: creating config/database.yml with development database #{database}"
|
127
143
|
remove_file "#{app_name}/config/database.yml" # the one that 'rails new' created
|
128
|
-
if
|
144
|
+
if database == 'mysql'
|
129
145
|
create_file "#{app_name}/config/database.yml", <<-END_DATABASEYML.strip_heredoc_with_indent
|
130
146
|
development:
|
131
147
|
adapter: mysql2
|
@@ -271,8 +287,19 @@ module InlineForms
|
|
271
287
|
RVM.run 'git add .'
|
272
288
|
RVM.run 'git commit -a -m " * Initial"'
|
273
289
|
|
274
|
-
|
275
|
-
|
290
|
+
if install_example?
|
291
|
+
say "\nInstalling example application..."
|
292
|
+
RVM.run 'rails g inline_forms Picture name:string caption:string image:image_field description:text apartment:belongs_to _presentation:\'#{name}\''
|
293
|
+
RVM.run 'rails generate uploader Image'
|
294
|
+
RVM.run 'rails g inline_forms Apartment name:string title:string description:text pictures:has_many pictures:associated _enabled:yes _presentation:\'#{name}\''
|
295
|
+
RVM.run 'bundle exec rake db:migrate'
|
296
|
+
say "\nDone! Now point your browser to http://localhost:3000/apartments !", :yellow
|
297
|
+
say "\nPress ctlr-C to quit...", :yellow
|
298
|
+
RVM.run 'rails s'
|
299
|
+
else
|
300
|
+
say "\nDone! Now make your tables with 'rails g inline_forms ...", :yellow
|
301
|
+
#say "- Don't forget: edit .rvmrc, config/{routes.rb, deploy.rb}, .git/config, delete public/index.html\n"
|
302
|
+
end
|
276
303
|
|
277
304
|
end
|
278
305
|
end
|
@@ -2,12 +2,16 @@
|
|
2
2
|
InlineForms::SPECIAL_COLUMN_TYPES[:image_field]=:string
|
3
3
|
|
4
4
|
def image_field_show(object, attribute)
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
5
|
+
o = object.send(attribute)
|
6
|
+
msg = o.to_s
|
7
|
+
if o.send(:present?)
|
8
|
+
if o.respond_to? :palm
|
9
|
+
msg = image_tag(o.send(:palm).send(:url))
|
10
|
+
else
|
11
|
+
msg = image_tag(o.send(:url))
|
12
|
+
end
|
13
|
+
end
|
14
|
+
link_to_inline_edit object, attribute, msg
|
11
15
|
end
|
12
16
|
|
13
17
|
def image_field_edit(object, attribute)
|
data/lib/inline_forms/version.rb
CHANGED