caboose-cms 0.9.228 → 0.9.229

Sign up to get free protection for your applications and to get access to all the features.
Files changed (109) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/javascripts/caboose/admin.js +1 -1
  3. data/app/assets/javascripts/caboose/admin_main.js +1 -13
  4. data/app/assets/javascripts/caboose/admin_media_index.js +161 -158
  5. data/app/assets/javascripts/caboose/application.js +8 -7
  6. data/app/assets/javascripts/caboose/block_content_controller_dragdrop.js +60 -4
  7. data/app/assets/javascripts/caboose/block_modal_controllers/block_dd_modal_controller.js +3 -2
  8. data/app/assets/javascripts/caboose/block_modal_controllers/media_modal_controller.js +17 -6
  9. data/app/assets/javascripts/caboose/model/all.js +5 -1
  10. data/app/assets/stylesheets/caboose/admin_block_edit_image.css.scss +2 -1
  11. data/app/assets/stylesheets/caboose/admin_edit_page_content_dragdrop.scss +71 -15
  12. data/app/assets/stylesheets/caboose/admin_main.css.scss +25 -29
  13. data/app/assets/stylesheets/caboose/admin_media_index.css.scss +26 -5
  14. data/app/assets/stylesheets/caboose/application.css +11 -5
  15. data/app/assets/stylesheets/caboose/login.scss +1 -0
  16. data/app/assets/stylesheets/caboose/model_binder.css +13 -4
  17. data/app/assets/stylesheets/caboose/page_bar_generator.css +2 -1
  18. data/app/controllers/caboose/admin_controller.rb +3 -4
  19. data/app/controllers/caboose/application_controller.rb +16 -19
  20. data/app/controllers/caboose/block_types_controller.rb +8 -6
  21. data/app/controllers/caboose/cart_controller.rb +2 -2
  22. data/app/controllers/caboose/change_logs_controller.rb +13 -0
  23. data/app/controllers/caboose/fonts_controller.rb +139 -2
  24. data/app/controllers/caboose/invoices_controller.rb +5 -4
  25. data/app/controllers/caboose/login_logs_controller.rb +5 -7
  26. data/app/controllers/caboose/media_categories_controller.rb +16 -2
  27. data/app/controllers/caboose/media_controller.rb +14 -11
  28. data/app/controllers/caboose/pages_controller.rb +104 -42
  29. data/app/controllers/caboose/posts_controller.rb +53 -7
  30. data/app/controllers/caboose/products_controller.rb +1 -1
  31. data/app/controllers/caboose/sites_controller.rb +25 -6
  32. data/app/controllers/caboose/sns_controller.rb +3 -3
  33. data/app/controllers/caboose/themes_controller.rb +30 -0
  34. data/app/controllers/caboose/users_controller.rb +17 -10
  35. data/app/controllers/caboose/variants_controller.rb +9 -9
  36. data/app/models/caboose/block.rb +98 -22
  37. data/app/models/caboose/block_type.rb +2 -1
  38. data/app/models/caboose/block_type_parser.rb +1 -1
  39. data/app/models/caboose/calendar_event_group.rb +2 -2
  40. data/app/models/caboose/change_log.rb +97 -0
  41. data/app/models/caboose/core_plugin.rb +4 -3
  42. data/app/models/caboose/font.rb +7 -2
  43. data/app/models/caboose/font_variant.rb +12 -0
  44. data/app/models/caboose/media.rb +15 -4
  45. data/app/models/caboose/media_category.rb +2 -4
  46. data/app/models/caboose/page.rb +316 -45
  47. data/app/models/caboose/page_bar_generator.rb +20 -10
  48. data/app/models/caboose/post.rb +108 -8
  49. data/app/models/caboose/product.rb +1 -1
  50. data/app/models/caboose/role.rb +2 -2
  51. data/app/models/caboose/schema.rb +73 -72
  52. data/app/models/caboose/site.rb +203 -1
  53. data/app/models/caboose/theme.rb +70 -5
  54. data/app/views/caboose/block_types/admin_edit.html.erb +6 -8
  55. data/app/views/caboose/blocks/_cached_block.html.erb +28 -0
  56. data/app/views/caboose/blocks/_file.html.erb +2 -2
  57. data/app/views/caboose/blocks/_ga.html.erb +1 -2
  58. data/app/views/caboose/blocks/_image.html.erb +4 -0
  59. data/app/views/caboose/blocks/_render_function.html.erb +9 -4
  60. data/app/views/caboose/change_logs/admin_index.html.erb +65 -0
  61. data/app/views/caboose/fonts/admin_family_edit.html.erb +63 -0
  62. data/app/views/caboose/fonts/admin_family_index.html.erb +42 -0
  63. data/app/views/caboose/fonts/admin_index.html.erb +55 -10
  64. data/app/views/caboose/fonts/admin_variant_edit.html.erb +84 -0
  65. data/app/views/caboose/invoices_mailer/customer_status_updated.html.erb +5 -14
  66. data/app/views/caboose/login_logs/admin_index_for_user.html.erb +1 -1
  67. data/app/views/caboose/media/admin_index.html.erb +14 -24
  68. data/app/views/caboose/my_account/index.html.erb +1 -0
  69. data/app/views/caboose/pages/_admin_header.html.erb +5 -0
  70. data/app/views/caboose/pages/admin_change_logs.html.erb +56 -0
  71. data/app/views/caboose/pages/admin_edit_content.html.erb +6 -2
  72. data/app/views/caboose/pages/admin_edit_general.html.erb +32 -4
  73. data/app/views/caboose/pages/compiled_asset.css.erb +0 -0
  74. data/app/views/caboose/pages/compiled_asset.js.erb +0 -0
  75. data/app/views/caboose/posts/_admin_header.html.erb +5 -0
  76. data/app/views/caboose/posts/admin_change_logs.html.erb +56 -0
  77. data/app/views/caboose/posts/admin_delete_form.html.erb +1 -1
  78. data/app/views/caboose/posts/admin_edit_content.html.erb +6 -2
  79. data/app/views/caboose/products/admin_group_variants.html.erb +1 -1
  80. data/app/views/caboose/products/admin_sort.html copy.erb +1 -1
  81. data/app/views/caboose/sites/admin_edit.html.erb +21 -0
  82. data/app/views/caboose/sites/compiled_asset.css.erb +0 -0
  83. data/app/views/caboose/sites/compiled_asset.js.erb +0 -0
  84. data/app/views/caboose/themes/admin_edit.html.erb +7 -3
  85. data/app/views/caboose/themes/admin_error_log.html.erb +9 -0
  86. data/app/views/caboose/themes/admin_js.html.erb +131 -0
  87. data/app/views/caboose/users/_admin_header.html.erb +4 -0
  88. data/app/views/caboose/users/admin_change_logs.html.erb +63 -0
  89. data/app/views/caboose/users/admin_edit_roles.html.erb +1 -0
  90. data/app/views/caboose/variants/admin_group.html.erb +1 -1
  91. data/app/views/layouts/caboose/admin.html.erb +9 -2
  92. data/app/views/layouts/caboose/application.html.erb +62 -92
  93. data/app/views/layouts/caboose/css.css.erb +44 -0
  94. data/app/views/layouts/caboose/footer_css.css.erb +41 -0
  95. data/app/views/layouts/caboose/footer_js.js.erb +31 -0
  96. data/app/views/layouts/caboose/js.js.erb +34 -0
  97. data/lib/caboose/version.rb +1 -1
  98. data/lib/tasks/caboose.rake +3 -14
  99. metadata +23 -27
  100. data/app/controllers/caboose/assets_controller.rb +0 -65
  101. data/app/models/caboose/asset.rb +0 -23
  102. data/app/models/caboose/asset_manifest.rb +0 -91
  103. data/app/models/caboose/block_cache.rb +0 -105
  104. data/app/models/caboose/block_cache_file.rb +0 -22
  105. data/app/models/caboose/block_cache_image.rb +0 -53
  106. data/app/models/caboose/page_cache.rb +0 -12
  107. data/app/models/caboose/page_cacher.rb +0 -137
  108. data/app/views/caboose/pages/admin_new_old.html.erb +0 -46
  109. data/app/views/caboose/pages/test.html.erb +0 -64
@@ -0,0 +1,9 @@
1
+ <h1>Error Log</h1>
2
+
3
+ <a href="#" onclick="window.history.back();return false;" class="caboose-btn">Back</a>
4
+
5
+ <% if !@theme.sass_error.blank? %>
6
+ <div class="error" style="font-size:13px;line-height:18px;font-family:monospace;margin-top:10px;">
7
+ <%== @theme.sass_error.gsub("\n","<br />") %>
8
+ </div>
9
+ <% end %>
@@ -0,0 +1,131 @@
1
+
2
+ <h1 id='page_title'>Edit Site Javascript</h1>
3
+
4
+
5
+ <div class="editor-wrapper">
6
+
7
+ <div class="holder">
8
+ <div class="clearfix buttons">
9
+ <p class="warning">WARNING: This code will apply to the entire website. Edit with caution.</p>
10
+ <a href="/admin/theme" class="caboose-btn">Back</a>
11
+ <a href="#" onclick="save();return false;" class="caboose-btn green">Save</a>
12
+ <span id="modified">Modified</span>
13
+ <div id="message"></div>
14
+ <p id="tips">
15
+ <span>Command+S = Save</span>
16
+ </p>
17
+ </div>
18
+ <div id="editor"><%= @theme.main_js %></div>
19
+ </div>
20
+
21
+ </div>
22
+
23
+ <% content_for :caboose_css do %>
24
+ <style>
25
+ p.warning {
26
+ color: #d43030;
27
+ font-size: 14px;
28
+ font-weight: bold;
29
+ margin: 0 0 8px 0;
30
+ }
31
+ p#tips {
32
+ display: inline-block;
33
+ float: right;
34
+ font-size: 13px;
35
+ color: gray;
36
+ margin: 0;
37
+ padding-top: 15px;
38
+ padding-right: 2px;
39
+ }
40
+ p#tips span {
41
+ display: inline-block;
42
+ margin-left: 12px;
43
+ }
44
+ span#modified {
45
+ font-size: 13px;
46
+ color: gray;
47
+ margin: 0 10px;
48
+ opacity: 0;
49
+ transition: opacity 100ms ease;
50
+ }
51
+ .buttons {
52
+ margin-bottom: 10px;
53
+ }
54
+ .buttons .caboose-btn {
55
+ margin-right: 5px;
56
+ }
57
+ .editor-wrapper {
58
+
59
+ padding-right: 30px;
60
+ }
61
+
62
+ .holder {
63
+
64
+ }
65
+ #editor {
66
+ height: 800px;
67
+ width: 100%;
68
+ opacity: 0;
69
+ }
70
+ #editor.ace_editor {
71
+ opacity: 1;
72
+ }
73
+ #message {
74
+ display: inline-block;
75
+ }
76
+ #message p.note {
77
+ padding: 1px 15px 2px 15px;
78
+ font-size: 15px;
79
+ line-height: 30px;
80
+ border-radius: 5px;
81
+ }
82
+ #message p.note.loading {
83
+ padding-left: 40px;
84
+ }
85
+ </style>
86
+ <% end %>
87
+
88
+ <% content_for :caboose_js do %>
89
+ <%= javascript_include_tag 'https://cdnjs.cloudflare.com/ajax/libs/ace/1.4.1/ace.js' %>
90
+ <script>
91
+ var editor = ace.edit("editor");
92
+ editor.setTheme("ace/theme/monokai");
93
+ editor.session.setMode("ace/mode/javascript");
94
+ editor.session.setOptions({
95
+ tabSize: 2
96
+ });
97
+
98
+ editor.on("change", function() {
99
+ $("span#modified").css('opacity',1);
100
+ });
101
+
102
+ editor.commands.addCommand({
103
+ name: 'save',
104
+ bindKey: {win: "Ctrl-S", "mac": "Cmd-S"},
105
+ exec: function(editor) { save(); }
106
+ });
107
+
108
+ function save() {
109
+ $('#message').html("<p class='note loading'>Saving code...</p>").fadeIn();
110
+ $.ajax({
111
+ url: '/admin/theme/js',
112
+ type: 'put',
113
+ data: {
114
+ code: editor.getValue()
115
+ },
116
+ success: function(resp) {
117
+ if (resp.error) $('#message').html("<p class='note error'>" + resp.error + "</p>").fadeIn();
118
+ if (resp.success) {
119
+ $("span#modified").css('opacity',0);
120
+ $('#message').html("<p class='note success'>JS saved!</p>").fadeIn().delay(2000).fadeOut();
121
+ }
122
+ }
123
+ });
124
+ }
125
+
126
+ </script>
127
+ <% end %>
128
+
129
+ <br style='clear: left; line-height: 0;' />
130
+
131
+
@@ -26,6 +26,10 @@ if Caboose::Subscription.where(:site_id => @site.id).exists?
26
26
  arr = tabs.to_a.insert(6, ['Subscriptions', "/admin/users/#{@edituser.id}/subscriptions"])
27
27
  tabs = Hash[arr]
28
28
  end
29
+ if @site.use_change_logs && Caboose::ChangeLog.where(:user_id => @edituser.id).exists? && @logged_in_user.is_allowed('logs','view')
30
+ arr = tabs.to_a.insert(4, ["Change Logs","/admin/users/#{@edituser.id}/logs"])
31
+ tabs = Hash[arr]
32
+ end
29
33
  tabs = Caboose.plugin_hook('admin_user_tabs', tabs, @edituser, @site)
30
34
  %>
31
35
  <% tabs.each do |text, href| %>
@@ -0,0 +1,63 @@
1
+ <%= render :partial => 'caboose/users/admin_header' %>
2
+
3
+ <div style="padding-right:30px;">
4
+ <table cellpadding="0" cellspacing="0">
5
+ <thead>
6
+ <tr>
7
+ <th>Resource</th>
8
+ <th>Title</th>
9
+ <th>Date</th>
10
+ <th>Action</th>
11
+ <th>Field</th>
12
+ <th>Old Value</th>
13
+ <th>New Value</th>
14
+ </tr>
15
+ </thead>
16
+ <% @logs.each do |log| %>
17
+ <%
18
+ res = log.page_id ? Caboose::Page.where(:id => log.page_id).first : (log.post_id ? Caboose::Post.where(:id => log.post_id).first : (log.media_id ? Caboose::Media.where(:id => log.media_id).first : nil))
19
+ res_type = log.page_id ? "Page" : (log.post_id ? "Post" : (log.description.include?('Media Category') && log.media_id ? ('Media Category') : (log.media_id ? "Media" : nil)))
20
+ res_title = res ? (log.page_id ? res.title : (log.post_id ? res.title : (log.description.include?('Media Category') && log.media_id ? (log.description.gsub('Media Category: ','')) : (log.media_id ? Caboose::Media.title_for_id(res.id) : "N/A")))) : log.description.gsub("Media Category: ","")
21
+ %>
22
+ <tr>
23
+ <td><%= res_type %></td>
24
+ <td><%= res_title %></td>
25
+ <td><%= log.timestamp.in_time_zone('Central Time (US & Canada)').strftime('%-m/%-d/%y, %l:%M%P') %></td>
26
+ <td><%= log.describe_action %></td>
27
+ <td><%= log.description.blank? ? '' : log.description.gsub("Media Category: ",'') %></td>
28
+ <td><%== (!log.description.blank? && log.description.include?('Custom Css') || log.description.include?('Custom Js')) || (!log.describe_old.blank? && log.describe_old.include?('</')) ? "<pre>" : "" %><%= log.describe_old %><%== (!log.description.blank? && log.description.include?('Custom Css') || log.description.include?('Custom Js')) || (!log.describe_old.blank? && log.describe_old.include?('</')) ? "</pre>" : "" %></td>
29
+ <td><%== (!log.description.blank? && log.description.include?('Custom Css') || log.description.include?('Custom Js')) || (!log.describe_new.blank? && log.describe_new.include?('</')) ? "<pre>" : "" %><%= log.describe_new %><%== (!log.description.blank? && log.description.include?('Custom Css') || log.description.include?('Custom Js')) || (!log.describe_new.blank? && log.describe_new.include?('</')) ? "</pre>" : "" %></td>
30
+ </tr>
31
+ <% end %>
32
+ </table>
33
+ </div>
34
+
35
+
36
+ <% content_for :caboose_css do %>
37
+ <style>
38
+ table {
39
+ width: 100%;
40
+ }
41
+ table tr {
42
+
43
+ }
44
+ table td, table th {
45
+ font-family: "Roboto";
46
+ font-weight: 300;
47
+ font-size: 13px;
48
+ padding: 6px 8px 6px 4px;
49
+ text-align: left;
50
+ max-width: 200px;
51
+ border-bottom: 1px solid #eaeaea;
52
+ }
53
+ td pre {
54
+ overflow: hidden;
55
+ white-space: pre-line;
56
+ font-size: 12px;
57
+ font-family: monospace;
58
+ }
59
+ table th {
60
+ font-weight: bold;
61
+ }
62
+ </style>
63
+ <% end %>
@@ -6,6 +6,7 @@
6
6
  <div id='roles'>
7
7
  <table class='data'>
8
8
  <% Caboose::Role.flat_tree(@site.id).each do |r| %>
9
+ <% next if !@logged_in_user.is_allowed('all','all') && (r.name == 'Admin' || r.name == 'Everyone Logged Out' || r.name == '-Everyone Logged In') %>
9
10
  <% is_member = Caboose::RoleMembership.where(:role_id => r.id, :user_id => @edituser.id).exists? %>
10
11
  <tr><td><input type='checkbox' name='role<%= r.id %>' <%= is_member ? "checked='true'" : '' %> onclick="toggle_role(<%= @edituser.id %>, <%= r.id %>, $(this).prop('checked'));" /></td><td><%= r.name %></td></tr>
11
12
  <% end %>
@@ -109,7 +109,7 @@
109
109
  <% end %>
110
110
 
111
111
  <% content_for :caboose_js do %>
112
- <%= javascript_include_tag 'underscore' %>
112
+ <%= javascript_include_tag 'https://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.9.1/underscore-min.js' %>
113
113
 
114
114
  <script>
115
115
  window.count = <%= @variants.count %>;
@@ -11,7 +11,11 @@ if request.env['HTTP_CF_VISITOR'] && request.env['HTTP_CF_VISITOR'].include?('ht
11
11
  end
12
12
 
13
13
  content_for :admin_css do
14
- %><%= stylesheet_link_tag "caboose/admin", :media => "all" %><%
14
+ %><%= stylesheet_link_tag "caboose/admin", :media => "all" %>
15
+ <%= stylesheet_link_tag "colorbox-rails", :media => "all" %>
16
+ <%= stylesheet_link_tag "caboose/model_binder", :media => "all" %>
17
+ <%# stylesheet_link_tag "caboose/page_bar_generator", :media => "all" %>
18
+ <%
15
19
  if File.exists?("#{Rails.root}/app/assets/stylesheets/admin.css")
16
20
  %><%= stylesheet_link_tag "admin", :media => "all" %><%
17
21
  end
@@ -27,7 +31,10 @@ if protocol == 'https://'
27
31
  end
28
32
 
29
33
  content_for :admin_js do
30
- %><%= javascript_include_tag "caboose/admin" %><%
34
+ %>
35
+ <%= javascript_include_tag "caboose/admin" %>
36
+ <%= javascript_include_tag "caboose/jquery.detect" %>
37
+ <%
31
38
  %><%= yield :caboose_js %><%
32
39
  end
33
40
 
@@ -1,41 +1,57 @@
1
1
  <% if @page && @page.title != 'Access Denied' %>
2
- <% content_for :js do %>
3
- <%= gzip_javascript_include_tag "caboose/application" %>
4
- <% if @site.theme %>
5
- <script type='text/javascript' src="<%= @site.theme.js_url %>"></script>
6
- <% else %>
7
- <%= gzip_javascript_include_tag @site.name == 'application' ? 'application' : "#{@site.name}/js/application" %>
8
- <% end %>
9
- <script>window.loggedIn = <%= logged_in?.to_json %></script>
10
- <% Caboose::javascripts.each do |js| %><%= javascript_include_tag(js) %><% end %>
11
- <% @page.linked_resources_map[:js].each do |r| %><%= gzip_javascript_include_tag r %><% end %>
12
- <% if @site.date_js_updated %><script type='text/javascript' src="<%= raw @site.custom_js_url %>"></script><% end %>
13
- <% if @page.custom_js_files && @page.custom_js_files.strip.length > 0 %>
14
- <% @page.custom_js_files.split("\n").each do |url| %><script type='text/javascript' src="<%= raw url %>"></script><% end %>
15
- <% end %>
16
- <% if @page.custom_js && @page.custom_js.strip.length > 0 %><script type='text/javascript'><%= raw @page.custom_js %></script><% end %>
17
- <%= yield :caboose_js %>
18
- <% end %>
19
- <% content_for :css do %>
20
- <%= gzip_stylesheet_link_tag 'caboose/application' %>
21
- <% if @site.theme %>
22
- <link rel='stylesheet' type='text/css' media='all' href="<%= @site.theme.asset_url(@site.id) %>" />
23
- <% else %>
24
- <%= gzip_stylesheet_link_tag @site.name == 'application' ? 'application' : "#{@site.name}/css/application" %>
25
- <% end %>
26
- <% Caboose::stylesheets.each do |css| %><%= gzip_stylesheet_link_tag(css) %><% end %>
27
- <% @page.linked_resources_map[:css].each do |r| %><%= gzip_stylesheet_link_tag r %><% end %>
28
- <% if @site.date_css_updated %><link rel='stylesheet' type='text/css' href="<%= raw @site.custom_css_url %>" /><% end %>
29
- <% if @page.custom_css_files && @page.custom_css_files.strip.length > 0 %>
30
- <% @page.custom_css_files.split("\n").each do |url| %><link rel="stylesheet" type='text/css' href="<%= raw url %>" /><% end %>
31
- <% end %>
32
- <% if @page.custom_css && @page.custom_css.strip.length > 0 %><style><%= raw @page.custom_css %></style><% end %>
33
- <%= yield :caboose_css %>
34
- <% end %>
2
+ <% content_for :js do %>
3
+ <%= gzip_javascript_include_tag "caboose/application" %>
4
+ <% if @site.theme %>
5
+ <script type='text/javascript' src="<%= @site.theme.js_url(@site.id) %>"></script>
6
+ <% else %>
7
+ <%= gzip_javascript_include_tag @site.name == 'application' ? 'application' : "#{@site.name}/js/application" %>
8
+ <% end %>
9
+ <% Caboose::javascripts.each do |js| %><%= javascript_include_tag(js) %><% end %>
10
+ <% if @site.date_js_updated %><script type='text/javascript' src="<%== @site.custom_js_url %>"></script><% end %>
11
+ <% if @page.custom_js_files && @page.custom_js_files.strip.length > 0 %>
12
+ <% @page.custom_js_files.split("\n").each do |url| %><script type='text/javascript' src="<%== url %>"></script><% end %>
13
+ <% end %>
14
+ <% if @page.custom_js && @page.custom_js.strip.length > 0 && (!@site.use_caching || @editing) %><script type='text/javascript'><%== @page.custom_js %></script><% end %>
15
+ <% if @site.use_caching && (!@editing || (@preview && @page.is_published)) %>
16
+ <% js_url = @page.js_url %>
17
+ <% if !js_url.include?('empty.js') && !@post %><script type='text/javascript' src="<%= js_url %>"></script><!-- page js --><% end %>
18
+ <% end %>
19
+ <% if @site.use_caching %>
20
+ <% footer_js_url = @site.footer_js_url %>
21
+ <% if !footer_js_url.include?('empty.js') && @page.parent_id != -1 %><script type='text/javascript' src="<%= footer_js_url %>"></script><!-- footer js --><% end %>
22
+ <% end %>
23
+ <% if !@site.custom_js_files.blank? && @page.parent_id != -1 %>
24
+ <% @site.custom_js_files.split("\n").each do |url| %><script type='text/javascript' src="<%== url %>"></script><% end %>
25
+ <% end %>
26
+ <%= yield :caboose_js %>
27
+ <% end %>
28
+ <% content_for :css do %>
29
+ <% if @site.theme %>
30
+ <link rel='stylesheet' type='text/css' media='all' href="<%= @site.theme.asset_url(@site.id) %>" />
31
+ <% else %>
32
+ <%= gzip_stylesheet_link_tag @site.name == 'application' ? 'application' : "#{@site.name}/css/application" %>
33
+ <% end %>
34
+ <% if @site.use_caching && (!@editing || (@preview && @page.is_published)) %>
35
+ <% css_url = @page.css_url %>
36
+ <% if !css_url.include?('empty.css') && !@post %><link rel='stylesheet' type='text/css' media='all' href="<%= css_url %>" /><!-- page css --><% end %>
37
+ <% end %>
38
+ <% if @site.use_caching %>
39
+ <% footer_css_url = @site.footer_css_url %>
40
+ <% if !footer_css_url.include?('empty.css') && @page.parent_id != -1 %><link rel='stylesheet' type='text/css' media='all' href="<%= footer_css_url %>" /><!-- footer css --><% end %>
41
+ <% end %>
42
+ <% if !@site.custom_css_files.blank? && @page.parent_id != -1 %>
43
+ <% @site.custom_css_files.split("\n").each do |url| %><link rel="stylesheet" type='text/css' href="<%== url %>" /><% end %>
44
+ <% end %>
45
+ <% Caboose::stylesheets.each do |css| %><%= gzip_stylesheet_link_tag(css) %><% end %>
46
+ <% if @site.date_css_updated %><link rel='stylesheet' type='text/css' href="<%== @site.custom_css_url %>" /><% end %>
47
+ <% if @page.custom_css_files && @page.custom_css_files.strip.length > 0 %>
48
+ <% @page.custom_css_files.split("\n").each do |url| %><link rel="stylesheet" type='text/css' href="<%== url %>" /><% end %>
49
+ <% end %>
50
+ <% if @page.custom_css && @page.custom_css.strip.length > 0 && (!@site.use_caching || @editing) %><style><%== @page.custom_css %></style><% end %>
51
+ <%= yield :caboose_css %>
52
+ <% end %>
35
53
  <%
36
54
  b = @post ? @post.block : @page.block
37
- #Caboose.log(@post)
38
- #Caboose.log(@page.block.inspect)
39
55
  if b.nil?
40
56
  bt = @site.default_layout
41
57
  if @post
@@ -47,7 +63,6 @@
47
63
  end
48
64
  b.create_children
49
65
  end
50
- #b.log_helper
51
66
  options = {
52
67
  :request => @request,
53
68
  :post => @post,
@@ -66,63 +81,19 @@
66
81
  :ga_events => @ga_events
67
82
  }
68
83
  @block_options.each{ |k,v| options[k] = v } if @block_options
69
-
70
- str = nil
71
- #if @use_page_cache
72
- # pc = Caboose::PageCache.where(:page_id => @page.id).first
73
- # if pc # If the page is cached, send it to the user
74
- #
75
- # require_dependency "#{Caboose.root}/app/models/caboose/block_cache.rb"
76
- # require_dependency "#{Caboose.root}/app/models/caboose/block_cache_file.rb"
77
- # require_dependency "#{Caboose.root}/app/models/caboose/block_cache_image.rb"
78
- #
79
- # @block = Marshal.load(pc.block)
80
- # @view = options[:view ]
81
- # @controller_view_content = options[:controller_view_content ]
82
- # @modal = options[:modal ]
83
- # @empty_text = options[:empty_text ]
84
- # @editing = options[:editing ]
85
- # @css = options[:css ]
86
- # @js = options[:js ]
87
- # @csrf_meta_tags = options[:csrf_meta_tags ]
88
- # @csrf_meta_tags2 = options[:csrf_meta_tags2 ]
89
- #
90
- # str = render(:inline => pc.render_function)
91
- # end
92
- #end
93
-
94
- # Render the blocks if we don't have it cached
95
84
  str = b.render(b, options) if str.nil?
96
-
97
- protocol = request.protocol
98
- #protocol = Caboose.plugin_hook('request_protocol', protocol, request)
99
-
100
- # See if we're using cloudflare
101
- if request.env['HTTP_CF_VISITOR'] && request.env['HTTP_CF_VISITOR'].include?('https')
102
- protocol = 'https://'
103
- request.env['REQUEST_URI'] = "https://#{request.env['REQUEST_URI'][7..-1]}" if (request.env['REQUEST_URI'] =~ %r"http://") == 0
104
- request.env['SERVER_PORT'] = '443' if request.env['SERVER_PORT'] == '80'
105
- request.env['HTTP_REFERER'] = "https://#{request.env['HTTP_REFERER'][7..-1]}" if (request.env['HTTP_REFERER'] =~ %r"http://") == 0
106
- request.env['rack.url_scheme'] = 'https'
107
- request.env['HTTPS'] = 'on'
108
- end
85
+ protocol = "https://"
109
86
 
110
87
  css = b.partial('ga', options)
111
88
  css << yield(:css)
112
- css.gsub!("<link href=\"//", "<link href=\"#{protocol}")
113
- css.gsub!("<link href='//" , "<link href='#{protocol}")
114
- if protocol == 'https://'
115
- css.gsub!("<link href=\"http://", "<link href=\"https://")
116
- css.gsub!("<link href='http://" , "<link href='https://")
117
- end
89
+ css << raw(@post ? @post.cached_css : @page.cached_css) if @post || (@site.use_caching && @editing && !@preview && (@post ? @post.is_published : @page.is_published))
90
+ css.gsub!("<link href=\"http://", "<link href=\"https://")
91
+ css.gsub!("<link href='http://" , "<link href='https://")
118
92
 
119
93
  js = yield(:js)
120
- js.gsub!("<script src=\"//", "<script src=\"#{protocol}")
121
- js.gsub!("<script src='//" , "<script src='#{protocol}")
122
- if protocol == 'https://'
123
- js.gsub!("<script src=\"http://", "<script src=\"https://")
124
- js.gsub!("<script src='http://" , "<script src='https://")
125
- end
94
+ js << raw(@post ? @post.cached_js : @page.cached_js) if @post || (@site.use_caching && @editing && !@preview && (@post ? @post.is_published : @page.is_published))
95
+ js.gsub!("<script src=\"http://", "<script src=\"https://")
96
+ js.gsub!("<script src='http://" , "<script src='https://")
126
97
  if @site.use_retargeting
127
98
  js << b.partial('retargeting', options)
128
99
  end
@@ -130,8 +101,7 @@
130
101
  str.gsub!('|CABOOSE_CSS|' , css)
131
102
  str.gsub!('|CABOOSE_PROTOCOL|' , protocol)
132
103
  str.gsub!('|CABOOSE_JAVASCRIPT|' , js)
133
- str.gsub!('|CABOOSE_CSRF|' , csrf_meta_tags)
134
-
135
- %><%= raw str %><%
136
- end
137
- %>
104
+ str.gsub!('|CABOOSE_CSRF|' , csrf_meta_tags)
105
+ %>
106
+ <%== str %>
107
+ <% end %>
@@ -0,0 +1,44 @@
1
+ <% if @page.custom_css && !@page.custom_css.blank? %>
2
+ <%== @page.custom_css %>
3
+ <% end %>
4
+ <%
5
+ css = ''
6
+ css << raw(@post ? @post.cached_css : @page.cached_css) if @site.use_caching
7
+ if !css.blank?
8
+ css = css.gsub('<style>','')
9
+ css = css.gsub('</style>','')
10
+ links = css.scan(/@import(\s)*url\(('|")(http(s)?:)?(\/\/[A-z 0-9?=@._\-\/]*)('|")\);/).flatten
11
+ links2 = css.scan(/<link href=('|")(http(s)?:)?(\/\/[A-z 0-9?=@._\-\/]*)('|")([A-z 0-9@?="'\/]*)\/>/).flatten
12
+ css_files = []
13
+ if links && links.length > 0
14
+ links.to_a.each do |link|
15
+ if !link.blank? && link.include?('.css') && !link.include?('@import')
16
+ if !css_files.include?(link)
17
+ css_files << link
18
+ end
19
+ end
20
+ end
21
+ end
22
+ if links2 && links2.length > 0
23
+ links2.to_a.each do |link|
24
+ if !link.blank? && link.include?('.css') && !link.include?('media')
25
+ if !css_files.include?(link)
26
+ css_files << link
27
+ end
28
+ end
29
+ end
30
+ end
31
+ str = @page.custom_css_files.blank? ? '' : @page.custom_css_files
32
+ css_files.each do |csf|
33
+ str += "\n" if !str.blank? && !str.include?(csf)
34
+ str += "#{csf}" if !str.include?(csf)
35
+ end
36
+ @page.custom_css_files = str
37
+ @page.save
38
+ if !css.blank?
39
+ css = css.gsub(/@import(\s)*url\(('|")(http(s)?:)?(\/\/[A-z 0-9?=@._\-\/]*)('|")\);/,'')
40
+ css = css.gsub(/<link href=('|")(http(s)?:)?(\/\/[A-z 0-9?=@._\-\/]*)('|")([A-z 0-9@?="'\/]*)\/>/,'')
41
+ end
42
+ %>
43
+ <%== css %>
44
+ <% end %>