Commit 7209de7505ecd385b0bdd797c7ea8ec4846392c6

Authored by Karpikau Andrei
1 parent e779bfaa

add template for render row and cell

1 PATH 1 PATH
2 remote: . 2 remote: .
3 specs: 3 specs:
4 - kanjai (0.0.92) 4 + kanjai (0.0.121)
5 acts_as_list 5 acts_as_list
6 acts_as_tree 6 acts_as_tree
7 aws-sdk-s3 7 aws-sdk-s3
@@ -13,70 +13,70 @@ PATH @@ -13,70 +13,70 @@ PATH
13 GEM 13 GEM
14 remote: https://rubygems.org/ 14 remote: https://rubygems.org/
15 specs: 15 specs:
16 - actioncable (5.2.1)  
17 - actionpack (= 5.2.1) 16 + actioncable (5.2.2)
  17 + actionpack (= 5.2.2)
18 nio4r (~> 2.0) 18 nio4r (~> 2.0)
19 websocket-driver (>= 0.6.1) 19 websocket-driver (>= 0.6.1)
20 - actionmailer (5.2.1)  
21 - actionpack (= 5.2.1)  
22 - actionview (= 5.2.1)  
23 - activejob (= 5.2.1) 20 + actionmailer (5.2.2)
  21 + actionpack (= 5.2.2)
  22 + actionview (= 5.2.2)
  23 + activejob (= 5.2.2)
24 mail (~> 2.5, >= 2.5.4) 24 mail (~> 2.5, >= 2.5.4)
25 rails-dom-testing (~> 2.0) 25 rails-dom-testing (~> 2.0)
26 - actionpack (5.2.1)  
27 - actionview (= 5.2.1)  
28 - activesupport (= 5.2.1) 26 + actionpack (5.2.2)
  27 + actionview (= 5.2.2)
  28 + activesupport (= 5.2.2)
29 rack (~> 2.0) 29 rack (~> 2.0)
30 rack-test (>= 0.6.3) 30 rack-test (>= 0.6.3)
31 rails-dom-testing (~> 2.0) 31 rails-dom-testing (~> 2.0)
32 rails-html-sanitizer (~> 1.0, >= 1.0.2) 32 rails-html-sanitizer (~> 1.0, >= 1.0.2)
33 - actionview (5.2.1)  
34 - activesupport (= 5.2.1) 33 + actionview (5.2.2)
  34 + activesupport (= 5.2.2)
35 builder (~> 3.1) 35 builder (~> 3.1)
36 erubi (~> 1.4) 36 erubi (~> 1.4)
37 rails-dom-testing (~> 2.0) 37 rails-dom-testing (~> 2.0)
38 rails-html-sanitizer (~> 1.0, >= 1.0.3) 38 rails-html-sanitizer (~> 1.0, >= 1.0.3)
39 - activejob (5.2.1)  
40 - activesupport (= 5.2.1) 39 + activejob (5.2.2)
  40 + activesupport (= 5.2.2)
41 globalid (>= 0.3.6) 41 globalid (>= 0.3.6)
42 - activemodel (5.2.1)  
43 - activesupport (= 5.2.1)  
44 - activerecord (5.2.1)  
45 - activemodel (= 5.2.1)  
46 - activesupport (= 5.2.1) 42 + activemodel (5.2.2)
  43 + activesupport (= 5.2.2)
  44 + activerecord (5.2.2)
  45 + activemodel (= 5.2.2)
  46 + activesupport (= 5.2.2)
47 arel (>= 9.0) 47 arel (>= 9.0)
48 - activestorage (5.2.1)  
49 - actionpack (= 5.2.1)  
50 - activerecord (= 5.2.1) 48 + activestorage (5.2.2)
  49 + actionpack (= 5.2.2)
  50 + activerecord (= 5.2.2)
51 marcel (~> 0.3.1) 51 marcel (~> 0.3.1)
52 - activesupport (5.2.1) 52 + activesupport (5.2.2)
53 concurrent-ruby (~> 1.0, >= 1.0.2) 53 concurrent-ruby (~> 1.0, >= 1.0.2)
54 i18n (>= 0.7, < 2) 54 i18n (>= 0.7, < 2)
55 minitest (~> 5.1) 55 minitest (~> 5.1)
56 tzinfo (~> 1.1) 56 tzinfo (~> 1.1)
57 - acts_as_list (0.9.16) 57 + acts_as_list (0.9.18)
58 activerecord (>= 3.0) 58 activerecord (>= 3.0)
59 - acts_as_tree (2.8.0) 59 + acts_as_tree (2.9.0)
60 activerecord (>= 3.0.0) 60 activerecord (>= 3.0.0)
61 arel (9.0.0) 61 arel (9.0.0)
62 aws-eventstream (1.0.1) 62 aws-eventstream (1.0.1)
63 - aws-partitions (1.105.0)  
64 - aws-sdk-core (3.31.0) 63 + aws-partitions (1.143.0)
  64 + aws-sdk-core (3.46.2)
65 aws-eventstream (~> 1.0) 65 aws-eventstream (~> 1.0)
66 aws-partitions (~> 1.0) 66 aws-partitions (~> 1.0)
67 aws-sigv4 (~> 1.0) 67 aws-sigv4 (~> 1.0)
68 jmespath (~> 1.0) 68 jmespath (~> 1.0)
69 - aws-sdk-kms (1.9.0)  
70 - aws-sdk-core (~> 3, >= 3.26.0) 69 + aws-sdk-kms (1.13.0)
  70 + aws-sdk-core (~> 3, >= 3.39.0)
71 aws-sigv4 (~> 1.0) 71 aws-sigv4 (~> 1.0)
72 - aws-sdk-s3 (1.21.0)  
73 - aws-sdk-core (~> 3, >= 3.26.0) 72 + aws-sdk-s3 (1.31.0)
  73 + aws-sdk-core (~> 3, >= 3.39.0)
74 aws-sdk-kms (~> 1) 74 aws-sdk-kms (~> 1)
75 aws-sigv4 (~> 1.0) 75 aws-sigv4 (~> 1.0)
76 aws-sigv4 (1.0.3) 76 aws-sigv4 (1.0.3)
77 bcrypt (3.1.12) 77 bcrypt (3.1.12)
78 builder (3.2.3) 78 builder (3.2.3)
79 - concurrent-ruby (1.0.5) 79 + concurrent-ruby (1.1.4)
80 crass (1.0.4) 80 crass (1.0.4)
81 devise (4.5.0) 81 devise (4.5.0)
82 bcrypt (~> 3.0) 82 bcrypt (~> 3.0)
@@ -84,65 +84,65 @@ GEM @@ -84,65 +84,65 @@ GEM
84 railties (>= 4.1.0, < 6.0) 84 railties (>= 4.1.0, < 6.0)
85 responders 85 responders
86 warden (~> 1.2.3) 86 warden (~> 1.2.3)
87 - erubi (1.7.1)  
88 - ffi (1.9.25)  
89 - globalid (0.4.1) 87 + erubi (1.8.0)
  88 + ffi (1.10.0)
  89 + globalid (0.4.2)
90 activesupport (>= 4.2.0) 90 activesupport (>= 4.2.0)
91 - i18n (1.1.1) 91 + i18n (1.6.0)
92 concurrent-ruby (~> 1.0) 92 concurrent-ruby (~> 1.0)
93 jmespath (1.4.0) 93 jmespath (1.4.0)
94 - loofah (2.2.2) 94 + loofah (2.2.3)
95 crass (~> 1.0.2) 95 crass (~> 1.0.2)
96 nokogiri (>= 1.5.9) 96 nokogiri (>= 1.5.9)
97 mail (2.7.1) 97 mail (2.7.1)
98 mini_mime (>= 0.1.1) 98 mini_mime (>= 0.1.1)
99 marcel (0.3.3) 99 marcel (0.3.3)
100 mimemagic (~> 0.3.2) 100 mimemagic (~> 0.3.2)
101 - method_source (0.9.0)  
102 - mimemagic (0.3.2) 101 + method_source (0.9.2)
  102 + mimemagic (0.3.3)
103 mini_mime (1.0.1) 103 mini_mime (1.0.1)
104 - mini_portile2 (2.3.0) 104 + mini_portile2 (2.4.0)
105 minitest (5.11.3) 105 minitest (5.11.3)
106 nio4r (2.3.1) 106 nio4r (2.3.1)
107 - nokogiri (1.8.5)  
108 - mini_portile2 (~> 2.3.0) 107 + nokogiri (1.10.1)
  108 + mini_portile2 (~> 2.4.0)
109 orm_adapter (0.5.0) 109 orm_adapter (0.5.0)
110 pg (1.0.0) 110 pg (1.0.0)
111 - rack (2.0.5) 111 + rack (2.0.6)
112 rack-test (1.1.0) 112 rack-test (1.1.0)
113 rack (>= 1.0, < 3) 113 rack (>= 1.0, < 3)
114 - rails (5.2.1)  
115 - actioncable (= 5.2.1)  
116 - actionmailer (= 5.2.1)  
117 - actionpack (= 5.2.1)  
118 - actionview (= 5.2.1)  
119 - activejob (= 5.2.1)  
120 - activemodel (= 5.2.1)  
121 - activerecord (= 5.2.1)  
122 - activestorage (= 5.2.1)  
123 - activesupport (= 5.2.1) 114 + rails (5.2.2)
  115 + actioncable (= 5.2.2)
  116 + actionmailer (= 5.2.2)
  117 + actionpack (= 5.2.2)
  118 + actionview (= 5.2.2)
  119 + activejob (= 5.2.2)
  120 + activemodel (= 5.2.2)
  121 + activerecord (= 5.2.2)
  122 + activestorage (= 5.2.2)
  123 + activesupport (= 5.2.2)
124 bundler (>= 1.3.0) 124 bundler (>= 1.3.0)
125 - railties (= 5.2.1) 125 + railties (= 5.2.2)
126 sprockets-rails (>= 2.0.0) 126 sprockets-rails (>= 2.0.0)
127 rails-dom-testing (2.0.3) 127 rails-dom-testing (2.0.3)
128 activesupport (>= 4.2.0) 128 activesupport (>= 4.2.0)
129 nokogiri (>= 1.6) 129 nokogiri (>= 1.6)
130 rails-html-sanitizer (1.0.4) 130 rails-html-sanitizer (1.0.4)
131 loofah (~> 2.2, >= 2.2.2) 131 loofah (~> 2.2, >= 2.2.2)
132 - railties (5.2.1)  
133 - actionpack (= 5.2.1)  
134 - activesupport (= 5.2.1) 132 + railties (5.2.2)
  133 + actionpack (= 5.2.2)
  134 + activesupport (= 5.2.2)
135 method_source 135 method_source
136 rake (>= 0.8.7) 136 rake (>= 0.8.7)
137 thor (>= 0.19.0, < 2.0) 137 thor (>= 0.19.0, < 2.0)
138 - rake (12.3.1) 138 + rake (12.3.2)
139 rb-fsevent (0.10.3) 139 rb-fsevent (0.10.3)
140 - rb-inotify (0.9.10)  
141 - ffi (>= 0.5.0, < 2) 140 + rb-inotify (0.10.0)
  141 + ffi (~> 1.0)
142 responders (2.4.0) 142 responders (2.4.0)
143 actionpack (>= 4.2.0, < 5.3) 143 actionpack (>= 4.2.0, < 5.3)
144 railties (>= 4.2.0, < 5.3) 144 railties (>= 4.2.0, < 5.3)
145 - sass (3.6.0) 145 + sass (3.7.3)
146 sass-listen (~> 4.0.0) 146 sass-listen (~> 4.0.0)
147 sass-listen (4.0.0) 147 sass-listen (4.0.0)
148 rb-fsevent (~> 0.9, >= 0.9.4) 148 rb-fsevent (~> 0.9, >= 0.9.4)
@@ -160,9 +160,9 @@ GEM @@ -160,9 +160,9 @@ GEM
160 actionpack (>= 4.0) 160 actionpack (>= 4.0)
161 activesupport (>= 4.0) 161 activesupport (>= 4.0)
162 sprockets (>= 3.0.0) 162 sprockets (>= 3.0.0)
163 - thor (0.20.0) 163 + thor (0.20.3)
164 thread_safe (0.3.6) 164 thread_safe (0.3.6)
165 - tilt (2.0.8) 165 + tilt (2.0.9)
166 tzinfo (1.2.5) 166 tzinfo (1.2.5)
167 thread_safe (~> 0.1) 167 thread_safe (~> 0.1)
168 warden (1.2.7) 168 warden (1.2.7)
@@ -178,4 +178,4 @@ DEPENDENCIES @@ -178,4 +178,4 @@ DEPENDENCIES
178 kanjai! 178 kanjai!
179 179
180 BUNDLED WITH 180 BUNDLED WITH
181 - 1.15.1 181 + 2.0.1
@@ -40,6 +40,10 @@ module Kanjai @@ -40,6 +40,10 @@ module Kanjai
40 def get_html_by_json_client(page_data) 40 def get_html_by_json_client(page_data)
41 json_data = page_data.template_content 41 json_data = page_data.template_content
42 html = '' 42 html = ''
  43 +
  44 + row_template = File.open("#{Rails.root}/app/view/kanjai/pages/templates/row.html.erb").read
  45 + cell_template = File.open("#{Rails.root}/app/view/kanjai/pages/templates/cell.html.erb").read
  46 +
43 json_data.each do |row| 47 json_data.each do |row|
44 row['attributes'] ||= {} 48 row['attributes'] ||= {}
45 49
@@ -63,22 +67,50 @@ module Kanjai @@ -63,22 +67,50 @@ module Kanjai
63 end 67 end
64 68
65 else 69 else
  70 +=begin
66 class_name = 'row-fluid clearfix' 71 class_name = 'row-fluid clearfix'
67 html_attributes = {} 72 html_attributes = {}
68 html_attributes[:class] = class_name 73 html_attributes[:class] = class_name
69 74
70 html += ActionController::Base.helpers.content_tag(:div, '', html_attributes) do 75 html += ActionController::Base.helpers.content_tag(:div, '', html_attributes) do
  76 + cells = ''
71 row["cells"].each do |cell| 77 row["cells"].each do |cell|
72 page_content = page_data.page_contents.where(:structure_id => cell['id']).first 78 page_content = page_data.page_contents.where(:structure_id => cell['id']).first
73 html = page_content.nil? ? '' : page_content.get_content_frontend 79 html = page_content.nil? ? '' : page_content.get_content_frontend
74 -  
75 -  
76 cell_class_name = cell['className'] 80 cell_class_name = cell['className']
77 81
  82 + data_attributes = [
  83 + "data-size='#{cell['size']}'",
  84 + "data-offset='#{cell['offset']}'",
  85 + "data-id='#{cell['id']}'",
  86 + "data-page_data_id='#{page_data.id}'",
  87 + "data-class='#{cell['className']}'",
  88 + ]
78 89
  90 + cells += ApplicationController.render assigns: {content: html.html_safe, cell: cell, class_name: cell_class_name, data_attributes: data_attributes.join(' ')}, inline: template
79 ActionController::Base.helpers.concat(ActionController::Base.helpers.content_tag(:div, html.html_safe, :class => "col-md-#{cell['size']} col #{cell_class_name}", 'data-size' => cell['size'], 'data-offset' => cell['offset'], 'data-id' => cell['id'], 'data-page_data_id' => page_data.id , 'data-class' => cell['className'])) 91 ActionController::Base.helpers.concat(ActionController::Base.helpers.content_tag(:div, html.html_safe, :class => "col-md-#{cell['size']} col #{cell_class_name}", 'data-size' => cell['size'], 'data-offset' => cell['offset'], 'data-id' => cell['id'], 'data-page_data_id' => page_data.id , 'data-class' => cell['className']))
80 end 92 end
81 end 93 end
  94 +=end
  95 +
  96 + cells = ''
  97 + row["cells"].each do |cell|
  98 + page_content = page_data.page_contents.where(:structure_id => cell['id']).first
  99 + html = page_content.nil? ? '' : page_content.get_content_frontend
  100 + cell_class_name = cell['className']
  101 +
  102 + data_attributes = [
  103 + "data-size='#{cell['size']}'",
  104 + "data-offset='#{cell['offset']}'",
  105 + "data-id='#{cell['id']}'",
  106 + "data-page_data_id='#{page_data.id}'",
  107 + "data-class='#{cell['className']}'",
  108 + ]
  109 +
  110 + cells += ApplicationController.render assigns: {content: html.html_safe, cell: cell, class_name: cell_class_name, data_attributes: data_attributes.join(' ')}, inline: template
  111 + end
  112 +
  113 + html += ApplicationController.render assigns: {content: cells}, inline: row_template
82 114
83 end 115 end
84 116
  1 +<div class="col-md-<%= @cell['size'] %> <%= @class_name %>" <%= @data_attributes %> >
  2 + <%= @content %>
  3 +</div>
  1 +<div class="row">
  2 + <div class="container">
  3 + <%= @content %>
  4 + </div>
  5 +</div>
1 module Kanjai 1 module Kanjai
2 - VERSION = "0.0.121" 2 + VERSION = "0.0.122"
3 end 3 end