Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge branch 'html_helper' into rails_3_upgrade

  • Loading branch information...
commit 9c66564f6a9ac4ef8f7ef25a299ac9a8446f94bb 2 parents c811d00 + 6c99265
@kentaro authored
View
39 app/helpers/application_helper.rb
@@ -20,9 +20,9 @@ def flashed_errors(object_name)
error_messages = obj.errors.full_messages.map {|msg| content_tag(:li, msg)}
html = content_tag(:p,"#{pluralize(obj.errors.size, 'error')} prohibited this #{object_name.to_s.gsub('_', ' ')} from being saved")
- html << content_tag(:div,
- content_tag(:ul, raw(error_messages))
- )
+ html << content_tag(:div) do
+ content_tag(:ul) { error_messages.each { |x| concat x } }
+ end
content_for(:flash_content) do
error_flash(raw(html))
@@ -37,25 +37,10 @@ def hide_password_in_value(config)
end
end
- def current_stage_project_description
- raw "stage: #{link_to current_stage.name, [current_project, current_stage]} (of project #{link_to current_project.name, current_project})"
+ def prompt_status_in_html(config)
+ content_tag('span', 'prompt', class: 'configuration_prompt') if config.prompt?
end
- # returns the open/closed status of a menu
- # either the active controller is used or the given status is returned
- def controller_in_use_or(contr_name, status, klass)
- if controller.is_a? contr_name
- :open
- else
- if status == :closed && (klass.count <= 3 )
- # the box should be closed
- # open it anyway if we have less than three
- status = :open
- end
-
- status
- end
- end
# returns the display:none/visible attribute
# if the stages of a project should be shown
@@ -119,15 +104,11 @@ def active_link_class(item)
end
def breadcrumb_box(&block)
- out = <<-EOS
-<ul class="breadcrumb">
-<li><a href="/">Top</a></li>
-<span class="divider">&raquo;</span>
-EOS
- out << capture(&block) if block
- out << "</ul>"
-
- raw out
+ content_tag 'div', class: 'breadcrumb' do
+ content_tag 'b' do
+ capture(&block) if block
+ end
+ end
end
def any_path(target)
View
9 app/helpers/stages_helper.rb
@@ -1,12 +1,11 @@
module StagesHelper
def display_deployment_problems(stage)
- out = "<ul>"
- stage.deployment_problems.each do |k,v|
- out += "<li>#{v}</li>"
+ content_tag 'ul' do
+ stage.deployment_problems.each do |k, v|
+ concat content_tag 'li', v
+ end
end
- out += "</ul>"
- return raw(out)
end
# returns the escaped format of a config value
View
8 app/models/configuration_parameter.rb
@@ -19,14 +19,6 @@ def empty_value_if_deploy_is_set
self.value = nil if self.prompt?
end
- def prompt_status_in_html
- if self.prompt?
- "<span class='configuration_prompt'>prompt</span>"
- else
- ''
- end
- end
-
private
def custom_validations
View
2  app/models/project_configuration.rb
@@ -5,7 +5,7 @@ class ProjectConfiguration < ConfigurationParameter
validates :project,
:presence => true
- validates :name,
+ validates :name,
:uniqueness => { :scope => :project_id }
# default templates for Projects
View
8 app/views/layouts/_menu.html.haml
@@ -1,19 +1,19 @@
- title = "Projects"
-- status = controller_in_use_or(ProjectsController, :open, Project)
+- status = :open
- locals = { :title => title, :status => status, :path => projects_path }
= render(:partial => 'layouts/projects', :locals => locals, :layout => 'layouts/menu_box')
- title = "Hosts"
-- status = controller_in_use_or(HostsController, :open, Host)
+- status = :open
- locals = { :title => title, :status => status, :path => hosts_path }
= render(:partial => 'layouts/hosts', :locals => locals, :layout => 'layouts/menu_box')
- title = "Recipes"
-- status = controller_in_use_or(RecipesController, :open, Recipe)
+- status = :open
- locals = { :title => title, :status => status, :path => recipes_path }
= render(:partial => 'layouts/recipes', :locals => locals, :layout => 'layouts/menu_box')
- title = "Users"
-- status = controller_in_use_or(UsersController, :open, User)
+- status = :open
- locals = { :title => title, :status => status, :path => users_path }
= render(:partial => 'layouts/users', :locals => locals, :layout => 'layouts/menu_box')
View
2  app/views/projects/_configs.html.erb
@@ -17,7 +17,7 @@
<tr>
<td><%= truncate(config.name, length: 25) %></td>
<td><%= truncate(hide_password_in_value(config), length: 45) %></td>
- <td><%= config.prompt_status_in_html %></td>
+ <td><%= prompt_status_in_html config %></td>
<td><%= link_to 'Edit', edit_project_project_configuration_path(@project, config) %></td>
<td><%= link_to 'Delete', project_project_configuration_path(@project, config), data: { confirm: 'Are you sure?' }, method: :delete %></td>
</tr>
View
2  app/views/stages/_configs.html.erb
@@ -15,7 +15,7 @@
<tr>
<td><%= truncate(config.name, length: 25) %></td>
<td><%= truncate(hide_password_in_value(config), length: 45) %></td>
- <td><%= config.prompt_status_in_html %></td>
+ <td><%= prompt_status_in_html config %></td>
<td><%= link_to 'Edit', edit_project_stage_stage_configuration_path(@project, @stage, config) %></td>
<td><%= link_to 'Delete', project_stage_stage_configuration_path(@project, @stage, config), data: { confirm: 'Are you sure?' }, method: :delete %></td>
</tr>
View
2  app/views/stages/_effective_config.html.erb
@@ -16,7 +16,7 @@
<tr>
<td><%= truncate(conf.name, length: 25) %></td>
<td><%= truncate(hide_password_in_value(conf), length: 45) %></td>
- <td><%= conf.prompt_status_in_html %></td>
+ <td><%= prompt_status_in_html conf %></td>
</tr>
<% end %>
</tbody>
Please sign in to comment.
Something went wrong with that request. Please try again.