From c95629a781667f5af1a3cd489522ee9fae1ee7df Mon Sep 17 00:00:00 2001 From: xdite Date: Mon, 11 Feb 2013 19:34:14 +0800 Subject: [PATCH 1/3] move google analytics to partial --- app/helpers/common_helper.rb | 7 +++++++ app/views/common/_google_analytics.html.erb | 14 ++++++++++++++ app/views/layouts/application.html.erb | 17 +---------------- 3 files changed, 22 insertions(+), 16 deletions(-) create mode 100644 app/helpers/common_helper.rb create mode 100644 app/views/common/_google_analytics.html.erb diff --git a/app/helpers/common_helper.rb b/app/helpers/common_helper.rb new file mode 100644 index 00000000000..83ee98efa5b --- /dev/null +++ b/app/helpers/common_helper.rb @@ -0,0 +1,7 @@ +module CommonHelper + def render_google_analytics_code + if Rails.env == "production" && SiteSetting.ga_tracking_code.present? + render :partial => "common/google_analytics" + end + end +end \ No newline at end of file diff --git a/app/views/common/_google_analytics.html.erb b/app/views/common/_google_analytics.html.erb new file mode 100644 index 00000000000..79f2414e848 --- /dev/null +++ b/app/views/common/_google_analytics.html.erb @@ -0,0 +1,14 @@ + \ No newline at end of file diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index 106abd5f98d..68e1351080c 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -124,22 +124,7 @@ Discourse.initialize() - <%- if Rails.env == "production" and SiteSetting.ga_tracking_code.present? %> - - <%-end%> + <%= render_google_analytics_code %> From c3fd34985de2c30931e496ba2d18cc2b3b053133 Mon Sep 17 00:00:00 2001 From: xdite Date: Mon, 11 Feb 2013 19:36:43 +0800 Subject: [PATCH 2/3] move discourse javascript setting --- .../common/_discourse_javascript.html.erb | 25 +++++++++++++++++ app/views/layouts/application.html.erb | 27 +------------------ 2 files changed, 26 insertions(+), 26 deletions(-) create mode 100644 app/views/common/_discourse_javascript.html.erb diff --git a/app/views/common/_discourse_javascript.html.erb b/app/views/common/_discourse_javascript.html.erb new file mode 100644 index 00000000000..8c54a574241 --- /dev/null +++ b/app/views/common/_discourse_javascript.html.erb @@ -0,0 +1,25 @@ + <%- if mini_profiler_enabled? %> + <%- Rack::MiniProfiler.step "application" do %> + <%= javascript_include_tag "application" %> + <%-end%> + + <%- Rack::MiniProfiler.step "admin" do %> + <%= javascript_include_tag "admin"%> + <%-end%> + <%- else %> + <%= javascript_include_tag "application" %> + <%- if admin? %> + <%= javascript_include_tag "admin"%> + <%- end %> + <%- end%> + + \ No newline at end of file diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index 68e1351080c..52ccbb50b8f 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -97,33 +97,8 @@ <%= yield :data %>
- - <%- if mini_profiler_enabled? %> - <%- Rack::MiniProfiler.step "application" do %> - <%= javascript_include_tag "application" %> - <%-end%> - <%- Rack::MiniProfiler.step "admin" do %> - <%= javascript_include_tag "admin"%> - <%-end%> - <%- else %> - <%= javascript_include_tag "application" %> - <%- if admin? %> - <%= javascript_include_tag "admin"%> - <%- end %> - <%- end%> - - - + <%= render :partial => "common/discourse_javascript" %> <%= render_google_analytics_code %> From 4175341b26d6ba3e23d56384a390bb78f70ece44 Mon Sep 17 00:00:00 2001 From: xdite Date: Mon, 11 Feb 2013 19:41:23 +0800 Subject: [PATCH 3/3] move stylesheet --- .../common/_discourse_stylesheet.html.erb | 12 ++++++ app/views/common/_special_font_face.html.erb | 31 +++++++++++++ app/views/layouts/application.html.erb | 43 ++----------------- 3 files changed, 46 insertions(+), 40 deletions(-) create mode 100644 app/views/common/_discourse_stylesheet.html.erb create mode 100644 app/views/common/_special_font_face.html.erb diff --git a/app/views/common/_discourse_stylesheet.html.erb b/app/views/common/_discourse_stylesheet.html.erb new file mode 100644 index 00000000000..6f81b70913f --- /dev/null +++ b/app/views/common/_discourse_stylesheet.html.erb @@ -0,0 +1,12 @@ + <%- unless SiteCustomization.override_default_style(session[:preview_style]) %> + <%=stylesheet_link_tag "application"%> + <%- end %> + + <%- if mini_profiler_enabled? %> + <%- Rack::MiniProfiler.step "stylsheet" do%> + <%= stylesheet_link_tag "admin"%> + <%-end%> + <%- elsif admin? %> + <%= stylesheet_link_tag "admin"%> + <%-end%> + <%=SiteCustomization.custom_stylesheet(session[:preview_style])%> \ No newline at end of file diff --git a/app/views/common/_special_font_face.html.erb b/app/views/common/_special_font_face.html.erb new file mode 100644 index 00000000000..bad6846bf53 --- /dev/null +++ b/app/views/common/_special_font_face.html.erb @@ -0,0 +1,31 @@ + + <%# + The fonts are loaded outside of the stylesheet so that we can dynamically change + the path. This is to get around CDN caching on the Origin: + + https://forums.aws.amazon.com/thread.jspa?threadID=114646 + %> + +<% font_domain = "#{request.protocol}#{request.host_with_port}" %> + + \ No newline at end of file diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index 52ccbb50b8f..f314b2819a0 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -19,48 +19,11 @@ <%= javascript_include_tag "preload_store" %> - <%# - The fonts are loaded outside of the stylesheet so that we can dynamically change - the path. This is to get around CDN caching on the Origin: - https://forums.aws.amazon.com/thread.jspa?threadID=114646 - %> + <%= render :partial => "common/special_font_face" %> + <%= render :partial => "common/discourse_stylesheet" %> - <%- font_domain = "#{request.protocol}#{request.host_with_port}" %> - - - <%- unless SiteCustomization.override_default_style(session[:preview_style]) %> - <%=stylesheet_link_tag "application"%> - <%- end %> - - <%- if mini_profiler_enabled? %> - <%- Rack::MiniProfiler.step "stylsheet" do%> - <%= stylesheet_link_tag "admin"%> - <%-end%> - <%- elsif admin? %> - <%= stylesheet_link_tag "admin"%> - <%-end%> - <%=SiteCustomization.custom_stylesheet(session[:preview_style])%> <%=csrf_meta_tags%> @@ -97,7 +60,7 @@ <%= yield :data %> - + <%= render :partial => "common/discourse_javascript" %> <%= render_google_analytics_code %>