Commit c5a6b574e854d8cc37f7ede6e702626a0a09d4c9
1 parent
92def34a
Exists in
master
and in
11 other branches
responsive: use prepend only on ruby 2.0.0+
Showing
4 changed files
with
34 additions
and
51 deletions
Show diff stats
plugins/responsive/lib/ext/application_helper.rb
1 | require_dependency 'application_helper' | 1 | require_dependency 'application_helper' |
2 | -require_relative 'input_helper' | ||
3 | 2 | ||
4 | module ApplicationHelper | 3 | module ApplicationHelper |
5 | 4 | ||
6 | - extend ActiveSupport::Concern | ||
7 | protected | 5 | protected |
8 | 6 | ||
9 | module ResponsiveMethods | 7 | module ResponsiveMethods |
@@ -408,8 +406,11 @@ module ApplicationHelper | @@ -408,8 +406,11 @@ module ApplicationHelper | ||
408 | end | 406 | end |
409 | 407 | ||
410 | include ResponsiveChecks | 408 | include ResponsiveChecks |
411 | - included do | ||
412 | - include ResponsiveMethods | 409 | + if RUBY_VERSION >= '2.0.0' |
410 | + prepend ResponsiveMethods | ||
411 | + else | ||
412 | + extend ActiveSupport::Concern | ||
413 | + included { include ResponsiveMethods } | ||
413 | end | 414 | end |
414 | 415 | ||
415 | # TODO: apply theme_responsive? condition | 416 | # TODO: apply theme_responsive? condition |
plugins/responsive/lib/ext/boxes_helper.rb
1 | require_dependency 'boxes_helper' | 1 | require_dependency 'boxes_helper' |
2 | -require_relative 'application_helper' | ||
3 | 2 | ||
4 | module BoxesHelper | 3 | module BoxesHelper |
5 | 4 | ||
6 | - extend ActiveSupport::Concern | ||
7 | protected | 5 | protected |
8 | 6 | ||
9 | module ResponsiveMethods | 7 | module ResponsiveMethods |
@@ -45,35 +43,31 @@ module BoxesHelper | @@ -45,35 +43,31 @@ module BoxesHelper | ||
45 | return main_content unless boxes.present? | 43 | return main_content unless boxes.present? |
46 | render partial: "templates/boxes_#{template}", locals: {boxes: boxes, main_content: main_content}, use_cache: use_cache? | 44 | render partial: "templates/boxes_#{template}", locals: {boxes: boxes, main_content: main_content}, use_cache: use_cache? |
47 | end | 45 | end |
48 | - end | ||
49 | 46 | ||
50 | - def display_topbox_content(box, main_content) | ||
51 | - context = {article: @page, request_path: request.path, locale: locale, params: request.params, controller: controller} | ||
52 | - box_decorator.select_blocks(box, box.blocks.includes(:box), context).map do |item| | ||
53 | - if item.class.name == 'LinkListBlock' and request.params[:controller] != 'profile_design' | ||
54 | - render_linklist_navbar(item) | ||
55 | - else | ||
56 | - display_block item, main_content | ||
57 | - end | ||
58 | - end.join("\n") + box_decorator.block_target(box) | ||
59 | - end | 47 | + def display_topbox_content(box, main_content) |
48 | + context = {article: @page, request_path: request.path, locale: locale, params: request.params, controller: controller} | ||
49 | + box_decorator.select_blocks(box, box.blocks.includes(:box), context).map do |item| | ||
50 | + if item.class.name == 'LinkListBlock' and request.params[:controller] != 'profile_design' | ||
51 | + render_linklist_navbar(item) | ||
52 | + else | ||
53 | + display_block item, main_content | ||
54 | + end | ||
55 | + end.join("\n") + box_decorator.block_target(box) | ||
56 | + end | ||
60 | 57 | ||
61 | - def render_linklist_navbar link_list | ||
62 | - list = link_list.links.select{ |i| i[:name].present? and i[:address].present? } | ||
63 | - render file: 'blocks/link_list_navbar', locals: {block: link_list, links: list} | 58 | + def render_linklist_navbar link_list |
59 | + list = link_list.links.select{ |i| i[:name].present? and i[:address].present? } | ||
60 | + render file: 'blocks/link_list_navbar', locals: {block: link_list, links: list} | ||
61 | + end | ||
64 | end | 62 | end |
65 | 63 | ||
66 | include ResponsiveChecks | 64 | include ResponsiveChecks |
67 | - extend ActiveSupport::Concern | ||
68 | - included do | ||
69 | - include ResponsiveMethods | 65 | + if RUBY_VERSION >= '2.0.0' |
66 | + prepend ResponsiveMethods | ||
67 | + else | ||
68 | + extend ActiveSupport::Concern | ||
69 | + included { include ResponsiveMethods } | ||
70 | end | 70 | end |
71 | 71 | ||
72 | end | 72 | end |
73 | 73 | ||
74 | -module ApplicationHelper | ||
75 | - | ||
76 | - include BoxesHelper::ResponsiveMethods | ||
77 | - | ||
78 | -end | ||
79 | - |
plugins/responsive/lib/ext/chat_helper.rb
1 | require_dependency 'chat_helper' | 1 | require_dependency 'chat_helper' |
2 | -require_relative 'application_helper' | ||
3 | 2 | ||
4 | module ChatHelper | 3 | module ChatHelper |
5 | 4 | ||
6 | - extend ActiveSupport::Concern | ||
7 | protected | 5 | protected |
8 | 6 | ||
9 | module ResponsiveMethods | 7 | module ResponsiveMethods |
@@ -25,17 +23,12 @@ module ChatHelper | @@ -25,17 +23,12 @@ module ChatHelper | ||
25 | end | 23 | end |
26 | 24 | ||
27 | include ResponsiveChecks | 25 | include ResponsiveChecks |
28 | - included do | ||
29 | - include ResponsiveMethods | 26 | + if RUBY_VERSION >= '2.0.0' |
27 | + prepend ResponsiveMethods | ||
28 | + else | ||
29 | + extend ActiveSupport::Concern | ||
30 | + included { include ResponsiveMethods } | ||
30 | end | 31 | end |
31 | 32 | ||
32 | - protected | ||
33 | - | ||
34 | -end | ||
35 | - | ||
36 | -module ApplicationHelper | ||
37 | - | ||
38 | - include ChatHelper::ResponsiveMethods | ||
39 | - | ||
40 | end | 33 | end |
41 | 34 |
plugins/responsive/lib/ext/forms_helper.rb
1 | require_dependency 'forms_helper' | 1 | require_dependency 'forms_helper' |
2 | -require_relative 'application_helper' | ||
3 | 2 | ||
4 | module FormsHelper | 3 | module FormsHelper |
5 | 4 | ||
6 | - extend ActiveSupport::Concern | ||
7 | protected | 5 | protected |
8 | 6 | ||
9 | module ResponsiveMethods | 7 | module ResponsiveMethods |
@@ -75,15 +73,12 @@ module FormsHelper | @@ -75,15 +73,12 @@ module FormsHelper | ||
75 | end | 73 | end |
76 | 74 | ||
77 | include ResponsiveChecks | 75 | include ResponsiveChecks |
78 | - included do | ||
79 | - include ResponsiveMethods | 76 | + if RUBY_VERSION >= '2.0.0' |
77 | + prepend ResponsiveMethods | ||
78 | + else | ||
79 | + extend ActiveSupport::Concern | ||
80 | + included { include ResponsiveMethods } | ||
80 | end | 81 | end |
81 | 82 | ||
82 | end | 83 | end |
83 | 84 | ||
84 | -module ApplicationHelper | ||
85 | - | ||
86 | - include FormsHelper::ResponsiveMethods | ||
87 | - | ||
88 | -end | ||
89 | - |