Showing
6 changed files
with
21 additions
and
21 deletions
| @@ -10,7 +10,7 @@ module Kanjai | @@ -10,7 +10,7 @@ module Kanjai | ||
| 10 | 10 | ||
| 11 | @remote_ip = request.remote_ip | 11 | @remote_ip = request.remote_ip |
| 12 | @scheme = request.protocol.to_s.downcase | 12 | @scheme = request.protocol.to_s.downcase |
| 13 | - $scheme = @scheme | 13 | + session[:scheme] = @scheme |
| 14 | end | 14 | end |
| 15 | end | 15 | end |
| 16 | end | 16 | end |
| @@ -71,7 +71,7 @@ module Kanjai | @@ -71,7 +71,7 @@ module Kanjai | ||
| 71 | 71 | ||
| 72 | def setTemplateContent(domain, page_template, layer, page_data) | 72 | def setTemplateContent(domain, page_template, layer, page_data) |
| 73 | 73 | ||
| 74 | - $scheme = 'http://' | 74 | + session[:scheme] = 'http://' |
| 75 | 75 | ||
| 76 | unless current_admin_user | 76 | unless current_admin_user |
| 77 | layer.gsub!('<meta name="csrf-param" content="###CSRF_PARAM###"/>', '') | 77 | layer.gsub!('<meta name="csrf-param" content="###CSRF_PARAM###"/>', '') |
| @@ -150,19 +150,19 @@ module Kanjai | @@ -150,19 +150,19 @@ module Kanjai | ||
| 150 | layer.gsub!(marker, Rack::Utils.escape_html(form_authenticity_token)) | 150 | layer.gsub!(marker, Rack::Utils.escape_html(form_authenticity_token)) |
| 151 | end | 151 | end |
| 152 | when '###DOMAIN_NAME###' | 152 | when '###DOMAIN_NAME###' |
| 153 | - layer.gsub!(marker, $scheme + ADMIN_CONFIG['domain_name']) | 153 | + layer.gsub!(marker, session[:scheme] + ADMIN_CONFIG['domain_name']) |
| 154 | when '###INCLUDE_JS_FILE###' | 154 | when '###INCLUDE_JS_FILE###' |
| 155 | js_array = [] | 155 | js_array = [] |
| 156 | if params[:format].to_s != 'pdf' | 156 | if params[:format].to_s != 'pdf' |
| 157 | if current_admin_user | 157 | if current_admin_user |
| 158 | - js_array << "<script src='#{$scheme}#{ADMIN_CONFIG['domain_name']}#{ActionController::Base.helpers.asset_path('kanjai/frontend.js')}'></script>" | ||
| 159 | - css_path = "#{$scheme}#{ADMIN_CONFIG['domain_name']}#{ActionController::Base.helpers.asset_path('kanjai/frontend.css')}" | 158 | + js_array << "<script src='#{session[:scheme]}#{ADMIN_CONFIG['domain_name']}#{ActionController::Base.helpers.asset_path('kanjai/frontend.js')}'></script>" |
| 159 | + css_path = "#{session[:scheme]}#{ADMIN_CONFIG['domain_name']}#{ActionController::Base.helpers.asset_path('kanjai/frontend.css')}" | ||
| 160 | js_array << "<script type='text/javascript'>$('<link>', {rel: 'stylesheet',type: 'text/css',href: '#{css_path}'}).appendTo('head');</script>" | 160 | js_array << "<script type='text/javascript'>$('<link>', {rel: 'stylesheet',type: 'text/css',href: '#{css_path}'}).appendTo('head');</script>" |
| 161 | else | 161 | else |
| 162 | - js_array << "<script src='#{$scheme}#{ADMIN_CONFIG['domain_name']}#{ActionController::Base.helpers.asset_path('kanjai/frontend_not_login.js')}'></script>" | 162 | + js_array << "<script src='#{session[:scheme]}#{ADMIN_CONFIG['domain_name']}#{ActionController::Base.helpers.asset_path('kanjai/frontend_not_login.js')}'></script>" |
| 163 | end | 163 | end |
| 164 | - js_array << "<script src='#{$scheme}#{ADMIN_CONFIG['domain_name']}#{ActionController::Base.helpers.asset_path('kanjai/frontend_extend.js')}'></script>" | ||
| 165 | - css_path = "#{$scheme}#{ADMIN_CONFIG['domain_name']}#{ActionController::Base.helpers.asset_path('kanjai/frontend_extend.css')}" | 164 | + js_array << "<script src='#{session[:scheme]}#{ADMIN_CONFIG['domain_name']}#{ActionController::Base.helpers.asset_path('kanjai/frontend_extend.js')}'></script>" |
| 165 | + css_path = "#{session[:scheme]}#{ADMIN_CONFIG['domain_name']}#{ActionController::Base.helpers.asset_path('kanjai/frontend_extend.css')}" | ||
| 166 | js_array << "<script type='text/javascript'>$('<link>', {rel: 'stylesheet',type: 'text/css',href: '#{css_path}'}).appendTo('head');</script>" | 166 | js_array << "<script type='text/javascript'>$('<link>', {rel: 'stylesheet',type: 'text/css',href: '#{css_path}'}).appendTo('head');</script>" |
| 167 | end | 167 | end |
| 168 | layer.gsub!(marker, js_array.join('')) | 168 | layer.gsub!(marker, js_array.join('')) |
| @@ -71,7 +71,7 @@ module Kanjai | @@ -71,7 +71,7 @@ module Kanjai | ||
| 71 | #@page_data = PageDatum.where(:url => @url).first | 71 | #@page_data = PageDatum.where(:url => @url).first |
| 72 | #$current_locale = PageLang.where(default_use: true).first.code | 72 | #$current_locale = PageLang.where(default_use: true).first.code |
| 73 | @page_data = PageDatum.joins(page: :domain).where(kanjai_domains: {id: domain.id}).where(:url => @url, lang: I18n.locale).first | 73 | @page_data = PageDatum.joins(page: :domain).where(kanjai_domains: {id: domain.id}).where(:url => @url, lang: I18n.locale).first |
| 74 | - $current_locale = I18n.locale | 74 | + session[:current_locale] = I18n.locale |
| 75 | if @page_data.nil? | 75 | if @page_data.nil? |
| 76 | mas = @url.split('/') | 76 | mas = @url.split('/') |
| 77 | if mas.length > 1 | 77 | if mas.length > 1 |
| @@ -87,7 +87,7 @@ module Kanjai | @@ -87,7 +87,7 @@ module Kanjai | ||
| 87 | if @url == '/' | 87 | if @url == '/' |
| 88 | root_page = Page.joins(:domain).where(kanjai_domains: {id: domain.id}).where(root_page: true).first | 88 | root_page = Page.joins(:domain).where(kanjai_domains: {id: domain.id}).where(root_page: true).first |
| 89 | if root_page | 89 | if root_page |
| 90 | - redirect_to root_page.menu_url($scheme) | 90 | + redirect_to root_page.menu_url(session[:scheme]) |
| 91 | else | 91 | else |
| 92 | render text: "Can not found page #{@url} for domain #{domain_title}" and return | 92 | render text: "Can not found page #{@url} for domain #{domain_title}" and return |
| 93 | end | 93 | end |
| @@ -95,7 +95,7 @@ module Kanjai | @@ -95,7 +95,7 @@ module Kanjai | ||
| 95 | render text: "Can not found page #{@url} for domain #{domain_title}" and return | 95 | render text: "Can not found page #{@url} for domain #{domain_title}" and return |
| 96 | end | 96 | end |
| 97 | end | 97 | end |
| 98 | - $url = @url | 98 | + session[:url] = @url |
| 99 | end | 99 | end |
| 100 | 100 | ||
| 101 | 101 |
| @@ -151,7 +151,7 @@ module Kanjai | @@ -151,7 +151,7 @@ module Kanjai | ||
| 151 | ActionController::Base.helpers.concat( | 151 | ActionController::Base.helpers.concat( |
| 152 | ActionController::Base.helpers.content_tag(:li) do | 152 | ActionController::Base.helpers.content_tag(:li) do |
| 153 | ActionController::Base.helpers.concat( | 153 | ActionController::Base.helpers.concat( |
| 154 | - ActionController::Base.helpers.link_to (page.lang_attributes(PageLang.default(page.domain), :title) + '<span class="caret"></span>').html_safe, page.menu_url($scheme, lang = nil), :class => 'dropdown-toggle', 'data-toggle' => "dropdown", 'role' => "button", 'aria-haspopup' => "true", 'aria-expanded' => "false" | 154 | + ActionController::Base.helpers.link_to (page.lang_attributes(PageLang.default(page.domain), :title) + '<span class="caret"></span>').html_safe, page.menu_url(session[:scheme], lang = nil), :class => 'dropdown-toggle', 'data-toggle' => "dropdown", 'role' => "button", 'aria-haspopup' => "true", 'aria-expanded' => "false" |
| 155 | ) | 155 | ) |
| 156 | ActionController::Base.helpers.concat( | 156 | ActionController::Base.helpers.concat( |
| 157 | ActionController::Base.helpers.content_tag(:ul) do | 157 | ActionController::Base.helpers.content_tag(:ul) do |
| @@ -166,7 +166,7 @@ module Kanjai | @@ -166,7 +166,7 @@ module Kanjai | ||
| 166 | ActionController::Base.helpers.concat( | 166 | ActionController::Base.helpers.concat( |
| 167 | ActionController::Base.helpers.content_tag(:li) do | 167 | ActionController::Base.helpers.content_tag(:li) do |
| 168 | ActionController::Base.helpers.concat( | 168 | ActionController::Base.helpers.concat( |
| 169 | - ActionController::Base.helpers.link_to page.lang_attributes(PageLang.default(page.domain), :title), page.menu_url($scheme, lang = nil) | 169 | + ActionController::Base.helpers.link_to page.lang_attributes(PageLang.default(page.domain), :title), page.menu_url(session[:scheme], lang = nil) |
| 170 | ) | 170 | ) |
| 171 | end | 171 | end |
| 172 | ) | 172 | ) |
| @@ -108,14 +108,14 @@ module Kanjai | @@ -108,14 +108,14 @@ module Kanjai | ||
| 108 | self.menu_generator(next_level[:children], subparts, nil, page) | 108 | self.menu_generator(next_level[:children], subparts, nil, page) |
| 109 | else | 109 | else |
| 110 | 110 | ||
| 111 | - if $url == page.lang_attributes(I18n.locale, :url) | 111 | + if session[:url] == page.lang_attributes(I18n.locale, :url) |
| 112 | if active_state_template.present? | 112 | if active_state_template.present? |
| 113 | - subparts << active_state_template.gsub('###link###', page.menu_url($scheme, lang = nil)) | 113 | + subparts << active_state_template.gsub('###link###', page.menu_url(session[:scheme], lang = nil)) |
| 114 | .gsub('###title###', page.lang_attributes(I18n.locale, :title)) | 114 | .gsub('###title###', page.lang_attributes(I18n.locale, :title)) |
| 115 | end | 115 | end |
| 116 | else | 116 | else |
| 117 | if normal_state_template.present? | 117 | if normal_state_template.present? |
| 118 | - subparts << normal_state_template.gsub('###link###', page.menu_url($scheme, lang = nil)) | 118 | + subparts << normal_state_template.gsub('###link###', page.menu_url(session[:scheme], lang = nil)) |
| 119 | .gsub('###title###', page.lang_attributes(I18n.locale, :title)) | 119 | .gsub('###title###', page.lang_attributes(I18n.locale, :title)) |
| 120 | end | 120 | end |
| 121 | end | 121 | end |
| @@ -147,7 +147,7 @@ module Kanjai | @@ -147,7 +147,7 @@ module Kanjai | ||
| 147 | elements.each do |item| | 147 | elements.each do |item| |
| 148 | case item[:name] | 148 | case item[:name] |
| 149 | when 'text' | 149 | when 'text' |
| 150 | - lang = domain.page_langs.find_by_code($current_locale) | 150 | + lang = domain.page_langs.find_by_code(session[:current_locale]) |
| 151 | content = item[:source] | 151 | content = item[:source] |
| 152 | content = content.gsub('###CURRENT_LANG_TITLE###', lang.title) | 152 | content = content.gsub('###CURRENT_LANG_TITLE###', lang.title) |
| 153 | .gsub('###CURRENT_LANG_CODE###', lang.code) | 153 | .gsub('###CURRENT_LANG_CODE###', lang.code) |
| @@ -174,12 +174,12 @@ module Kanjai | @@ -174,12 +174,12 @@ module Kanjai | ||
| 174 | end | 174 | end |
| 175 | 175 | ||
| 176 | 176 | ||
| 177 | - page_data = PageDatum.where(:url => $url, :lang => $current_locale).first | 177 | + page_data = PageDatum.where(:url => session[:url], :lang => session[:current_locale]).first |
| 178 | if page_data | 178 | if page_data |
| 179 | page = page_data.page | 179 | page = page_data.page |
| 180 | end | 180 | end |
| 181 | domain.page_langs.all.each do |lang| | 181 | domain.page_langs.all.each do |lang| |
| 182 | - if lang.code.to_s == $current_locale.to_s && active_state_template | 182 | + if lang.code.to_s == session[:current_locale].to_s && active_state_template |
| 183 | content = active_state_template.gsub('###LANG_CODE###', lang.code) | 183 | content = active_state_template.gsub('###LANG_CODE###', lang.code) |
| 184 | .gsub('###LANG_TITLE###', lang.title) | 184 | .gsub('###LANG_TITLE###', lang.title) |
| 185 | 185 | ||
| @@ -190,7 +190,7 @@ module Kanjai | @@ -190,7 +190,7 @@ module Kanjai | ||
| 190 | end | 190 | end |
| 191 | if content | 191 | if content |
| 192 | if page | 192 | if page |
| 193 | - content = content.gsub('###PAGE_LINK###', page.menu_url($scheme, lang.code)) | 193 | + content = content.gsub('###PAGE_LINK###', page.menu_url(session[:scheme], lang.code)) |
| 194 | else | 194 | else |
| 195 | content = content.gsub('###PAGE_LINK###', '/') | 195 | content = content.gsub('###PAGE_LINK###', '/') |
| 196 | end | 196 | end |