Skip to content

Commit 49e4146

Browse files
committed
#85 hierapolis-rails added
1 parent 0de956e commit 49e4146

File tree

10 files changed

+247
-29
lines changed

10 files changed

+247
-29
lines changed

lib/cybele/app_builder.rb

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ def convert_application_css_to_sass
101101
end
102102

103103
def configure_smtp
104-
104+
remove_file 'config/settings/production.yml'
105105
copy_file 'config/settings/production.yml', 'config/settings/production.yml'
106106

107107
config = <<-RUBY
@@ -123,7 +123,7 @@ def setup_staging_environment
123123
email:
124124
125125
YML
126-
prepend_file 'config/setting.yml', config
126+
prepend_file 'config/settings.yml', config
127127
end
128128

129129
def configure_action_mailer
@@ -210,7 +210,7 @@ def generate_hq_namespace
210210
generate "devise Admin"
211211
create_namespace_routing('hq')
212212
directory 'app/controllers/hq', 'app/controllers/hq'
213-
template 'app/views/layouts/hq/base.html.haml.erb', 'app/views/layouts/hq/base.html.haml', force: true
213+
#template 'app/views/layouts/hq/base.html.haml.erb', 'app/views/layouts/hq/base.html.haml', force: true
214214
template 'app/views/hq/dashboard/index.html.haml.erb', 'app/views/hq/dashboard/index.html.haml', force: true
215215
directory 'app/views/hq/sessions', 'app/views/hq/sessions'
216216
gsub_file 'config/routes.rb', /devise_for :admins/, "devise_for :admins, controllers: {sessions: 'hq/sessions'}, path: 'hq',
@@ -224,6 +224,20 @@ def set_time_zone
224224
add_time_zone_to_user
225225
end
226226

227+
def create_hierapolis_theme
228+
remove_file 'lib/templates/rails/responders_controller/controller.rb'
229+
remove_file 'lib/templates/haml/scaffold/_form.html.haml'
230+
generate 'hierapolis:install'
231+
end
232+
233+
def replace_simple_form_wrapper
234+
remove_file 'config/initializers/simple_form.rb'
235+
remove_file 'config/initializers/simple_form_bootstrap.rb'
236+
237+
copy_file 'config/initializers/simple_form.rb', 'config/initializers/simple_form.rb'
238+
copy_file 'config/initializers/simple_form_bootstrap.rb', 'config/initializers/simple_form_bootstrap.rb'
239+
end
240+
227241
private
228242

229243
def action_mailer_host(rails_env, host)

lib/cybele/generators/app_generator.rb

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ def customization
2727
invoke :install_gems
2828
invoke :gitignore_files_and_folders
2929
invoke :setup_bootstrap_sass_coffee
30+
invoke :setup_rails_config
3031
invoke :configure_mail_setting
3132
invoke :setup_rspec
3233
invoke :setup_capybara
@@ -36,6 +37,7 @@ def customization
3637
invoke :setup_welcome_page
3738
invoke :setup_devise
3839
invoke :setup_time_zone
40+
invoke :setup_staging_environment
3941
invoke :goodbye
4042
end
4143

@@ -172,6 +174,14 @@ def goodbye
172174
def run_bundle
173175
end
174176

177+
def setup_hierapolis
178+
build :create_hierapolis_theme
179+
end
180+
181+
def setup_sipmle_form_wrapper
182+
build :replace_simple_form_wrapper
183+
end
184+
175185
protected
176186

177187
def get_builder_class

templates/app/assets/javascripts/application.js.coffee

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,5 @@
1414
#= require jquery_ujs
1515
#= require turbolinks
1616
#= require bootstrap
17+
#= require hierapolis
1718
#= require_tree .

templates/app/assets/stylesheets/application.css.sass

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,7 @@
1111
*= require_self
1212
*= require_tree .
1313
14-
@import "compass"
15-
@import "bootstrap"
16-
@import "bootstrap-responsive"
14+
@import "hierapolis"
1715

1816
body
1917
padding-top: 20px

templates/app/controllers/hq/base_controller.rb renamed to templates/app/controllers/hq/application_controller.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
require 'application_responder'
22

3-
class Hq::BaseController < ActionController::Base
3+
class Hq::ApplicationController < ActionController::Base
44
before_action :authenticate_admin!
55
self.responder = ApplicationResponder
66
respond_to :html, :json
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
class Hq::SessionsController < Devise::SessionsController
2-
2+
layout 'login'
33
end

templates/app/views/layouts/hq/base.html.haml.erb

Lines changed: 0 additions & 21 deletions
This file was deleted.
Lines changed: 142 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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 = :simple_form
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 the native HTML5 validations (novalidate form option).
110+
# These validations are enabled in SimpleForm's internal config but disabled by default
111+
# in this configuration, which is recommended due to some quirks from different browsers.
112+
# To stop SimpleForm from generating the novalidate option, enabling the HTML5 validations,
113+
# change this configuration to true.
114+
config.browser_validations = false
115+
116+
# Collection of methods to detect if a file type was given.
117+
# config.file_methods = [ :mounted_as, :file?, :public_filename ]
118+
119+
# Custom mappings for input types. This should be a hash containing a regexp
120+
# to match as key, and the input type that will be used when the field name
121+
# matches the regexp as value.
122+
# config.input_mappings = { /count/ => :integer }
123+
124+
# Custom wrappers for input types. This should be a hash containing an input
125+
# type as key and the wrapper that will be used for all inputs with specified type.
126+
# config.wrapper_mappings = { string: :prepend }
127+
128+
# Default priority for time_zone inputs.
129+
# config.time_zone_priority = nil
130+
131+
# Default priority for country inputs.
132+
# config.country_priority = nil
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
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
# Use this setup block to configure all options available in SimpleForm.
2+
# File Path: RAILS_ROOT/config/initializers/simple_form_bootstrap.rb
3+
SimpleForm.setup do |config|
4+
config.wrappers :bootstrap, tag: 'div', class: 'form-group', error_class: 'has-error' do |b|
5+
b.use :html5
6+
b.use :placeholder
7+
b.use :label, class: 'control-label'
8+
b.use :input
9+
b.use :error, wrap_with: { tag: 'span', class: 'help-block' }
10+
b.use :hint, wrap_with: { tag: 'p', class: 'help-block' }
11+
end
12+
13+
config.wrappers :prepend, tag: 'div', class: 'form-group', error_class: 'has-error' do |b|
14+
b.use :html5
15+
b.use :placeholder
16+
b.use :label, class: 'control-label'
17+
b.wrapper tag: 'div', class: 'input-group' do |input|
18+
input.wrapper tag: 'div', class: 'input-prepend' do |prepend|
19+
prepend.use :input
20+
end
21+
input.use :hint, wrap_with: { tag: 'span', class: 'help-block' }
22+
input.use :error, wrap_with: { tag: 'span', class: 'help-inline' }
23+
end
24+
end
25+
26+
config.wrappers :append, tag: 'div', class: 'form-group', error_class: 'has-error' do |b|
27+
b.use :html5
28+
b.use :placeholder
29+
b.use :label
30+
b.wrapper tag: 'div', class: 'input-group' do |input|
31+
input.wrapper tag: 'div', class: 'input-append' do |append|
32+
append.use :input
33+
end
34+
input.use :hint, wrap_with: { tag: 'span', class: 'help-block' }
35+
input.use :error, wrap_with: { tag: 'span', class: 'help-inline' }
36+
end
37+
end
38+
config.error_notification_class = 'alert alert-danger'
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
46+
47+
48+
inputs = %w[
49+
CollectionSelectInput
50+
DateTimeInput
51+
FileInput
52+
GroupedCollectionSelectInput
53+
NumericInput
54+
PasswordInput
55+
RangeInput
56+
StringInput
57+
TextInput
58+
]
59+
60+
inputs.each do |input_type|
61+
superclass = "SimpleForm::Inputs::#{input_type}".constantize
62+
63+
new_class = Class.new(superclass) do
64+
def input_html_classes
65+
super.push('form-control')
66+
end
67+
end
68+
69+
Object.const_set(input_type, new_class)
70+
end

templates/cybele_Gemfile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@ gem 'ransack'
3131

3232
# gem 'rails-observers'
3333

34+
gem 'hierapolis-rails', '~> 0.3.0'
35+
gem 'breadcrumbs_on_rails', '~> 2.3.0'
36+
gem 'blankable', '~> 0.2.0'
37+
3438
group :doc do
3539
gem 'sdoc', require: false
3640
end

0 commit comments

Comments
 (0)