tabulous 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +5 -0
- data/CHANGELOG.rdoc +2 -0
- data/Gemfile +4 -0
- data/MIT-LICENSE +21 -0
- data/README.rdoc +85 -0
- data/Rakefile +54 -0
- data/lib/generators/tabs/USAGE +1 -0
- data/lib/generators/tabs/tabs_generator.rb +13 -0
- data/lib/generators/tabs/templates/tabulous.rb +170 -0
- data/lib/tabulous.rb +11 -0
- data/lib/tabulous/css_scaffolding.rb +111 -0
- data/lib/tabulous/errors.rb +16 -0
- data/lib/tabulous/formatter.rb +278 -0
- data/lib/tabulous/helpers.rb +13 -0
- data/lib/tabulous/options.rb +37 -0
- data/lib/tabulous/railtie.rb +23 -0
- data/lib/tabulous/tab.rb +79 -0
- data/lib/tabulous/tabulous.rb +162 -0
- data/lib/tabulous/version.rb +3 -0
- data/lib/tasks/tabulous.rake +11 -0
- data/tabulous.gemspec +30 -0
- data/test/applications/main/.gitignore +3 -0
- data/test/applications/main/Gemfile +7 -0
- data/test/applications/main/Rakefile +7 -0
- data/test/applications/main/app/controllers/application_controller.rb +3 -0
- data/test/applications/main/app/controllers/galaxies_controller.rb +83 -0
- data/test/applications/main/app/controllers/home_controller.rb +4 -0
- data/test/applications/main/app/controllers/planets_controller.rb +83 -0
- data/test/applications/main/app/controllers/stars_controller.rb +83 -0
- data/test/applications/main/app/controllers/subtabs_controller.rb +8 -0
- data/test/applications/main/app/helpers/application_helper.rb +2 -0
- data/test/applications/main/app/helpers/galaxies_helper.rb +2 -0
- data/test/applications/main/app/helpers/planets_helper.rb +2 -0
- data/test/applications/main/app/helpers/stars_helper.rb +2 -0
- data/test/applications/main/app/models/galaxy.rb +2 -0
- data/test/applications/main/app/models/planet.rb +2 -0
- data/test/applications/main/app/models/star.rb +2 -0
- data/test/applications/main/app/views/galaxies/_form.html.erb +21 -0
- data/test/applications/main/app/views/galaxies/edit.html.erb +6 -0
- data/test/applications/main/app/views/galaxies/index.html.erb +23 -0
- data/test/applications/main/app/views/galaxies/new.html.erb +5 -0
- data/test/applications/main/app/views/galaxies/show.html.erb +10 -0
- data/test/applications/main/app/views/home/index.html.erb +3 -0
- data/test/applications/main/app/views/layouts/application.html.erb +16 -0
- data/test/applications/main/app/views/planets/_form.html.erb +21 -0
- data/test/applications/main/app/views/planets/edit.html.erb +6 -0
- data/test/applications/main/app/views/planets/index.html.erb +23 -0
- data/test/applications/main/app/views/planets/new.html.erb +5 -0
- data/test/applications/main/app/views/planets/show.html.erb +10 -0
- data/test/applications/main/app/views/stars/_form.html.erb +21 -0
- data/test/applications/main/app/views/stars/edit.html.erb +6 -0
- data/test/applications/main/app/views/stars/index.html.erb +23 -0
- data/test/applications/main/app/views/stars/new.html.erb +5 -0
- data/test/applications/main/app/views/stars/show.html.erb +10 -0
- data/test/applications/main/app/views/subtabs/one.html.erb +1 -0
- data/test/applications/main/app/views/subtabs/three.html.erb +1 -0
- data/test/applications/main/app/views/subtabs/two.html.erb +1 -0
- data/test/applications/main/config.ru +4 -0
- data/test/applications/main/config/application.rb +42 -0
- data/test/applications/main/config/boot.rb +13 -0
- data/test/applications/main/config/database.yml +22 -0
- data/test/applications/main/config/environment.rb +5 -0
- data/test/applications/main/config/environments/development.rb +26 -0
- data/test/applications/main/config/environments/production.rb +49 -0
- data/test/applications/main/config/environments/test.rb +35 -0
- data/test/applications/main/config/initializers/backtrace_silencers.rb +7 -0
- data/test/applications/main/config/initializers/inflections.rb +10 -0
- data/test/applications/main/config/initializers/mime_types.rb +5 -0
- data/test/applications/main/config/initializers/secret_token.rb +7 -0
- data/test/applications/main/config/initializers/session_store.rb +8 -0
- data/test/applications/main/config/initializers/tabulous.rb +156 -0
- data/test/applications/main/config/locales/en.yml +5 -0
- data/test/applications/main/config/routes.rb +69 -0
- data/test/applications/main/db/development.sqlite3 +0 -0
- data/test/applications/main/db/migrate/20110223232547_create_galaxies.rb +13 -0
- data/test/applications/main/db/migrate/20110223232552_create_stars.rb +13 -0
- data/test/applications/main/db/migrate/20110223232557_create_planets.rb +13 -0
- data/test/applications/main/db/production.sqlite3 +0 -0
- data/test/applications/main/db/schema.rb +33 -0
- data/test/applications/main/db/test.sqlite3 +0 -0
- data/test/applications/main/public/404.html +26 -0
- data/test/applications/main/public/422.html +26 -0
- data/test/applications/main/public/500.html +26 -0
- data/test/applications/main/public/favicon.ico +0 -0
- data/test/applications/main/public/javascripts/application.js +2 -0
- data/test/applications/main/public/javascripts/controls.js +965 -0
- data/test/applications/main/public/javascripts/dragdrop.js +974 -0
- data/test/applications/main/public/javascripts/effects.js +1123 -0
- data/test/applications/main/public/javascripts/prototype.js +6001 -0
- data/test/applications/main/public/javascripts/rails.js +175 -0
- data/test/applications/main/public/stylesheets/.gitkeep +0 -0
- data/test/applications/main/script/rails +6 -0
- data/test/applications/main/test/integration/actions_test.rb +79 -0
- data/test/applications/main/test/integration/active_tab_clickable_test.rb +86 -0
- data/test/applications/main/test/integration/always_render_subtabs_test.rb +84 -0
- data/test/applications/main/test/integration/css_no_scaffolding_test.rb +57 -0
- data/test/applications/main/test/integration/css_scaffolding_test.rb +67 -0
- data/test/applications/main/test/integration/display_text_test.rb +73 -0
- data/test/applications/main/test/integration/enabled_test.rb +80 -0
- data/test/applications/main/test/integration/html5_test.rb +64 -0
- data/test/applications/main/test/integration/main_tabs_test.rb +10 -0
- data/test/applications/main/test/integration/path_test.rb +81 -0
- data/test/applications/main/test/integration/visible_test.rb +80 -0
- data/test/applications/main/test/integration_test_helper.rb +6 -0
- data/test/applications/main/test/test_helper.rb +8 -0
- data/test/applications/main/test/unit/tabs_generator_test.rb +14 -0
- data/test/applications/simple_tabs/.gitignore +3 -0
- data/test/applications/simple_tabs/Gemfile +7 -0
- data/test/applications/simple_tabs/Rakefile +7 -0
- data/test/applications/simple_tabs/app/controllers/application_controller.rb +3 -0
- data/test/applications/simple_tabs/app/controllers/galaxies_controller.rb +83 -0
- data/test/applications/simple_tabs/app/controllers/home_controller.rb +4 -0
- data/test/applications/simple_tabs/app/controllers/planets_controller.rb +83 -0
- data/test/applications/simple_tabs/app/controllers/stars_controller.rb +83 -0
- data/test/applications/simple_tabs/app/helpers/application_helper.rb +2 -0
- data/test/applications/simple_tabs/app/helpers/galaxies_helper.rb +2 -0
- data/test/applications/simple_tabs/app/helpers/planets_helper.rb +2 -0
- data/test/applications/simple_tabs/app/helpers/stars_helper.rb +2 -0
- data/test/applications/simple_tabs/app/models/galaxy.rb +2 -0
- data/test/applications/simple_tabs/app/models/planet.rb +2 -0
- data/test/applications/simple_tabs/app/models/star.rb +2 -0
- data/test/applications/simple_tabs/app/views/galaxies/_form.html.erb +21 -0
- data/test/applications/simple_tabs/app/views/galaxies/edit.html.erb +6 -0
- data/test/applications/simple_tabs/app/views/galaxies/index.html.erb +23 -0
- data/test/applications/simple_tabs/app/views/galaxies/new.html.erb +5 -0
- data/test/applications/simple_tabs/app/views/galaxies/show.html.erb +10 -0
- data/test/applications/simple_tabs/app/views/home/index.html.erb +4 -0
- data/test/applications/simple_tabs/app/views/layouts/application.html.erb +16 -0
- data/test/applications/simple_tabs/app/views/planets/_form.html.erb +21 -0
- data/test/applications/simple_tabs/app/views/planets/edit.html.erb +6 -0
- data/test/applications/simple_tabs/app/views/planets/index.html.erb +23 -0
- data/test/applications/simple_tabs/app/views/planets/new.html.erb +5 -0
- data/test/applications/simple_tabs/app/views/planets/show.html.erb +10 -0
- data/test/applications/simple_tabs/app/views/stars/_form.html.erb +21 -0
- data/test/applications/simple_tabs/app/views/stars/edit.html.erb +6 -0
- data/test/applications/simple_tabs/app/views/stars/index.html.erb +23 -0
- data/test/applications/simple_tabs/app/views/stars/new.html.erb +5 -0
- data/test/applications/simple_tabs/app/views/stars/show.html.erb +10 -0
- data/test/applications/simple_tabs/config.ru +4 -0
- data/test/applications/simple_tabs/config/application.rb +42 -0
- data/test/applications/simple_tabs/config/boot.rb +13 -0
- data/test/applications/simple_tabs/config/database.yml +22 -0
- data/test/applications/simple_tabs/config/environment.rb +5 -0
- data/test/applications/simple_tabs/config/environments/development.rb +26 -0
- data/test/applications/simple_tabs/config/environments/production.rb +49 -0
- data/test/applications/simple_tabs/config/environments/test.rb +35 -0
- data/test/applications/simple_tabs/config/initializers/backtrace_silencers.rb +7 -0
- data/test/applications/simple_tabs/config/initializers/inflections.rb +10 -0
- data/test/applications/simple_tabs/config/initializers/mime_types.rb +5 -0
- data/test/applications/simple_tabs/config/initializers/secret_token.rb +7 -0
- data/test/applications/simple_tabs/config/initializers/session_store.rb +8 -0
- data/test/applications/simple_tabs/config/initializers/tabulous.rb +149 -0
- data/test/applications/simple_tabs/config/locales/en.yml +5 -0
- data/test/applications/simple_tabs/config/routes.rb +65 -0
- data/test/applications/simple_tabs/db/development.sqlite3 +0 -0
- data/test/applications/simple_tabs/db/migrate/20110220170240_create_galaxies.rb +13 -0
- data/test/applications/simple_tabs/db/migrate/20110220170245_create_stars.rb +13 -0
- data/test/applications/simple_tabs/db/migrate/20110220170250_create_planets.rb +13 -0
- data/test/applications/simple_tabs/db/production.sqlite3 +0 -0
- data/test/applications/simple_tabs/db/schema.rb +33 -0
- data/test/applications/simple_tabs/db/test.sqlite3 +0 -0
- data/test/applications/simple_tabs/public/404.html +26 -0
- data/test/applications/simple_tabs/public/422.html +26 -0
- data/test/applications/simple_tabs/public/500.html +26 -0
- data/test/applications/simple_tabs/public/favicon.ico +0 -0
- data/test/applications/simple_tabs/public/javascripts/application.js +2 -0
- data/test/applications/simple_tabs/public/javascripts/controls.js +965 -0
- data/test/applications/simple_tabs/public/javascripts/dragdrop.js +974 -0
- data/test/applications/simple_tabs/public/javascripts/effects.js +1123 -0
- data/test/applications/simple_tabs/public/javascripts/prototype.js +6001 -0
- data/test/applications/simple_tabs/public/javascripts/rails.js +175 -0
- data/test/applications/simple_tabs/public/stylesheets/.gitkeep +0 -0
- data/test/applications/simple_tabs/script/rails +6 -0
- data/test/applications/simple_tabs/test/integration/simple_tabs_test.rb +34 -0
- data/test/applications/simple_tabs/test/integration_test_helper.rb +6 -0
- data/test/applications/simple_tabs/test/test_helper.rb +8 -0
- data/test/applications/subtabs/.gitignore +3 -0
- data/test/applications/subtabs/Gemfile +7 -0
- data/test/applications/subtabs/Rakefile +7 -0
- data/test/applications/subtabs/app/controllers/application_controller.rb +3 -0
- data/test/applications/subtabs/app/controllers/exoplanets_controller.rb +83 -0
- data/test/applications/subtabs/app/controllers/galaxies/elliptical_galaxies_controller.rb +85 -0
- data/test/applications/subtabs/app/controllers/galaxies/lenticular_galaxies_controller.rb +85 -0
- data/test/applications/subtabs/app/controllers/galaxies/spiral_galaxies_controller.rb +85 -0
- data/test/applications/subtabs/app/controllers/home_controller.rb +4 -0
- data/test/applications/subtabs/app/controllers/misc_controller.rb +15 -0
- data/test/applications/subtabs/app/controllers/rogue_planets_controller.rb +83 -0
- data/test/applications/subtabs/app/controllers/stars_controller.rb +83 -0
- data/test/applications/subtabs/app/helpers/application_helper.rb +2 -0
- data/test/applications/subtabs/app/helpers/elliptical_galaxies_helper.rb +2 -0
- data/test/applications/subtabs/app/helpers/exoplanets_helper.rb +2 -0
- data/test/applications/subtabs/app/helpers/lenticular_galaxies_helper.rb +2 -0
- data/test/applications/subtabs/app/helpers/rogue_planets_helper.rb +2 -0
- data/test/applications/subtabs/app/helpers/spiral_galaxies_helper.rb +2 -0
- data/test/applications/subtabs/app/helpers/stars_helper.rb +2 -0
- data/test/applications/subtabs/app/models/elliptical_galaxy.rb +2 -0
- data/test/applications/subtabs/app/models/exoplanet.rb +2 -0
- data/test/applications/subtabs/app/models/lenticular_galaxy.rb +2 -0
- data/test/applications/subtabs/app/models/rogue_planet.rb +2 -0
- data/test/applications/subtabs/app/models/spiral_galaxy.rb +2 -0
- data/test/applications/subtabs/app/models/star.rb +2 -0
- data/test/applications/subtabs/app/views/exoplanets/_form.html.erb +21 -0
- data/test/applications/subtabs/app/views/exoplanets/edit.html.erb +6 -0
- data/test/applications/subtabs/app/views/exoplanets/index.html.erb +23 -0
- data/test/applications/subtabs/app/views/exoplanets/new.html.erb +5 -0
- data/test/applications/subtabs/app/views/exoplanets/show.html.erb +10 -0
- data/test/applications/subtabs/app/views/galaxies/elliptical_galaxies/_form.html.erb +21 -0
- data/test/applications/subtabs/app/views/galaxies/elliptical_galaxies/edit.html.erb +6 -0
- data/test/applications/subtabs/app/views/galaxies/elliptical_galaxies/index.html.erb +23 -0
- data/test/applications/subtabs/app/views/galaxies/elliptical_galaxies/new.html.erb +5 -0
- data/test/applications/subtabs/app/views/galaxies/elliptical_galaxies/show.html.erb +10 -0
- data/test/applications/subtabs/app/views/galaxies/lenticular_galaxies/_form.html.erb +21 -0
- data/test/applications/subtabs/app/views/galaxies/lenticular_galaxies/edit.html.erb +6 -0
- data/test/applications/subtabs/app/views/galaxies/lenticular_galaxies/index.html.erb +23 -0
- data/test/applications/subtabs/app/views/galaxies/lenticular_galaxies/new.html.erb +5 -0
- data/test/applications/subtabs/app/views/galaxies/lenticular_galaxies/show.html.erb +10 -0
- data/test/applications/subtabs/app/views/galaxies/spiral_galaxies/_form.html.erb +21 -0
- data/test/applications/subtabs/app/views/galaxies/spiral_galaxies/edit.html.erb +6 -0
- data/test/applications/subtabs/app/views/galaxies/spiral_galaxies/index.html.erb +23 -0
- data/test/applications/subtabs/app/views/galaxies/spiral_galaxies/new.html.erb +5 -0
- data/test/applications/subtabs/app/views/galaxies/spiral_galaxies/show.html.erb +10 -0
- data/test/applications/subtabs/app/views/home/index.html.erb +14 -0
- data/test/applications/subtabs/app/views/layouts/application.html.erb +21 -0
- data/test/applications/subtabs/app/views/misc/always_enabled.html.erb +4 -0
- data/test/applications/subtabs/app/views/misc/always_visible.html.erb +4 -0
- data/test/applications/subtabs/app/views/rogue_planets/_form.html.erb +21 -0
- data/test/applications/subtabs/app/views/rogue_planets/edit.html.erb +6 -0
- data/test/applications/subtabs/app/views/rogue_planets/index.html.erb +23 -0
- data/test/applications/subtabs/app/views/rogue_planets/new.html.erb +5 -0
- data/test/applications/subtabs/app/views/rogue_planets/show.html.erb +10 -0
- data/test/applications/subtabs/app/views/stars/_form.html.erb +21 -0
- data/test/applications/subtabs/app/views/stars/edit.html.erb +6 -0
- data/test/applications/subtabs/app/views/stars/index.html.erb +23 -0
- data/test/applications/subtabs/app/views/stars/new.html.erb +5 -0
- data/test/applications/subtabs/app/views/stars/show.html.erb +10 -0
- data/test/applications/subtabs/config.ru +4 -0
- data/test/applications/subtabs/config/application.rb +42 -0
- data/test/applications/subtabs/config/boot.rb +13 -0
- data/test/applications/subtabs/config/database.yml +22 -0
- data/test/applications/subtabs/config/environment.rb +5 -0
- data/test/applications/subtabs/config/environments/development.rb +26 -0
- data/test/applications/subtabs/config/environments/production.rb +49 -0
- data/test/applications/subtabs/config/environments/test.rb +35 -0
- data/test/applications/subtabs/config/initializers/backtrace_silencers.rb +7 -0
- data/test/applications/subtabs/config/initializers/inflections.rb +10 -0
- data/test/applications/subtabs/config/initializers/mime_types.rb +5 -0
- data/test/applications/subtabs/config/initializers/secret_token.rb +7 -0
- data/test/applications/subtabs/config/initializers/session_store.rb +8 -0
- data/test/applications/subtabs/config/initializers/tabulous.rb +167 -0
- data/test/applications/subtabs/config/locales/en.yml +5 -0
- data/test/applications/subtabs/config/routes.rb +74 -0
- data/test/applications/subtabs/db/development.sqlite3 +0 -0
- data/test/applications/subtabs/db/migrate/20110223220628_create_galaxies.rb +13 -0
- data/test/applications/subtabs/db/migrate/20110223220634_create_stars.rb +13 -0
- data/test/applications/subtabs/db/migrate/20110223220640_create_planets.rb +13 -0
- data/test/applications/subtabs/db/migrate/20110226190125_create_rogue_planets.rb +13 -0
- data/test/applications/subtabs/db/migrate/20110226190131_create_exoplanets.rb +13 -0
- data/test/applications/subtabs/db/migrate/20110226190532_create_spiral_galaxies.rb +13 -0
- data/test/applications/subtabs/db/migrate/20110226190537_create_lenticular_galaxies.rb +13 -0
- data/test/applications/subtabs/db/migrate/20110226190543_create_elliptical_galaxies.rb +13 -0
- data/test/applications/subtabs/db/production.sqlite3 +0 -0
- data/test/applications/subtabs/db/schema.rb +63 -0
- data/test/applications/subtabs/db/test.sqlite3 +0 -0
- data/test/applications/subtabs/public/404.html +26 -0
- data/test/applications/subtabs/public/422.html +26 -0
- data/test/applications/subtabs/public/500.html +26 -0
- data/test/applications/subtabs/public/favicon.ico +0 -0
- data/test/applications/subtabs/public/javascripts/application.js +2 -0
- data/test/applications/subtabs/public/javascripts/controls.js +965 -0
- data/test/applications/subtabs/public/javascripts/dragdrop.js +974 -0
- data/test/applications/subtabs/public/javascripts/effects.js +1123 -0
- data/test/applications/subtabs/public/javascripts/prototype.js +6001 -0
- data/test/applications/subtabs/public/javascripts/rails.js +175 -0
- data/test/applications/subtabs/public/stylesheets/.gitkeep +0 -0
- data/test/applications/subtabs/public/stylesheets/application.css +49 -0
- data/test/applications/subtabs/public/stylesheets/reset.css +48 -0
- data/test/applications/subtabs/script/rails +6 -0
- data/test/applications/subtabs/test/integration/subtabs_test.rb +67 -0
- data/test/applications/subtabs/test/integration_test_helper.rb +6 -0
- data/test/applications/subtabs/test/test_helper.rb +8 -0
- data/test/test_application_gemfile.rb +14 -0
- data/test/test_application_integration_test_helper.rb +89 -0
- data/test/test_application_test_helper.rb +11 -0
- data/test/test_initializers/empty +0 -0
- data/test/test_initializers/expected +55 -0
- data/test/test_initializers/random_horizontal_whitespace +55 -0
- data/test/test_initializers/random_vertical_whitespace +102 -0
- data/test/test_initializers/text +144 -0
- data/test/test_initializers/trailing_comments +55 -0
- data/test/unit_test_helper.rb +13 -0
- data/test/units/tabulous_formatter_test.rb +69 -0
- metadata +466 -0
data/.gitignore
ADDED
data/CHANGELOG.rdoc
ADDED
data/Gemfile
ADDED
data/MIT-LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
Copyright 2011 Wyatt Greene
|
2
|
+
http://techiferous.com
|
3
|
+
|
4
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
5
|
+
a copy of this software and associated documentation files (the
|
6
|
+
"Software"), to deal in the Software without restriction, including
|
7
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
8
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
9
|
+
permit persons to whom the Software is furnished to do so, subject to
|
10
|
+
the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be
|
13
|
+
included in all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
16
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
17
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
18
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
19
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
20
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
21
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
ADDED
@@ -0,0 +1,85 @@
|
|
1
|
+
= Tabulous
|
2
|
+
|
3
|
+
== Description
|
4
|
+
|
5
|
+
Tabulous provides an easy way to add tabs to your Rails application.
|
6
|
+
|
7
|
+
== Requirements
|
8
|
+
|
9
|
+
Tabulous only works with Rails 3. It has been tested on Ruby 1.8.7 and 1.9.2.
|
10
|
+
|
11
|
+
== Usage
|
12
|
+
|
13
|
+
Traditionally, implementing tabs in Rails involves adding logic to your views and sprinkling
|
14
|
+
tab-related code all over your controllers. Tabulous takes a different approach and
|
15
|
+
consolidates all of the tab-related code into one configuration file. Apart from this
|
16
|
+
configuration file, you just have to call <%= tabs %> and <%= subtabs %> in your view layout(s)
|
17
|
+
and then create your own CSS styles for the tabs.
|
18
|
+
|
19
|
+
To get started, add the gem to your Rails application's Gemfile and install it using:
|
20
|
+
|
21
|
+
bundle install
|
22
|
+
|
23
|
+
Then generate the tab initializer:
|
24
|
+
|
25
|
+
rails generate tabs
|
26
|
+
|
27
|
+
This will generate config/initializers/tabulous.rb. Open the file and configure it to your liking.
|
28
|
+
You'll notice the code is formatted into a grid. After you edit the file, run the following rake
|
29
|
+
task to prettify the code back into a nice grid:
|
30
|
+
|
31
|
+
rake tabs:format
|
32
|
+
|
33
|
+
Make sure you call the following view helpers in your layout(s):
|
34
|
+
|
35
|
+
<%= tabs %>
|
36
|
+
<%= subtabs %>
|
37
|
+
|
38
|
+
The tabs helper will generate markup that looks like this:
|
39
|
+
|
40
|
+
<div id="tabs">
|
41
|
+
<ul>
|
42
|
+
<li class="active enabled"><span class="tab">Explanation</span></li>
|
43
|
+
<li class="inactive enabled"><a href="/galaxies/elliptical_galaxies" class="tab">Galaxies</a></li>
|
44
|
+
<li class="inactive enabled"><a href="/exoplanets" class="tab">Planets</a></li>
|
45
|
+
<li class="inactive enabled"><a href="/stars" class="tab">Stars</a></li>
|
46
|
+
<li class="inactive disabled"><span class="tab">Asteroids</span></li>
|
47
|
+
</ul>
|
48
|
+
</div>
|
49
|
+
|
50
|
+
And the subtabs helper will generate markup that looks like this:
|
51
|
+
|
52
|
+
<div id="subtabs">
|
53
|
+
<ul>
|
54
|
+
<li class="active enabled"><span class="tab">Exoplanets</span></li>
|
55
|
+
<li class="inactive enabled"><a href="/rogue_planets" class="tab">Rogue Planets</a></li>
|
56
|
+
</ul>
|
57
|
+
</div>
|
58
|
+
|
59
|
+
Tabulous will start you off with some CSS scaffolding but you'll eventually want to create your own
|
60
|
+
CSS.
|
61
|
+
|
62
|
+
== Examples
|
63
|
+
|
64
|
+
Look in this gem's test/applications directory to find working example applications. Look at their
|
65
|
+
config/initializers/tabulous.rb and app/layouts/application.html.erb files.
|
66
|
+
|
67
|
+
== Contributing
|
68
|
+
|
69
|
+
Developers are encouraged to contribute ideas or code.
|
70
|
+
|
71
|
+
To make code changes:
|
72
|
+
|
73
|
+
* First, check out this gem's code from github.
|
74
|
+
* Next, type bundle install in tabulous's directory. This will install any gems you need
|
75
|
+
for developing tabulous.
|
76
|
+
* Then go to each directory in test/applications and type bundle install. This makes sure
|
77
|
+
the test applications have the gems that they need to run.
|
78
|
+
* To save you the effort of having to create and migrate databases for each test application,
|
79
|
+
I've committed the sqlite databases of each test application to the repository.
|
80
|
+
* Now go to tabulous's directory and type rake test. If everything has been installed
|
81
|
+
properly, all of the tests will pass.
|
82
|
+
* Now you should be all set to code.
|
83
|
+
|
84
|
+
Please send me a message if you find any confusing or incorrect documentation in tabulous or if
|
85
|
+
you encounter any bugs. Thank you and enjoy!
|
data/Rakefile
ADDED
@@ -0,0 +1,54 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'bundler'
|
5
|
+
Bundler::GemHelper.install_tasks
|
6
|
+
require 'colored'
|
7
|
+
require 'rake'
|
8
|
+
require 'rake/rdoctask'
|
9
|
+
require 'rake/testtask'
|
10
|
+
|
11
|
+
namespace :test do
|
12
|
+
Dir['test/applications/*'].each do |filename|
|
13
|
+
if File.directory?(filename)
|
14
|
+
name = filename.split('/').last
|
15
|
+
desc "run tests for the test application #{name}"
|
16
|
+
Rake::TestTask.new(name) do |t|
|
17
|
+
t.libs << 'lib'
|
18
|
+
t.libs << 'test'
|
19
|
+
t.pattern = "test/applications/#{name}/**/*_test.rb"
|
20
|
+
t.verbose = false
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
desc "run unit tests for tabulous"
|
25
|
+
Rake::TestTask.new(:units) do |t|
|
26
|
+
t.libs << 'lib'
|
27
|
+
t.pattern = 'test/units/**/*_test.rb'
|
28
|
+
t.verbose = true
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
task :test do
|
33
|
+
# we cannot load more than one Rails app at a time so we run the rake tasks
|
34
|
+
# from the shell so that each has its own process
|
35
|
+
Dir['test/applications/*'].each do |filename|
|
36
|
+
if File.directory?(filename)
|
37
|
+
name = filename.split('/').last
|
38
|
+
puts "Running tests for test application \"#{name}\"".magenta
|
39
|
+
puts %x{rake test:#{name}}
|
40
|
+
end
|
41
|
+
end
|
42
|
+
puts "Running unit tests".magenta
|
43
|
+
Rake::Task['test:units'].invoke
|
44
|
+
end
|
45
|
+
|
46
|
+
task :default => :test
|
47
|
+
|
48
|
+
Rake::RDocTask.new(:rdoc) do |rdoc|
|
49
|
+
rdoc.rdoc_dir = 'rdoc'
|
50
|
+
rdoc.title = 'Test'
|
51
|
+
rdoc.options << '--line-numbers' << '--inline-source'
|
52
|
+
rdoc.rdoc_files.include('README.rdoc')
|
53
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
54
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
This will generate tabs for your Rails app.
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require 'colored'
|
2
|
+
class TabsGenerator < Rails::Generators::Base
|
3
|
+
source_root File.expand_path("../templates", __FILE__)
|
4
|
+
def create_tabs_initializer_file
|
5
|
+
template "tabulous.rb", "config/initializers/tabulous.rb"
|
6
|
+
puts
|
7
|
+
puts ("Tabulous made some guesses about how you want your tabs configured but " +
|
8
|
+
"probably got some things wrong. So you need to edit " +
|
9
|
+
"config/initializers/tabulous.rb to your liking.").magenta
|
10
|
+
puts
|
11
|
+
puts "Don't forget to put <%= tabs %> and <%= subtabs %> in your layout(s).".magenta
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,170 @@
|
|
1
|
+
# Tabulous gives you an easy way to set up tabs for your Rails application.
|
2
|
+
#
|
3
|
+
# 1. Configure this initializer.
|
4
|
+
# 2. Add <%%= tabs %> and <%%= subtabs %> in your layout(s) wherever you want
|
5
|
+
# your tabs to appear.
|
6
|
+
# 3. Add styles for these tabs in your stylesheets.
|
7
|
+
# 4. Profit!
|
8
|
+
|
9
|
+
<% controllers = []
|
10
|
+
Dir[File.join(Rails.root.to_s, 'app/controllers/*.rb')].each do |filename|
|
11
|
+
filename = filename.split('/').last
|
12
|
+
if filename =~ /(\w+)_controller.rb/
|
13
|
+
controller_name = $1.downcase
|
14
|
+
if controller_name != 'application'
|
15
|
+
controllers << controller_name
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
-%>
|
20
|
+
Tabulous.setup do |config|
|
21
|
+
|
22
|
+
#---------------------------
|
23
|
+
# HOW TO USE THE TABLES
|
24
|
+
#---------------------------
|
25
|
+
#
|
26
|
+
# The following tables are just an array of arrays. As such, you can put
|
27
|
+
# any Ruby code into a cell. For example, you could put "/foo/bar" in
|
28
|
+
# a path cell or you could put "/foo" + "/bar". You can even wrap up code
|
29
|
+
# in a lambda to be executed later. These will be executed in the context
|
30
|
+
# of a Rails view meaning they will have access to view helpers.
|
31
|
+
#
|
32
|
+
# However, there is something special about the format of these tables.
|
33
|
+
# Because it would be a pain for you to manually prettify the tables each
|
34
|
+
# time you edit them, there is a special rake task that does this for
|
35
|
+
# you: rake tabs:format. However, for this prettifier to work properly
|
36
|
+
# you have to follow some special rules:
|
37
|
+
#
|
38
|
+
# * No comments are allowed between rows.
|
39
|
+
# * Comments are allowed to the right of rows, except for header rows.
|
40
|
+
# * And most importantly: commas that separate cells should be surrounded
|
41
|
+
# by spaces and commas that are within cells should not. This gives the
|
42
|
+
# formatter an easy way to distinguish between cells without having
|
43
|
+
# to actually parse the Ruby.
|
44
|
+
|
45
|
+
#----------
|
46
|
+
# TABS
|
47
|
+
#----------
|
48
|
+
#
|
49
|
+
# This is where you define your tabs and subtabs. The order that the tabs
|
50
|
+
# appear in this list is the order they will appear in your views. Any
|
51
|
+
# subtabs defined will have the previous tab as their parent.
|
52
|
+
#
|
53
|
+
# TAB NAME
|
54
|
+
# must end in _tab or _subtab
|
55
|
+
# DISPLAY TEXT
|
56
|
+
# the text the user sees on the tab
|
57
|
+
# PATH
|
58
|
+
# the URL that gets sent to the server when the tab is clicked
|
59
|
+
# VISIBLE
|
60
|
+
# whether to display the tab
|
61
|
+
# ENABLED
|
62
|
+
# whether the tab is disabled (unclickable)
|
63
|
+
|
64
|
+
<% index_routes = Rails.application.routes.routes.select{|r| r.requirements[:action] == 'index'}
|
65
|
+
tab_data = index_routes.map do |route|
|
66
|
+
name = route.requirements[:controller].gsub('/', '_')
|
67
|
+
{ :text => name.titleize,
|
68
|
+
:name => name,
|
69
|
+
:path_helper => route.name + '_path' }
|
70
|
+
end
|
71
|
+
-%>
|
72
|
+
<%= s = []
|
73
|
+
s << ' config.tabs = ['
|
74
|
+
s << ' #-------------------------------------------------------------------------------------------------#'
|
75
|
+
s << ' # TAB NAME | DISPLAY TEXT | PATH | VISIBLE? | ENABLED? #'
|
76
|
+
s << ' #-------------------------------------------------------------------------------------------------#'
|
77
|
+
for tab in tab_data
|
78
|
+
s << "[ :#{tab[:name]}_tab , '#{tab[:text]}' , lambda { #{tab[:path_helper]} } , true , true ],"
|
79
|
+
end
|
80
|
+
s << ' #-------------------------------------------------------------------------------------------------#'
|
81
|
+
s << ' # TAB NAME | DISPLAY TEXT | PATH | VISIBLE? | ENABLED? #'
|
82
|
+
s << ' #-------------------------------------------------------------------------------------------------#'
|
83
|
+
s << ' ]'
|
84
|
+
Tabulous::Formatter.format(s).join("\n") %>
|
85
|
+
|
86
|
+
#-------------
|
87
|
+
# ACTIONS
|
88
|
+
#-------------
|
89
|
+
#
|
90
|
+
# This is where you hook up actions with tabs. That way tabulous knows
|
91
|
+
# which tab and subtab to mark active when an action is rendered.
|
92
|
+
#
|
93
|
+
# CONTROLLER
|
94
|
+
# the name of the controller
|
95
|
+
# ACTION
|
96
|
+
# the name of the action, or :all_actions
|
97
|
+
# TAB
|
98
|
+
# the name of the tab or subtab that is active when this action is rendered
|
99
|
+
|
100
|
+
<%= s = []
|
101
|
+
s << ' config.actions = ['
|
102
|
+
s << ' #-------------------------------------------------------------#'
|
103
|
+
s << ' # CONTROLLER | ACTION | TAB #'
|
104
|
+
s << ' #-------------------------------------------------------------#'
|
105
|
+
for tab in tab_data
|
106
|
+
s << "[ :#{tab[:name]} , :all_actions , :#{tab[:name]}_tab ],"
|
107
|
+
end
|
108
|
+
s << ' #-------------------------------------------------------------#'
|
109
|
+
s << ' # CONTROLLER | ACTION | TAB #'
|
110
|
+
s << ' #-------------------------------------------------------------#'
|
111
|
+
s << ' ]'
|
112
|
+
Tabulous::Formatter.format(s).join("\n") %>
|
113
|
+
|
114
|
+
#-------------
|
115
|
+
# OPTIONS
|
116
|
+
#-------------
|
117
|
+
|
118
|
+
# By default, you cannot click on the active tab.
|
119
|
+
config.active_tab_clickable = false
|
120
|
+
|
121
|
+
# By default, the subtabs HTML element is not rendered if it is empty.
|
122
|
+
config.always_render_subtabs = false
|
123
|
+
|
124
|
+
# By default, when an action renders and no tab is defined for that action,
|
125
|
+
# an error is thrown. If you turn this off, no error is thrown and the
|
126
|
+
# tabs are simply not rendered.
|
127
|
+
config.raise_error_if_no_tab_found = true
|
128
|
+
|
129
|
+
# By default, div elements are used in the tab markup. When html5 is
|
130
|
+
# true, nav elements are used instead.
|
131
|
+
config.html5 = false
|
132
|
+
|
133
|
+
#------------
|
134
|
+
# STYLES
|
135
|
+
#------------
|
136
|
+
#
|
137
|
+
# The markup that is generated has the following properties:
|
138
|
+
#
|
139
|
+
# Tabs and subtabs that are selected have the class "active".
|
140
|
+
# Tabs and subtabs that are not selected have the class "inactive".
|
141
|
+
# Tabs that are disabled have the class "disabled"; otherwise, "enabled".
|
142
|
+
# Tabs that are not visible do not appear in the markup at all.
|
143
|
+
#
|
144
|
+
# These classes are provided to make it easier for you to create your
|
145
|
+
# own CSS (and JavaScript) for the tabs.
|
146
|
+
|
147
|
+
# Some styles will be generated for you to get you off to a good start.
|
148
|
+
# Scaffolded styles are not meant to be used in production as they
|
149
|
+
# generate invalid HTML markup. They are merely meant to give you a
|
150
|
+
# head start or an easy way to prototype quickly.
|
151
|
+
#
|
152
|
+
config.css.scaffolding = true
|
153
|
+
|
154
|
+
# You can tweak the colors of the generated CSS.
|
155
|
+
#
|
156
|
+
# config.css.background_color = '#ccc'
|
157
|
+
# config.css.text_color = '#444'
|
158
|
+
# config.css.active_tab_color = 'white'
|
159
|
+
# config.css.hover_tab_color = '#ddd'
|
160
|
+
# config.css.inactive_tab_color = '#aaa'
|
161
|
+
# config.css.inactive_text_color = '#888'
|
162
|
+
|
163
|
+
#-----------
|
164
|
+
# NOTES
|
165
|
+
#-----------
|
166
|
+
#
|
167
|
+
# In development mode this initializer is reloaded for each request so that
|
168
|
+
# you don't have to restart the server each time you edit this file.
|
169
|
+
|
170
|
+
end
|
data/lib/tabulous.rb
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
module Tabulous
|
2
|
+
require 'tabulous/railtie' if defined?(Rails)
|
3
|
+
end
|
4
|
+
|
5
|
+
require 'tabulous/errors'
|
6
|
+
require 'tabulous/options'
|
7
|
+
require 'tabulous/css_scaffolding'
|
8
|
+
require 'tabulous/helpers'
|
9
|
+
require 'tabulous/formatter'
|
10
|
+
require 'tabulous/tab'
|
11
|
+
require 'tabulous/tabulous'
|
@@ -0,0 +1,111 @@
|
|
1
|
+
module Tabulous
|
2
|
+
def self.embed_styles
|
3
|
+
return '' unless @@css.scaffolding
|
4
|
+
%Q{
|
5
|
+
<style type="text/css">
|
6
|
+
|
7
|
+
body {
|
8
|
+
margin: 0;
|
9
|
+
padding: 0;
|
10
|
+
}
|
11
|
+
|
12
|
+
#tabs, #tabs ul, #tabs ul li, #tabs ul li span, #tabs ul li a,
|
13
|
+
#subtabs, #subtabs ul, #subtabs ul li, #subtabs ul li span, #subtabs ul li a {
|
14
|
+
margin: 0;
|
15
|
+
padding: 0;
|
16
|
+
line-height: 1;
|
17
|
+
}
|
18
|
+
|
19
|
+
#tabs, #tabs a, #tabs a:visited, #tabs a:hover {
|
20
|
+
color: #{@@css.text_color};
|
21
|
+
}
|
22
|
+
|
23
|
+
#tabs li.disabled, #tabs li.disabled a, #tabs li.disabled a:visited, #tabs li.disabled a:hover,
|
24
|
+
#subtabs li.disabled, #subtabs li.disabled a, #subtabs li.disabled a:visited, #subtabs li.disabled a:hover {
|
25
|
+
color: #{@@css.inactive_text_color};
|
26
|
+
}
|
27
|
+
|
28
|
+
#tabs a {
|
29
|
+
text-decoration: none;
|
30
|
+
}
|
31
|
+
|
32
|
+
#tabs ul {
|
33
|
+
font-size: 24px;
|
34
|
+
height: 57px;
|
35
|
+
list-style-type: none;
|
36
|
+
background-color: #{@@css.background_color};
|
37
|
+
padding: 0 0 0 50px;
|
38
|
+
}
|
39
|
+
|
40
|
+
#tabs ul li {
|
41
|
+
padding-top: 25px;
|
42
|
+
padding-right: 5px;
|
43
|
+
float: left;
|
44
|
+
}
|
45
|
+
|
46
|
+
#tabs ul li .tab {
|
47
|
+
background-color: #{@@css.inactive_tab_color};
|
48
|
+
padding: 5px 15px 3px 15px;
|
49
|
+
float: left;
|
50
|
+
-webkit-border-top-left-radius: 8px;
|
51
|
+
-khtml-border-radius-topleft: 8px;
|
52
|
+
-moz-border-radius-topleft: 8px;
|
53
|
+
border-top-left-radius: 8px;
|
54
|
+
-webkit-border-top-right-radius: 8px;
|
55
|
+
-khtml-border-radius-topright: 8px;
|
56
|
+
-moz-border-radius-topright: 8px;
|
57
|
+
border-top-right-radius: 8px;
|
58
|
+
}
|
59
|
+
|
60
|
+
#tabs ul li.active .tab {
|
61
|
+
background-color: #{@@css.active_tab_color};
|
62
|
+
padding-bottom: 14px;
|
63
|
+
}
|
64
|
+
|
65
|
+
#tabs ul li a:hover {
|
66
|
+
background-color: #{@@css.hover_tab_color};
|
67
|
+
}
|
68
|
+
|
69
|
+
#tabs ul {
|
70
|
+
/* float clearing */
|
71
|
+
overflow: hidden;
|
72
|
+
display: inline-block; /* Necessary to trigger "hasLayout" in IE */
|
73
|
+
display: block; /* Sets element back to block */
|
74
|
+
}
|
75
|
+
|
76
|
+
#subtabs ul {
|
77
|
+
margin-top: 5px;
|
78
|
+
}
|
79
|
+
|
80
|
+
#subtabs, #subtabs a, #subtabs a:visited {
|
81
|
+
color: #{@@css.text_color};
|
82
|
+
}
|
83
|
+
|
84
|
+
#subtabs li.active {
|
85
|
+
font-weight: bold;
|
86
|
+
}
|
87
|
+
|
88
|
+
#subtabs a {
|
89
|
+
text-decoration: none;
|
90
|
+
}
|
91
|
+
|
92
|
+
#subtabs ul {
|
93
|
+
font-size: 16px;
|
94
|
+
height: 30px;
|
95
|
+
list-style-type: none;
|
96
|
+
padding: 0 0 0 50px;
|
97
|
+
}
|
98
|
+
|
99
|
+
#subtabs ul li {
|
100
|
+
padding: 10px;
|
101
|
+
float: left;
|
102
|
+
}
|
103
|
+
|
104
|
+
#subtabs ul li a:hover {
|
105
|
+
text-decoration: underline;
|
106
|
+
}
|
107
|
+
|
108
|
+
</style>
|
109
|
+
}
|
110
|
+
end
|
111
|
+
end
|