casein 4.0.0 → 5.0.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (83) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE +246 -0
  3. data/PUBLIC_VERSION.yml +2 -2
  4. data/README.rdoc +73 -49
  5. data/Rakefile +7 -5
  6. data/app/assets/fonts/casein/glyphiconshalflings-regular.eot +0 -0
  7. data/app/assets/fonts/casein/glyphiconshalflings-regular.otf +0 -0
  8. data/app/assets/fonts/casein/glyphiconshalflings-regular.svg +175 -0
  9. data/app/assets/fonts/casein/glyphiconshalflings-regular.ttf +0 -0
  10. data/app/assets/fonts/casein/glyphiconshalflings-regular.woff +0 -0
  11. data/app/assets/images/casein/casein.png +0 -0
  12. data/app/assets/javascripts/casein/bootstrap.js +1966 -0
  13. data/app/assets/javascripts/casein/casein.js +34 -19
  14. data/app/assets/javascripts/casein/html5shiv.js +8 -0
  15. data/app/assets/stylesheets/casein/bootstrap-glyphicons.css.scss +2 -0
  16. data/app/assets/stylesheets/casein/bootstrap.css +4692 -0
  17. data/app/assets/stylesheets/casein/casein-bootstrap-overrides.css.scss +76 -0
  18. data/app/assets/stylesheets/casein/casein.css.scss +258 -3
  19. data/app/assets/stylesheets/casein/login.css.scss +48 -109
  20. data/app/controllers/casein/{user_sessions_controller.rb → admin_user_sessions_controller.rb} +6 -10
  21. data/app/controllers/casein/admin_users_controller.rb +124 -0
  22. data/app/controllers/casein/casein_controller.rb +11 -9
  23. data/app/controllers/casein/password_resets_controller.rb +8 -10
  24. data/app/helpers/casein/casein_helper.rb +94 -31
  25. data/app/mailers/casein/casein_notification.rb +13 -13
  26. data/app/models/casein/{user.rb → admin_user.rb} +2 -2
  27. data/app/models/casein/{user_session.rb → admin_user_session.rb} +1 -1
  28. data/app/views/casein/admin_user_sessions/new.html.erb +56 -0
  29. data/app/views/casein/admin_users/index.html.erb +39 -0
  30. data/app/views/casein/admin_users/new.html.erb +57 -0
  31. data/app/views/casein/admin_users/show.html.erb +104 -0
  32. data/app/views/casein/casein/blank.html.erb +12 -1
  33. data/app/views/casein/casein_notification/generate_new_password.erb +1 -1
  34. data/app/views/casein/casein_notification/new_user_information.erb +1 -1
  35. data/app/views/casein/casein_notification/password_reset_instructions.erb +1 -1
  36. data/app/views/casein/password_resets/edit.html.erb +21 -33
  37. data/app/views/layouts/casein_auth.html.erb +34 -22
  38. data/app/views/layouts/casein_main.html.erb +111 -64
  39. data/config/initializers/will_paginate.rb +40 -0
  40. data/config/routes.rb +2 -2
  41. data/lib/casein.rb +9 -3
  42. data/lib/casein/engine.rb +5 -1
  43. data/lib/generators/casein/install/install_generator.rb +3 -3
  44. data/lib/generators/casein/install/templates/app/helpers/casein/config_helper.rb +10 -11
  45. data/lib/generators/casein/install/templates/app/views/casein/layouts/{_left_navigation.html.erb → _tab_navigation.html.erb} +0 -0
  46. data/lib/generators/casein/install/templates/app/views/casein/layouts/_top_navigation.html.erb +4 -0
  47. data/lib/generators/casein/install/templates/db/migrate/{casein_create_users.rb → casein_create_admin_users.rb} +3 -3
  48. data/lib/generators/casein/scaffold/scaffold_generator.rb +20 -8
  49. data/lib/generators/casein/scaffold/templates/controller.rb +6 -6
  50. data/lib/generators/casein/scaffold/templates/views/_form.html.erb +11 -8
  51. data/lib/generators/casein/scaffold/templates/views/_table.html.erb +12 -10
  52. data/lib/generators/casein/scaffold/templates/views/index.html.erb +7 -3
  53. data/lib/generators/casein/scaffold/templates/views/new.html.erb +3 -3
  54. data/lib/generators/casein/scaffold/templates/views/show.html.erb +5 -5
  55. data/lib/railties/tasks.rake +15 -13
  56. metadata +67 -46
  57. data/MIT-LICENSE +0 -21
  58. data/app/assets/images/casein/header.png +0 -0
  59. data/app/assets/images/casein/icons/add.png +0 -0
  60. data/app/assets/images/casein/icons/delete.png +0 -0
  61. data/app/assets/images/casein/icons/table.png +0 -0
  62. data/app/assets/images/casein/login/alertBg.png +0 -0
  63. data/app/assets/images/casein/login/background.png +0 -0
  64. data/app/assets/images/casein/login/bottom.png +0 -0
  65. data/app/assets/images/casein/login/loginBoxBg.png +0 -0
  66. data/app/assets/images/casein/login/loginBoxBottom.png +0 -0
  67. data/app/assets/images/casein/login/loginBoxTop.png +0 -0
  68. data/app/assets/images/casein/login/loginSubmit.png +0 -0
  69. data/app/assets/images/casein/login/recoverSubmit.png +0 -0
  70. data/app/assets/images/casein/login/top.png +0 -0
  71. data/app/assets/images/casein/nav.png +0 -0
  72. data/app/assets/images/casein/rightNav.png +0 -0
  73. data/app/assets/images/casein/rightNavButton.png +0 -0
  74. data/app/assets/images/casein/visitSiteNav.png +0 -0
  75. data/app/assets/javascripts/casein/login.js +0 -27
  76. data/app/assets/stylesheets/casein/elements.css.scss +0 -307
  77. data/app/assets/stylesheets/casein/screen.css.scss +0 -224
  78. data/app/controllers/casein/users_controller.rb +0 -108
  79. data/app/views/casein/user_sessions/new.html.erb +0 -66
  80. data/app/views/casein/users/index.html.erb +0 -35
  81. data/app/views/casein/users/new.html.erb +0 -46
  82. data/app/views/casein/users/show.html.erb +0 -94
  83. data/lib/generators/casein/install/templates/app/views/casein/layouts/_right_navigation.html.erb +0 -1
@@ -1,24 +1,36 @@
1
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
2
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
3
-
4
- <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
5
- <head>
6
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
7
- <title>Welcome to <%= casein_config_website_name %></title>
8
- <%= stylesheet_link_tag "casein/login" %>
9
- <%= javascript_include_tag "casein/login" %>
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>Welcome to <%= casein_config_website_name %></title>
7
+ <%= stylesheet_link_tag "casein/login" %>
8
+ <%= javascript_include_tag "casein/casein" %>
10
9
  <%= csrf_meta_tag %>
11
- </head>
12
- <body>
13
- <div id="header">
14
- <h1><%= image_tag(casein_config_logo, :alt => casein_config_website_name) %></h1>
15
- </div>
16
- <div id="content">
17
- <%= yield %>
18
- </div>
19
- <div id="footer">
20
- <p>Based on <%= link_to "Casein", "http://www.caseincms.com" %> <%= casein_get_short_version_string %> technology,
21
- an open-source project.</p>
10
+
11
+ <!-- HTML5 shim, for IE6-8 support of HTML5 elements -->
12
+ <!--[if lt IE 9]>
13
+ <%= javascript_include_tag("casein/html5shiv") %>
14
+ <![endif]-->
15
+
16
+ </head>
17
+
18
+ <body>
19
+ <div class="container-narrow">
20
+ <div class="jumbotron">
21
+ <div class="row brand">
22
+ <%= image_tag(casein_config_logo, :alt => casein_config_website_name) %>
23
+ </div>
24
+ <%= yield %>
25
+ </div>
26
+ <div class="row">
27
+ <div class="col-lg-12">
28
+ <hr />
29
+ <footer>
30
+ <p><%= casein_get_footer_string(false) %></p>
31
+ </footer>
32
+ </div>
33
+ </div>
22
34
  </div>
23
- </body>
24
- </html>
35
+ </body>
36
+ </html>
@@ -1,67 +1,114 @@
1
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
2
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
3
6
 
4
- <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
5
- <head>
6
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
7
- <title><%= casein_generate_page_title %></title>
8
- <% casein_config_stylesheet_includes.each do |stylesheet| %>
9
- <%= stylesheet_link_tag(stylesheet) %>
10
- <% end %>
11
-
12
- <% casein_config_javascript_includes.each do |javascript| %>
13
- <%= javascript_include_tag(javascript) %>
14
- <% end %>
7
+ <title><%= casein_generate_page_title %></title>
8
+ <% casein_config_stylesheet_includes.each do |stylesheet| %>
9
+ <%= stylesheet_link_tag(stylesheet) %>
10
+ <% end %>
11
+
12
+ <% casein_config_javascript_includes.each do |javascript| %>
13
+ <%= javascript_include_tag(javascript) %>
14
+ <% end %>
15
15
 
16
- <%= csrf_meta_tag %>
17
- </head>
18
- <body>
19
- <div id="header">
20
- <h1><%= link_to(image_tag(casein_config_logo, :alt => casein_config_website_name), :controller => :casein) %></h1>
21
- <div id="dashboard">
22
- <% if @session_user != nil %>
23
- <ul>
24
- <li>Hello <%= @session_user.name %></li>
25
- <li><%= Time.zone.name %></li>
26
- <li><%= link_to 'Profile', casein_user_path(@session_user) %></li>
27
- <li class="lastItem"><%= link_to 'Logout', casein_user_session_path, :method => :delete %></li>
28
- </ul>
29
- <% end %>
30
- </div>
31
- <div id="navigation">
32
- <ul>
33
- <%= render :partial => '/casein/layouts/left_navigation' %>
34
- </ul>
35
- </div>
36
- <div id="altNavigation">
37
- <ul>
38
- <% if @session_user.is_admin? %>
39
- <li><%= link_to 'Users', casein_users_path %></li>
40
- <% end %>
41
- <%= render :partial => '/casein/layouts/right_navigation' %>
42
- </ul>
43
- </div>
44
- </div>
45
- <div id="rightBar">
46
- <div class="spacer"></div>
47
- <ul>
48
- <%= yield :sidebar %>
49
- </ul>
50
- </div>
51
- <div id="content">
52
- <div id="data">
53
- <% if flash[:warning] %>
54
- <div id="error">
55
- <%= flash[:warning] %>
56
- </div>
57
- <% end %>
58
- <% if flash[:notice] %>
59
- <div id="notice">
60
- <%= flash[:notice] %>
61
- </div>
62
- <% end %>
63
- <%= yield %>
64
- </div>
65
- </div>
66
- </body>
16
+ <%= csrf_meta_tag %>
17
+
18
+ <!-- HTML5 shim, for IE6-8 support of HTML5 elements -->
19
+ <!--[if lt IE 9]>
20
+ <%= javascript_include_tag("casein/html5shiv") %>
21
+ <![endif]-->
22
+
23
+ <script type="text/javascript">
24
+ var current_controller = "<%= controller_name %>";
25
+ </script>
26
+
27
+ </head>
28
+
29
+ <body>
30
+ <div class="navbar navbar-static-top">
31
+ <% if @session_user != nil %>
32
+ <div class="container">
33
+ <div id="user-info">
34
+ <ul>
35
+ <li class="hidden-sm">Hello <%= @session_user.name %></li>
36
+ <li class="hidden-sm"><%= Time.zone.name %></li>
37
+ <li><%= link_to 'Profile', casein_admin_user_path(@session_user) %></li>
38
+
39
+ <% if @session_user.is_admin? %>
40
+ <li><%= link_to 'Users', casein_admin_users_path %></li>
41
+ <% end %>
42
+
43
+ <%= render :partial => '/casein/layouts/top_navigation' %>
44
+ <li class="last-item signout"><%= link_to 'Sign out', casein_admin_user_session_path, :method => :delete %></li>
45
+ </ul>
46
+ </div>
47
+ </div>
48
+ <% end %>
49
+
50
+ <div class="container">
51
+ <%= link_to(image_tag(casein_config_logo, :alt => casein_config_website_name), {:controller => :casein}, :class => "navbar-brand") %>
52
+ </div>
53
+ <div class="container">
54
+ <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".nav-collapse">
55
+ <span class="icon-bar"></span>
56
+ <span class="icon-bar"></span>
57
+ <span class="icon-bar"></span>
58
+ </button>
59
+
60
+ <div class="nav-collapse collapse">
61
+ <ul class="nav navbar-nav">
62
+ <%= render :partial => '/casein/layouts/tab_navigation' %>
63
+ </ul>
64
+ </div>
65
+ </div>
66
+ </div>
67
+
68
+ <div class="container">
69
+ <div id="content">
70
+ <div class="row">
71
+ <% if content_for?(:sidebar) %>
72
+ <div id="right-column" class="col-lg-2">
73
+ <ul class="nav nav-pills nav-stacked content-bottom-padding">
74
+ <%= yield :sidebar %>
75
+ </ul>
76
+ </div>
77
+ <div id="left-column" class="col-lg-10 content-bottom-padding">
78
+ <% else %>
79
+ <div class="col-lg-12 content-bottom-padding">
80
+ <% end %>
81
+
82
+ <% if flash[:warning] %>
83
+ <div id="error" class="alert alert-danger">
84
+ <%= flash[:warning] %>
85
+ </div>
86
+ <% end %>
87
+ <% if flash[:notice] %>
88
+ <div id="notice" class="alert alert-success">
89
+ <%= flash[:notice] %>
90
+ </div>
91
+ <% end %>
92
+ <% if content_for?(:help) %>
93
+ <div id="help" class="alert alert-info">
94
+ <%= yield :help %>
95
+ </div>
96
+ <% end %>
97
+
98
+ <%= yield %>
99
+
100
+ </div>
101
+
102
+ </div>
103
+ <div class="row">
104
+ <div class="col-lg-12">
105
+ <hr />
106
+ <footer>
107
+ <p><%= casein_get_footer_string(true) %></p>
108
+ </footer>
109
+ </div>
110
+ </div>
111
+ </div>
112
+ </div>
113
+ </body>
67
114
  </html>
@@ -0,0 +1,40 @@
1
+ # config/initializers/will_paginate.rb
2
+ #
3
+ # This extension code was written by Isaac Bowen, originally found
4
+ # at http://isaacbowen.com/blog/using-will_paginate-action_view-and-bootstrap/
5
+
6
+ require 'will_paginate/view_helpers/action_view'
7
+
8
+ module WillPaginate
9
+ module ActionView
10
+
11
+ def will_paginate(collection = nil, options = {})
12
+ options, collection = collection, nil if collection.is_a? Hash
13
+ # Taken from original will_paginate code to handle if the helper is not passed a collection object.
14
+ collection ||= infer_collection_from_controller
15
+ options[:renderer] ||= BootstrapLinkRenderer
16
+ super.try :html_safe
17
+ end
18
+
19
+ class BootstrapLinkRenderer < LinkRenderer
20
+ protected
21
+
22
+ def html_container(html)
23
+ tag :div, tag(:ul, html, :class => "pagination"), container_attributes
24
+ end
25
+
26
+ def page_number(page)
27
+ tag :li, link(page, page, :rel => rel_value(page)), :class => ('active' if page == current_page)
28
+ end
29
+
30
+ def gap
31
+ tag :li, link('&hellip;'.html_safe, '#'), :class => 'disabled'
32
+ end
33
+
34
+ def previous_or_next_page(page, text, classname)
35
+ tag :li, link(text, page || '#'),
36
+ :class => [(classname[0..3] if @options[:page_links]), (classname if @options[:page_links]), ('disabled' unless page)].join(' ')
37
+ end
38
+ end
39
+ end
40
+ end
@@ -4,13 +4,13 @@ Rails.application.routes.draw do
4
4
 
5
5
  namespace :casein do
6
6
 
7
- resources :users do
7
+ resources :admin_users do
8
8
  member do
9
9
  patch :update_password, :reset_password
10
10
  end
11
11
  end
12
12
 
13
- resource :user_session
13
+ resource :admin_user_session
14
14
  resource :password_reset, :only => [:create, :edit, :update]
15
15
 
16
16
  match "/blank" => "casein#blank", :via => :get
@@ -1,3 +1,9 @@
1
- require 'casein/engine' if defined?(Rails) && Rails::VERSION::MAJOR == 4
2
- require 'will_paginate'
3
- require 'authlogic'
1
+ if defined?(Rails) && Rails::VERSION::MAJOR == 4
2
+ require 'casein/engine'
3
+ require 'will_paginate'
4
+ require 'authlogic'
5
+ else
6
+ puts("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!")
7
+ puts("!!! WARNING !!! This version of Casein requires Rails 4.x !!!")
8
+ puts("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!")
9
+ end
@@ -4,8 +4,12 @@ require "rails"
4
4
  module Casein
5
5
  class Engine < Rails::Engine
6
6
 
7
+ config.after_initialize do
8
+ Rails.application.config.assets.paths << root.join("app", "assets", "fonts")
9
+ end
10
+
7
11
  initializer "casein.assets.precompile" do |app|
8
- app.config.assets.precompile += %w(casein/login.js casein/login.css casein/casein.css casein/casein.js casein/custom.css.scss casein/custom.js casein/*.png casein/login/*.png casein/icons/*.png)
12
+ app.config.assets.precompile += %w(casein/*.svg casein/*.eot casein/*.woff casein/*.ttf casein/login.css casein/casein.css casein/casein.js casein/html5shiv.js casein/custom.css casein/custom.js casein/*.png)
9
13
  end
10
14
 
11
15
  rake_tasks do
@@ -19,8 +19,8 @@ module Casein
19
19
  copy_file "app/helpers/casein/config_helper.rb", "app/helpers/casein/config_helper.rb"
20
20
 
21
21
  #initial view partials
22
- copy_file "app/views/casein/layouts/_left_navigation.html.erb", "app/views/casein/layouts/_left_navigation.html.erb"
23
- copy_file "app/views/casein/layouts/_right_navigation.html.erb", "app/views/casein/layouts/_right_navigation.html.erb"
22
+ copy_file "app/views/casein/layouts/_tab_navigation.html.erb", "app/views/casein/layouts/_tab_navigation.html.erb"
23
+ copy_file "app/views/casein/layouts/_top_navigation.html.erb", "app/views/casein/layouts/_top_navigation.html.erb"
24
24
 
25
25
  #robots.txt
26
26
  puts " ** Overwrite if you haven't yet modified your robots.txt, otherwise add disallow rules for /casein and /admin manually **"
@@ -31,7 +31,7 @@ module Casein
31
31
  copy_file "app/assets/javascripts/casein/custom.js", "app/assets/javascripts/casein/custom.js"
32
32
 
33
33
  #migrations
34
- migration_template 'db/migrate/casein_create_users.rb', "db/migrate/casein_create_users.rb"
34
+ migration_template 'db/migrate/casein_create_admin_users.rb', "db/migrate/casein_create_admin_users.rb"
35
35
  end
36
36
  end
37
37
  end
@@ -1,45 +1,44 @@
1
1
  module Casein
2
2
  module ConfigHelper
3
3
 
4
- # Text string containing the name of the website or client
5
- # Used in text and titles throughout Casein
4
+ # Name of website or client used throughout Casein.
6
5
  def casein_config_website_name
7
6
  'Casein'
8
7
  end
9
8
 
10
- # URL to the logo used for the login screen and top banner - it should be a transparent PNG
9
+ # Filename of logo image. Ideally, it should be a transparent PNG around 140x30px
11
10
  def casein_config_logo
12
11
  'casein/casein.png'
13
12
  end
14
13
 
15
14
  # The server hostname where Casein will run
16
15
  def casein_config_hostname
17
- if ENV['RAILS_ENV'] == 'production'
16
+ if Rails.env.production?
18
17
  'http://www.caseincms.com'
19
18
  else
20
19
  'http://0.0.0.0:3000'
21
20
  end
22
21
  end
23
22
 
24
- # The sender email address used for notifications
23
+ # The sender address used for email notifications
25
24
  def casein_config_email_from_address
26
25
  'donotreply@caseincms.com'
27
26
  end
28
27
 
29
- # The page that the user is shown when they login or click the logo
30
- # do not point this at casein/index!
28
+ # The initial page the user is shown after they sign in or click the logo. Probably this should be set to the first tab.
29
+ # Do not point this at casein/index!
31
30
  def casein_config_dashboard_url
32
31
  url_for :controller => :casein, :action => :blank
33
32
  end
34
33
 
35
- # A list of stylesheet files to include in the page head section
34
+ # A list of stylesheets to include. Do not remove the core casein/casein, but you can change the load order, if required.
36
35
  def casein_config_stylesheet_includes
37
- %w[casein/custom casein/casein]
36
+ %w[casein/casein casein/custom]
38
37
  end
39
38
 
40
- # A list of JavaScript files to include in the page head section
39
+ # A list of JavaScript files to include. Do not remove the core casein/casein, but you can change the load order, if required.
41
40
  def casein_config_javascript_includes
42
- %w[casein/custom casein/casein]
41
+ %w[casein/casein casein/custom]
43
42
  end
44
43
 
45
44
  end
@@ -0,0 +1,4 @@
1
+ <!-- NOTE: add "hidden-sm" class to li elements you want to be hidden at small browser widths -->
2
+ <!-- e.g. <li class="hidden-sm"><%= link_to "Visit site", casein_config_hostname, :target => "_blank" %></li> -->
3
+
4
+ <li><%= link_to "Visit site", casein_config_hostname, :target => "_blank" %></li>
@@ -1,7 +1,7 @@
1
- class CaseinCreateUsers < ActiveRecord::Migration
1
+ class CaseinCreateAdminUsers < ActiveRecord::Migration
2
2
 
3
3
  def self.up
4
- create_table :casein_users do |t|
4
+ create_table :casein_admin_users do |t|
5
5
  t.string :login, :null => false
6
6
  t.string :name
7
7
  t.string :email
@@ -24,7 +24,7 @@ class CaseinCreateUsers < ActiveRecord::Migration
24
24
  end
25
25
 
26
26
  def self.down
27
- drop_table :casein_users
27
+ drop_table :casein_admin_users
28
28
  end
29
29
 
30
30
  end
@@ -7,7 +7,7 @@ module Casein
7
7
 
8
8
  argument :attributes, :type => :array, :required => true, :desc => "attribute list required"
9
9
 
10
- class_options :create_model_and_migration => false, :force_plural => false
10
+ class_options :create_model_and_migration => false, :read_only => false, :no_index => false
11
11
 
12
12
  def self.next_migration_number dirname
13
13
  if ActiveRecord::Base.timestamped_migrations
@@ -19,17 +19,19 @@ module Casein
19
19
 
20
20
  def generate_files
21
21
  @plural_route = (plural_name != singular_name) ? plural_name : "#{plural_name}_index"
22
-
22
+ @read_only = options[:read_only]
23
+ @no_index = options[:no_index]
24
+
23
25
  template 'controller.rb', "app/controllers/casein/#{plural_name}_controller.rb"
24
- template 'views/index.html.erb', "app/views/casein/#{plural_name}/index.html.erb"
26
+ template 'views/index.html.erb', "app/views/casein/#{plural_name}/index.html.erb" unless @no_index
25
27
  template 'views/show.html.erb', "app/views/casein/#{plural_name}/show.html.erb"
26
- template 'views/new.html.erb', "app/views/casein/#{plural_name}/new.html.erb"
28
+ template 'views/new.html.erb', "app/views/casein/#{plural_name}/new.html.erb" unless @read_only
27
29
  template 'views/_form.html.erb', "app/views/casein/#{plural_name}/_form.html.erb"
28
30
  template 'views/_table.html.erb', "app/views/casein/#{plural_name}/_table.html.erb"
29
31
 
30
32
  add_namespace_to_routes
31
33
  add_to_routes
32
- add_to_navigation
34
+ add_to_navigation unless @no_index
33
35
 
34
36
  if options[:create_model_and_migration]
35
37
  template 'model.rb', "app/models/#{singular_name}.rb"
@@ -53,15 +55,25 @@ module Casein
53
55
  def add_to_routes
54
56
  puts " casein adding #{plural_name} resources to routes.rb"
55
57
  file_to_update = Rails.root + 'config/routes.rb'
56
- line_to_add = "resources :#{plural_name}"
58
+
59
+ if @no_index && @read_only
60
+ line_to_add = "resources :#{plural_name}, :only => [:show]"
61
+ elsif @no_index
62
+ line_to_add = "resources :#{plural_name}, :except => [:index]"
63
+ elsif @read_only
64
+ line_to_add = "resources :#{plural_name}, :only => [:index, :show]"
65
+ else
66
+ line_to_add = "resources :#{plural_name}"
67
+ end
68
+
57
69
  insert_sentinel = 'namespace :casein do'
58
70
  gsub_add_once plural_name, file_to_update, "\t\t" + line_to_add, insert_sentinel
59
71
  end
60
72
 
61
73
  def add_to_navigation
62
74
  puts " casein adding #{plural_name} to left navigation bar"
63
- file_to_update = Rails.root + 'app/views/casein/layouts/_left_navigation.html.erb'
64
- line_to_add = "<li id=\"visitSite\"><%= link_to \"#{plural_name.humanize.capitalize}\", casein_#{@plural_route}_path %></li>"
75
+ file_to_update = Rails.root + 'app/views/casein/layouts/_tab_navigation.html.erb'
76
+ line_to_add = "<li id=\"tab-#{@plural_route}\"><%= link_to \"#{plural_name.humanize.capitalize}\", casein_#{@plural_route}_path %></li>"
65
77
  insert_sentinel = '<!-- SCAFFOLD_INSERT -->'
66
78
  gsub_add_once plural_name, file_to_update, line_to_add, insert_sentinel
67
79
  end