Module: Breeze::ViewHelper
Class Method Summary
collapse
Instance Method Summary
collapse
#aspect_ratio, #card_field_name, #last_change_class, #last_change_digit, #last_change_text, #updated_by
#markdown, #markdown_image, #prose_classes, #renderer, #rows
#background_option, #column_option, #date_precision, #height_option, #item_align_option, #margin_option, #options, #order_option, #prose_option, #shade_option, #slider_columns_option, #text_align_option, #text_color_option, #text_columns_option
Class Method Details
.last_blog ⇒ Object
just for tailwind bg-cyan-200
86
87
88
89
90
|
# File 'app/helpers/breeze/view_helper.rb', line 86
def self.last_blog
blog = Page.find_by_type(:blog)
return nil unless blog
blog.sections.last
end
|
Instance Method Details
#bg(section, clazz = "") ⇒ Object
background image as inline style
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
# File 'app/helpers/breeze/view_helper.rb', line 40
def bg(section , clazz = "")
return {class: clazz} if section.image.blank?
img = asset_url( section.image.asset_name )
style = "background-image: url('#{img}');"
if(section.option("fixed") == "on")
clazz += " bg-fixed"
end
if(align = section.option("image_align"))
clazz += " bg-#{align}"
end
{class: clazz , style: style}
end
|
private, just breaking it up. Returns not safe string
21
22
23
24
25
26
27
28
|
# File 'app/helpers/breeze/view_helper.rb', line 21
def breeze_fb_tags
return "" unless @page.options
image = Image.find( @page.options["main_image"] )
return "" unless image
image_path = asset_path("breeze/" + image.id.to_s + "." + image.type)
"\n<meta property='og:image' content='http://nomads.feenix.community#{image_path}' />" +
"\n<meta property='og:image:secure_url' content='https://nomads.feenix.community#{image_path}' />"
end
|
13
14
15
16
17
18
|
# File 'app/helpers/breeze/view_helper.rb', line 13
def breeze_meta_tags
metas = "<title> #{title}</title>\n" +
"<meta name='description' content='#{description}' />" +
breeze_fb_tags
metas.html_safe
end
|
62
63
64
|
# File 'app/helpers/breeze/view_helper.rb', line 62
def button_classes
"inline-block rounded-lg px-3 py-2 text-base font-medium border border-gray-500 hover:border-black"
end
|
#current_lang ⇒ Object
30
31
32
|
# File 'app/helpers/breeze/view_helper.rb', line 30
def current_lang
params[:lang]
end
|
#description ⇒ Object
9
10
11
|
# File 'app/helpers/breeze/view_helper.rb', line 9
def description
@page.options ? @page.options["description"] : ""
end
|
#get_button_text(element) ⇒ Object
66
67
68
69
70
|
# File 'app/helpers/breeze/view_helper.rb', line 66
def get_button_text(element)
text = element.option("button_text")
return text unless text.include?("_")
I18n.t( text )
end
|
96
97
98
99
100
101
102
103
|
# File 'app/helpers/breeze/view_helper.rb', line 96
def
return "" unless blog_section = last_blog
blog = blog_section.page
= blog.sections.collect{|s| "- " + s.}
.shift
return "" if .empty?
markdown .join("\n")
end
|
#image_for(element, classes = "") ⇒ Object
works for with sections and cards that respond to .image
56
57
58
59
60
|
# File 'app/helpers/breeze/view_helper.rb', line 56
def image_for(element , classes = "")
return "" if element.image.blank?
image = element.image
image_tag(image.asset_name , alt: image.name , class: classes )
end
|
#last_blog ⇒ Object
92
93
94
|
# File 'app/helpers/breeze/view_helper.rb', line 92
def last_blog
ViewHelper.last_blog
end
|
#render_section(section) ⇒ Object
34
35
36
37
|
# File 'app/helpers/breeze/view_helper.rb', line 34
def render_section(section)
template = "breeze/view/" + section.template
render( template , section: section)
end
|
#title ⇒ Object
5
6
7
|
# File 'app/helpers/breeze/view_helper.rb', line 5
def title
@page.options ? @page.options["title"] : ""
end
|
72
73
74
75
76
77
78
79
80
81
82
83
|
# File 'app/helpers/breeze/view_helper.rb', line 72
def view_button(element , = "")
return "" unless element.has_option?("button_link")
["<button class='#{button_classes} ",
,
"'>" ,
"<a href='" ,
element.option("button_link") ,
"'>" ,
get_button_text(element) ,
"</a>",
" </button>"].join.html_safe
end
|