Commit ed391b46e436b4eff7744c5389a09ff1d4ed11e8

Authored by Andrey Karpikov
1 parent d785d583

add language part support

@@ -176,7 +176,7 @@ module Kanjai @@ -176,7 +176,7 @@ module Kanjai
176 @obj.update(permitted_params[:page_content]) 176 @obj.update(permitted_params[:page_content])
177 177
178 if params[:frontend_part].to_i == 1 178 if params[:frontend_part].to_i == 1
179 - render :json => {:status => 'ok', :structure_id => @structure_id, frontentd: 1, :html => @obj.get_content_frontend} 179 + render :json => {:status => 'ok', :structure_id => @structure_id, frontentd: 1, :html => @obj.get_content_frontend(session) }
180 else 180 else
181 render :json => {:status => 'ok', :structure_id => @structure_id, :html => @obj.get_content} 181 render :json => {:status => 'ok', :structure_id => @structure_id, :html => @obj.get_content}
182 end 182 end
@@ -294,7 +294,7 @@ module Kanjai @@ -294,7 +294,7 @@ module Kanjai
294 294
295 295
296 296
297 - render :json => {:status => 'ok', :structure_id => @structure_id, :html => @obj.get_content_frontend} 297 + render :json => {:status => 'ok', :structure_id => @structure_id, :html => @obj.get_content_frontend(session) }
298 end 298 end
299 299
300 private 300 private
@@ -49,7 +49,7 @@ module Kanjai @@ -49,7 +49,7 @@ module Kanjai
49 end 49 end
50 end 50 end
51 else 51 else
52 - page_content = get_html_by_json_client(@page_data) 52 + page_content = get_html_by_json_client(@page_data, session)
53 render :html => page_content.html_safe and return 53 render :html => page_content.html_safe and return
54 end 54 end
55 55
@@ -125,7 +125,7 @@ module Kanjai @@ -125,7 +125,7 @@ module Kanjai
125 markers.each do |marker| 125 markers.each do |marker|
126 case marker 126 case marker
127 when '###CONTENT###' 127 when '###CONTENT###'
128 - page_content = get_html_by_json_client(page_data) 128 + page_content = get_html_by_json_client(page_data, session)
129 layer.gsub!(marker, page_content) 129 layer.gsub!(marker, page_content)
130 layer.gsub!('make-checked="false"', '') 130 layer.gsub!('make-checked="false"', '')
131 layer.gsub!("make-checked='false'", '') 131 layer.gsub!("make-checked='false'", '')
@@ -45,7 +45,7 @@ module Kanjai @@ -45,7 +45,7 @@ module Kanjai
45 end 45 end
46 46
47 47
48 - def get_html_by_json_client(page_data) 48 + def get_html_by_json_client(page_data, session = nil)
49 json_data = page_data.template_content 49 json_data = page_data.template_content
50 html = '' 50 html = ''
51 #row_template = File.open("#{Rails.root}/app/view/kanjai/pages/templates/row.html.erb").read 51 #row_template = File.open("#{Rails.root}/app/view/kanjai/pages/templates/row.html.erb").read
@@ -70,7 +70,7 @@ module Kanjai @@ -70,7 +70,7 @@ module Kanjai
70 if page_content.type_content.split('-').include?('wrapper') 70 if page_content.type_content.split('-').include?('wrapper')
71 html += (page_content.get_simple_content).html_safe 71 html += (page_content.get_simple_content).html_safe
72 else 72 else
73 - cells = page_content.nil? ? '' : page_content.get_content_frontend 73 + cells = page_content.nil? ? '' : page_content.get_content_frontend(session)
74 74
75 data_attributes = [ 75 data_attributes = [
76 "data-id=#{row['attributes']['id']}", 76 "data-id=#{row['attributes']['id']}",
@@ -78,9 +78,6 @@ module Kanjai @@ -78,9 +78,6 @@ module Kanjai
78 ] 78 ]
79 html += ApplicationController.render(file: 'kanjai/pages/templates/block', assigns: {content: cells.html_safe, data_attributes: data_attributes.join(' '), row: row}, layout: false).html_safe 79 html += ApplicationController.render(file: 'kanjai/pages/templates/block', assigns: {content: cells.html_safe, data_attributes: data_attributes.join(' '), row: row}, layout: false).html_safe
80 80
81 - #html += ActionController::Base.helpers.content_tag(:div, '', html_attributes) do  
82 - # ActionController::Base.helpers.concat((page_content.nil? ? '' : page_content.get_content_frontend).html_safe)  
83 - #end  
84 end 81 end
85 end 82 end
86 end 83 end
@@ -92,7 +89,7 @@ module Kanjai @@ -92,7 +89,7 @@ module Kanjai
92 row["cells"].each do |cell| 89 row["cells"].each do |cell|
93 if cell['status'].to_s == 'enabled' || cell['status'].to_s.empty? 90 if cell['status'].to_s == 'enabled' || cell['status'].to_s.empty?
94 page_content = page_data.page_contents.where(:structure_id => cell['id']).first 91 page_content = page_data.page_contents.where(:structure_id => cell['id']).first
95 - html_content = page_content.nil? ? '' : page_content.get_content_frontend 92 + html_content = page_content.nil? ? '' : page_content.get_content_frontend(session)
96 cell_class_name = cell['className'] 93 cell_class_name = cell['className']
97 94
98 data_attributes = [ 95 data_attributes = [
@@ -121,9 +118,9 @@ module Kanjai @@ -121,9 +118,9 @@ module Kanjai
121 html.to_s 118 html.to_s
122 end 119 end
123 120
124 - def get_html_by_json_client_url(url, locale) 121 + def get_html_by_json_client_url(url, locale, session = nil)
125 page_data = PageDatum.where(:url => url, lang: locale).first 122 page_data = PageDatum.where(:url => url, lang: locale).first
126 - get_html_by_json_client(page_data) 123 + get_html_by_json_client(page_data, session)
127 end 124 end
128 125
129 def make_navigation(parent_id, level) 126 def make_navigation(parent_id, level)
@@ -164,7 +164,7 @@ module Kanjai @@ -164,7 +164,7 @@ module Kanjai
164 end 164 end
165 end 165 end
166 166
167 - def get_content_frontend 167 + def get_content_frontend(session = nil)
168 if self.type_content == 'rte_editor' 168 if self.type_content == 'rte_editor'
169 self.text_html.to_s 169 self.text_html.to_s
170 elsif self.type_content == 'plugin' 170 elsif self.type_content == 'plugin'
@@ -180,7 +180,7 @@ module Kanjai @@ -180,7 +180,7 @@ module Kanjai
180 page_template = self.page.page_template 180 page_template = self.page.page_template
181 subpart = page_template.template_parts.find_by_code(self.type_content) 181 subpart = page_template.template_parts.find_by_code(self.type_content)
182 if subpart 182 if subpart
183 - html = Kanjai::TemplateGenerator.subpart_generate(nil, self.page.domain, page_template, 'content', subpart.elements, self.marker_hash, self.id) 183 + html = Kanjai::TemplateGenerator.subpart_generate(session, self.page.domain, page_template, 'content', subpart.elements, self.marker_hash, self.id)
184 else 184 else
185 html = '' 185 html = ''
186 end 186 end
@@ -245,6 +245,11 @@ module Kanjai @@ -245,6 +245,11 @@ module Kanjai
245 245
246 end 246 end
247 247
  248 + when 'language'
  249 + code = item[:attributes]['code']
  250 + if I18n.locale.to_s == code.to_s
  251 + self.content_generator(session, domain, item[:children], subparts, hash_value)
  252 + end
248 else 253 else
249 condition_process = true 254 condition_process = true
250 255
1 module Kanjai 1 module Kanjai
2 - VERSION = "0.0.279" 2 + VERSION = "0.0.280"
3 end 3 end