active_i18n 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/MIT-LICENSE +20 -0
- data/README.md +105 -0
- data/Rakefile +35 -0
- data/app/assets/images/active_i18n/flags.png +0 -0
- data/app/assets/javascripts/active_i18n.js +1 -0
- data/app/assets/javascripts/active_i18n/layout.js.coffee +31 -0
- data/app/assets/stylesheets/active_i18n.css.sass +5 -0
- data/app/assets/stylesheets/active_i18n/application.css +13 -0
- data/app/assets/stylesheets/active_i18n/flags.css.scss +258 -0
- data/app/assets/stylesheets/active_i18n/list.css.sass +70 -0
- data/app/assets/stylesheets/active_i18n/sidebar.css.sass +60 -0
- data/app/assets/stylesheets/active_i18n/structure.css.sass +4 -0
- data/app/controllers/active_i18n/application_controller.rb +4 -0
- data/app/helpers/active_i18n/view_helper.rb +66 -0
- data/app/views/active_i18n/_content.html.haml +36 -0
- data/app/views/active_i18n/_sidebar.html.haml +5 -0
- data/app/views/layouts/active_i18n/application.html.erb +14 -0
- data/config/locales/en.yml +76 -0
- data/config/routes.rb +2 -0
- data/lib/active_i18n.rb +32 -0
- data/lib/active_i18n/active_admin.rb +28 -0
- data/lib/active_i18n/base_store.rb +42 -0
- data/lib/active_i18n/engine.rb +18 -0
- data/lib/active_i18n/translations_store.rb +26 -0
- data/lib/active_i18n/version.rb +3 -0
- data/lib/tasks/active_i18n_tasks.rake +4 -0
- data/spec/dummy/README.rdoc +261 -0
- data/spec/dummy/Rakefile +7 -0
- data/spec/dummy/app/admin/admin_users.rb +20 -0
- data/spec/dummy/app/admin/dashboard.rb +33 -0
- data/spec/dummy/app/admin/translation.rb +4 -0
- data/spec/dummy/app/assets/javascripts/active_admin.js +2 -0
- data/spec/dummy/app/assets/javascripts/application.js +15 -0
- data/spec/dummy/app/assets/stylesheets/active_admin.css.scss +32 -0
- data/spec/dummy/app/assets/stylesheets/application.css +13 -0
- data/spec/dummy/app/controllers/application_controller.rb +3 -0
- data/spec/dummy/app/helpers/application_helper.rb +2 -0
- data/spec/dummy/app/models/admin_user.rb +17 -0
- data/spec/dummy/app/views/layouts/application.html.erb +14 -0
- data/spec/dummy/config.ru +4 -0
- data/spec/dummy/config/application.rb +66 -0
- data/spec/dummy/config/boot.rb +10 -0
- data/spec/dummy/config/database.yml +25 -0
- data/spec/dummy/config/environment.rb +5 -0
- data/spec/dummy/config/environments/development.rb +37 -0
- data/spec/dummy/config/environments/production.rb +67 -0
- data/spec/dummy/config/environments/test.rb +37 -0
- data/spec/dummy/config/initializers/active_admin.rb +210 -0
- data/spec/dummy/config/initializers/active_i18n.rb +3 -0
- data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/dummy/config/initializers/devise.rb +256 -0
- data/spec/dummy/config/initializers/inflections.rb +15 -0
- data/spec/dummy/config/initializers/mime_types.rb +5 -0
- data/spec/dummy/config/initializers/secret_token.rb +7 -0
- data/spec/dummy/config/initializers/session_store.rb +8 -0
- data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/spec/dummy/config/locales/devise.en.yml +59 -0
- data/spec/dummy/config/locales/en.yml +5 -0
- data/spec/dummy/config/locales/en_test.yml +7 -0
- data/spec/dummy/config/locales/pl_test.yml +5 -0
- data/spec/dummy/config/routes.rb +7 -0
- data/spec/dummy/db/development.sqlite3 +0 -0
- data/spec/dummy/db/migrate/20140811102607_devise_create_admin_users.rb +48 -0
- data/spec/dummy/db/migrate/20140811102609_create_admin_notes.rb +17 -0
- data/spec/dummy/db/migrate/20140811102610_move_admin_notes_to_comments.rb +26 -0
- data/spec/dummy/db/schema.rb +49 -0
- data/spec/dummy/db/test.sqlite3 +0 -0
- data/spec/dummy/log/development.log +36840 -0
- data/spec/dummy/log/test.log +961 -0
- data/spec/dummy/public/404.html +26 -0
- data/spec/dummy/public/422.html +26 -0
- data/spec/dummy/public/500.html +25 -0
- data/spec/dummy/public/favicon.ico +0 -0
- data/spec/dummy/script/rails +6 -0
- data/spec/dummy/spec/factories/admin_users.rb +6 -0
- data/spec/dummy/spec/models/admin_user_spec.rb +5 -0
- data/spec/dummy/tmp/cache/assets/C58/410/sprockets%2F5c7886d2d5716b050cd38b9121769471 +0 -0
- data/spec/dummy/tmp/cache/assets/C7F/FE0/sprockets%2Fd8b50477b1b153638c7346534a0877da +0 -0
- data/spec/dummy/tmp/cache/assets/C8C/900/sprockets%2F1112043d14fe51296aa033bd024d0b78 +0 -0
- data/spec/dummy/tmp/cache/assets/C9A/D60/sprockets%2Fa62368179337c7154198e2786eeec9a8 +0 -0
- data/spec/dummy/tmp/cache/assets/CAD/C50/sprockets%2F8319a9f588005b0a424b90472c6a9a3f +0 -0
- data/spec/dummy/tmp/cache/assets/CAF/020/sprockets%2F9454bc172681345fa525aff08281b74c +0 -0
- data/spec/dummy/tmp/cache/assets/CB8/1D0/sprockets%2Fb510c0fc9803866436178e77582c7bad +0 -0
- data/spec/dummy/tmp/cache/assets/CBC/0B0/sprockets%2Fc0bba633769759659c7d4f0a2224499d +0 -0
- data/spec/dummy/tmp/cache/assets/CBF/620/sprockets%2F109dfac52e95799730667ba8e11e2765 +0 -0
- data/spec/dummy/tmp/cache/assets/CCD/670/sprockets%2F08edc1d5a073b0625304ba682985a24b +0 -0
- data/spec/dummy/tmp/cache/assets/CDB/040/sprockets%2Fc732474e67003a4eb840eb44c5ca9385 +0 -0
- data/spec/dummy/tmp/cache/assets/CDD/600/sprockets%2F65df7604a9339ce6a3d1923b472ee400 +0 -0
- data/spec/dummy/tmp/cache/assets/CE1/540/sprockets%2F305fa586dc7c7615d59e593120abf353 +0 -0
- data/spec/dummy/tmp/cache/assets/CEA/470/sprockets%2F8303f8f5f77c51100f64ff283ea6757a +0 -0
- data/spec/dummy/tmp/cache/assets/CEC/BA0/sprockets%2F7c5072074b471dff1cbf726f3786e548 +0 -0
- data/spec/dummy/tmp/cache/assets/D10/870/sprockets%2F5e7ab7f11ed7390a5ff8950121c40e49 +0 -0
- data/spec/dummy/tmp/cache/assets/D24/D10/sprockets%2Ff884c60f003f6ce75e3ef9f53891375a +0 -0
- data/spec/dummy/tmp/cache/assets/D28/200/sprockets%2Fb030b1c02160352cc756faec0ef883d5 +0 -0
- data/spec/dummy/tmp/cache/assets/D29/620/sprockets%2F3d664b0b71ca2fb901d77dce24215a32 +0 -0
- data/spec/dummy/tmp/cache/assets/D2D/2F0/sprockets%2Fd8ccd71f1767785f8489039e3d6c8a5b +0 -0
- data/spec/dummy/tmp/cache/assets/D33/CA0/sprockets%2F4dbc63d52f13068b8e72f3dd1107ba27 +0 -0
- data/spec/dummy/tmp/cache/assets/D36/2D0/sprockets%2Fcdfd2af48a61389a0dc7c751025504b7 +0 -0
- data/spec/dummy/tmp/cache/assets/D38/540/sprockets%2F86e1ad844bc9df4491a2a52b870421db +0 -0
- data/spec/dummy/tmp/cache/assets/D41/DE0/sprockets%2F9c89ee33751a67901a0ceead0d82781b +0 -0
- data/spec/dummy/tmp/cache/assets/D43/110/sprockets%2Fd5e364fe2e128443f5250e419af9bbc8 +0 -0
- data/spec/dummy/tmp/cache/assets/D44/3F0/sprockets%2F29e1206c858c89cf5453cf370dc2eca4 +0 -0
- data/spec/dummy/tmp/cache/assets/D45/110/sprockets%2F87892bd05e664b62bdbbc1e3704b67d9 +0 -0
- data/spec/dummy/tmp/cache/assets/D45/240/sprockets%2F5fa87c4a361e5f2866c52e12257c9ead +0 -0
- data/spec/dummy/tmp/cache/assets/D46/EB0/sprockets%2F663efa9a78c238c8a3aaf09a07d74627 +0 -0
- data/spec/dummy/tmp/cache/assets/D48/640/sprockets%2F9f4f18d910b678b1d0777e04cdaf6f24 +0 -0
- data/spec/dummy/tmp/cache/assets/D4B/C50/sprockets%2Ff28e143f4b4887e0f5e8cff05227c55b +0 -0
- data/spec/dummy/tmp/cache/assets/D59/D70/sprockets%2Fed9f0de1b65ae8d7ef89087c83728461 +0 -0
- data/spec/dummy/tmp/cache/assets/D60/F90/sprockets%2F85a232fb35c16bf87279047aa1ccbbb2 +0 -0
- data/spec/dummy/tmp/cache/assets/D62/770/sprockets%2F76a285eb6576ee1f11132bcd07f0eea0 +0 -0
- data/spec/dummy/tmp/cache/assets/D67/0C0/sprockets%2F09eed8ed6f341c0c429007ab0219ee7c +0 -0
- data/spec/dummy/tmp/cache/assets/D68/E10/sprockets%2F36d13da052a68af78a38a6dec93bd900 +0 -0
- data/spec/dummy/tmp/cache/assets/D6C/2F0/sprockets%2F107964995ee0c0bae0b46fdae574fa42 +0 -0
- data/spec/dummy/tmp/cache/assets/D6D/540/sprockets%2Fedbc4e34cd1e2cc70b7428678932aa92 +0 -0
- data/spec/dummy/tmp/cache/assets/D72/C80/sprockets%2Fa1430f4544581c9e76e56fcfdbe41c3e +0 -0
- data/spec/dummy/tmp/cache/assets/D7B/5F0/sprockets%2Fa4b788c26c44568cb71b3c79edc4b7f4 +0 -0
- data/spec/dummy/tmp/cache/assets/D8A/7E0/sprockets%2F2ce302007a5d81840ddc07b7cb1d5ffc +0 -0
- data/spec/dummy/tmp/cache/assets/D8F/670/sprockets%2F810ec022c6fe22bdec817bd7c0d808c1 +0 -0
- data/spec/dummy/tmp/cache/assets/D93/4C0/sprockets%2F857ecd2092cee11f740b3cf2e373ad2a +0 -0
- data/spec/dummy/tmp/cache/assets/D97/F90/sprockets%2Fc016a87d244c59a9a39ca8a90febe10b +0 -0
- data/spec/dummy/tmp/cache/assets/DA4/970/sprockets%2Fa93e382f3ec0e5b8cf765c062b946bcd +0 -0
- data/spec/dummy/tmp/cache/assets/DA8/D80/sprockets%2F0c96c0d9696bd756aad0d36bcf77db47 +0 -0
- data/spec/dummy/tmp/cache/assets/DBB/7C0/sprockets%2F00b6b9b17a4f12bae8eb17ef61abe731 +0 -0
- data/spec/dummy/tmp/cache/assets/DC7/A30/sprockets%2F5c6134fae4cb1a1dc4ae77cf661d42e9 +0 -0
- data/spec/dummy/tmp/cache/assets/DC9/A70/sprockets%2Fa0ca172bddf418f3ccd34a8e77725a8d +0 -0
- data/spec/dummy/tmp/cache/assets/DCE/840/sprockets%2F266fbe1ca258f3ccfec16753dafd4409 +0 -0
- data/spec/dummy/tmp/cache/assets/DDE/420/sprockets%2Ffb8b186d5bf0307f86f65fc787d2adeb +0 -0
- data/spec/dummy/tmp/cache/assets/DEE/CC0/sprockets%2Fa3dbe0de23a16d72f3abc3cd9388b80a +0 -0
- data/spec/dummy/tmp/cache/assets/DF1/BE0/sprockets%2Fcbdfaa7ea4d66d31e20da6754b4534dc +0 -0
- data/spec/dummy/tmp/cache/assets/DFA/E20/sprockets%2Ffe14bdb79b2a9dbf0b539198d3aba6b4 +0 -0
- data/spec/dummy/tmp/cache/assets/E27/B80/sprockets%2Fbced6cfc13bcfab45a1fa5b479d15486 +0 -0
- data/spec/dummy/tmp/cache/assets/E57/9A0/sprockets%2Fdf25986ad4babcf83acc6ac19e2a04fd +0 -0
- data/spec/lib/active_i18n_base_score_spec.rb +21 -0
- data/spec/lib/active_i18n_spec.rb +27 -0
- data/spec/lib/active_i18n_translations_store_spec.rb +34 -0
- data/spec/spec_helper.rb +15 -0
- metadata +471 -0
@@ -0,0 +1,18 @@
|
|
1
|
+
module ActiveI18n
|
2
|
+
class Engine < ::Rails::Engine
|
3
|
+
isolate_namespace ActiveI18n
|
4
|
+
|
5
|
+
initializer 'active_skin.action_controller' do |app|
|
6
|
+
ActiveSupport.on_load :action_controller do
|
7
|
+
helper ActiveI18n::ViewHelper
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
config.generators do |g|
|
12
|
+
g.test_framework :rspec, :fixture => false
|
13
|
+
g.fixture_replacement :factory_girl, :dir => 'spec/factories'
|
14
|
+
g.assets false
|
15
|
+
g.helper false
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module ActiveI18n
|
2
|
+
module TranslationsStore
|
3
|
+
extend(Module.new {
|
4
|
+
def set_backend(backend)
|
5
|
+
@backend = backend
|
6
|
+
end
|
7
|
+
|
8
|
+
def store_translation(value, scope, locale)
|
9
|
+
@backend.store_translations(locale, unflatten_scope(value, scope))
|
10
|
+
end
|
11
|
+
|
12
|
+
private
|
13
|
+
def unflatten_scope(value, scope)
|
14
|
+
strip_first(value, scope)
|
15
|
+
end
|
16
|
+
|
17
|
+
def strip_first(value, str)
|
18
|
+
a = str.split(".")
|
19
|
+
return value unless a.any?
|
20
|
+
hash = Hash.new
|
21
|
+
hash[a.shift] = strip_first(value, a.join("."))
|
22
|
+
hash
|
23
|
+
end
|
24
|
+
})
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,261 @@
|
|
1
|
+
== Welcome to Rails
|
2
|
+
|
3
|
+
Rails is a web-application framework that includes everything needed to create
|
4
|
+
database-backed web applications according to the Model-View-Control pattern.
|
5
|
+
|
6
|
+
This pattern splits the view (also called the presentation) into "dumb"
|
7
|
+
templates that are primarily responsible for inserting pre-built data in between
|
8
|
+
HTML tags. The model contains the "smart" domain objects (such as Account,
|
9
|
+
Product, Person, Post) that holds all the business logic and knows how to
|
10
|
+
persist themselves to a database. The controller handles the incoming requests
|
11
|
+
(such as Save New Account, Update Product, Show Post) by manipulating the model
|
12
|
+
and directing data to the view.
|
13
|
+
|
14
|
+
In Rails, the model is handled by what's called an object-relational mapping
|
15
|
+
layer entitled Active Record. This layer allows you to present the data from
|
16
|
+
database rows as objects and embellish these data objects with business logic
|
17
|
+
methods. You can read more about Active Record in
|
18
|
+
link:files/vendor/rails/activerecord/README.html.
|
19
|
+
|
20
|
+
The controller and view are handled by the Action Pack, which handles both
|
21
|
+
layers by its two parts: Action View and Action Controller. These two layers
|
22
|
+
are bundled in a single package due to their heavy interdependence. This is
|
23
|
+
unlike the relationship between the Active Record and Action Pack that is much
|
24
|
+
more separate. Each of these packages can be used independently outside of
|
25
|
+
Rails. You can read more about Action Pack in
|
26
|
+
link:files/vendor/rails/actionpack/README.html.
|
27
|
+
|
28
|
+
|
29
|
+
== Getting Started
|
30
|
+
|
31
|
+
1. At the command prompt, create a new Rails application:
|
32
|
+
<tt>rails new myapp</tt> (where <tt>myapp</tt> is the application name)
|
33
|
+
|
34
|
+
2. Change directory to <tt>myapp</tt> and start the web server:
|
35
|
+
<tt>cd myapp; rails server</tt> (run with --help for options)
|
36
|
+
|
37
|
+
3. Go to http://localhost:3000/ and you'll see:
|
38
|
+
"Welcome aboard: You're riding Ruby on Rails!"
|
39
|
+
|
40
|
+
4. Follow the guidelines to start developing your application. You can find
|
41
|
+
the following resources handy:
|
42
|
+
|
43
|
+
* The Getting Started Guide: http://guides.rubyonrails.org/getting_started.html
|
44
|
+
* Ruby on Rails Tutorial Book: http://www.railstutorial.org/
|
45
|
+
|
46
|
+
|
47
|
+
== Debugging Rails
|
48
|
+
|
49
|
+
Sometimes your application goes wrong. Fortunately there are a lot of tools that
|
50
|
+
will help you debug it and get it back on the rails.
|
51
|
+
|
52
|
+
First area to check is the application log files. Have "tail -f" commands
|
53
|
+
running on the server.log and development.log. Rails will automatically display
|
54
|
+
debugging and runtime information to these files. Debugging info will also be
|
55
|
+
shown in the browser on requests from 127.0.0.1.
|
56
|
+
|
57
|
+
You can also log your own messages directly into the log file from your code
|
58
|
+
using the Ruby logger class from inside your controllers. Example:
|
59
|
+
|
60
|
+
class WeblogController < ActionController::Base
|
61
|
+
def destroy
|
62
|
+
@weblog = Weblog.find(params[:id])
|
63
|
+
@weblog.destroy
|
64
|
+
logger.info("#{Time.now} Destroyed Weblog ID ##{@weblog.id}!")
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
The result will be a message in your log file along the lines of:
|
69
|
+
|
70
|
+
Mon Oct 08 14:22:29 +1000 2007 Destroyed Weblog ID #1!
|
71
|
+
|
72
|
+
More information on how to use the logger is at http://www.ruby-doc.org/core/
|
73
|
+
|
74
|
+
Also, Ruby documentation can be found at http://www.ruby-lang.org/. There are
|
75
|
+
several books available online as well:
|
76
|
+
|
77
|
+
* Programming Ruby: http://www.ruby-doc.org/docs/ProgrammingRuby/ (Pickaxe)
|
78
|
+
* Learn to Program: http://pine.fm/LearnToProgram/ (a beginners guide)
|
79
|
+
|
80
|
+
These two books will bring you up to speed on the Ruby language and also on
|
81
|
+
programming in general.
|
82
|
+
|
83
|
+
|
84
|
+
== Debugger
|
85
|
+
|
86
|
+
Debugger support is available through the debugger command when you start your
|
87
|
+
Mongrel or WEBrick server with --debugger. This means that you can break out of
|
88
|
+
execution at any point in the code, investigate and change the model, and then,
|
89
|
+
resume execution! You need to install ruby-debug to run the server in debugging
|
90
|
+
mode. With gems, use <tt>sudo gem install ruby-debug</tt>. Example:
|
91
|
+
|
92
|
+
class WeblogController < ActionController::Base
|
93
|
+
def index
|
94
|
+
@posts = Post.all
|
95
|
+
debugger
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
So the controller will accept the action, run the first line, then present you
|
100
|
+
with a IRB prompt in the server window. Here you can do things like:
|
101
|
+
|
102
|
+
>> @posts.inspect
|
103
|
+
=> "[#<Post:0x14a6be8
|
104
|
+
@attributes={"title"=>nil, "body"=>nil, "id"=>"1"}>,
|
105
|
+
#<Post:0x14a6620
|
106
|
+
@attributes={"title"=>"Rails", "body"=>"Only ten..", "id"=>"2"}>]"
|
107
|
+
>> @posts.first.title = "hello from a debugger"
|
108
|
+
=> "hello from a debugger"
|
109
|
+
|
110
|
+
...and even better, you can examine how your runtime objects actually work:
|
111
|
+
|
112
|
+
>> f = @posts.first
|
113
|
+
=> #<Post:0x13630c4 @attributes={"title"=>nil, "body"=>nil, "id"=>"1"}>
|
114
|
+
>> f.
|
115
|
+
Display all 152 possibilities? (y or n)
|
116
|
+
|
117
|
+
Finally, when you're ready to resume execution, you can enter "cont".
|
118
|
+
|
119
|
+
|
120
|
+
== Console
|
121
|
+
|
122
|
+
The console is a Ruby shell, which allows you to interact with your
|
123
|
+
application's domain model. Here you'll have all parts of the application
|
124
|
+
configured, just like it is when the application is running. You can inspect
|
125
|
+
domain models, change values, and save to the database. Starting the script
|
126
|
+
without arguments will launch it in the development environment.
|
127
|
+
|
128
|
+
To start the console, run <tt>rails console</tt> from the application
|
129
|
+
directory.
|
130
|
+
|
131
|
+
Options:
|
132
|
+
|
133
|
+
* Passing the <tt>-s, --sandbox</tt> argument will rollback any modifications
|
134
|
+
made to the database.
|
135
|
+
* Passing an environment name as an argument will load the corresponding
|
136
|
+
environment. Example: <tt>rails console production</tt>.
|
137
|
+
|
138
|
+
To reload your controllers and models after launching the console run
|
139
|
+
<tt>reload!</tt>
|
140
|
+
|
141
|
+
More information about irb can be found at:
|
142
|
+
link:http://www.rubycentral.org/pickaxe/irb.html
|
143
|
+
|
144
|
+
|
145
|
+
== dbconsole
|
146
|
+
|
147
|
+
You can go to the command line of your database directly through <tt>rails
|
148
|
+
dbconsole</tt>. You would be connected to the database with the credentials
|
149
|
+
defined in database.yml. Starting the script without arguments will connect you
|
150
|
+
to the development database. Passing an argument will connect you to a different
|
151
|
+
database, like <tt>rails dbconsole production</tt>. Currently works for MySQL,
|
152
|
+
PostgreSQL and SQLite 3.
|
153
|
+
|
154
|
+
== Description of Contents
|
155
|
+
|
156
|
+
The default directory structure of a generated Ruby on Rails application:
|
157
|
+
|
158
|
+
|-- app
|
159
|
+
| |-- assets
|
160
|
+
| | |-- images
|
161
|
+
| | |-- javascripts
|
162
|
+
| | `-- stylesheets
|
163
|
+
| |-- controllers
|
164
|
+
| |-- helpers
|
165
|
+
| |-- mailers
|
166
|
+
| |-- models
|
167
|
+
| `-- views
|
168
|
+
| `-- layouts
|
169
|
+
|-- config
|
170
|
+
| |-- environments
|
171
|
+
| |-- initializers
|
172
|
+
| `-- locales
|
173
|
+
|-- db
|
174
|
+
|-- doc
|
175
|
+
|-- lib
|
176
|
+
| |-- assets
|
177
|
+
| `-- tasks
|
178
|
+
|-- log
|
179
|
+
|-- public
|
180
|
+
|-- script
|
181
|
+
|-- test
|
182
|
+
| |-- fixtures
|
183
|
+
| |-- functional
|
184
|
+
| |-- integration
|
185
|
+
| |-- performance
|
186
|
+
| `-- unit
|
187
|
+
|-- tmp
|
188
|
+
| `-- cache
|
189
|
+
| `-- assets
|
190
|
+
`-- vendor
|
191
|
+
|-- assets
|
192
|
+
| |-- javascripts
|
193
|
+
| `-- stylesheets
|
194
|
+
`-- plugins
|
195
|
+
|
196
|
+
app
|
197
|
+
Holds all the code that's specific to this particular application.
|
198
|
+
|
199
|
+
app/assets
|
200
|
+
Contains subdirectories for images, stylesheets, and JavaScript files.
|
201
|
+
|
202
|
+
app/controllers
|
203
|
+
Holds controllers that should be named like weblogs_controller.rb for
|
204
|
+
automated URL mapping. All controllers should descend from
|
205
|
+
ApplicationController which itself descends from ActionController::Base.
|
206
|
+
|
207
|
+
app/models
|
208
|
+
Holds models that should be named like post.rb. Models descend from
|
209
|
+
ActiveRecord::Base by default.
|
210
|
+
|
211
|
+
app/views
|
212
|
+
Holds the template files for the view that should be named like
|
213
|
+
weblogs/index.html.erb for the WeblogsController#index action. All views use
|
214
|
+
eRuby syntax by default.
|
215
|
+
|
216
|
+
app/views/layouts
|
217
|
+
Holds the template files for layouts to be used with views. This models the
|
218
|
+
common header/footer method of wrapping views. In your views, define a layout
|
219
|
+
using the <tt>layout :default</tt> and create a file named default.html.erb.
|
220
|
+
Inside default.html.erb, call <% yield %> to render the view using this
|
221
|
+
layout.
|
222
|
+
|
223
|
+
app/helpers
|
224
|
+
Holds view helpers that should be named like weblogs_helper.rb. These are
|
225
|
+
generated for you automatically when using generators for controllers.
|
226
|
+
Helpers can be used to wrap functionality for your views into methods.
|
227
|
+
|
228
|
+
config
|
229
|
+
Configuration files for the Rails environment, the routing map, the database,
|
230
|
+
and other dependencies.
|
231
|
+
|
232
|
+
db
|
233
|
+
Contains the database schema in schema.rb. db/migrate contains all the
|
234
|
+
sequence of Migrations for your schema.
|
235
|
+
|
236
|
+
doc
|
237
|
+
This directory is where your application documentation will be stored when
|
238
|
+
generated using <tt>rake doc:app</tt>
|
239
|
+
|
240
|
+
lib
|
241
|
+
Application specific libraries. Basically, any kind of custom code that
|
242
|
+
doesn't belong under controllers, models, or helpers. This directory is in
|
243
|
+
the load path.
|
244
|
+
|
245
|
+
public
|
246
|
+
The directory available for the web server. Also contains the dispatchers and the
|
247
|
+
default HTML files. This should be set as the DOCUMENT_ROOT of your web
|
248
|
+
server.
|
249
|
+
|
250
|
+
script
|
251
|
+
Helper scripts for automation and generation.
|
252
|
+
|
253
|
+
test
|
254
|
+
Unit and functional tests along with fixtures. When using the rails generate
|
255
|
+
command, template test files will be generated for you and placed in this
|
256
|
+
directory.
|
257
|
+
|
258
|
+
vendor
|
259
|
+
External libraries that the application depends on. Also includes the plugins
|
260
|
+
subdirectory. If the app has frozen rails, those gems also go here, under
|
261
|
+
vendor/rails/. This directory is in the load path.
|
data/spec/dummy/Rakefile
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
#!/usr/bin/env rake
|
2
|
+
# Add your own tasks in files placed in lib/tasks ending in .rake,
|
3
|
+
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
|
4
|
+
|
5
|
+
require File.expand_path('../config/application', __FILE__)
|
6
|
+
|
7
|
+
Dummy::Application.load_tasks
|
@@ -0,0 +1,20 @@
|
|
1
|
+
ActiveAdmin.register AdminUser do
|
2
|
+
index do
|
3
|
+
column :email
|
4
|
+
column :current_sign_in_at
|
5
|
+
column :last_sign_in_at
|
6
|
+
column :sign_in_count
|
7
|
+
default_actions
|
8
|
+
end
|
9
|
+
|
10
|
+
filter :email
|
11
|
+
|
12
|
+
form do |f|
|
13
|
+
f.inputs "Admin Details" do
|
14
|
+
f.input :email
|
15
|
+
f.input :password
|
16
|
+
f.input :password_confirmation
|
17
|
+
end
|
18
|
+
f.actions
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
ActiveAdmin.register_page "Dashboard" do
|
2
|
+
|
3
|
+
menu :priority => 1, :label => proc{ I18n.t("active_admin.dashboard") }
|
4
|
+
|
5
|
+
content :title => proc{ I18n.t("active_admin.dashboard") } do
|
6
|
+
div :class => "blank_slate_container", :id => "dashboard_default_message" do
|
7
|
+
span :class => "blank_slate" do
|
8
|
+
span I18n.t("active_admin.dashboard_welcome.welcome")
|
9
|
+
small I18n.t("active_admin.dashboard_welcome.call_to_action")
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
# Here is an example of a simple dashboard with columns and panels.
|
14
|
+
#
|
15
|
+
# columns do
|
16
|
+
# column do
|
17
|
+
# panel "Recent Posts" do
|
18
|
+
# ul do
|
19
|
+
# Post.recent(5).map do |post|
|
20
|
+
# li link_to(post.title, admin_post_path(post))
|
21
|
+
# end
|
22
|
+
# end
|
23
|
+
# end
|
24
|
+
# end
|
25
|
+
|
26
|
+
# column do
|
27
|
+
# panel "Info" do
|
28
|
+
# para "Welcome to ActiveAdmin."
|
29
|
+
# end
|
30
|
+
# end
|
31
|
+
# end
|
32
|
+
end # content
|
33
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
// This is a manifest file that'll be compiled into application.js, which will include all the files
|
2
|
+
// listed below.
|
3
|
+
//
|
4
|
+
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
|
5
|
+
// or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
|
6
|
+
//
|
7
|
+
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
|
8
|
+
// the compiled file.
|
9
|
+
//
|
10
|
+
// WARNING: THE FIRST BLANK LINE MARKS THE END OF WHAT'S TO BE PROCESSED, ANY BLANK LINE SHOULD
|
11
|
+
// GO AFTER THE REQUIRES BELOW.
|
12
|
+
//
|
13
|
+
//= require jquery
|
14
|
+
//= require jquery_ujs
|
15
|
+
//= require_tree .
|
@@ -0,0 +1,32 @@
|
|
1
|
+
// SASS variable overrides must be declared before loading up Active Admin's styles.
|
2
|
+
//
|
3
|
+
// To view the variables that Active Admin provides, take a look at
|
4
|
+
// `app/assets/stylesheets/active_admin/mixins/_variables.css.scss` in the
|
5
|
+
// Active Admin source.
|
6
|
+
//
|
7
|
+
// For example, to change the sidebar width:
|
8
|
+
// $sidebar-width: 300px;
|
9
|
+
|
10
|
+
// Active Admin's got SASS!
|
11
|
+
@import "active_admin/mixins";
|
12
|
+
@import "active_admin/base";
|
13
|
+
|
14
|
+
@import "active_skin";
|
15
|
+
@import "active_i18n";
|
16
|
+
|
17
|
+
// Overriding any non-variable SASS must be done after the fact.
|
18
|
+
// For example, to change the default status-tag color:
|
19
|
+
//
|
20
|
+
// body.active_admin {
|
21
|
+
// .status_tag { background: #6090DB; }
|
22
|
+
// }
|
23
|
+
//
|
24
|
+
// Notice that Active Admin CSS rules are nested within a
|
25
|
+
// 'body.active_admin' selector to prevent conflicts with
|
26
|
+
// other pages in the app. It is best to wrap your changes in a
|
27
|
+
// namespace so they are properly recognized. You have options
|
28
|
+
// if you e.g. want different styles for different namespaces:
|
29
|
+
//
|
30
|
+
// .active_admin applies to any Active Admin namespace
|
31
|
+
// .admin_namespace applies to the admin namespace (eg: /admin)
|
32
|
+
// .other_namespace applies to a custom namespace named other (eg: /other)
|
@@ -0,0 +1,13 @@
|
|
1
|
+
/*
|
2
|
+
* This is a manifest file that'll be compiled into application.css, which will include all the files
|
3
|
+
* listed below.
|
4
|
+
*
|
5
|
+
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
|
6
|
+
* or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path.
|
7
|
+
*
|
8
|
+
* You're free to add application-wide styles to this file and they'll appear at the top of the
|
9
|
+
* compiled file, but it's generally better to create a new file per style scope.
|
10
|
+
*
|
11
|
+
*= require_self
|
12
|
+
*= require_tree .
|
13
|
+
*/
|