openshift-origin-console 1.3.2
Sign up to get free protection for your applications and to get access to all the features.
- data/COPYRIGHT +1 -0
- data/Gemfile +21 -0
- data/LICENSE +203 -0
- data/README.md +123 -0
- data/Rakefile +44 -0
- data/app/assets/images/cartridge-edge.gif +0 -0
- data/app/assets/images/console/arrow-down.png +0 -0
- data/app/assets/images/console/console-sprite.png +0 -0
- data/app/assets/images/favicon-32.png +0 -0
- data/app/assets/images/loader-dark.gif +0 -0
- data/app/assets/images/loader.gif +0 -0
- data/app/assets/images/sprite-vert.png +0 -0
- data/app/assets/javascripts/console.js +10 -0
- data/app/assets/javascripts/console/form.js.coffee +51 -0
- data/app/assets/stylesheets/_alerts.scss +84 -0
- data/app/assets/stylesheets/_breadcrumbs.scss +31 -0
- data/app/assets/stylesheets/_buttons.scss +229 -0
- data/app/assets/stylesheets/_code.scss +86 -0
- data/app/assets/stylesheets/_custom.scss +207 -0
- data/app/assets/stylesheets/_footer.scss +54 -0
- data/app/assets/stylesheets/_forms.scss +710 -0
- data/app/assets/stylesheets/_grid.scss +28 -0
- data/app/assets/stylesheets/_input-prepend-append.scss +138 -0
- data/app/assets/stylesheets/_labels.scss +40 -0
- data/app/assets/stylesheets/_mixins.scss +76 -0
- data/app/assets/stylesheets/_override-variables.scss +1 -0
- data/app/assets/stylesheets/_responsive.scss +438 -0
- data/app/assets/stylesheets/_ribbon.scss +57 -0
- data/app/assets/stylesheets/_type.scss +306 -0
- data/app/assets/stylesheets/_utilities.scss +10 -0
- data/app/assets/stylesheets/_variables.scss +131 -0
- data/app/assets/stylesheets/common.css.scss +82 -0
- data/app/assets/stylesheets/console/_application.scss +194 -0
- data/app/assets/stylesheets/console/_base.scss +26 -0
- data/app/assets/stylesheets/console/_breadcrumbs.scss +32 -0
- data/app/assets/stylesheets/console/_buttons.scss +214 -0
- data/app/assets/stylesheets/console/_core.scss +1002 -0
- data/app/assets/stylesheets/console/_dropdowns.scss +63 -0
- data/app/assets/stylesheets/console/_help.scss +54 -0
- data/app/assets/stylesheets/console/_mixins.scss +11 -0
- data/app/assets/stylesheets/console/_navbar.scss +415 -0
- data/app/assets/stylesheets/console/_ribbon.scss +82 -0
- data/app/assets/stylesheets/console/_tile.scss +122 -0
- data/app/assets/stylesheets/origin.css.scss +37 -0
- data/app/controllers/account/dashboard.rb +13 -0
- data/app/controllers/account_controller.rb +3 -0
- data/app/controllers/application_types_controller.rb +80 -0
- data/app/controllers/applications_controller.rb +183 -0
- data/app/controllers/building_controller.rb +81 -0
- data/app/controllers/capability_aware.rb +18 -0
- data/app/controllers/cartridge_types_controller.rb +53 -0
- data/app/controllers/cartridges_controller.rb +43 -0
- data/app/controllers/console/auth/basic.rb +65 -0
- data/app/controllers/console/auth/none.rb +5 -0
- data/app/controllers/console/auth/remote_user.rb +69 -0
- data/app/controllers/console/rescue.rb +48 -0
- data/app/controllers/console_controller.rb +19 -0
- data/app/controllers/console_index_controller.rb +14 -0
- data/app/controllers/domain_aware.rb +26 -0
- data/app/controllers/domain_session_sweeper.rb +29 -0
- data/app/controllers/domains_controller.rb +30 -0
- data/app/controllers/keys_controller.rb +43 -0
- data/app/controllers/scaling_controller.rb +46 -0
- data/app/controllers/sshkey_aware.rb +23 -0
- data/app/controllers/sshkey_session_sweeper.rb +29 -0
- data/app/controllers/user_session_sweeper.rb +29 -0
- data/app/helpers/console/community_helper.rb +78 -0
- data/app/helpers/console/console_helper.rb +26 -0
- data/app/helpers/console/help_helper.rb +270 -0
- data/app/helpers/console/html5_boilerplate_helper.rb +63 -0
- data/app/helpers/console/layout_helper.rb +277 -0
- data/app/helpers/console/model_helper.rb +106 -0
- data/app/helpers/console/secured_helper.rb +5 -0
- data/app/models/alias.rb +10 -0
- data/app/models/application.rb +148 -0
- data/app/models/application_associations.rb +36 -0
- data/app/models/application_template.rb +90 -0
- data/app/models/application_type.rb +258 -0
- data/app/models/async_aware.rb +60 -0
- data/app/models/capabilities.rb +62 -0
- data/app/models/cartridge.rb +122 -0
- data/app/models/cartridge_type.rb +140 -0
- data/app/models/domain.rb +44 -0
- data/app/models/domain_associations.rb +33 -0
- data/app/models/embedded.rb +11 -0
- data/app/models/gear.rb +13 -0
- data/app/models/gear_group.rb +104 -0
- data/app/models/key.rb +87 -0
- data/app/models/quickstart.rb +135 -0
- data/app/models/rest_api.rb +130 -0
- data/app/models/rest_api/base.rb +781 -0
- data/app/models/rest_api/cacheable.rb +91 -0
- data/app/models/rest_api/environment.rb +13 -0
- data/app/models/rest_api/info.rb +34 -0
- data/app/models/rest_api/log_subscriber.rb +29 -0
- data/app/models/rest_api/railties/controller_runtime.rb +37 -0
- data/app/models/user.rb +27 -0
- data/app/models/user_associations.rb +6 -0
- data/app/views/account/_domain.html.haml +14 -0
- data/app/views/account/_keys.html.haml +20 -0
- data/app/views/account/_user.html.haml +5 -0
- data/app/views/account/show.html.haml +15 -0
- data/app/views/application_templates/_application_template.html.haml +5 -0
- data/app/views/application_types/_application_type.html.haml +19 -0
- data/app/views/application_types/_custom.html.haml +19 -0
- data/app/views/application_types/_persisted.html.haml +26 -0
- data/app/views/application_types/_tile.html.haml +9 -0
- data/app/views/application_types/index.html.haml +87 -0
- data/app/views/application_types/search.html.haml +67 -0
- data/app/views/application_types/show.html.haml +219 -0
- data/app/views/applications/_application.html.haml +34 -0
- data/app/views/applications/_applications_filter.html.haml +8 -0
- data/app/views/applications/_footer.html.haml +0 -0
- data/app/views/applications/_name.html.haml +28 -0
- data/app/views/applications/delete.html.haml +19 -0
- data/app/views/applications/get_started.html.haml +145 -0
- data/app/views/applications/index.html.haml +55 -0
- data/app/views/applications/show.html.haml +193 -0
- data/app/views/building/delete.html.haml +22 -0
- data/app/views/building/new.html.haml +57 -0
- data/app/views/building/show.html.haml +12 -0
- data/app/views/cartridge_types/_cartridge_type.html.haml +61 -0
- data/app/views/cartridge_types/index.html.haml +37 -0
- data/app/views/cartridge_types/show.html.haml +21 -0
- data/app/views/cartridges/next_steps.html.haml +58 -0
- data/app/views/cartridges/show.html.haml +1 -0
- data/app/views/console/error.html.haml +58 -0
- data/app/views/console/help.html.haml +90 -0
- data/app/views/console/not_found.html.haml +69 -0
- data/app/views/console/unauthorized.html.haml +7 -0
- data/app/views/domains/_domain.html.haml +14 -0
- data/app/views/domains/_form.html.haml +13 -0
- data/app/views/domains/edit.html.haml +5 -0
- data/app/views/domains/new.html.haml +6 -0
- data/app/views/keys/_form.html.haml +14 -0
- data/app/views/keys/_simple_form.html.haml +14 -0
- data/app/views/keys/new.html.haml +2 -0
- data/app/views/layouts/_footer.html.haml +38 -0
- data/app/views/layouts/_head.html.haml +35 -0
- data/app/views/layouts/console.html.haml +60 -0
- data/app/views/layouts/console/_header.html.haml +44 -0
- data/app/views/layouts/console/_identity.html.haml +7 -0
- data/app/views/layouts/console/_javascripts.html.haml +5 -0
- data/app/views/layouts/console/_stylesheets.html.haml +6 -0
- data/app/views/scaling/delete.html.haml +17 -0
- data/app/views/scaling/new.html.haml +24 -0
- data/app/views/scaling/show.html.haml +81 -0
- data/app/views/shared/_tracking.html.haml +0 -0
- data/conf/console.conf.example +108 -0
- data/conf/openshift_console.conf +10 -0
- data/config/cartridge_types.yml +54 -0
- data/config/initializers/barista_config.rb +86 -0
- data/config/initializers/cartridge_types.rb +5 -0
- data/config/initializers/console_security.rb +1 -0
- data/config/initializers/date_helper.rb +5 -0
- data/config/initializers/extended_logger.rb +51 -0
- data/config/initializers/formtastic.rb +100 -0
- data/config/initializers/inflections.rb +38 -0
- data/config/initializers/rdiscount.rb +8 -0
- data/config/initializers/rest_api.rb +22 -0
- data/config/initializers/sass.rb +30 -0
- data/config/initializers/session_trace.rb +32 -0
- data/config/initializers/x_frame_options.rb +53 -0
- data/config/locales/en.yml +12 -0
- data/lib/active_resource/associations.rb +107 -0
- data/lib/active_resource/associations/builder/association.rb +35 -0
- data/lib/active_resource/associations/builder/belongs_to.rb +5 -0
- data/lib/active_resource/associations/builder/has_many.rb +5 -0
- data/lib/active_resource/associations/builder/has_one.rb +5 -0
- data/lib/active_resource/persistent_connection.rb +341 -0
- data/lib/active_resource/persistent_http_mock.rb +68 -0
- data/lib/active_resource/reflection.rb +78 -0
- data/lib/console.rb +8 -0
- data/lib/console/config_file.rb +13 -0
- data/lib/console/configuration.rb +163 -0
- data/lib/console/engine.rb +28 -0
- data/lib/console/formtastic/bootstrap_form_builder.rb +369 -0
- data/lib/console/rails/app_redirector.rb +40 -0
- data/lib/console/rails/filter_hash.rb +15 -0
- data/lib/console/rails/routes.rb +51 -0
- data/lib/console/version.rb +5 -0
- data/lib/tasks/assets.rake +79 -0
- data/lib/tasks/stats.rake +18 -0
- data/lib/tasks/test_suites.rake +73 -0
- data/test/coverage_helper.rb +27 -0
- data/test/fixtures/cartridges.json +1 -0
- data/test/fixtures/quickstarts.csv +3 -0
- data/test/functional/account_controller_test.rb +14 -0
- data/test/functional/application_types_controller_test.rb +251 -0
- data/test/functional/applications_controller_sanity_test.rb +26 -0
- data/test/functional/applications_controller_test.rb +365 -0
- data/test/functional/building_controller_test.rb +203 -0
- data/test/functional/cartridge_types_controller_isolation_test.rb +68 -0
- data/test/functional/cartridge_types_controller_test.rb +48 -0
- data/test/functional/cartridges_controller_test.rb +83 -0
- data/test/functional/console_auth_basic_controller_test.rb +82 -0
- data/test/functional/console_auth_remote_user_controller_test.rb +90 -0
- data/test/functional/console_index_controller_test.rb +22 -0
- data/test/functional/domains_controller_test.rb +194 -0
- data/test/functional/keys_controller_test.rb +163 -0
- data/test/functional/quickstarts.json +18 -0
- data/test/functional/scaling_controller_test.rb +153 -0
- data/test/integration/assets_test.rb +34 -0
- data/test/integration/help_link_test.rb +43 -0
- data/test/integration/quickstarts_test.rb +24 -0
- data/test/integration/rescue_from_test.rb +25 -0
- data/test/integration/rest_api/application_test.rb +115 -0
- data/test/integration/rest_api/cartridge_test.rb +44 -0
- data/test/integration/rest_api/cartridge_type_test.rb +143 -0
- data/test/integration/rest_api/domain_test.rb +91 -0
- data/test/integration/rest_api/info_test.rb +9 -0
- data/test/integration/rest_api/key_test.rb +85 -0
- data/test/integration/static_pages_test.rb +44 -0
- data/test/rails_app/Rakefile +7 -0
- data/test/rails_app/app/controllers/application_controller.rb +5 -0
- data/test/rails_app/config.ru +4 -0
- data/test/rails_app/config/application.rb +48 -0
- data/test/rails_app/config/boot.rb +10 -0
- data/test/rails_app/config/database.yml +25 -0
- data/test/rails_app/config/environment.rb +5 -0
- data/test/rails_app/config/environments/development.rb +38 -0
- data/test/rails_app/config/environments/production.rb +70 -0
- data/test/rails_app/config/environments/test.rb +43 -0
- data/test/rails_app/config/initializers/auth.rb +0 -0
- data/test/rails_app/config/initializers/backtrace_silencers.rb +7 -0
- data/test/rails_app/config/initializers/inflections.rb +10 -0
- data/test/rails_app/config/initializers/mime_types.rb +5 -0
- data/test/rails_app/config/initializers/secret_token.rb +7 -0
- data/test/rails_app/config/initializers/session_store.rb +8 -0
- data/test/rails_app/config/locales/en.yml +5 -0
- data/test/rails_app/config/routes.rb +4 -0
- data/test/rails_app/script/rails +6 -0
- data/test/support/auth.rb +111 -0
- data/test/support/base.rb +142 -0
- data/test/support/errors.rb +28 -0
- data/test/support/rest_api.rb +189 -0
- data/test/test_helper.rb +14 -0
- data/test/unit/active_model_compliance_test.rb +23 -0
- data/test/unit/async_aware_test.rb +55 -0
- data/test/unit/configuration_test.rb +158 -0
- data/test/unit/filter_hash_test.rb +64 -0
- data/test/unit/helpers/model_helper_test.rb +61 -0
- data/test/unit/overrides_test.rb +9 -0
- data/test/unit/rest_api_test.rb +1590 -0
- data/vendor/assets/javascripts/MIT-LICENSE.txt +20 -0
- data/vendor/assets/javascripts/bootstrap-collapse.js +157 -0
- data/vendor/assets/javascripts/bootstrap-dropdown.js +100 -0
- data/vendor/assets/javascripts/bootstrap-tab.js +135 -0
- data/vendor/assets/javascripts/bootstrap-transition.js +61 -0
- data/vendor/assets/javascripts/jquery.spin.js +47 -0
- data/vendor/assets/javascripts/jquery.ui.widget.js +16 -0
- data/vendor/assets/javascripts/jquery_cookie.js +41 -0
- data/vendor/assets/javascripts/jquery_validate_min.js +51 -0
- data/vendor/assets/javascripts/modernizr.min.js +2 -0
- data/vendor/assets/javascripts/plugins.js +16 -0
- data/vendor/assets/stylesheets/bootstrap/_accordion.scss +28 -0
- data/vendor/assets/stylesheets/bootstrap/_alerts.scss +70 -0
- data/vendor/assets/stylesheets/bootstrap/_breadcrumbs.scss +22 -0
- data/vendor/assets/stylesheets/bootstrap/_button-groups.scss +147 -0
- data/vendor/assets/stylesheets/bootstrap/_buttons.scss +183 -0
- data/vendor/assets/stylesheets/bootstrap/_carousel.scss +121 -0
- data/vendor/assets/stylesheets/bootstrap/_close.scss +18 -0
- data/vendor/assets/stylesheets/bootstrap/_code.scss +57 -0
- data/vendor/assets/stylesheets/bootstrap/_component-animations.scss +18 -0
- data/vendor/assets/stylesheets/bootstrap/_dropdowns.scss +130 -0
- data/vendor/assets/stylesheets/bootstrap/_forms.scss +522 -0
- data/vendor/assets/stylesheets/bootstrap/_grid.scss +8 -0
- data/vendor/assets/stylesheets/bootstrap/_hero-unit.scss +20 -0
- data/vendor/assets/stylesheets/bootstrap/_labels.scss +32 -0
- data/vendor/assets/stylesheets/bootstrap/_layouts.scss +17 -0
- data/vendor/assets/stylesheets/bootstrap/_mixins.scss +602 -0
- data/vendor/assets/stylesheets/bootstrap/_modals.scss +84 -0
- data/vendor/assets/stylesheets/bootstrap/_navbar.scss +299 -0
- data/vendor/assets/stylesheets/bootstrap/_navs.scss +353 -0
- data/vendor/assets/stylesheets/bootstrap/_pager.scss +30 -0
- data/vendor/assets/stylesheets/bootstrap/_pagination.scss +55 -0
- data/vendor/assets/stylesheets/bootstrap/_popovers.scss +49 -0
- data/vendor/assets/stylesheets/bootstrap/_progress-bars.scss +95 -0
- data/vendor/assets/stylesheets/bootstrap/_reset.scss +126 -0
- data/vendor/assets/stylesheets/bootstrap/_scaffolding.scss +33 -0
- data/vendor/assets/stylesheets/bootstrap/_sprites.scss +158 -0
- data/vendor/assets/stylesheets/bootstrap/_tables.scss +150 -0
- data/vendor/assets/stylesheets/bootstrap/_thumbnails.scss +35 -0
- data/vendor/assets/stylesheets/bootstrap/_tooltip.scss +35 -0
- data/vendor/assets/stylesheets/bootstrap/_type.scss +218 -0
- data/vendor/assets/stylesheets/bootstrap/_utilities.scss +23 -0
- data/vendor/assets/stylesheets/bootstrap/_variables.scss +107 -0
- data/vendor/assets/stylesheets/bootstrap/_wells.scss +17 -0
- data/vendor/assets/stylesheets/bootstrap/bootstrap.scss +66 -0
- data/vendor/assets/stylesheets/bootstrap/responsive.scss +334 -0
- metadata +506 -0
@@ -0,0 +1,63 @@
|
|
1
|
+
module Console::Html5BoilerplateHelper
|
2
|
+
# Create a named haml tag to wrap IE conditional around a block
|
3
|
+
# http://paulirish.com/2008/conditional-stylesheets-vs-css-hacks-answer-neither
|
4
|
+
def ie_tag(name=:body, attrs={}, &block)
|
5
|
+
attrs.symbolize_keys!
|
6
|
+
haml_concat("<!--[if lt IE 7]> #{ tag(name, add_class('ie6', attrs), true) } <![endif]-->".html_safe)
|
7
|
+
haml_concat("<!--[if IE 7]> #{ tag(name, add_class('ie7', attrs), true) } <![endif]-->".html_safe)
|
8
|
+
haml_concat("<!--[if IE 8]> #{ tag(name, add_class('ie8', attrs), true) } <![endif]-->".html_safe)
|
9
|
+
haml_concat("<!--[if IE 9]> #{ tag(name, add_class('ie9', attrs), true) } <![endif]-->".html_safe)
|
10
|
+
haml_concat("<!--[if gt IE 8]><!-->".html_safe)
|
11
|
+
haml_tag name, attrs do
|
12
|
+
haml_concat("<!--<![endif]-->".html_safe)
|
13
|
+
block.call
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
def ie_html(attrs={}, &block)
|
18
|
+
ie_tag(:html, attrs, &block)
|
19
|
+
end
|
20
|
+
|
21
|
+
def ie_body(attrs={}, &block)
|
22
|
+
ie_tag(:body, attrs, &block)
|
23
|
+
end
|
24
|
+
|
25
|
+
def google_account_id
|
26
|
+
ENV['GOOGLE_ACCOUNT_ID'] || google_config(:google_account_id)
|
27
|
+
end
|
28
|
+
|
29
|
+
def google_api_key
|
30
|
+
ENV['GOOGLE_API_KEY'] || google_config(:google_api_key)
|
31
|
+
end
|
32
|
+
|
33
|
+
def remote_jquery(version)
|
34
|
+
if Rails.env == 'development'
|
35
|
+
"'jquery', '#{version}', {uncompressed:true}"
|
36
|
+
else
|
37
|
+
"'jquery', '#{version}'"
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
def local_jquery(version)
|
42
|
+
if Rails.env == 'development'
|
43
|
+
"#{version}/jquery.js"
|
44
|
+
else
|
45
|
+
"#{version}/jquery.min.js"
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
private
|
50
|
+
|
51
|
+
def add_class(name, attrs)
|
52
|
+
classes = attrs[:class] || ''
|
53
|
+
classes.strip!
|
54
|
+
classes = ' ' + classes if !classes.blank?
|
55
|
+
classes = name + classes
|
56
|
+
attrs.merge(:class => classes)
|
57
|
+
end
|
58
|
+
|
59
|
+
def google_config(key)
|
60
|
+
configs = YAML.load_file(File.join(Rails.root, 'config', 'google.yml'))[Rails.env.to_sym] rescue {}
|
61
|
+
configs[key]
|
62
|
+
end
|
63
|
+
end
|
@@ -0,0 +1,277 @@
|
|
1
|
+
require 'enumerator'
|
2
|
+
|
3
|
+
module Console::LayoutHelper
|
4
|
+
|
5
|
+
def in_columns_of(count, arr)
|
6
|
+
arr.enum_for(:each_with_index).inject(Array.new(count) {[]}){ |a, (item,i)| a[i % count] << item; a }
|
7
|
+
end
|
8
|
+
|
9
|
+
def in_balanced_columns_of(count, groups)
|
10
|
+
columns = Array.new(count){ [] }
|
11
|
+
counts = Array.new(count,0)
|
12
|
+
groups.each do |group|
|
13
|
+
column = counts.index(counts.min)
|
14
|
+
columns[column] << group
|
15
|
+
counts[column] += group[1].size
|
16
|
+
end
|
17
|
+
columns
|
18
|
+
end
|
19
|
+
|
20
|
+
def navigation_tabs(options={}, &block)
|
21
|
+
content = capture(&block)
|
22
|
+
content_tag(:ul, content, :class => 'nav')
|
23
|
+
end
|
24
|
+
|
25
|
+
def navigation_tab(name, options={})
|
26
|
+
action = options[:action]
|
27
|
+
active = (name.to_s == controller_name) && (action.nil? || action.to_s == controller.action_name)
|
28
|
+
content_tag(
|
29
|
+
:li,
|
30
|
+
link_to(
|
31
|
+
options[:name] || ActiveSupport::Inflector.humanize(name),
|
32
|
+
url_for({
|
33
|
+
:action => action || :index,
|
34
|
+
:controller => name
|
35
|
+
})
|
36
|
+
),
|
37
|
+
active ? {:class => 'active'} : nil)
|
38
|
+
end
|
39
|
+
|
40
|
+
#
|
41
|
+
# Renders the flash only once. In normal rails flow templates are rendered first
|
42
|
+
# and so the flash will be displayed in the template - otherwise the layout has
|
43
|
+
# an opportunity to render it.
|
44
|
+
#
|
45
|
+
def flashes
|
46
|
+
return if @flashed_once || flash.nil?; @flashed_once = true
|
47
|
+
tags = []
|
48
|
+
flash.each do |key, value|
|
49
|
+
(value.kind_of?(Array) ? value : [value]).each do |value|
|
50
|
+
next if value.blank?
|
51
|
+
tags << content_tag(flash_element_for(key), value, :class => alert_class_for(key))
|
52
|
+
end
|
53
|
+
end
|
54
|
+
content_tag(:div, tags.join.html_safe, :id => 'flash') unless tags.empty?
|
55
|
+
end
|
56
|
+
|
57
|
+
def flash_element_for(key)
|
58
|
+
case key
|
59
|
+
when :info_pre
|
60
|
+
:pre
|
61
|
+
else
|
62
|
+
:div
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
def alert_class_for(key)
|
67
|
+
case key
|
68
|
+
when :success
|
69
|
+
'alert alert-success'
|
70
|
+
when :notice
|
71
|
+
'alert alert-info'
|
72
|
+
when :error
|
73
|
+
'alert alert-error'
|
74
|
+
when :info
|
75
|
+
'alert alert-info'
|
76
|
+
when :info_pre
|
77
|
+
'cli'
|
78
|
+
else
|
79
|
+
Rails.logger.debug "Handling alert key #{key.inspect}"
|
80
|
+
'alert'
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
def render_thumbnails( collection, options )
|
85
|
+
unless collection.empty?
|
86
|
+
content_tag(
|
87
|
+
:ul,
|
88
|
+
collection.collect { |o|
|
89
|
+
content_tag(
|
90
|
+
:li,
|
91
|
+
render(options.merge(:object => o)).html_safe,
|
92
|
+
:class => options[:grid] || 'span3'
|
93
|
+
)
|
94
|
+
}.join.html_safe,
|
95
|
+
:class => 'thumbnails'
|
96
|
+
)
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
def breadcrumb_divider
|
101
|
+
content_tag(:span, '/', :class => 'divider')
|
102
|
+
end
|
103
|
+
|
104
|
+
AppWizardStepsCreate = [
|
105
|
+
{
|
106
|
+
:name => 'Choose a type of application',
|
107
|
+
:link => 'application_types_path'
|
108
|
+
},
|
109
|
+
{
|
110
|
+
:name => 'Configure and deploy the application'
|
111
|
+
},
|
112
|
+
{
|
113
|
+
:name => 'Next steps'
|
114
|
+
}
|
115
|
+
]
|
116
|
+
|
117
|
+
def app_wizard_steps_create(active, options={})
|
118
|
+
wizard_steps(AppWizardStepsCreate, active, options)
|
119
|
+
end
|
120
|
+
|
121
|
+
CartridgeWizardStepsCreate = [
|
122
|
+
{
|
123
|
+
:name => 'Choose a cartridge type',
|
124
|
+
:link => 'application_cartridge_types_path'
|
125
|
+
},
|
126
|
+
{
|
127
|
+
:name => 'Configure and deploy the cartridge'
|
128
|
+
},
|
129
|
+
{
|
130
|
+
:name => 'Next steps'
|
131
|
+
}
|
132
|
+
]
|
133
|
+
|
134
|
+
def cartridge_wizard_steps_create(active, options={})
|
135
|
+
wizard_steps(CartridgeWizardStepsCreate, active, options)
|
136
|
+
end
|
137
|
+
|
138
|
+
def wizard_steps(items, active, options={})
|
139
|
+
content_tag(
|
140
|
+
:ol,
|
141
|
+
(items + [options[:and]].compact).each_with_index.map do |item, index|
|
142
|
+
name = item[:name]
|
143
|
+
content = if item[:link] and ((index < active and !options[:completed]) or options[:active])
|
144
|
+
link_to(name, send("#{item[:link]}")).html_safe
|
145
|
+
else
|
146
|
+
name
|
147
|
+
end
|
148
|
+
|
149
|
+
content = content_tag(:span, [
|
150
|
+
content_tag(:i, index+1),
|
151
|
+
content].join.html_safe)
|
152
|
+
|
153
|
+
classes = if index < active
|
154
|
+
'completed'
|
155
|
+
elsif index == active
|
156
|
+
'active'
|
157
|
+
end
|
158
|
+
content_tag(:li, content, :class => classes)
|
159
|
+
end.join.html_safe,
|
160
|
+
:class => 'wizard'
|
161
|
+
)
|
162
|
+
end
|
163
|
+
|
164
|
+
def breadcrumbs_for_each(items)
|
165
|
+
last_index = items.length - 1
|
166
|
+
content_for :breadcrumbs, content_tag(
|
167
|
+
:ul,
|
168
|
+
items.each_with_index.map do |crumb, index|
|
169
|
+
content = crumb
|
170
|
+
active_tag = ""
|
171
|
+
if index == last_index
|
172
|
+
active_tag = "active"
|
173
|
+
else
|
174
|
+
content += breadcrumb_divider
|
175
|
+
end
|
176
|
+
|
177
|
+
content_tag(:li, content, :class => active_tag)
|
178
|
+
end.join.html_safe,
|
179
|
+
:class => 'breadcrumb')
|
180
|
+
end
|
181
|
+
|
182
|
+
def breadcrumb_for_application(application, *args)
|
183
|
+
breadcrumbs_for_each [
|
184
|
+
link_to('My Applications', :applications, :action => :index),
|
185
|
+
link_to(application.name, application),
|
186
|
+
] + args
|
187
|
+
end
|
188
|
+
|
189
|
+
def breadcrumb_for_create_application(*args)
|
190
|
+
breadcrumbs_for_each [
|
191
|
+
link_to('Create an application', application_types_path),
|
192
|
+
] + args
|
193
|
+
end
|
194
|
+
|
195
|
+
def take_action(link, text, *args)
|
196
|
+
options = args.extract_options!
|
197
|
+
link_to link, {:class => (['action-call'] << options[:class]).join(' ')}.reverse_merge!(options) do
|
198
|
+
([content_tag(:div, text.html_safe)] <<
|
199
|
+
args.collect { |text| content_tag(:div, text, :class => 'highlight') } <<
|
200
|
+
content_tag(:div, '>', :class => 'highlight-arrow')).join.html_safe
|
201
|
+
end
|
202
|
+
end
|
203
|
+
|
204
|
+
def greetings_for_select
|
205
|
+
[ 'Mr.', 'Mrs.', 'Ms.', 'Miss', 'Dr.', 'Hr.', 'Sr.' ]
|
206
|
+
end
|
207
|
+
|
208
|
+
def map_to_sentence(items, &block)
|
209
|
+
items.map{ |c| capture_haml{ yield c }.strip }.to_sentence.html_safe
|
210
|
+
end
|
211
|
+
|
212
|
+
HIDDEN_TAGS = [:featured, :framework, :web_framework, :experimental, :in_development, :template, :cartridge]
|
213
|
+
IMPORTANT_TAGS = [:new, :premium]
|
214
|
+
|
215
|
+
def application_type_tags(tags)
|
216
|
+
(tags - HIDDEN_TAGS).uniq.sort!.partition{ |t| IMPORTANT_TAGS.include?(t) }.flatten.map do |tag|
|
217
|
+
link_to tag.to_s.humanize, application_types_path(:tag => tag), :class => "label label-#{tag}"
|
218
|
+
end.join.html_safe
|
219
|
+
end
|
220
|
+
|
221
|
+
def us_states_for_select
|
222
|
+
[
|
223
|
+
['Alabama', 'AL'],
|
224
|
+
['Alaska', 'AK'],
|
225
|
+
['Arizona', 'AZ'],
|
226
|
+
['Arkansas', 'AR'],
|
227
|
+
['California', 'CA'],
|
228
|
+
['Colorado', 'CO'],
|
229
|
+
['Connecticut', 'CT'],
|
230
|
+
['Delaware', 'DE'],
|
231
|
+
['District of Columbia', 'DC'],
|
232
|
+
['Florida', 'FL'],
|
233
|
+
['Georgia', 'GA'],
|
234
|
+
['Hawaii', 'HI'],
|
235
|
+
['Idaho', 'ID'],
|
236
|
+
['Illinois', 'IL'],
|
237
|
+
['Indiana', 'IN'],
|
238
|
+
['Iowa', 'IA'],
|
239
|
+
['Kansas', 'KS'],
|
240
|
+
['Kentucky', 'KY'],
|
241
|
+
['Louisiana', 'LA'],
|
242
|
+
['Maine', 'ME'],
|
243
|
+
['Maryland', 'MD'],
|
244
|
+
['Massachusetts', 'MA'],
|
245
|
+
['Michigan', 'MI'],
|
246
|
+
['Minnesota', 'MN'],
|
247
|
+
['Mississippi', 'MS'],
|
248
|
+
['Missouri', 'MO'],
|
249
|
+
['Montana', 'MT'],
|
250
|
+
['Nebraska', 'NE'],
|
251
|
+
['Nevada', 'NV'],
|
252
|
+
['New Hampshire', 'NH'],
|
253
|
+
['New Jersey', 'NJ'],
|
254
|
+
['New Mexico', 'NM'],
|
255
|
+
['New York', 'NY'],
|
256
|
+
['North Carolina', 'NC'],
|
257
|
+
['North Dakota', 'ND'],
|
258
|
+
['Ohio', 'OH'],
|
259
|
+
['Oklahoma', 'OK'],
|
260
|
+
['Oregon', 'OR'],
|
261
|
+
['Pennsylvania', 'PA'],
|
262
|
+
['Puerto Rico', 'PR'],
|
263
|
+
['Rhode Island', 'RI'],
|
264
|
+
['South Carolina', 'SC'],
|
265
|
+
['South Dakota', 'SD'],
|
266
|
+
['Tennessee', 'TN'],
|
267
|
+
['Texas', 'TX'],
|
268
|
+
['Utah', 'UT'],
|
269
|
+
['Vermont', 'VT'],
|
270
|
+
['Virginia', 'VA'],
|
271
|
+
['Washington', 'WA'],
|
272
|
+
['West Virginia', 'WV'],
|
273
|
+
['Wisconsin', 'WI'],
|
274
|
+
['Wyoming', 'WY']
|
275
|
+
]
|
276
|
+
end
|
277
|
+
end
|
@@ -0,0 +1,106 @@
|
|
1
|
+
module Console::ModelHelper
|
2
|
+
def gear_group_states(states)
|
3
|
+
return states[0].to_s.humanize if states.uniq.length == 1
|
4
|
+
"#{states.count{ |s| s == :started }}/#{states.length} started"
|
5
|
+
end
|
6
|
+
def gear_group_state(states)
|
7
|
+
css_class = if states.all? {|s| s == :started}
|
8
|
+
'state_started'
|
9
|
+
elsif states.none? {|s| s == :started}
|
10
|
+
'state_stopped'
|
11
|
+
end
|
12
|
+
|
13
|
+
content_tag(:span, gear_group_states(states), :class => css_class)
|
14
|
+
end
|
15
|
+
|
16
|
+
def gear_group_count(gears)
|
17
|
+
types = gears.inject({}){ |h,g| h[g.gear_profile.to_s] ||= 0; h[g.gear_profile.to_s] += 1; h }
|
18
|
+
return 'None' if types.empty?
|
19
|
+
types.keys.sort.map do |k|
|
20
|
+
"#{types[k]} #{k.humanize.downcase}"
|
21
|
+
end.to_sentence
|
22
|
+
end
|
23
|
+
|
24
|
+
def web_cartridge_scale_title(cartridge)
|
25
|
+
if cartridge.current_scale == cartridge.scales_from
|
26
|
+
'Your web cartridge is running on the minimum amount of gears and will scale up if needed'
|
27
|
+
elsif cartridge.current_scale == cartridge.scales_to
|
28
|
+
'Your web cartridge is running on the maximum amount of gears and cannot scale up any further'
|
29
|
+
else
|
30
|
+
'Your web cartridge is running multiple copies to handle increased web traffic'
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
def cartridge_gear_group_count(group)
|
35
|
+
return 'None' if group.gears.empty?
|
36
|
+
"#{group.gears.length} #{group.gear_profile.to_s.humanize.downcase}"
|
37
|
+
end
|
38
|
+
|
39
|
+
def gear_group_count_title(total_gears)
|
40
|
+
"OpenShift runs each cartridge inside one or more gears on a server and is allocated a fixed portion of CPU time and memory use."
|
41
|
+
end
|
42
|
+
|
43
|
+
def scale_range(from, to, max, max_choices)
|
44
|
+
limit = to == -1 ? max : to
|
45
|
+
return if limit > max_choices
|
46
|
+
(from .. limit).map{ |i| [i.to_s, i] }
|
47
|
+
end
|
48
|
+
def scale_from_options(obj, max, max_choices=20)
|
49
|
+
if range = scale_range(obj.supported_scales_from, obj.supported_scales_to, max, max_choices)
|
50
|
+
{:as => :select, :collection => range, :include_blank => false}
|
51
|
+
else
|
52
|
+
{:as => :string}
|
53
|
+
end
|
54
|
+
end
|
55
|
+
def scale_to_options(obj, max, max_choices=20)
|
56
|
+
if range = scale_range(obj.supported_scales_from, obj.supported_scales_to, max, max_choices)
|
57
|
+
range << ['All available', -1] if obj.supported_scales_to == -1
|
58
|
+
{:as => :select, :collection => range, :include_blank => false}
|
59
|
+
else
|
60
|
+
{:as => :string, :hint => 'Use -1 to scale to your current account limits'}
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
def scale_options
|
65
|
+
[['No scaling',false],['Scale with web traffic',true]]
|
66
|
+
end
|
67
|
+
|
68
|
+
def can_scale_application_type(type, capabilities)
|
69
|
+
type.scalable? and capabilities.gears_free >= 2 and !type.template?
|
70
|
+
end
|
71
|
+
|
72
|
+
def cannot_scale_title(type, capabilities)
|
73
|
+
unless can_scale_application_type(type, capabilities)
|
74
|
+
if type.scalable? and !@application_type.template
|
75
|
+
"You need at least two free gears to create a scaling application; you are currently using #{capabilities.consumed_gears} out of #{capabilities.max_gears}."
|
76
|
+
else
|
77
|
+
"This application shares resources and can't be scaled."
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
def in_groups_by_tag(ary, tags)
|
83
|
+
groups = {}
|
84
|
+
other = ary.reject do |t|
|
85
|
+
tags.any? do |tag|
|
86
|
+
(groups[tag] ||= []) << t if t.tags.include?(tag)
|
87
|
+
end
|
88
|
+
end
|
89
|
+
groups = tags.map do |tag|
|
90
|
+
types = groups[tag]
|
91
|
+
if types
|
92
|
+
if types.length < 2
|
93
|
+
other.concat(types)
|
94
|
+
nil
|
95
|
+
else
|
96
|
+
[tag, types]
|
97
|
+
end
|
98
|
+
end
|
99
|
+
end.compact!
|
100
|
+
[groups, other]
|
101
|
+
end
|
102
|
+
|
103
|
+
def common_tags_for(ary)
|
104
|
+
ary.length < 2 ? [] : ary.inject(nil){ |tags, a| tags ? (a.tags & tags) : a.tags } || []
|
105
|
+
end
|
106
|
+
end
|