Module: RdcmsHelper
- Included in:
- ApplicationHelper
- Defined in:
- app/helpers/rdcms_helper.rb
Instance Method Summary collapse
- #basic_headers(options = {}) ⇒ Object
- #bugtracker ⇒ Object
- #edit_post_link ⇒ Object
-
#errors_for(object, message = nil) ⇒ Object
Error explanation.
-
#flash_message(options = {}) ⇒ Object
Menssagem de notificações.
-
#language_links(options = {}) ⇒ Object
Renderiza language selector.
-
#render_address ⇒ Object
Renderiza o endereço formatado.
-
#render_footer(setting_layout = "application", preview = false, options = {}) ⇒ Object
Renderiza o rodapé.
-
#render_header(setting_layout = "application", preview = false, options = {}) ⇒ Object
Renderiza o cabeçalho.
-
#s(name) ⇒ Object
alias para Setting.for_key(name).
-
#social_buttons_json ⇒ Object
Renderiza botões de curti nas redes sociais.
-
#social_pages_buttons(options = {}) ⇒ Object
Renderiza botões de páginas das redes sociais.
Instance Method Details
#basic_headers(options = {}) ⇒ Object
71 72 73 |
# File 'app/helpers/rdcms_helper.rb', line 71 def basic_headers(={}) render :partial => "/posts/headers", :locals => {:options => } end |
#bugtracker ⇒ Object
54 55 56 57 58 59 60 61 |
# File 'app/helpers/rdcms_helper.rb', line 54 def bugtracker user_mod = Setting.for_key("rdcms.bugherd.user") role_mod = Setting.for_key("rdcms.bugherd.role") bugherd_api = Setting.for_key("rdcms.bugherd.api") if bugherd_api.present? && user_mod.present? && role_mod.present? && eval("#{user_mod} && #{user_mod}.present? && #{user_mod}.has_role?('#{role_mod}')") render :partial => "posts/bugherd", :locals => {:bugherd_api => bugherd_api} end end |
#edit_post_link ⇒ Object
63 64 65 66 67 68 69 |
# File 'app/helpers/rdcms_helper.rb', line 63 def edit_post_link user_mod = Setting.for_key("rdcms.post.edit_link.user") role_mod = Setting.for_key("rdcms.post.edit_link.role") if user_mod.present? && role_mod.present? && eval("#{user_mod} && #{user_mod}.present? && #{user_mod}.has_role?('#{role_mod}')") render :partial => "/posts/edit_post_link" end end |
#errors_for(object, message = nil) ⇒ Object
Error explanation
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'app/helpers/rdcms_helper.rb', line 27 def errors_for(object, =nil) html = "" unless object.errors.blank? html << "<div id=\"error_explanation\" class=\"alert alert-error #{object.class.name.humanize.downcase}Errors'>\n" html << "\t<button type=\"button\" class=\"close\" data-dismiss=\"alert\">×</button>\n" if .blank? html << "\t<h2>#{pluralize(f.object.errors.count, "error")} prohibited this product from being saved:</h2>" else html << "<h2>#{}</h2>" end html << "\t<ul>\n" object.errors..each do |error| html << "\t\t<li>#{error}</li>\n" end html << "\t</ul>\n" html << "</div>\n" end html end |
#flash_message(options = {}) ⇒ Object
Menssagem de notificações
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'app/helpers/rdcms_helper.rb', line 5 def (={}) = { close_button: true }.merge = [] = "<button data-dismiss=\"alert\" class=\"close\" type=\"button\">×</button>" if [:close_button] [:notice, :info, :warning, :error].each {|type| classtype = case type when :notice then "success" else type end if flash[type] << content_tag(:div, "#{}#{flash[type]}".html_safe, class: "alert alert-#{classtype}") end } # messages.html_safe content_tag(:div, .join("\n").html_safe, class: "flash_message_container") end |
#language_links(options = {}) ⇒ Object
Renderiza language selector
76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 |
# File 'app/helpers/rdcms_helper.rb', line 76 def language_links(={}) links = [] selector = [] [:dropdown ] = defined?([:dropdown ]) ? [:dropdown ] : true string = defined?([:string ]) ? [:string ] : true placement = defined?([:placement ]) ? [:placement ] : "bottom" # data-placement="bottom" I18n.available_locales.each do |locale| locale_key = "translation.#{locale}" span_key = "<span class=\"text\">#{I18n.t(locale_key)}</span>" icon = "<i class=\"flag flag-#{locale}\"></i>" if [:dropdown ] if locale == I18n.locale selector << link_to('#', { class: "dropdown-toggle", :"data-toggle" => "dropdown", title: I18n.t(locale_key) }, rel: "tooltip", :"data-placement" => placement) do "#{icon} #{span_key}<span class=\"caret\"></span>".html_safe end else link = link_to("#{icon} #{span_key}</span>".html_safe, url_for(locale: locale.to_s)) links << content_tag(:li, link).html_safe end else = locale == I18n.locale ? { class: "active" } : {} [:title] = I18n.t(locale_key) unless string [:rel] = "tooltip" [:"data-placement"] = placement link = link_to("#{icon} #{span_key}".html_safe, url_for(locale: locale.to_s)) links << content_tag(:li, link, ).html_safe end end object_class = "nav nav-pills pull-right language_selector" object_class << " no_string" unless string if [:dropdown ] dropdown = content_tag(:ul, links.join("\n").html_safe, class: "dropdown-menu") selector = content_tag(:li, selector.join("\n").html_safe + dropdown, { class: "dropdown" }) else selector = links.join("\n").html_safe end content_tag(:ul, selector, class: "#{object_class}") end |
#render_address ⇒ Object
Renderiza o endereço formatado
149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 |
# File 'app/helpers/rdcms_helper.rb', line 149 def render_address @companyName = Setting.get_object("rdcms.company.name") @companyAddress = Setting.get_object("rdcms.company.address") @companyDistrict = Setting.get_object("rdcms.company.district") @companyCep = Setting.get_object("rdcms.company.cep") @companyCity = Setting.get_object("rdcms.company.city") @companyState = Setting.get_object("rdcms.company.state") @companyCountry = Setting.get_object("rdcms.company.country") @companyPhone = Setting.get_object("rdcms.company.phone") @companyEmail = Setting.get_object("rdcms.company.email") # Dados a serem exibidos sobre a companhia address = "" address = "<strong>#{@companyName.value}</strong><br>" unless @companyName.value.empty? address << "#{@companyAddress.value}<br>" unless @companyAddress.value.empty? address << "#{@companyDistrict.value}" unless @companyDistrict.value.empty? address << ", CEP: #{@companyCep.value}" unless @companyCep.value.empty? address << "<br>" if !@companyDistrict.value.empty? or !@companyCep.value.empty? address << "#{@companyCity.value}" unless @companyCity.value.empty? address << " - #{@companyState.value}" unless @companyState.value.empty? address << ", #{@companyCountry.value}" unless @companyCountry.value.empty? address.html_safe end |
#render_footer(setting_layout = "application", preview = false, options = {}) ⇒ Object
Renderiza o rodapé
273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 |
# File 'app/helpers/rdcms_helper.rb', line 273 def (setting_layout="application", preview=false, ={}) setting_layout = "application" if defined?(setting_layout) setting_name = "rdcms.view.#{setting_layout}" isApplication = setting_name == "rdcms.view.application" if isApplication # Data objetos com algumas informações da companhia @companyName = Setting.get_object("rdcms.company.name") @companyPhone = Setting.get_object("rdcms.company.phone") @companyEmail = Setting.get_object("rdcms.company.email") @companyYear = Setting.get_object("rdcms.company.year") phone = "<em>#{I18n.t('attributes_all.phone' )}: #{@companyPhone.value}</em><br>" unless @companyPhone.value.empty? email = "<em>#{I18n.t('attributes_all.contact_email')}: <a href=\"mailto:#{@companyEmail.value}\">#{@companyEmail.value}</a></em>" unless @companyEmail.value.empty? # Objetos da Estilização @footerBackground = Setting.get_object("#{setting_name}.footer.background") @footerPadding = Setting.get_object("#{setting_name}.footer.padding") @footerContainerBackground = Setting.get_object("#{setting_name}.footer.container_background") # Simula form quando for preview if preview form = %Q{ <div id="updates" class="hidden"> #{best_in_place(@footerBackground , :value, type: :input, classes: "footerBackground", path: [:admin, @footerBackground])} #{best_in_place(@footerContainerBackground, :value, type: :input, classes: "footerContainerBackground", path: [:admin, @footerContainerBackground])} </div> } end = "" << "background: #{@footerBackground.value};" unless @footerBackground.value.empty? << "padding: #{@footerPadding.value};" unless @footerPadding.value.empty? = "" << "background: #{@footerContainerBackground.value};" unless @footerContainerBackground.value.empty? << "#{[:styles]}" unless [:styles].blank? return html = %Q{ <footer class="#{setting_layout}" #{"style=\"position: relative;\"" if preview}> <div class="footer-box nav-background" style="#{}"> <div class="footer-container" style="#{}"> <div class="container"> <div class="row"> <div class="span4"> <h4>#{t("layouts.#{setting_layout}.contact")}</h4> <address> <p>#{render_address}</p> #{phone} #{email} </address> </div> <div class="span4"> <h4>#{t("layouts.#{setting_layout}.pages")}</h4> #{ "nav", { dropdown: false }} <ul class="nav"> <li>#{link_to t("menu_nav.login"), admin_root_path, target: "_blank"}</li> </ul> </div> <div class="span4"> <div class="row"> <div class="span4">#{}</div> </div> <div class="row"> <div class="span4 newsletter"> <div class="newsletter_form"> <p class="description">#{t("layouts.#{setting_layout}.newsletter_description")}.</p> #{render :template => "newsletters/new"} </div> </div> </div> </div> #{form} </div> </div> </div> </div> <div class="copyright_developer"> <div class="container"> <div class="row"> <div class="copyright span8"> <em>#{t("layouts.#{setting_layout}.copyright", :company => @companyName.value, :year => @companyYear.value)}</em> </div> <div class="developer span4"> #{t("layouts.#{setting_layout}.developed_by")}: <a title="Requestdev Sistemas" class="developer-logo" href="http://www.requestdev.com.br" rel="tooltip" data-placement="top"> <img alt="Requestdev Sistemas" src="http://requestdev.com.br/images/requestdev_developer.png"> </a> </div> </div> </div> </div> #{"<div class=\"overlay-block\"></div>".html_safe if preview} </footer> }.html_safe else return html = %Q{}.html_safe end end |
#render_header(setting_layout = "application", preview = false, options = {}) ⇒ Object
Renderiza o cabeçalho
175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 |
# File 'app/helpers/rdcms_helper.rb', line 175 def render_header(setting_layout="application", preview=false, ={}) setting_layout ||= "application" setting_name = "rdcms.view.#{setting_layout}" = { type: "inner", # before = antes do menu, inner = junto ao menu language: { dropdown: true, string: true } }.merge styleHeader = "" form = "" style = "" styleHeader << "position: relative;" if preview block = %Q{<div class="overlay-block"></div>} if preview # Application template if setting_layout == "application" @logo = Setting.get_object("#{setting_name}.header.logo") @background = Setting.get_object("#{setting_name}.header.background") @innerBackground = Setting.get_object("#{setting_name}.header.inner_background") @padding = Setting.get_object("#{setting_name}.header.padding") styleHeader << "background: #{@background.value};" unless @background.value.empty? styleHeader << "padding: #{@padding.value};" unless @padding.value.empty? style << "background: #{@innerBackground.value};" unless @innerBackground.value.empty? style << "#{[:styles]}" unless [:styles].blank? # Fullscreen elsif setting_layout == "full_screen" @logo = Setting.get_object("#{setting_name}.logo") end noBlk = @logo.uploads.last.blank? image = !noBlk ? @logo.uploads.last.upload(:logo) : @logo.value unless preview or setting_layout == "full_screen" nav = %Q{ <div class="nav-collapse collapse"> #{.html_safe} #{language_links([:language]).html_safe if [:type] == "inner"} </div>} else form = %Q{<div id="updates" class="hidden">} form << %Q{#{best_in_place(@logo , :upload_ids, type: :input, classes: "brand_logo", path: [:admin, @logo])} } form << %Q{ #{best_in_place(@background , :value, type: :input, classes: "background", path: [:admin, @background])} #{best_in_place(@innerBackground, :value, type: :input, classes: "innerBackground", path: [:admin, @innerBackground])} } if setting_layout == "application" form << %Q{</div>} end brand = link_to("/#{I18n.locale.to_s}/", class: "brand", title: I18n.t(".back_to_homepage"), rel: "tooltip") do html = image_tag(image, :class => "logo") html end header_html = %Q{ <div class="navbar #{setting_layout} before_header_nav"> <div class="navbar-inner nav-colorize" style="#{style}"> <div class="container" style="#{style}"> #{brand if [:type] == "before"} #{language_links([:language]).html_safe if [:type] == "before"} </div> </div> </div>} if [:type] == "before" or [:type] == "before" # style = styleHeader if options[:type] == "before" inner_html = %Q{ #{header_html} <div class="navbar #{setting_layout} #{"navbar navbar-fixed-top navbar-fade-background" if [:fixed] == true}"> <div class="navbar-inner nav-colorize" style="#{styleHeader}"> <div class="container nav-background" style="#{style if [:type] == "inner"}"> <a class="btn btn-navbar" data-target=".nav-collapse" data-toggle="collapse"> <span class="icon-bar"></span> <span class="icon-bar"></span> <span class="icon-bar"></span> </a> #{brand if [:type] == "inner"} #{nav} #{form} </div> #{block} </div> </div>} inner_html.html_safe end |
#s(name) ⇒ Object
alias para Setting.for_key(name)
48 49 50 51 52 |
# File 'app/helpers/rdcms_helper.rb', line 48 def s(name) if name.present? Setting.for_key(name) end end |
#social_buttons_json ⇒ Object
Renderiza botões de curti nas redes sociais
122 123 124 125 126 127 128 129 130 131 132 |
# File 'app/helpers/rdcms_helper.rb', line 122 def data = { "twitter" => { "data-via" => "#{Setting.for_key("rdcms.twitter.via")}", "data-rel" => "#{Setting.for_key("rdcms.twitter.rel")}", "data-hash" => "#{Setting.for_key("rdcms.twitter.hash")}", "data-lang" => I18n.locale } } data.to_json end |
#social_pages_buttons(options = {}) ⇒ Object
Renderiza botões de páginas das redes sociais
135 136 137 138 139 140 141 142 143 144 145 146 |
# File 'app/helpers/rdcms_helper.rb', line 135 def (={}) # Botões das redes sociais @social_pages = Setting.get_object("rdcms.social_pages") html = "" @social_pages.children.each do |record| html << content_tag(:li, title: I18n.t(".social_pages.#{record.title}"), rel: "tooltip") do link_to("<i class=\"icon-#{record.title}\"></i>".html_safe, record.value, target: "_blank", rel: "publisher") end unless record.value.empty? end content_tag(:ul, html.html_safe, class: "nav pull-right follow_us #{[:class]}") end |