brightcontent 2.0.0.alpha2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (178) hide show
  1. data/.gitignore +8 -0
  2. data/MIT-LICENSE +20 -0
  3. data/README.md +44 -0
  4. data/Rakefile +14 -0
  5. data/brightcontent.gemspec +21 -0
  6. data/core/.gitignore +9 -0
  7. data/core/Gemfile +17 -0
  8. data/core/Gemfile.lock +163 -0
  9. data/core/MIT-LICENSE +20 -0
  10. data/core/README.md +44 -0
  11. data/core/Rakefile +14 -0
  12. data/core/app/assets/images/brightcontent/.gitkeep +0 -0
  13. data/core/app/assets/images/brightcontent/glyphicons-halflings-white.png +0 -0
  14. data/core/app/assets/images/brightcontent/glyphicons-halflings.png +0 -0
  15. data/core/app/assets/javascripts/brightcontent/bootstrap.min.js +6 -0
  16. data/core/app/assets/javascripts/brightcontent/brightcontent.js +17 -0
  17. data/core/app/assets/javascripts/brightcontent/custom.js +1 -0
  18. data/core/app/assets/javascripts/brightcontent/main.js +3 -0
  19. data/core/app/assets/stylesheets/brightcontent/bootstrap-responsive.min.css +9 -0
  20. data/core/app/assets/stylesheets/brightcontent/bootstrap.min.css +9 -0
  21. data/core/app/assets/stylesheets/brightcontent/brightcontent.css +17 -0
  22. data/core/app/assets/stylesheets/brightcontent/custom.css +1 -0
  23. data/core/app/assets/stylesheets/brightcontent/main.css +44 -0
  24. data/core/app/controllers/brightcontent/admin_users_controller.rb +6 -0
  25. data/core/app/controllers/brightcontent/application_controller.rb +22 -0
  26. data/core/app/controllers/brightcontent/base_controller.rb +27 -0
  27. data/core/app/controllers/brightcontent/sessions_controller.rb +24 -0
  28. data/core/app/helpers/brightcontent/application_helper.rb +4 -0
  29. data/core/app/helpers/brightcontent/base_helper.rb +17 -0
  30. data/core/app/models/brightcontent/admin_user.rb +7 -0
  31. data/core/app/views/brightcontent/application/_menu.html.erb +3 -0
  32. data/core/app/views/brightcontent/application/_show_flash_names.html.erb +5 -0
  33. data/core/app/views/brightcontent/base/_form.html.erb +10 -0
  34. data/core/app/views/brightcontent/base/_list.html.erb +8 -0
  35. data/core/app/views/brightcontent/base/_list_actions.html.erb +2 -0
  36. data/core/app/views/brightcontent/base/edit.html.erb +3 -0
  37. data/core/app/views/brightcontent/base/index.html.erb +22 -0
  38. data/core/app/views/brightcontent/base/new.html.erb +3 -0
  39. data/core/app/views/brightcontent/sessions/new.html.erb +12 -0
  40. data/core/app/views/layouts/brightcontent/application.html.erb +53 -0
  41. data/core/brightcontent-core.gemspec +31 -0
  42. data/core/config/initializers/simple_form.rb +142 -0
  43. data/core/config/initializers/simple_form_bootstrap.rb +45 -0
  44. data/core/config/initializers/will_paginate.rb +28 -0
  45. data/core/config/routes.rb +9 -0
  46. data/core/db/migrate/20121206121725_create_brightcontent_admin_users.rb +12 -0
  47. data/core/lib/brightcontent/core/version.rb +5 -0
  48. data/core/lib/brightcontent/core.rb +32 -0
  49. data/core/lib/brightcontent/default_actions.rb +19 -0
  50. data/core/lib/brightcontent/engine.rb +9 -0
  51. data/core/lib/brightcontent/pagination.rb +24 -0
  52. data/core/lib/brightcontent/rails/routes.rb +16 -0
  53. data/core/lib/brightcontent/routes_parser.rb +38 -0
  54. data/core/lib/brightcontent-core.rb +1 -0
  55. data/core/lib/generators/brightcontent/install_generator.rb +34 -0
  56. data/core/lib/generators/brightcontent/resource_generator.rb +22 -0
  57. data/core/lib/generators/brightcontent/templates/brightcontent_controller.rb +2 -0
  58. data/core/lib/generators/brightcontent/templates/initializer.rb +8 -0
  59. data/core/script/rails +8 -0
  60. data/core/spec/dummy/README.rdoc +261 -0
  61. data/core/spec/dummy/Rakefile +7 -0
  62. data/core/spec/dummy/app/assets/javascripts/application.js +15 -0
  63. data/core/spec/dummy/app/assets/javascripts/brightcontent/custom.js +1 -0
  64. data/core/spec/dummy/app/assets/stylesheets/application.css +13 -0
  65. data/core/spec/dummy/app/assets/stylesheets/brightcontent/custom.css +1 -0
  66. data/core/spec/dummy/app/controllers/application_controller.rb +3 -0
  67. data/core/spec/dummy/app/controllers/brightcontent/blogs_controller.rb +2 -0
  68. data/core/spec/dummy/app/controllers/pages_controller.rb +8 -0
  69. data/core/spec/dummy/app/helpers/application_helper.rb +2 -0
  70. data/core/spec/dummy/app/mailers/.gitkeep +0 -0
  71. data/core/spec/dummy/app/models/.gitkeep +0 -0
  72. data/core/spec/dummy/app/models/blog.rb +3 -0
  73. data/core/spec/dummy/app/views/layouts/application.html.erb +14 -0
  74. data/core/spec/dummy/app/views/pages/index.html.erb +1 -0
  75. data/core/spec/dummy/config/application.rb +59 -0
  76. data/core/spec/dummy/config/boot.rb +10 -0
  77. data/core/spec/dummy/config/database.yml +25 -0
  78. data/core/spec/dummy/config/environment.rb +5 -0
  79. data/core/spec/dummy/config/environments/development.rb +37 -0
  80. data/core/spec/dummy/config/environments/production.rb +67 -0
  81. data/core/spec/dummy/config/environments/test.rb +37 -0
  82. data/core/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
  83. data/core/spec/dummy/config/initializers/brightcontent.rb +3 -0
  84. data/core/spec/dummy/config/initializers/inflections.rb +15 -0
  85. data/core/spec/dummy/config/initializers/mime_types.rb +5 -0
  86. data/core/spec/dummy/config/initializers/secret_token.rb +7 -0
  87. data/core/spec/dummy/config/initializers/session_store.rb +8 -0
  88. data/core/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
  89. data/core/spec/dummy/config/locales/en.yml +5 -0
  90. data/core/spec/dummy/config/routes.rb +7 -0
  91. data/core/spec/dummy/config.ru +4 -0
  92. data/core/spec/dummy/db/migrate/20121206225720_create_blogs.rb +10 -0
  93. data/core/spec/dummy/db/schema.rb +30 -0
  94. data/core/spec/dummy/lib/assets/.gitkeep +0 -0
  95. data/core/spec/dummy/public/404.html +26 -0
  96. data/core/spec/dummy/public/422.html +26 -0
  97. data/core/spec/dummy/public/500.html +25 -0
  98. data/core/spec/dummy/public/favicon.ico +0 -0
  99. data/core/spec/dummy/script/rails +6 -0
  100. data/core/spec/factories.rb +16 -0
  101. data/core/spec/features/login_spec.rb +29 -0
  102. data/core/spec/features/menu_spec.rb +27 -0
  103. data/core/spec/features/resources_form_spec.rb +51 -0
  104. data/core/spec/features/resources_index_spec.rb +50 -0
  105. data/core/spec/lib/brightcontent/routes_parser_spec.rb +34 -0
  106. data/core/spec/spec_helper.rb +18 -0
  107. data/core/spec/support/acceptance_helper.rb +8 -0
  108. data/lib/brightcontent.rb +2 -0
  109. data/lib/tasks/release.rake +0 -0
  110. data/lib/tasks/rspec.rake +5 -0
  111. data/pages/.gitignore +9 -0
  112. data/pages/Gemfile +5 -0
  113. data/pages/Gemfile.lock +173 -0
  114. data/pages/MIT-LICENSE +20 -0
  115. data/pages/README.md +35 -0
  116. data/pages/Rakefile +14 -0
  117. data/pages/app/assets/images/brightcontent/.gitkeep +0 -0
  118. data/pages/app/controllers/brightcontent/pages_controller.rb +16 -0
  119. data/pages/app/helpers/brightcontent/pages_helper.rb +13 -0
  120. data/pages/app/models/brightcontent/page.rb +27 -0
  121. data/pages/app/views/brightcontent/pages/_form_field_parent_id.html.erb +1 -0
  122. data/pages/app/views/brightcontent/pages/_list_field_name.html.erb +1 -0
  123. data/pages/brightcontent-pages.gemspec +26 -0
  124. data/pages/config/routes.rb +3 -0
  125. data/pages/db/migrate/20121207132810_create_brightcontent_pages.rb +16 -0
  126. data/pages/lib/brightcontent/pages/engine.rb +14 -0
  127. data/pages/lib/brightcontent/pages/methods.rb +9 -0
  128. data/pages/lib/brightcontent/pages/version.rb +5 -0
  129. data/pages/lib/brightcontent/pages.rb +10 -0
  130. data/pages/lib/brightcontent-pages.rb +1 -0
  131. data/pages/lib/generators/brightcontent/pages/install_generator.rb +15 -0
  132. data/pages/script/rails +8 -0
  133. data/pages/spec/dummy/README.rdoc +261 -0
  134. data/pages/spec/dummy/Rakefile +7 -0
  135. data/pages/spec/dummy/app/assets/javascripts/application.js +15 -0
  136. data/pages/spec/dummy/app/assets/javascripts/brightcontent/custom.js +1 -0
  137. data/pages/spec/dummy/app/assets/stylesheets/application.css +13 -0
  138. data/pages/spec/dummy/app/assets/stylesheets/brightcontent/custom.css +1 -0
  139. data/pages/spec/dummy/app/controllers/application_controller.rb +3 -0
  140. data/pages/spec/dummy/app/controllers/brightcontent/blogs_controller.rb +2 -0
  141. data/pages/spec/dummy/app/controllers/pages_controller.rb +8 -0
  142. data/pages/spec/dummy/app/helpers/application_helper.rb +2 -0
  143. data/pages/spec/dummy/app/mailers/.gitkeep +0 -0
  144. data/pages/spec/dummy/app/models/.gitkeep +0 -0
  145. data/pages/spec/dummy/app/models/blog.rb +3 -0
  146. data/pages/spec/dummy/app/views/layouts/application.html.erb +14 -0
  147. data/pages/spec/dummy/app/views/pages/index.html.erb +1 -0
  148. data/pages/spec/dummy/config/application.rb +59 -0
  149. data/pages/spec/dummy/config/boot.rb +10 -0
  150. data/pages/spec/dummy/config/database.yml +25 -0
  151. data/pages/spec/dummy/config/environment.rb +5 -0
  152. data/pages/spec/dummy/config/environments/development.rb +37 -0
  153. data/pages/spec/dummy/config/environments/production.rb +67 -0
  154. data/pages/spec/dummy/config/environments/test.rb +37 -0
  155. data/pages/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
  156. data/pages/spec/dummy/config/initializers/brightcontent.rb +3 -0
  157. data/pages/spec/dummy/config/initializers/inflections.rb +15 -0
  158. data/pages/spec/dummy/config/initializers/mime_types.rb +5 -0
  159. data/pages/spec/dummy/config/initializers/secret_token.rb +7 -0
  160. data/pages/spec/dummy/config/initializers/session_store.rb +8 -0
  161. data/pages/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
  162. data/pages/spec/dummy/config/locales/en.yml +5 -0
  163. data/pages/spec/dummy/config/routes.rb +6 -0
  164. data/pages/spec/dummy/config.ru +4 -0
  165. data/pages/spec/dummy/db/schema.rb +44 -0
  166. data/pages/spec/dummy/lib/assets/.gitkeep +0 -0
  167. data/pages/spec/dummy/public/404.html +26 -0
  168. data/pages/spec/dummy/public/422.html +26 -0
  169. data/pages/spec/dummy/public/500.html +25 -0
  170. data/pages/spec/dummy/public/favicon.ico +0 -0
  171. data/pages/spec/dummy/script/rails +6 -0
  172. data/pages/spec/factories.rb +16 -0
  173. data/pages/spec/features/menu_spec.rb +16 -0
  174. data/pages/spec/features/pages_spec.rb +18 -0
  175. data/pages/spec/models/brightcontent/page_spec.rb +49 -0
  176. data/pages/spec/spec_helper.rb +18 -0
  177. data/pages/spec/support/acceptance_helper.rb +8 -0
  178. metadata +253 -0
@@ -0,0 +1,142 @@
1
+ # Use this setup block to configure all options available in SimpleForm.
2
+ SimpleForm.setup do |config|
3
+ # Wrappers are used by the form builder to generate a
4
+ # complete input. You can remove any component from the
5
+ # wrapper, change the order or even add your own to the
6
+ # stack. The options given below are used to wrap the
7
+ # whole input.
8
+ config.wrappers :default, :class => :input,
9
+ :hint_class => :field_with_hint, :error_class => :field_with_errors do |b|
10
+ ## Extensions enabled by default
11
+ # Any of these extensions can be disabled for a
12
+ # given input by passing: `f.input EXTENSION_NAME => false`.
13
+ # You can make any of these extensions optional by
14
+ # renaming `b.use` to `b.optional`.
15
+
16
+ # Determines whether to use HTML5 (:email, :url, ...)
17
+ # and required attributes
18
+ b.use :html5
19
+
20
+ # Calculates placeholders automatically from I18n
21
+ # You can also pass a string as f.input :placeholder => "Placeholder"
22
+ b.use :placeholder
23
+
24
+ ## Optional extensions
25
+ # They are disabled unless you pass `f.input EXTENSION_NAME => :lookup`
26
+ # to the input. If so, they will retrieve the values from the model
27
+ # if any exists. If you want to enable the lookup for any of those
28
+ # extensions by default, you can change `b.optional` to `b.use`.
29
+
30
+ # Calculates maxlength from length validations for string inputs
31
+ b.optional :maxlength
32
+
33
+ # Calculates pattern from format validations for string inputs
34
+ b.optional :pattern
35
+
36
+ # Calculates min and max from length validations for numeric inputs
37
+ b.optional :min_max
38
+
39
+ # Calculates readonly automatically from readonly attributes
40
+ b.optional :readonly
41
+
42
+ ## Inputs
43
+ b.use :label_input
44
+ b.use :hint, :wrap_with => { :tag => :span, :class => :hint }
45
+ b.use :error, :wrap_with => { :tag => :span, :class => :error }
46
+ end
47
+
48
+ # The default wrapper to be used by the FormBuilder.
49
+ config.default_wrapper = :default
50
+
51
+ # Define the way to render check boxes / radio buttons with labels.
52
+ # Defaults to :nested for bootstrap config.
53
+ # :inline => input + label
54
+ # :nested => label > input
55
+ config.boolean_style = :nested
56
+
57
+ # Default class for buttons
58
+ config.button_class = 'btn'
59
+
60
+ # Method used to tidy up errors. Specify any Rails Array method.
61
+ # :first lists the first message for each field.
62
+ # Use :to_sentence to list all errors for each field.
63
+ # config.error_method = :first
64
+
65
+ # Default tag used for error notification helper.
66
+ config.error_notification_tag = :div
67
+
68
+ # CSS class to add for error notification helper.
69
+ config.error_notification_class = 'alert alert-error'
70
+
71
+ # ID to add for error notification helper.
72
+ # config.error_notification_id = nil
73
+
74
+ # Series of attempts to detect a default label method for collection.
75
+ # config.collection_label_methods = [ :to_label, :name, :title, :to_s ]
76
+
77
+ # Series of attempts to detect a default value method for collection.
78
+ # config.collection_value_methods = [ :id, :to_s ]
79
+
80
+ # You can wrap a collection of radio/check boxes in a pre-defined tag, defaulting to none.
81
+ # config.collection_wrapper_tag = nil
82
+
83
+ # You can define the class to use on all collection wrappers. Defaulting to none.
84
+ # config.collection_wrapper_class = nil
85
+
86
+ # You can wrap each item in a collection of radio/check boxes with a tag,
87
+ # defaulting to :span. Please note that when using :boolean_style = :nested,
88
+ # SimpleForm will force this option to be a label.
89
+ # config.item_wrapper_tag = :span
90
+
91
+ # You can define a class to use in all item wrappers. Defaulting to none.
92
+ # config.item_wrapper_class = nil
93
+
94
+ # How the label text should be generated altogether with the required text.
95
+ # config.label_text = lambda { |label, required| "#{required} #{label}" }
96
+
97
+ # You can define the class to use on all labels. Default is nil.
98
+ config.label_class = 'control-label'
99
+
100
+ # You can define the class to use on all forms. Default is simple_form.
101
+ config.form_class = 'form-horizontal'
102
+
103
+ # You can define which elements should obtain additional classes
104
+ # config.generate_additional_classes_for = [:wrapper, :label, :input]
105
+
106
+ # Whether attributes are required by default (or not). Default is true.
107
+ # config.required_by_default = true
108
+
109
+ # Tell browsers whether to use default HTML5 validations (novalidate option).
110
+ # Default is enabled.
111
+ config.browser_validations = false
112
+
113
+ # Collection of methods to detect if a file type was given.
114
+ # config.file_methods = [ :mounted_as, :file?, :public_filename ]
115
+
116
+ # Custom mappings for input types. This should be a hash containing a regexp
117
+ # to match as key, and the input type that will be used when the field name
118
+ # matches the regexp as value.
119
+ # config.input_mappings = { /count/ => :integer }
120
+
121
+ # Custom wrappers for input types. This should be a hash containing an input
122
+ # type as key and the wrapper that will be used for all inputs with specified type.
123
+ # config.wrapper_mappings = { :string => :prepend }
124
+
125
+ # Default priority for time_zone inputs.
126
+ # config.time_zone_priority = nil
127
+
128
+ # Default priority for country inputs.
129
+ # config.country_priority = nil
130
+
131
+ # Default size for text inputs.
132
+ # config.default_input_size = 50
133
+
134
+ # When false, do not use translations for labels.
135
+ # config.translate_labels = true
136
+
137
+ # Automatically discover new inputs in Rails' autoload path.
138
+ # config.inputs_discovery = true
139
+
140
+ # Cache SimpleForm inputs discovery
141
+ config.cache_discovery = !Rails.env.development?
142
+ end
@@ -0,0 +1,45 @@
1
+ # Use this setup block to configure all options available in SimpleForm.
2
+ SimpleForm.setup do |config|
3
+ config.wrappers :bootstrap, :tag => 'div', :class => 'control-group', :error_class => 'error' do |b|
4
+ b.use :html5
5
+ b.use :placeholder
6
+ b.use :label
7
+ b.wrapper :tag => 'div', :class => 'controls' do |ba|
8
+ ba.use :input
9
+ ba.use :error, :wrap_with => { :tag => 'span', :class => 'help-inline' }
10
+ ba.use :hint, :wrap_with => { :tag => 'p', :class => 'help-block' }
11
+ end
12
+ end
13
+
14
+ config.wrappers :prepend, :tag => 'div', :class => "control-group", :error_class => 'error' do |b|
15
+ b.use :html5
16
+ b.use :placeholder
17
+ b.use :label
18
+ b.wrapper :tag => 'div', :class => 'controls' do |input|
19
+ input.wrapper :tag => 'div', :class => 'input-prepend' do |prepend|
20
+ prepend.use :input
21
+ end
22
+ input.use :hint, :wrap_with => { :tag => 'span', :class => 'help-block' }
23
+ input.use :error, :wrap_with => { :tag => 'span', :class => 'help-inline' }
24
+ end
25
+ end
26
+
27
+ config.wrappers :append, :tag => 'div', :class => "control-group", :error_class => 'error' do |b|
28
+ b.use :html5
29
+ b.use :placeholder
30
+ b.use :label
31
+ b.wrapper :tag => 'div', :class => 'controls' do |input|
32
+ input.wrapper :tag => 'div', :class => 'input-append' do |append|
33
+ append.use :input
34
+ end
35
+ input.use :hint, :wrap_with => { :tag => 'span', :class => 'help-block' }
36
+ input.use :error, :wrap_with => { :tag => 'span', :class => 'help-inline' }
37
+ end
38
+ end
39
+
40
+ # Wrappers for forms and inputs using the Twitter Bootstrap toolkit.
41
+ # Check the Bootstrap docs (http://twitter.github.com/bootstrap)
42
+ # to learn about the different styles for forms and inputs,
43
+ # buttons and other elements.
44
+ config.default_wrapper = :bootstrap
45
+ end
@@ -0,0 +1,28 @@
1
+ module WillPaginate
2
+ module ActionView
3
+ def will_paginate(collection = nil, options = {})
4
+ options[:renderer] ||= BootstrapLinkRenderer
5
+ super.try :html_safe
6
+ end
7
+
8
+ class BootstrapLinkRenderer < LinkRenderer
9
+ protected
10
+
11
+ def html_container(html)
12
+ tag :div, tag(:ul, html), container_attributes
13
+ end
14
+
15
+ def page_number(page)
16
+ tag :li, link(page, page, :rel => rel_value(page)), :class => ('active' if page == current_page)
17
+ end
18
+
19
+ def previous_or_next_page(page, text, classname)
20
+ tag :li, link(text, page || '#'), :class => [classname[0..3], classname, ('disabled' unless page)].join(' ')
21
+ end
22
+
23
+ def gap
24
+ tag :li, link(super, '#'), :class => 'disabled'
25
+ end
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,9 @@
1
+ Brightcontent::Engine.routes.draw do
2
+ get 'login', to: 'sessions#new'
3
+ get 'logout', to: 'sessions#destroy'
4
+
5
+ resources :admin_users
6
+ resources :sessions, only: [:new, :create, :destroy]
7
+
8
+ root to: "admin_users#index"
9
+ end
@@ -0,0 +1,12 @@
1
+ class CreateBrightcontentAdminUsers < ActiveRecord::Migration
2
+ def change
3
+ create_table :brightcontent_admin_users do |t|
4
+ t.string :email
5
+ t.string :password_digest
6
+
7
+ t.timestamps
8
+ end
9
+
10
+ Brightcontent::AdminUser.create!(:email => 'admin@example.com', :password => 'password')
11
+ end
12
+ end
@@ -0,0 +1,5 @@
1
+ module Brightcontent
2
+ module Core
3
+ VERSION = "2.0.0.alpha2"
4
+ end
5
+ end
@@ -0,0 +1,32 @@
1
+ require "inherited_resources"
2
+ require "simple_form"
3
+ require "jquery-rails"
4
+ require "will_paginate"
5
+ require "bootstrap-wysihtml5-rails"
6
+
7
+ require "brightcontent/rails/routes"
8
+ require "brightcontent/engine"
9
+
10
+ module Brightcontent
11
+
12
+ autoload :Pagination, 'brightcontent/pagination'
13
+ autoload :PageMethods, 'brightcontent/page_methods'
14
+ autoload :RoutesParser, 'brightcontent/routes_parser'
15
+ autoload :DefaultActions, 'brightcontent/default_actions'
16
+
17
+ mattr_accessor :engine_resources
18
+ @@engine_resources = %w{sessions admin_users}
19
+
20
+ mattr_accessor :path
21
+ @@path = "admin"
22
+
23
+ mattr_accessor :application_name
24
+ @@application_name = "Brightcontent"
25
+
26
+ # Default way to setup Brightcontent.
27
+ # Run rails g brightcontent:install to create initializer
28
+ def self.setup
29
+ yield self
30
+ end
31
+
32
+ end
@@ -0,0 +1,19 @@
1
+ module Brightcontent
2
+ module DefaultActions
3
+ def show
4
+ redirect_to action: :edit
5
+ end
6
+
7
+ def create
8
+ create! { polymorphic_url(resource_class) }
9
+ end
10
+
11
+ def update
12
+ update! { polymorphic_url(resource_class) }
13
+ end
14
+
15
+ def destroy
16
+ destroy! { polymorphic_url(resource_class) }
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,9 @@
1
+ module Brightcontent
2
+ class Engine < ::Rails::Engine
3
+ isolate_namespace Brightcontent
4
+
5
+ initializer "Brightcontent precompile hook", :group => :all do |app|
6
+ app.config.assets.precompile += ['brightcontent/brightcontent.js', 'brightcontent/brightcontent.css']
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,24 @@
1
+ require 'active_support/concern'
2
+
3
+ module Brightcontent
4
+ module Pagination
5
+ extend ActiveSupport::Concern
6
+
7
+ module ClassMethods
8
+ def per_page(number)
9
+ @per_page_count = number
10
+ end
11
+
12
+ def per_page_count
13
+ @per_page_count || 30
14
+ end
15
+ end
16
+
17
+ private
18
+
19
+ def end_of_association_chain
20
+ super.paginate(page: params[:page], per_page: self.class.per_page_count)
21
+ end
22
+
23
+ end
24
+ end
@@ -0,0 +1,16 @@
1
+ module ActionDispatch::Routing
2
+ class Mapper
3
+ def brightcontent_resources(&block)
4
+ define_user_resources(block) if block_given?
5
+ mount Brightcontent::Engine => Brightcontent.path
6
+ end
7
+
8
+ private
9
+
10
+ def define_user_resources(block)
11
+ Brightcontent::Engine.routes.draw do
12
+ instance_eval &block
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,38 @@
1
+ require 'active_support/inflector'
2
+
3
+ module Brightcontent
4
+ class RoutesParser
5
+
6
+ def self.parse(routes_hash=nil, engine_resources=nil)
7
+ new(routes_hash, engine_resources).user_resource
8
+ end
9
+
10
+ def initialize(routes_hash=nil, engine_resources=nil)
11
+ @routes_hash = routes_hash
12
+ @engine_resources = engine_resources
13
+ end
14
+
15
+ def user_resource
16
+ resource_names - engine_resources
17
+ end
18
+
19
+ private
20
+
21
+ def resource_names
22
+ routes_hash.map do |route|
23
+ if route && route[:action] == "index"
24
+ route[:controller].match(/brightcontent\/(.+)/)[1]
25
+ end
26
+ end.compact
27
+ end
28
+
29
+ def routes_hash
30
+ @routes_hash ||= Engine.routes.routes.map(&:defaults)
31
+ end
32
+
33
+ def engine_resources
34
+ @engine_resources ||= Brightcontent.engine_resources
35
+ end
36
+
37
+ end
38
+ end
@@ -0,0 +1 @@
1
+ require 'brightcontent/core'
@@ -0,0 +1,34 @@
1
+ module Brightcontent
2
+ module Generators
3
+ class InstallGenerator < Rails::Generators::Base
4
+ source_root File.expand_path("../templates", __FILE__)
5
+
6
+ desc "Creates a Brightcontent initializer, copy migrations, edit routes file"
7
+
8
+ def copy_initializer
9
+ template "initializer.rb", "config/initializers/brightcontent.rb"
10
+ end
11
+
12
+ def copy_migrations
13
+ rake "brightcontent:install:migrations"
14
+ end
15
+
16
+ def add_routes
17
+ route "brightcontent_resources do\n" \
18
+ " #resources :vacancies #for example\n" \
19
+ " end"
20
+ end
21
+
22
+ def copy_custom_assets
23
+ copy_file "../../../../app/assets/stylesheets/brightcontent/custom.css", "app/assets/stylesheets/brightcontent/custom.css"
24
+ copy_file "../../../../app/assets/javascripts/brightcontent/custom.js", "app/assets/javascripts/brightcontent/custom.js"
25
+ end
26
+
27
+ def setup_directory
28
+ empty_directory "app/controllers/brightcontent"
29
+ empty_directory "app/views/brightcontent"
30
+ end
31
+
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,22 @@
1
+ module Brightcontent
2
+ module Generators
3
+ class ResourceGenerator < Rails::Generators::NamedBase
4
+ source_root File.expand_path("../templates", __FILE__)
5
+
6
+ desc "Creates Brightcontent controller, route and empty views dir"
7
+
8
+ def generate_controller
9
+ template "brightcontent_controller.rb", "app/controllers/brightcontent/#{@name.pluralize.underscore}_controller.rb"
10
+ end
11
+
12
+ def generate_views_directory
13
+ empty_directory "app/views/brightcontent/#{name.pluralize.underscore}"
14
+ end
15
+
16
+ def add_route
17
+ inject_into_file 'config/routes.rb', "\n resources :#{name.pluralize.underscore}", { :after => "brightcontent_resources do" }
18
+ end
19
+
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,2 @@
1
+ class Brightcontent::<%= name.capitalize.pluralize %>Controller < Brightcontent::BaseController
2
+ end
@@ -0,0 +1,8 @@
1
+ Brightcontent.setup do |config|
2
+ # The path where the admin interface should mount.
3
+ config.path = "admin"
4
+
5
+ # Name of the application which is displayed in header
6
+ # Defaults to Rails application name
7
+ # config.application_name = "Custom app name"
8
+ end
data/core/script/rails ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env ruby
2
+ # This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
3
+
4
+ ENGINE_ROOT = File.expand_path('../..', __FILE__)
5
+ ENGINE_PATH = File.expand_path('../../lib/brightcontent/engine', __FILE__)
6
+
7
+ require 'rails/all'
8
+ require 'rails/engine/commands'