Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge bootstrap UI into master

  • Loading branch information...
commit 7da47c0975476d85612a75ae606e4966fbf6b684 2 parents 27945e5 + 345dc13
peakpg peakpg authored
Showing with 1,997 additions and 1,562 deletions.
  1. +5 −0 Gemfile
  2. +6 −2 Gemfile.lock
  3. +1 −0  app/assets/javascripts/cms/application.js
  4. +27 −12 app/assets/javascripts/cms/content_library.js
  5. +8 −0 app/assets/javascripts/cms/page_editing.js
  6. +6 −1 app/assets/javascripts/cms/toolbar.js
  7. +0 −7 app/assets/stylesheets/browsercms/application.css
  8. +0 −171 app/assets/stylesheets/cms/application.css.erb
  9. +16 −0 app/assets/stylesheets/cms/application.css.scss
  10. +20 −0 app/assets/stylesheets/cms/bootstrap_corrections.css.scss
  11. +1 −0  app/assets/stylesheets/cms/load_bootstrap.css.scss
  12. +44 −0 app/assets/stylesheets/cms/page_content_editing.css.scss
  13. +4 −0 app/assets/stylesheets/cms/page_editor.css
  14. +100 −78 app/assets/stylesheets/cms/page_toolbar.css.erb
  15. +167 −0 app/assets/stylesheets/cms/styles.css.scss.erb
  16. +30 −29 app/controllers/cms/application_controller.rb
  17. +8 −12 app/controllers/cms/base_controller.rb
  18. +16 −17 app/controllers/cms/cache_controller.rb
  19. +5 −4 app/controllers/cms/content_block_controller.rb
  20. +28 −24 app/controllers/cms/content_controller.rb
  21. +5 −5 app/controllers/cms/content_types_controller.rb
  22. +1 −2  app/controllers/cms/dynamic_views_controller.rb
  23. +18 −13 app/controllers/cms/email_messages_controller.rb
  24. +16 −16 app/controllers/cms/groups_controller.rb
  25. +13 −9 app/controllers/cms/redirects_controller.rb
  26. +2 −5 app/controllers/cms/users_controller.rb
  27. +12 −27 app/helpers/cms/application_helper.rb
  28. +1 −1  app/helpers/cms/content_block_helper.rb
  29. +23 −0 app/helpers/cms/nav_menu_helper.rb
  30. +16 −10 app/helpers/cms/page_helper.rb
  31. +1 −7 app/helpers/cms/template_support.rb
  32. +140 −1 app/helpers/cms/ui_elements_helper.rb
  33. +5 −0 app/models/cms/dynamic_view.rb
  34. +5 −0 app/models/cms/portlet.rb
  35. +0 −1  app/models/cms/templates.rb
  36. +17 −0 app/views/cms/blocks/_buttonbar.html.erb
  37. +1 −1  app/views/cms/blocks/edit.html.erb
  38. +1 −1  app/views/cms/blocks/index.html.erb
  39. +1 −1  app/views/cms/blocks/new.html.erb
  40. +1 −2  app/views/cms/blocks/show.html.erb
  41. +1 −1  app/views/cms/blocks/usages.html.erb
  42. +3 −3 app/views/cms/blocks/versions.html.erb
  43. +2 −3 app/views/cms/cache/show.html.erb
  44. +41 −39 app/views/cms/connectors/new.html.erb
  45. +4 −0 app/views/cms/content/editing_frame.html.erb
  46. +0 −3  app/views/cms/content/no_page.html.erb
  47. +10 −13 app/views/cms/content/show.html.erb
  48. +1 −2  app/views/cms/content_types/index.html.erb
  49. +1 −0  app/views/cms/dynamic_views/_form.html.erb
  50. +10 −0 app/views/cms/dynamic_views/_toolbar.html.erb
  51. +1 −2  app/views/cms/dynamic_views/edit.html.erb
  52. +1 −6 app/views/cms/dynamic_views/index.html.erb
  53. +1 −2  app/views/cms/dynamic_views/new.html.erb
  54. +1 −6 app/views/cms/groups/_form.html.erb
  55. +6 −0 app/views/cms/groups/_toolbar.html.erb
  56. +2 −3 app/views/cms/groups/edit.html.erb
  57. +1 −5 app/views/cms/groups/index.html.erb
  58. +0 −1  app/views/cms/groups/new.html.erb
  59. +1 −5 app/views/cms/links/edit.html.erb
  60. +8 −12 app/views/cms/links/new.html.erb
  61. +3 −0  app/views/cms/page_routes/_back_to_routes.html.erb
  62. +7 −0 app/views/cms/page_routes/_toolbar.html.erb
  63. +2 −2 app/views/cms/page_routes/edit.html.erb
  64. +1 −8 app/views/cms/page_routes/index.html.erb
  65. +2 −2 app/views/cms/page_routes/new.html.erb
  66. +8 −8 app/views/cms/page_routes/show.html.erb
  67. +20 −12 app/views/cms/pages/_edit_connector.html.erb
  68. +4 −4 app/views/cms/pages/_edit_container.html.erb
  69. +3 −5 app/views/cms/pages/edit.html.erb
  70. +1 −6 app/views/cms/pages/new.html.erb
  71. +9 −9 app/views/cms/pages/versions.html.erb
  72. +2 −0  app/views/cms/redirects/_form.html.erb
  73. +2 −3 app/views/cms/redirects/edit.html.erb
  74. +5 −5 app/views/cms/redirects/index.html.erb
  75. +2 −3 app/views/cms/redirects/new.html.erb
  76. +2 −3 app/views/cms/routes/index.html.erb
  77. +3 −0  app/views/cms/section_nodes/_button_bar.html.erb
  78. +13 −11 app/views/cms/section_nodes/index.html.erb
  79. +1 −5 app/views/cms/sections/edit.html.erb
  80. +12 −16 app/views/cms/sections/new.html.erb
  81. +0 −1  app/views/cms/shared/access_denied.html.erb
  82. +0 −3  app/views/cms/shared/error.html.erb
  83. +2 −4 app/views/cms/tasks/new.html.erb
  84. +20 −0 app/views/cms/toolbar/_editor_toolbar.html.erb
  85. +0 −33 app/views/cms/toolbar/_mobile_toggle.html.erb
  86. +17 −0 app/views/cms/toolbar/_mobile_toolbar.html.erb
  87. +10 −0 app/views/cms/toolbar/_new_pages_menu.html.erb
  88. +80 −0 app/views/cms/toolbar/_toolbar.html.erb
  89. +82 −1 app/views/cms/toolbar/index.html.erb
  90. +19 −22 app/views/cms/users/_toolbar.html.erb
  91. +2 −9 app/views/cms/users/change_password.html.erb
  92. +2 −15 app/views/cms/users/edit.html.erb
  93. +54 −48 app/views/cms/users/index.html.erb
  94. +2 −12 app/views/cms/users/new.html.erb
  95. +2 −14 app/views/cms/users/show.html.erb
  96. +1 −32 app/views/layouts/_cms_toolbar.html.erb
  97. +0 −119 app/views/layouts/_page_toolbar.html.erb
  98. +2 −2 app/views/layouts/cms/_head.html.erb
  99. +122 −0 app/views/layouts/cms/_thin_toolbar.html.erb
  100. +2 −9 app/views/layouts/cms/administration.html.erb
  101. +2 −1  app/views/layouts/cms/application.html.erb
  102. +1 −3 app/views/layouts/cms/content_library.html.erb
  103. +9 −9 app/views/layouts/cms/dashboard.html.erb
  104. +20 −0 app/views/layouts/cms/page_editor.html.erb
  105. +17 −16 app/views/layouts/cms/section_nodes.html.erb
  106. +4 −6 app/views/layouts/cms/toolbar.html.erb
  107. +1 −0  browsercms.gemspec
  108. +12 −1 doc/release_notes.md
  109. +7 −9 features/add_content_to_pages.feature
  110. +1 −1  features/ckeditor.feature
  111. +3 −4 features/content_blocks/manage_custom_blocks.feature
  112. +8 −1 features/content_blocks/manage_html_blocks.feature
  113. +64 −1 features/manage_users.feature
  114. +4 −5 features/mobile_templates.feature
  115. +44 −0 features/navigation_menu/new_button.feature
  116. +4 −4 features/page_templates.feature
  117. +1 −2  features/portlets/email_friend_portlet.feature
  118. +1 −1  features/portlets/portlet_helpers.feature
  119. +10 −11 features/portlets/portlets.feature
  120. +3 −4 features/portlets/tag_cloud_portlet.feature
  121. +22 −43 features/step_definitions/content_pages_steps.rb
  122. +25 −0 features/step_definitions/manage_content_blocks_steps.rb
  123. +3 −0  features/step_definitions/manage_user_steps.rb
  124. +1 −1  features/step_definitions/mobile_steps.rb
  125. +38 −0 features/step_definitions/new_button_steps.rb
  126. +7 −2 features/step_definitions/portlets_steps.rb
  127. +113 −0 features/step_definitions/user_steps.rb
  128. +7 −0 features/support/cms_api.rb
  129. +25 −0 features/support/factories.rb
  130. +18 −0 features/support/page_inspector.rb
  131. +3 −1 features/support/slowest_scenarios.rb
  132. +17 −1 features/support/transforms.rb
  133. +11 −5 features/taxonomy/manage_categories.feature
  134. +23 −0 features/user_self_service.feature
  135. +1 −0  lib/browsercms.rb
  136. +3 −0  lib/cms/acts/content_page.rb
  137. +17 −0 lib/cms/admin_tab.rb
  138. +0 −4 lib/cms/domain_support.rb
  139. +0 −2  lib/generators/browser_cms/demo_site/templates/demo.seeds.rb
  140. +1 −1  test/dummy/app/portlets/uses_helper_portlet.rb
  141. +0 −1  test/dummy/app/views/layouts/mobile/mobile-ready.html.erb
  142. +0 −1  test/dummy/app/views/layouts/templates/default.html.erb
  143. +0 −1  test/dummy/app/views/layouts/templates/desktop-only.html.erb
  144. +0 −1  test/dummy/app/views/layouts/templates/mobile-ready.html.erb
  145. +0 −1  test/dummy/app/views/layouts/templates/subpage.html.erb
  146. +6 −1 test/factories/factories.rb
  147. +0 −28 test/functional/cms/categories_controller_test.rb
  148. +0 −12 test/functional/cms/content_controller_test.rb
  149. +0 −20 test/functional/cms/dashboard_controller_test.rb
  150. +0 −23 test/functional/cms/html_blocks_controller_test.rb
  151. +0 −57 test/functional/cms/portlets_controller_test.rb
  152. +0 −76 test/functional/cms/toolbar_controller_test.rb
  153. +0 −205 test/functional/cms/users_controller_test.rb
  154. +1 −2  test/unit/helpers/application_helper_test.rb
  155. +3 −3 test/unit/lib/cms/domain_support_test.rb
  156. +5 −0 test/unit/models/dynamic_views_test.rb
  157. +7 −0 test/unit/models/portlet_test.rb
  158. +37 −0 todo_bootstrap.md
5 Gemfile
View
@@ -16,6 +16,11 @@ group :production do
gem 'uglifier'
end
+group :assets do
+ gem 'sass-rails'
+ gem 'bootstrap-sass'
+end
+
group :test do
gem 'factory_girl_rails', '3.3.0'
gem 'test-unit', '2.1.1'
8 Gemfile.lock
View
@@ -1,8 +1,9 @@
PATH
remote: .
specs:
- browsercms (3.5.5)
+ browsercms (4.0.0.a)
ancestry (~> 1.2.4)
+ bootstrap-sass
ckeditor_rails (~> 3.6.4)
jquery-rails (~> 2.0)
paperclip (~> 3.0.3)
@@ -50,6 +51,7 @@ GEM
ffi (>= 1.0.11)
rspec (>= 2.7.0)
bluecloth (2.2.0)
+ bootstrap-sass (2.1.0.1)
builder (3.0.4)
capybara (1.1.2)
mime-types (>= 1.16)
@@ -179,7 +181,7 @@ GEM
treetop (1.4.11)
polyglot
polyglot (>= 0.3.1)
- tzinfo (0.3.33)
+ tzinfo (0.3.34)
uglifier (1.3.0)
execjs (>= 0.3.0)
multi_json (~> 1.0, >= 1.0.2)
@@ -193,6 +195,7 @@ PLATFORMS
DEPENDENCIES
aruba
bluecloth
+ bootstrap-sass
browsercms!
capybara
cucumber
@@ -203,6 +206,7 @@ DEPENDENCIES
mocha (= 0.9.8)
mysql2
ruby-prof
+ sass-rails
sqlite3-ruby
test-unit (= 2.1.1)
thin
1  app/assets/javascripts/cms/application.js
View
@@ -8,5 +8,6 @@
//= require jquery.taglist
//= require cms/core_library
//= require cms/attachment_manager
+//= require bootstrap
//
39 app/assets/javascripts/cms/content_library.js
View
@@ -1,4 +1,4 @@
-jQuery(function($) {
+jQuery(function ($) {
//----- Helper Functions -----------------------------------------------------
//In all of this code, we are defining functions that we use later
@@ -8,12 +8,12 @@ jQuery(function($) {
//For example, if you have section_node_5,
//you pass this 'section_node_5', 'section_node'
//and this returns 5
- var getId = function(elementId, s) {
+ var getId = function (elementId, s) {
return elementId.replace(s, '')
}
- var nodeOnDoubleClick = function() {
+ var nodeOnDoubleClick = function () {
if ($('#edit_button').hasClass('disabled')) {
//$('#view_button').click()
location.href = $('#view_button')[0].href
@@ -23,7 +23,7 @@ jQuery(function($) {
}
}
- var addNodeOnDoubleClick = function() {
+ var addNodeOnDoubleClick = function () {
$('#blocks tr').dblclick(nodeOnDoubleClick)
}
@@ -39,21 +39,20 @@ jQuery(function($) {
// I.e. Select a row, the 'View' button becomes active and the URL goes to the right path.
//
// Any element with class='cms-content-table' will have this applied to it.
-(function($) {
- $.fn.cmsContentToolbar = function() {
-
+(function ($) {
+ $.fn.cmsContentToolbar = function () {
var content_type = this.data('content_type')
var is_versioned = this.data('versioned')
var can_publish = this.data('can_publish')
var plural_title = this.data('plural_title')
$('table.data tbody tr').hover(
- function() {
+ function () {
$(this).addClass('hover')
},
- function() {
+ function () {
$(this).removeClass('hover')
- }).click(function() {
+ }).click(function () {
var view_path = $(this).data('view_path');
var edit_path = $(this).data('edit_path');
var delete_path = $(this).data('delete_path');
@@ -89,14 +88,30 @@ jQuery(function($) {
}
if (can_publish) {
if (status == 'draft' && publishable) {
- $('#publish_button').removeClass('disabled').attr('href', publish_path);
+ $('#publish_button')
+ .attr('href', publish_path)
+ .enable_menu_button();
+ } else {
+ $('#publish_button')
+ .disable_menu_button();
}
}
})
};
})(jQuery);
-$(function() {
+(function ($) {
+ $.fn.disable_menu_button = function () {
+ $(this).addClass('disabled');
+ $(this).attr("href", "#");
+ }
+ $.fn.enable_menu_button = function () {
+ $(this).removeClass('disabled');
+ return $(this);
+ }
+})(jQuery);
+
+$(function () {
$('.cms-content-table').cmsContentToolbar();
});
8 app/assets/javascripts/cms/page_editing.js
View
@@ -0,0 +1,8 @@
+//= require 'jquery'
+//= require 'jquery_ujs'
+//= require 'cms/core_library'
+
+// Since we are within the page editing iframe, add a 'target=_top' to all links so links refresh the entire page.
+$(function () {
+ $('a').attr('target', '_top');
+});
7 app/assets/javascripts/cms/toolbar.js
View
@@ -2,4 +2,9 @@
// A manifest file for all CMS toolbar related js.
//= require jquery
//= require jquery.selectbox
-//= require cms/application
+//= require cms/application
+
+// Add an information popup to the Edit Properties button on the Page Toolbar
+$(function(){
+ $('#edit_properties_button').popover({placement: 'bottom'});
+});
7 app/assets/stylesheets/browsercms/application.css
View
@@ -1,7 +0,0 @@
-/*
- * This is a manifest file that'll automatically include all the stylesheets available in this directory
- * and any sub-directories. You're free to add application-wide styles to this file and they'll appear at
- * the top of the compiled file, but it's generally better to create a new file per style scope.
- *= require_self
- *= require_tree .
-*/
171 app/assets/stylesheets/cms/application.css.erb
View
@@ -1,171 +0,0 @@
-/**
-*
-*= require cms/reset
-*= require cms/nav
-*= require cms/menu
-*= require cms/buttons
-*= require cms/data_table
-*= require cms/attachment_manager
-*= require_self
-*/
-
-body {
-background: #FFF url(<%= asset_path "cms/bg.png" %>) repeat-x 0 0;
-text-align: center;
-font: 62.5%/100% "Trebuchet MS", Helvetica, Verdana, Arial, sans-serif;
-color: #727171;
-}
-
-
-
-a img { border: 0 }
-
-a {
- color: #36659D;
- text-decoration: none;
-}
-
-a:hover {
- text-decoration: underline;
-}
-
-.check_uncheck { font-size: 80%; }
-
-/* Layout
-*/
-
-#wrapper {
-margin: 0 auto;
-text-align: left;
-width: 1000px;
-}
-
-
-#main {
-margin-top: 30px;
-}
-
-
-#contentwrap {
- background: transparent url(<%= asset_path "cms/dot.png" %>) repeat 0 0;
-float: left;
-width: 826px;
-}
-div.bottom_cap_content {
-height: 10px;
-background: transparent url(<%= asset_path "cms/bottom_cap_content.png" %>) no-repeat 100% 0;
-}
-div.top_cap_content {
-height: 5px;
-background: transparent url(<%= asset_path "cms/top_cap_content.png" %>) no-repeat 100% 0;
-}
-
- #contentwrapbig {
- width: 1000px;
- background: transparent url(<%= asset_path "cms/dot.png" %>) repeat 0 0;
- float: left;
- }
-
-#content {
-background: #FFF;
-width: 816px;
-margin-left: 5px;
-}
-
- #contentwrapbig #content {
- width: 990px;
- }
-
-#footer {
-text-align: right;
-padding: 16px 15px 100px 0;
-color: #A1A1A1;
-}
-#footer p{
-margin-bottom: 7px;
-}
-
- #footer a {
- color: #5489C7;
- text-decoration: none;
- }
- #footer a:hover {
- text-decoration: underline;
- }
-
-
-/* Utility
-*/
-
-
-/* FUNCTION BUTTONS
-*/
-
-
-.searchbox {
- background: #FFF;
- padding: 6px;
- font-size: 100%;
-}
-.searchbox select {
-width: 160px;
-}
-
-#search_term {
- width: 132px;
- height: 18px;
-* width: 130px;
- border: 1px solid #B9B9B9;
- border-right: none;
-}
-#search_term_container, #search_submit_container {
-float: left;
-}
-
-#search_submit_container{
-* margin-top: 1px;
-}
-
-
-#flash {
- position: absolute;
- top: 0;
- left: 250px;
- background: #ffff99;
- padding: 5px;
- color: #000;
- width: 500px;
- text-align: center;
- font-weight: bold
-}
-
-
-#functions h1 {
-color: #FFF;
-font-size: large;
-text-transform: capitalize;
-margin: 0 0 10px 0;
-padding-bottom: 10px;
-border-bottom: 3px solid #505358;
-line-height: 1;
-}
-#functions {
-padding: 10px 20px 10px 20px;
-text-transform: uppercase;
-}
-#functions .button {
-* margin-bottom: 10px;
-}
-#content .pad {
- padding: 1px 5px 5px 5px;
-}
-#content .top_pad {
- padding: 5px;
-}
-#content .bottom_pad {
- padding: 5px
-}
-div.top_cap {
-height: 9px;
-background: transparent url(<%= asset_path "cms/top_cap.png" %>) no-repeat 0 0;
-}
16 app/assets/stylesheets/cms/application.css.scss
View
@@ -0,0 +1,16 @@
+/**
+* Manifest file for the CMS Admin interface
+*
+*= require cms/load_bootstrap
+*= require cms/reset
+*= require cms/nav
+*= require cms/menu
+*= require cms/buttons
+*= require cms/data_table
+*= require cms/attachment_manager
+*= require cms/styles
+*= require cms/content_library
+*= require cms/administration
+*= require cms/bootstrap_corrections
+*
+*/
20 app/assets/stylesheets/cms/bootstrap_corrections.css.scss
View
@@ -0,0 +1,20 @@
+/**
+* Correct styles for bootstrap that the CSS has broken
+*/
+
+.navbar {
+ a {
+ font-size: 13px;
+ text-align: left;
+ }
+}
+
+#button-bar {
+ padding-top: 40px;
+}
+
+// Pushes body below fixed nav menu for admin.
+body {
+ padding-top: 75px;
+}
+
1  app/assets/stylesheets/cms/load_bootstrap.css.scss
View
@@ -0,0 +1 @@
+@import "bootstrap";
44 app/assets/stylesheets/cms/page_content_editing.css.scss
View
@@ -0,0 +1,44 @@
+// Minimalist styles for page editing controls that are added to CMS pages in edit mode.
+image.cms-content-button {
+ text-decoration: none;
+ padding: 0;
+ background: none;
+ margin: 0;
+ float: none;
+ border: none;
+}
+
+a.cms-content-link {
+ text-decoration: none;
+ padding: 0 2px 0 0;
+ background: none;
+ margin: 0;
+ float: none;
+ border: none;
+}
+
+a.cms-content-status {
+ @extend a.cms-content-link;
+ position: absolute;
+ top: -1px;
+ right: 10px;
+}
+
+.cms-outer-container {
+ display: block;
+ height: auto;
+ position: relative;
+ border: 1px solid #999;
+ margin: 1px -6px 0 -6px;
+ padding: 25px 5px 0 5px;
+ background: image-url("cms/containers/beta.png") repeat-x 0 0;
+}
+
+.cms-inner-container {
+ display: block;
+ width: 100%;
+ position: absolute;
+ top: 5px;
+ left: 5px;
+ height: 30px;
+}
4 app/assets/stylesheets/cms/page_editor.css
View
@@ -0,0 +1,4 @@
+body {
+ padding-top: 92px;
+ background-image: none;
+}
178 app/assets/stylesheets/cms/page_toolbar.css.erb
View
@@ -1,135 +1,157 @@
+/**
+* While the toolbar is in an iframe, it needs no padding
+*/
+
body {
-background: #FFF url(<%= asset_path "cms/toolbar_bg.png" %>) repeat-x 0 0;
+ background: #FFF url(<%= asset_path "cms/toolbar_bg.png" %>) repeat-x 0 0;
+ padding-top: 0;
+
}
+
#page_toolbar {
-background: #FFF url(<%= asset_path "cms/page_toolbar/page_toolbar_bg.gif" %>) repeat-x 0 0;
-height: 24px;
-text-transform: uppercase;
+ background: #FFF url(<%= asset_path "cms/page_toolbar/page_toolbar_bg.gif" %>) repeat-x 0 0;
+ height: 24px;
+ text-transform: uppercase;
}
+
.page_attribute_div {
-float: left;
-color: #EEE;
-* font-size: 8pt;
+ float: left;
+ color: #EEE;
+ *font-size: 8pt;
-height: 24px;
-padding-right: 8px;
+ height: 24px;
+ padding-right: 8px;
}
#status_div.draft {
-background: #F00 url(<%= asset_path "cms/page_toolbar/status_draft_bg.gif" %>) repeat-x 0 0;
+ background: #F00 url(<%= asset_path "cms/page_toolbar/status_draft_bg.gif" %>) repeat-x 0 0;
}
+
#status_div.published {
-background: #888 url(<%= asset_path "cms/page_toolbar/status_published_bg.gif" %>) repeat-x 0 0;
+ background: #888 url(<%= asset_path "cms/page_toolbar/status_published_bg.gif" %>) repeat-x 0 0;
}
+
.page_attribute_div div {
-padding: 0;
+ padding: 0;
}
.page_attribute_label {
-float: left;
-margin-top: 5px;
-margin-left: 7px;
+ float: left;
+ margin-top: 5px;
+ margin-left: 7px;
}
.page_attribute_value {
-float: left;
-margin-top: 2px;
-margin-right: 5px;
-margin-left: 4px;
+ float: left;
+ margin-top: 2px;
+ margin-right: 5px;
+ margin-left: 4px;
}
.page_attribute_value_container {
-margin-top: 4px;
-margin-left: 4px;
-float: left;
-background: #FFF url(<%= asset_path "cms/page_toolbar/page_toolbar_inset_bg.gif" %>) repeat-x 0 0;
+ margin-top: 4px;
+ margin-left: 4px;
+ float: left;
+ background: #FFF url(<%= asset_path "cms/page_toolbar/page_toolbar_inset_bg.gif" %>) repeat-x 0 0;
}
+
.page_attribute_value_container a {
-color: #EEE;
-text-decoration: none;
+ color: #EEE;
+ text-decoration: none;
}
+
.page_attribute_value_container a:hover {
-color: blue;
-text-decoration: underline;
+ color: blue;
+ text-decoration: underline;
}
-
#draft_page_status_container {
-background: #FFF url(<%= asset_path "cms/page_toolbar/page_toolbar_inset_draft_bg.gif" %>) repeat-x 0 0;
+ background: #FFF url(<%= asset_path "cms/page_toolbar/page_toolbar_inset_draft_bg.gif" %>) repeat-x 0 0;
}
+
#published_page_status_container {
-margin-top: 4px;
-float: left;
-background: #FFF url(<%= asset_path "cms/page_toolbar/page_toolbar_inset_published_bg.gif" %>) repeat-x 0 0;
+ margin-top: 4px;
+ float: left;
+ background: #FFF url(<%= asset_path "cms/page_toolbar/page_toolbar_inset_published_bg.gif" %>) repeat-x 0 0;
}
+
.buttons a {
-* font-size: 8pt;
-color: #EEE;
-margin-top: 7px;
-text-transform: uppercase;
+ *font-size: 8pt;
+ color: #EEE;
+ margin-top: 7px;
+ text-transform: uppercase;
}
+
#visual_editor_toggle {
-float: right;
-text-transform: uppercase;
-margin-top: 12px;
-margin-right: 0px;
-color: #000;
-font-weight: bold;
+ float: right;
+ text-transform: uppercase;
+ margin-top: 12px;
+ margin-right: 0px;
+ color: #000;
+ font-weight: bold;
}
+
#visual_editor_toggle div {
-float: left;
+ float: left;
}
+
.visual_editor_label {
-margin-right: 5px;
-margin-top: 6px;
+ margin-right: 5px;
+ margin-top: 6px;
}
+
.visual_editor_value_container {
-background: url(<%= asset_path "cms/page_toolbar/visual_editor_state_bg.gif" %>) no-repeat 0 0;
-width: 35px;
-height: 23px;
-padding: 0;
-color: #EEE;
+ background: url(<%= asset_path "cms/page_toolbar/visual_editor_state_bg.gif" %>) no-repeat 0 0;
+ width: 35px;
+ height: 23px;
+ padding: 0;
+ color: #EEE;
}
+
.visual_editor_toggle_container {
-height: 20px;
-padding: 0;
-margin-left: 4px;
-margin-top: 1px;
-}
-.visual_editor_value_container span, .visual_editor_toggle_container a{
-display: block;
-text-align: center;
-float: left;
-height: 15px;
-text-decoration: none;
+ height: 20px;
+ padding: 0;
+ margin-left: 4px;
+ margin-top: 1px;
}
-.visual_editor_value_container span{
-padding-top: 5px;
-width: 34px;
-margin: 1px 0 0 0;
+
+.visual_editor_value_container span, .visual_editor_toggle_container a {
+ display: block;
+ text-align: center;
+ float: left;
+ height: 15px;
+ text-decoration: none;
}
-.visual_editor_toggle_container a.sm_button{
-margin: 0;
-width: 62px;
- padding: 5px 0 0 0;
- background: url(<%= asset_path "cms/buttons/sm_button.gif" %>) no-repeat top right;
- color: #FFF;
- text-decoration: none;
- margin-right: 0px;
+
+.visual_editor_value_container span {
+ padding-top: 5px;
+ width: 34px;
+ margin: 1px 0 0 0;
}
-.visual_editor_toggle_container a.sm_button span{
-padding-left: 2px;
+
+.visual_editor_toggle_container a.sm_button {
+ margin: 0;
+ width: 62px;
+ padding: 5px 0 0 0;
+ background: url(<%= asset_path "cms/buttons/sm_button.gif" %>) no-repeat top right;
+ color: #FFF;
+ text-decoration: none;
+ margin-right: 0px;
}
+.visual_editor_toggle_container a.sm_button span {
+ padding-left: 2px;
+}
.visual_editor_toggle_container a.sm_button:hover {
- background: url(<%= asset_path "cms/buttons/sm_button_h.gif" %>) no-repeat top right;
+ background: url(<%= asset_path "cms/buttons/sm_button_h.gif" %>) no-repeat top right;
}
.buttons .publish_button {
}
.spacer {
-margin-left: 3px;
-}
+ margin-left: 3px;
+}
+
167 app/assets/stylesheets/cms/styles.css.scss.erb
View
@@ -0,0 +1,167 @@
+body {
+ background: #FFF url(<%= asset_path "cms/bg.png" %>) repeat-x 0 0;
+ text-align: center;
+ font: 62.5%/100% "Trebuchet MS", Helvetica, Verdana, Arial, sans-serif;
+ color: #727171;
+}
+
+a img {
+ border: 0
+}
+
+a {
+ color: #36659D;
+ text-decoration: none;
+}
+
+a:hover {
+ text-decoration: underline;
+}
+
+.check_uncheck {
+ font-size: 80%;
+}
+
+/* Layout
+*/
+
+#wrapper {
+ margin: 0 auto;
+ text-align: left;
+ width: 1000px;
+}
+
+#main {
+ margin-top: 30px;
+}
+
+#contentwrap {
+ background: transparent url(<%= asset_path "cms/dot.png" %>) repeat 0 0;
+ float: left;
+ width: 826px;
+}
+
+div.bottom_cap_content {
+ height: 10px;
+ background: transparent url(<%= asset_path "cms/bottom_cap_content.png" %>) no-repeat 100% 0;
+}
+
+div.top_cap_content {
+ height: 5px;
+ background: transparent url(<%= asset_path "cms/top_cap_content.png" %>) no-repeat 100% 0;
+}
+
+#contentwrapbig {
+ width: 1000px;
+ background: transparent url(<%= asset_path "cms/dot.png" %>) repeat 0 0;
+ float: left;
+}
+
+#content {
+ background: #FFF;
+ width: 816px;
+ margin-left: 5px;
+}
+
+#contentwrapbig #content {
+ width: 990px;
+}
+
+#footer {
+ text-align: right;
+ padding: 16px 15px 100px 0;
+ color: #A1A1A1;
+}
+
+#footer p {
+ margin-bottom: 7px;
+}
+
+#footer a {
+ color: #5489C7;
+ text-decoration: none;
+}
+
+#footer a:hover {
+ text-decoration: underline;
+}
+
+/* Utility
+*/
+
+/* FUNCTION BUTTONS
+*/
+
+.searchbox {
+ background: #FFF;
+ padding: 6px;
+ font-size: 100%;
+}
+
+.searchbox select {
+ width: 160px;
+}
+
+#search_term {
+ width: 132px;
+ height: 18px;
+ *width: 130px;
+ border: 1px solid #B9B9B9;
+ border-right: none;
+}
+
+#search_term_container, #search_submit_container {
+ float: left;
+}
+
+#search_submit_container {
+ *margin-top: 1px;
+}
+
+#flash {
+ position: absolute;
+ top: 0;
+ left: 250px;
+ background: #ffff99;
+ padding: 5px;
+ color: #000;
+ width: 500px;
+ text-align: center;
+ font-weight: bold
+}
+
+#functions h1 {
+ color: #FFF;
+ font-size: large;
+ text-transform: capitalize;
+ margin: 0 0 10px 0;
+ padding-bottom: 10px;
+ border-bottom: 3px solid #505358;
+ line-height: 1;
+}
+
+#functions {
+ padding: 10px 20px 10px 20px;
+ text-transform: uppercase;
+}
+
+#functions .button {
+ *margin-bottom: 10px;
+}
+
+#content .pad {
+ padding: 1px 5px 5px 5px;
+}
+
+#content .top_pad {
+ padding: 5px;
+}
+
+#content .bottom_pad {
+ padding: 5px
+}
+
+div.top_cap {
+ height: 9px;
+ background: transparent url(<%= asset_path "cms/top_cap.png" %>) no-repeat 0 0;
+}
59 app/controllers/cms/application_controller.rb
View
@@ -1,24 +1,25 @@
module Cms
-class ApplicationController < ::ApplicationController
- include Cms::Authentication::Controller
- include Cms::ErrorHandling
- include Cms::DomainSupport
+ class ApplicationController < ::ApplicationController
+ include Cms::Authentication::Controller
+ include Cms::ErrorHandling
+ include Cms::DomainSupport
- helper Cms::ApplicationHelper
- helper Cms::FormTagHelper
- include Cms::PathHelper
- helper Cms::PathHelper
- include Cms::PageHelper
- helper Cms::PageHelper
- helper Cms::MenuHelper
- helper Cms::RenderingHelper
- helper Cms::UiElementsHelper
+ helper Cms::ApplicationHelper
+ helper Cms::FormTagHelper
+ include Cms::PathHelper
+ helper Cms::PathHelper
+ include Cms::PageHelper
+ helper Cms::PageHelper
+ helper Cms::MenuHelper
+ helper Cms::RenderingHelper
+ helper Cms::UiElementsHelper
+ include Cms::NavMenuHelper
- protected
+ protected
def escape_javascript(javascript)
- (javascript || '').gsub('\\','\0\0').gsub('</','<\/').gsub(/\r\n|\n|\r/, "\\n").gsub(/["']/) { |m| "\\#{m}" }
+ (javascript || '').gsub('\\', '\0\0').gsub('</', '<\/').gsub(/\r\n|\n|\r/, "\\n").gsub(/["']/) { |m| "\\#{m}" }
end
-
+
def redirect_to_first(*urls)
urls.each do |url|
unless url.blank?
@@ -26,33 +27,33 @@ def redirect_to_first(*urls)
end
end
end
-
+
def current_site
@current_site ||= Site.find_by_domain(request.host)
end
-
+
def redirect_to_cms_site
if using_cms_subdomains? && !request_is_for_cms_subdomain?
redirect_to(url_with_cms_domain_prefix)
end
- end
-
+ end
+
def append_to_query_string(url, *params)
new_url = url["?"] ? url : "#{url}?"
- new_url << params.map{|k,v| "#{k.to_s}=#{CGI::escape(v.to_s)}"}.join("&")
+ new_url << params.map { |k, v| "#{k.to_s}=#{CGI::escape(v.to_s)}" }.join("&")
end
-
+
def cms_access_required
raise Cms::Errors::AccessDenied unless current_user.able_to?(:administrate, :edit_content, :publish_content)
end
-
+
def self.check_permissions(*perms)
opts = Hash === perms.last ? perms.pop : {}
before_filter(opts) do |controller|
raise Cms::Errors::AccessDenied unless controller.send(:current_user).able_to?(*perms)
- end
+ end
end
-
+
def url_with_cms_domain_prefix
if cms_site?
request.url
@@ -62,10 +63,10 @@ def url_with_cms_domain_prefix
request.url.sub(/:\/\//, "://#{cms_domain_prefix}.")
end
end
-
+
def url_without_cms_domain_prefix
- request.url.sub(/#{cms_domain_prefix}\./,'')
+ request.url.sub(/#{cms_domain_prefix}\./, '')
end
-
-end
+
+ end
end
20 app/controllers/cms/base_controller.rb
View
@@ -1,15 +1,11 @@
module Cms
-class BaseController < Cms::ApplicationController
-
- before_filter :redirect_to_cms_site
- before_filter :login_required
- before_filter :cms_access_required
+ class BaseController < Cms::ApplicationController
- layout 'cms/application'
-
-# verify :method => :post, :only => [:create]
-# verify :method => :put, :only => [:update]
-# verify :method => :delete, :only => [:destroy]
-
-end
+ before_filter :redirect_to_cms_site
+ before_filter :login_required
+ before_filter :cms_access_required
+
+ layout 'cms/application'
+
+ end
end
33 app/controllers/cms/cache_controller.rb
View
@@ -1,24 +1,23 @@
module Cms
-class CacheController < Cms::BaseController
- layout 'cms/administration'
-
- check_permissions :administrate
- before_filter :set_menu_section
+ class CacheController < Cms::BaseController
- def show
-
- end
-
- def destroy
- Cms::Cache.flush
- flash[:notice] = "Page Cache Flushed"
- redirect_to :action => "show"
- end
-
- private
+ include Cms::AdminTab
+ check_permissions :administrate
+
+ def show
+
+ end
+
+ def destroy
+ Cms::Cache.flush
+ flash[:notice] = "Page Cache Flushed"
+ redirect_to :action => "show"
+ end
+
+ private
def set_menu_section
@menu_section = 'caching'
end
-end
+ end
end
9 app/controllers/cms/content_block_controller.rb
View
@@ -4,7 +4,7 @@
module Cms
class ContentBlockController < Cms::BaseController
- layout :determine_layout
+ layout 'cms/content_library'
before_filter :set_toolbar_tab
@@ -99,6 +99,10 @@ def usages
render "#{template_directory}/usages"
end
+ def new_button_path
+ cms_new_path_for(content_type)
+ end
+
protected
# methods that are used to detemine what content block type we are dealing with
@@ -291,9 +295,6 @@ def set_toolbar_tab
@toolbar_tab = :content_library
end
- def determine_layout
- 'cms/content_library'
- end
def template_directory
"cms/blocks"
52 app/controllers/cms/content_controller.rb
View
@@ -18,11 +18,18 @@ class ContentController < Cms::ApplicationController
# ----- Actions --------------------------------------------------------------
def show
- render_page_with_caching
+ if @show_toolbar && params[:show_page] != 'show'
+ render_editing_frame
+ else
+ render_page
+ end
+ cache_if_eligible
end
def show_page_route
- render_page_with_caching
+ @_page_route.execute(self) if @_page_route
+ render_page
+ cache_if_eligible
end
@@ -40,20 +47,31 @@ def assign(key, value)
private
- # This is the method all actions delegate to
- # check_access_to_page will also call this directly
- # if caching is not enabled
+ def render_editing_frame
+ @page_title = @page.page_title
+ render 'editing_frame', :layout => 'cms/page_editor'
+ end
+
def render_page
- logger.warn "Render page (id: #{@page.id})"
- @_page_route.execute(self) if @_page_route
prepare_connectables_for_render
page_layout = determine_page_layout
render :layout => page_layout, :action => 'show'
end
- def render_page_with_caching
- render_page
- cache_page if should_write_to_page_cache?
+ def cache_if_eligible
+ cache_page if should_cache_page?
+ end
+
+ # Determine if this page is eligible for caching or not.
+ def should_cache_page?
+ should_cache = (using_cms_subdomains? && !logged_in? && @page.cacheable? && params[:cms_cache] != "false")
+ if should_cache
+ msg = "'#{request.path}' being written to cache."
+ else
+ msg = "'#{request.path}' not eligible for caching."
+ end
+ logger.info msg
+ should_cache
end
# ----- Before Filters -------------------------------------------------------
@@ -140,20 +158,6 @@ def check_access_to_page
raise Cms::Errors::AccessDenied
end
- # Doing this so if you are logged in, you never see the cached page
- # We are calling render_page just like the show action does
- # But since we do it from a before filter, the page doesn't get cached
- if logged_in?
- logger.info "Not Caching, user is logged in"
- render_page
- elsif !@page.cacheable?
- logger.info "Not Caching, page cachable is false"
- render_page
- elsif params[:cms_cache] == "false"
- logger.info "Not Caching, cms_cache is false"
- render_page
- end
-
end
# ----- Other Methods --------------------------------------------------------
10 app/controllers/cms/content_types_controller.rb
View
@@ -1,9 +1,9 @@
module Cms
-class ContentTypesController < Cms::BaseController
+ class ContentTypesController < Cms::BaseController
+
+ def index
+ @content_types = ContentType.find(:all, :order => 'name')
+ end
- def index
- @content_types = ContentType.find(:all, :order => 'name')
end
-
-end
end
3  app/controllers/cms/dynamic_views_controller.rb
View
@@ -1,10 +1,9 @@
module Cms
class DynamicViewsController < Cms::BaseController
- layout 'cms/administration'
+ include Cms::AdminTab
check_permissions :administrate
- before_filter :set_menu_section
before_filter :load_view, :only => [:show, :edit, :update, :destroy]
helper_method :dynamic_view_type
31 app/controllers/cms/email_messages_controller.rb
View
@@ -1,16 +1,21 @@
module Cms
-class EmailMessagesController < Cms::BaseController
- layout 'cms/administration'
-
- check_permissions :administrate
-
- def index
- @messages = EmailMessage.paginate(:page => params[:page])
+ class EmailMessagesController < Cms::BaseController
+
+ include Cms::AdminTab
+
+ check_permissions :administrate
+
+ def index
+ @messages = EmailMessage.paginate(:page => params[:page])
+ end
+
+ def show
+ @message = EmailMessage.find(params[:id])
+ end
+
+ private
+ def set_menu_section
+ @menu_section = 'email_messages'
+ end
end
-
- def show
- @message = EmailMessage.find(params[:id])
- end
-
-end
end
32 app/controllers/cms/groups_controller.rb
View
@@ -1,21 +1,21 @@
module Cms
-class GroupsController < Cms::ResourceController
- layout 'cms/administration'
-
- check_permissions :administrate
- before_filter :set_menu_section
-
- def index
- @groups = Group.paginate(
- :include => :group_type,
- :page => params[:page],
- :order => params[:order] || "#{Group.table_name}.name")
- end
-
- protected
+ class GroupsController < Cms::ResourceController
+ include Cms::AdminTab
+
+ check_permissions :administrate
+
+ def index
+ @groups = Group.paginate(
+ :include => :group_type,
+ :page => params[:page],
+ :order => params[:order] || "#{Group.table_name}.name")
+ end
+
+ protected
def after_create_url
index_url
end
+
def after_update_url
index_url
end
@@ -23,6 +23,6 @@ def after_update_url
def set_menu_section
@menu_section = 'groups'
end
-
-end
+
+ end
end
22 app/controllers/cms/redirects_controller.rb
View
@@ -1,21 +1,25 @@
module Cms
-class RedirectsController < Cms::ResourceController
- layout 'cms/administration'
- check_permissions :administrate
- before_filter :set_menu_section
- protected
+ class RedirectsController < Cms::ResourceController
+ include Cms::AdminTab
+ check_permissions :administrate
+
+ def new_button_path
+ new_redirect_path
+ end
+
+ protected
def show_url
index_url
end
-
+
def order_by_column
"from_path, to_path"
end
-
- private
+
+ private
def set_menu_section
@menu_section = 'redirects'
end
-end
+ end
end
7 app/controllers/cms/users_controller.rb
View
@@ -1,16 +1,13 @@
module Cms
class UsersController < Cms::ResourceController
- layout 'cms/administration'
+ include Cms::AdminTab
check_permissions :administrate, :except => [:show, :change_password, :update_password]
before_filter :only_self_or_administrator, :only => [:show, :change_password, :update_password]
- before_filter :set_menu_section
after_filter :update_group_membership, :only => [:update, :create]
after_filter :update_flash, :only => [ :update, :create ]
-
-# verify :method => :put, :only => [ :enable, :disable, :update_password ]
-
+
def index
query, conditions = [], []
39 app/helpers/cms/application_helper.rb
View
@@ -186,53 +186,38 @@ def determine_order(current_order, order)
end
end
- # Render a CMS styled 'X Delete' button. This button will appear on tool bars, typically set apart visually from other buttons.
- # Has a 'confirm?' popup attached to it as well.
- # Assumes that javascript code to handle the 'confirm' has already been included in the page.
- #
- # @param [Hash] options The options for this tag
- # @option options [String or Boolean] :title Title for 'confirm' popup. If specified as 'true' or with a string value a standard 'confirm yes/no' window should be used. If true is specified, its assume that the javascript popup handles the title.
- # @option options [Path] :path The path or URL to link_to. Takes same types at url_for or link_to. Defaults to '#' if not specified.
- # @option options [Boolean] :enabled If false, the button will be marked disabled. Default to false.
- def delete_button(options={})
- classes = "button"
- classes << " disabled" if !options[:enabled]
- classes << " delete_button"
- classes << " http_delete confirm_with_title" if options[:title]
-
- link_to_path = options[:path] ? options[:path] : "#"
-
- span_options = {:id => 'delete_button', :class => classes}
- span_options[:title] = options[:title] if (!options[:title].blank? && options[:title].class == String)
- link_to span_tag("<span class=\"delete_img\">&nbsp;</span>Delete".html_safe), link_to_path, span_options
- end
-
# Render a CMS styled 'Edit' button. This button will appear on tool bars, typically set apart visually from other buttons.
#
# @param [Hash] options The options for this tag
# @option options [Path] :path The path or URL to link_to. Takes same types at url_for or link_to. Defaults to '#' if not specified.
# @option options [Boolean] :enabled If false, the button will be marked disabled. Default to false.
- def edit_button(options={})
- classes = "button"
+ def edit_button(options={bootstrap: false})
+
+ label = options[:bootstrap]? "Edit" : span_tag("&nbsp;Edit&nbsp;".html_safe)
+ classes = styles_for_button(options)
classes << " disabled" if !options[:enabled]
link_to_path = options[:path] ? options[:path] : "#"
span_options = {:id => 'edit_button', :class => classes}
- link_to span_tag("&nbsp;Edit&nbsp;".html_safe), link_to_path, span_options
+ link_to label, link_to_path, span_options
end
# Render a CMS styled 'Add' button. This button will appear on tool bars, typically set apart visually from other buttons.
#
# @param [Path] The path or URL to link_to. Takes same types at url_for or link_to.
- def add_button(path, options={})
- classes = "button"
+ def add_button(path, options={bootstrap: false})
+ classes = styles_for_button(options)
+ label = options[:bootstrap]? "Add" : span_tag("&nbsp;Add&nbsp;".html_safe)
span_options = {:class => classes}
- link_to span_tag("&nbsp;Add&nbsp;".html_safe), path, span_options
+ link_to label, path, span_options
end
private
+ def styles_for_button(options)
+ options[:bootstrap] ? "btn btn-primary pull-left": "button"
+ end
# Converts a CSS jQuery selector into something that can be suitably used as a CSS id element.
def to_id(selector, suffix=nil)
id = selector.gsub(".", "_")
2  app/helpers/cms/content_block_helper.rb
View
@@ -32,7 +32,7 @@ def content_block_tr_tag(block)
options = {}
data = options[:data] = {}
- data[:status] = block.class.publishable? && !block.published? ? ' draft' : ' published'
+ data[:status] = block.class.publishable? && !block.published? ? 'draft' : 'published'
options[:id] = "#{cname}_#{block.id}"
options[:class] = [cname]
23 app/helpers/cms/nav_menu_helper.rb
View
@@ -0,0 +1,23 @@
+module Cms
+ module NavMenuHelper
+ extend ActiveSupport::Concern
+
+ included do
+ helper_method :new_button_path, :target_section
+ end
+
+ # In most cases, the 'New' button should go to create a new page.
+ def new_button_path
+ cms.new_section_page_path(target_section)
+ end
+
+ # Used to determine which section a New Page should go in, based on the current context.
+ def target_section
+ if @page
+ @page.section
+ else
+ Cms::Section.first
+ end
+ end
+ end
+end
26 app/helpers/cms/page_helper.rb
View
@@ -1,5 +1,21 @@
module Cms
+
+ module DeprecatedBehavior
+
+ # Add the code to render the CMS toolbar.
+ # @deprecated This method is no longer required for BrowserCMS templates.
+ def cms_toolbar
+ ActiveSupport::Deprecation.warn "The cms_toolbar helper is deprecated and no longer necessary. You can safely remove <%= cms_toolbar %> from templates.", caller
+ return ""
+ end
+ end
+
module PageHelper
+ include Cms::DeprecatedBehavior
+
+ # Keep this taller until we reverse the iframes (so menus will work)
+ PAGE_TOOLBAR_HEIGHT = 159
+ TOOLBAR_HEIGHT = 100
# Return the JS file to load the configured default WYSIWYG editor
#
@@ -65,16 +81,6 @@ def container_has_block?(name, &block)
end
end
- # Add the code to render the CMS toolbar.
- def cms_toolbar
- toolbar = <<HTML
-<iframe src="#{cms.toolbar_path(:page_id => @page.id, :page_version => @page.version, :mode => @mode, :page_toolbar => @show_page_toolbar ? 1 : 0) }" width="100%" height="#{@show_page_toolbar ? 159 : 100 }px" frameborder="0" marginwidth="0" marginheight="0" scrolling="no" name="cms_toolbar"></iframe>
-HTML
- toolbar.html_safe if @show_toolbar
- end
-
-
-
# Renders breadcrumbs based on the current_page. This will generate an unordered list representing the
# current page and all it's ancestors including the root name of of the site. The UL can be styled via CSS for
# layout purposes. Each breadcrumb except the last will be linked to the page in question.
8 app/helpers/cms/template_support.rb
View
@@ -10,13 +10,7 @@ def self.included(controller)
helper Cms::PageHelper
helper Cms::MenuHelper
helper Cms::RenderingHelper
- helper do
- def cms_toolbar
- if current_user.able_to?(:administrate, :edit_content, :publish_content)
- %Q{<iframe src="#{cms.toolbar_path(:page_toolbar => 0)}" width="100%" height="100px" frameborder="0" marginwidth="0" marginheight="0" scrolling="no" name="cms_toolbar"></iframe>}
- end
- end
- end
+
end
end
end
141 app/helpers/cms/ui_elements_helper.rb
View
@@ -1,4 +1,7 @@
module Cms
+
+ # Defines functions for creating buttons and links using the CMS styling.
+ # I.e. Menus, Save, Publish buttons and links.
module UiElementsHelper
# Renders a Save And Publish button if:
@@ -17,11 +20,147 @@ def publish_button(type)
lt_button_wrapper html.html_safe
end
+ # Renders a Publish button for the menu based on whether:
+ # 1. The current user can publish
+ # 2. The content item can or needs to be published.
+ def publish_menu_button(content_item)
+ options = {class: ["btn", "btn-primary", "http_put"], id: "publish_button"}
+ path = "#"
+ if current_user.able_to?(:publish_content) && !content_item.new_record? && content_item.respond_to?(:live?) && !content_item.live?
+ path = block_path(@block, :publish)
+ else
+ options[:class] << "disabled"
+ end
+ link_to "Publish", path, options
+ end
+
+ def edit_content_menu_button(content_item)
+ path = "#"
+ unless content_item.new_record?
+ path = block_path(content_item, :edit)
+ end
+ link_to "Edit Content", path, class: "btn btn-primary", id: "edit_button"
+ end
+
+ def view_content_menu_button(content_item)
+ path = "#"
+ unless content_item.new_record?
+ path = block_path(content_item)
+ end
+ link_to "View Content", path, class: "btn btn-primary", id: "view_button"
+ end
+
+
+ # Generic bootstrap based menu button
+ # @param [Hash] options
+ # @option options [Boolean] :enabled
+ # @option options [Array<String>] :class An array of additional classes to apply
+ def menu_button(label, path, options={})
+ defaults = {
+ enabled: true,
+ pull: 'left'
+ }
+ options = defaults.merge!(options)
+ options[:class] = %w{btn btn-primary}
+ if (options[:pull] == 'left' || options[:pull]== 'right')
+ options[:class] << "pull-#{options.delete(:pull)}"
+ end
+
+ options[:class] << 'disabled' unless options[:enabled]
+ options.delete(:enabled)
+ options[:class] << 'http_put' if options[:method] == :put
+ options.delete(:method)
+ copy_title(options, options)
+ link_to(label, path, options)
+ end
+
+ def versions_menu_button(content_item)
+ options = {class: ["btn", "btn-primary"], id: "revisions_button"}
+ path = "#"
+ if !content_item.new_record? && content_item.class.versioned?
+ block_path(content_item, :versions)
+ else
+ options[:class] << "disabled"
+
+ end
+ link_to "List Versions", path, options
+ end
+
+ # @deprecated Use 'delete_menu_button'' instead as we move to use bootstrap
+ #
+ # Render a CMS styled 'X Delete' button. This button will appear on tool bars, typically set apart visually from other buttons.
+ # Has a 'confirm?' popup attached to it as well.
+ # Assumes that javascript code to handle the 'confirm' has already been included in the page.
+ #
+ # @param [Hash] options The options for this tag
+ # @option options [String or Boolean] :title Title for 'confirm' popup. If specified as 'true' or with a string value a standard 'confirm yes/no' window should be used. If true is specified, its assume that the javascript popup handles the title.
+ # @option options [Path] :path The path or URL to link_to. Takes same types at url_for or link_to. Defaults to '#' if not specified.
+ # @option options [Boolean] :enabled If false, the button will be marked disabled. Default to false.
+ def delete_button(options={})
+ classes = "button"
+ classes << " disabled" if !options[:enabled]
+ classes << " delete_button"
+ classes << " http_delete confirm_with_title" if options[:title]
+
+ link_to_path = options[:path] ? options[:path] : "#"
+
+ span_options = {:id => 'delete_button', :class => classes}
+ copy_title(options, span_options)
+ link_to span_tag("<span class=\"delete_img\">&nbsp;</span>Delete".html_safe), link_to_path, span_options
+ end
+
+
+ # Render a CMS styled 'Delete' button. This button will appear on tool bars, typically set apart visually from other buttons.
+ # Has a 'confirm?' popup attached to it as well.
+ # Assumes that javascript code to handle the 'confirm' has already been included in the page.
+ #
+ def delete_menu_button(content_item=nil, opts={class: []})
+ classes = ["btn", "http_delete", "confirm_with_title"]
+ if current_user.able_to_publish?(content_item)
+ classes << 'btn-primary'
+ else
+ classes << 'disabled'
+ end
+
+ link_to_path = "#"
+ options = {:id => 'delete_button', :class => classes}
+ options[:class].concat(opts[:class]) if opts[:class]
+
+ if content_item == nil || content_item.new_record?
+ classes << 'disabled'
+ else
+ options[:title] = "Are you sure you want to delete '#{content_item.name}'?"
+ link_to_path = block_path(content_item)
+ end
+ if opts[:title]
+ options[:title] = opts[:title]
+ end
+ link_to "Delete", link_to_path, options
+ end
def select_content_type_tag(type, &block)
options = {:rel => "select-#{type.key}"}
- options[:class] = "on" if content_type == type
+ if (defined?(content_type) && content_type == type)
+ options[:class] = "on"
+ end
content_tag_for(:li, type, nil, options, &block)
end
+
+ # Used by Twitter Bootstrap dropdown menus used to divide groups of menu items.
+ # @param [Integer] index
+ def divider_tag(index = 1)
+ content_tag(:li, "&nbsp;", {class: "divider"}) if index != 0
+ end
+
+ def nav_link_to(name, link, options={})
+ content_tag(:li, link_to(name, link, options))
+ end
+
+ private
+
+ def copy_title(from, to)
+ to[:title] = from[:title] if (!from[:title].blank? && from[:title].class == String)
+ end
+
end
end
5 app/models/cms/dynamic_view.rb
View
@@ -37,6 +37,11 @@ def self.inherited(subclass)
end
end
+ # Returns the title of this class
+ def self.title
+ self.name.demodulize.titleize
+ end
+
def self.new_with_defaults(options={})
new({:format => "html", :handler => "erb", :body => default_body}.merge(options))
end
5 app/models/cms/portlet.rb
View
@@ -137,6 +137,11 @@ def self.connectable?
true
end
+ # For polymorphic permissions
+ # A generic portlet shouldn't be connected to pages.
+ def connected_pages
+ []
+ end
#----- Portlet Action Related Methods ----------------------------------------
# Used by portlets to set a custom title, typically in the render body.
1  app/models/cms/templates.rb
View
@@ -16,7 +16,6 @@ def self.default_body
<%= yield :html_head %>
</head>
<body style="margin: 0; padding: 0; text-align: center;">
- <%= cms_toolbar %>
<div id="wrapper" style="width: 700px; margin: 0 auto; text-align: left; padding: 30px">
Breadcrumbs: <%= render_breadcrumbs %>
Main Menu: <%= render_menu %>
17 app/views/cms/blocks/_buttonbar.html.erb
View
@@ -0,0 +1,17 @@
+<% # Handles both looking at a single block and a collection of blocks.
+ unless @block
+ @block = content_type.model_class.new
+ end
+%>
+<%#
+ Enable/Disable publish button for
+ - editting permission
+ - If block is already published.
+%>
+<span class="btn-group pull-left">
+ <%= publish_menu_button(@block) %>
+ <%= view_content_menu_button(@block) %>
+ <%= edit_content_menu_button(@block) %>
+</span>
+<%= versions_menu_button(@block) %>
+<%= delete_menu_button(@block) %>
2  app/views/cms/blocks/edit.html.erb
View
@@ -4,7 +4,7 @@
<% end %>
<% page_title "Content Library / Edit #{content_type.display_name}" %>
<% @toolbar_title = "Edit #{content_type.display_name} '#{@block.name}'".html_safe %>
-<%= content_for :functions, render(:partial => 'cms/blocks/toolbar') %>
+<%= content_for :button_bar, render(:partial => 'cms/blocks/buttonbar') %>
<% if @block.respond_to?(:deleted) && @block.deleted %>
<div class="header">This <%= @block.class.name %> has been deleted.</div>
2  app/views/cms/blocks/index.html.erb
View
@@ -4,7 +4,7 @@
<% end %>
<% page_title "Content Library / List #{content_type.display_name_plural}" %>
<% @toolbar_title = "List #{content_type.display_name_plural}" %>
-<%= render :partial => 'cms/blocks/toolbar' %>
+<%= content_for :button_bar, render(:partial => 'cms/blocks/buttonbar') %>
<div class="roundedcorners">
<table id="blocks" class="data cms-content-table"
data-content_type="<%= content_type.content_block_type %>"
2  app/views/cms/blocks/new.html.erb
View
@@ -4,7 +4,7 @@
<% end %>
<% page_title "Content Library / Add New #{content_type.display_name}" %>
<% @toolbar_title = "Add New #{content_type.display_name}" %>
-<%= content_for :functions, render(:partial => 'cms/blocks/toolbar') %>
+<%= content_for :button_bar, render(:partial => 'cms/blocks/buttonbar') %>
<%= form_for(@block, :url => blocks_path, :html => {:multipart => true}) do |f| %>
<%= f.cms_error_messages %>
<%= render :partial => 'cms/shared/exception', :object => @exception if @exception %>
3  app/views/cms/blocks/show.html.erb
View
@@ -10,8 +10,7 @@
}
</style>
<% end %>
-<%= content_for :functions, render(:partial => 'cms/blocks/toolbar') %>
-
+<%= content_for :button_bar, render(:partial => 'cms/blocks/buttonbar') %>
<div id="block_content">
<% if @block.respond_to?(:deleted) && @block.deleted %>
<div class="header">This <%= @block.class.name %> has been deleted.</div>
2  app/views/cms/blocks/usages.html.erb
View
@@ -13,7 +13,7 @@
<% end %>
<% end %>
-<%= render :partial => 'cms/blocks/toolbar' %>
+<%= content_for :button_bar, render(:partial => 'cms/blocks/buttonbar') %>
<div class="roundedcorners">
<table id="blocks" class="data">
<thead>
6 app/views/cms/blocks/versions.html.erb
View
@@ -31,9 +31,9 @@
<% end %>
-<%= content_for :functions do %>
- <%= render :partial => 'cms/blocks/toolbar' %>
- <%= link_to span_tag("Revert"), "#", :id => "revert_button", :class => "http_put button disabled" %>
+<%= content_for :button_bar do %>
+ <%= render :partial => 'cms/blocks/buttonbar' %>
+ <%= link_to "Revert", "#", :id => "revert_button", :class => "http_put btn btn-primary disabled pull-right" %>
<% end %>
<div class="roundedcorners">
5 app/views/cms/cache/show.html.erb
View
@@ -4,9 +4,8 @@
<%= stylesheet_link_tag("cms/form_layout") %>
<% end %>
-<%= content_for :functions do %>
- <%= link_to(span_tag("Clear Page Cache"), cache_path,
- :class => "button http_delete") %>
+<%= content_for :button_bar do %>
+ <%= menu_button "Clear Page Cache", cache_path, :class => "http_delete" %>
<% end %>
<p style="font-size: larger; margin: 10px; line-height: 20px;">The CMS System caches pages which are frequently accessed by guest users to increase throughput. If data appears stale, you may manually clear this page cache.</p>
80 app/views/cms/connectors/new.html.erb
View
@@ -1,15 +1,15 @@
<% @toolbar_title = @page_title = "Add Existing Content to '#{@page.page_title}' Page".html_safe %>
<%= content_for :html_head do %>
- <%= stylesheet_link_tag("cms/content_library") %>
- <%= javascript_tag do %>
- jQuery(function($){
- var collectionName = '<%= @block_type.content_block_type %>'
- $('table.data tbody tr').hover(function(){
+ <%= stylesheet_link_tag("cms/content_library") %>
+ <%= javascript_tag do %>
+ jQuery(function($){
+ var collectionName = '<%= @block_type.content_block_type %>'
+ $('table.data tbody tr').hover(function(){
$(this).addClass('hover');
- }, function(){
+ }, function(){
$(this).removeClass('hover');
- }).click(function(){
+ }).click(function(){
var match = this.id.match(/(.*)_(\d+)/);
var type = match[1];
var id = match[2];
@@ -18,52 +18,54 @@
$('#connectable_type').attr('value', type);
$('#connectable_id').attr('value', id);
$('#add_button').removeClass('disabled').click(function(){
- $('#connect_form').submit();
- return false;
+ $('#connect_form').submit();
+ return false;
});
$('#view_button').removeClass('disabled').attr('href', '/cms/'+collectionName+'/'+id);
- })
- })
- <% end %>
+ })
+ })
+ <% end %>
<% end %>
-<%= content_for :functions do %>
- <h1><%=h @toolbar_title %></h1>
- <%= link_to span_tag("Add to Page"), "#", :id => "add_button", :class => "button disabled" %>
- <%= link_to span_tag("View Content"), "#", :id => "view_button", :class => "button disabled" %>
- <%= form_tag connectors_path, :id => 'connect_form' do %>
+<%= content_for :button_bar do %>
+ <%= menu_button "Back to Page", page_path(@page) %>
+ <%= menu_button "Add to Page", "#", :id => "add_button", :enabled => false %>
+ <%= menu_button "View Content", "#", :id => "view_button", :enabled => false %>
+<% end %>
+<%= form_tag connectors_path, :id => 'connect_form' do %>
<%= hidden_field_tag :page_id, @page.to_param %>
- <%= hidden_field_tag :container, @container %>
+ <%= hidden_field_tag :container, @container %>
<%= hidden_field_tag :connectable_type, '' %>
<%= hidden_field_tag :connectable_id, '' %>
- <% end %>
- <br clear="all" />
<% end %>
-
<%= form_tag new_connector_path, :method => :get do %>
- <%= hidden_field_tag :page_id, @page.to_param %>
- <%= hidden_field_tag :container, @container %>
- <div style="margin: 20px 2px;">
- <label>
- Choose Type of Content
- <%= select_tag "block_type", options_for_select(Cms::ContentType.connectable.all.map{|ct| [ct.display_name, ct.content_block_type]}, @block_type.content_block_type), :onchange => 'this.form.submit()' %>
- </label>
- </div>
+ <%= hidden_field_tag :page_id, @page.to_param %>
+ <%= hidden_field_tag :container, @container %>
+ <div style="margin: 20px 2px;">
+ <label>
+ Choose Type of Content
+ <%= select_tag "block_type", options_for_select(Cms::ContentType.connectable.all.map { |ct| [ct.display_name, ct.content_block_type] }, @block_type.content_block_type), :onchange => 'this.form.submit()' %>
+ </label>
+ </div>
<% end %>
<table class="data">
<thead>
- <tr>
- <th class="name first"><div class="dividers">Name</div></th>
- <th class="updated"><div class="dividers">Updated</div></th>
- <th class="used last">Uses</th>
- </tr>
+ <tr>
+ <th class="name first">
+ <div class="dividers">Name</div>
+ </th>
+ <th class="updated">
+ <div class="dividers">Updated</div>
+ </th>
+ <th class="used last">Uses</th>
+ </tr>
</thead>
<% @blocks.each do |block| %>
- <tr id="<%= @block_type.content_block_type.singularize %>_<%= block.id %>">
- <td class="name"><%= block.name %></td>
- <td class="updated"><%= block.updated_at.to_formatted_s(:date) %></td>
- <td class="used"><%= link_to_usages(block) %></td>
- </tr>
+ <tr id="<%= @block_type.content_block_type.singularize %>_<%= block.id %>">
+ <td class="name"><%= block.name %></td>
+ <td class="updated"><%= block.updated_at.to_formatted_s(:date) %></td>
+ <td class="used"><%= link_to_usages(block) %></td>
+ </tr>
<% end %>
</table>
4 app/views/cms/content/editing_frame.html.erb
View
@@ -0,0 +1,4 @@
+<%= content_for :button_bar do %>
+ <%= render 'cms/toolbar/toolbar' %>
+<% end %>
+<iframe id="page_content" src="<%= "#{@page.path}?show_page=show" %>" frameborder="0" height="1600px" width="100%"></iframe>
3  app/views/cms/content/no_page.html.erb
View
@@ -7,9 +7,6 @@
set in those variables
%>
-<% @content_for_functions = "" %>
-<%= content_for :functions, "<h1>#{ page_title }</h1>".html_safe %>
-
<% @content_for_html_head = "" %>
<%= content_for :html_head do %>
<style type="text/css">
23 app/views/cms/content/show.html.erb
View
@@ -1,22 +1,19 @@
<%= content_for :html_head do %>
- <meta name="generator" content="BrowserCMS <%= Cms.version %>"/>
- <% if is_editing_page?(current_page) %>
- <%= javascript_include_tag 'cms/core_library' %>
- <% if @authenticity_token_loaded.nil? && protect_against_forgery? %><script type="text/javascript">
- jQuery(function($){
- $.cms.authenticity_token = '<%= form_authenticity_token %>'
- })
- </script><% end %><% @authenticity_token_loaded = true %>
- <% end %>
+<meta name="generator" content="BrowserCMS <%= Cms.version %>"/>
+<% if @show_toolbar %>
+<%= javascript_include_tag 'cms/page_editing' %>
+<%= stylesheet_link_tag 'cms/page_content_editing' %>
+<%= csrf_meta_tags %>
+<% end %>
<% end %>
<% if @show_toolbar %>
- <% flash.keep %>
+ <% flash.keep %>
<% end %>
<% @_connectors.each_with_index do |connector, i| %>
- <%= content_for(connector.container.to_sym) do %>
- <%= render_connector_and_connectable(connector, @_connectables[i]) %>
- <% end %>
+ <%= content_for(connector.container.to_sym) do %>
+ <%= render_connector_and_connectable(connector, @_connectables[i]) %>
+ <% end %>
<% end %>
3  app/views/cms/content_types/index.html.erb
View
@@ -1,5 +1,4 @@
<% page_title "Select Content Type" %>
-<%= content_for :functions, "<h1>#{ @page_title }</h1>" %>
<%= content_for :html_head, stylesheet_link_tag('cms/content_types') %>
<ul id="content_types">
<% Cms::ContentType.connectable.all.each_with_index do |type, i| %>
@@ -7,7 +6,7 @@
<%= link_to h(type.display_name), cms_new_path_for(type,
"#{type.model_class_form_name}[connect_to_page_id]" => params[:connect_to_page_id],
"#{type.model_class_form_name}[connect_to_container]" => params[:connect_to_container]
- ) %>
+ ), id: "add_new_#{type.key}" %>
<% if i == 1 %><div style="margin: 10px 0">&nbsp;</div><% end %>
</li>
<% end %>
1  app/views/cms/dynamic_views/_form.html.erb
View
@@ -1,4 +1,5 @@
<%= content_for :html_head, stylesheet_link_tag('cms/form_layout') %>
+<%= render 'toolbar' %>
<%= form_for(@view) do |f| %>
<%= f.cms_error_messages %>
<%= f.cms_text_field :name %>
10 app/views/cms/dynamic_views/_toolbar.html.erb
View
@@ -0,0 +1,10 @@
+<%= content_for :button_bar do %>
+ <% if @view %>
+ <%= link_to "Back to #{dynamic_view_type.title.pluralize}", cms_index_path_for(dynamic_view_type), class: 'btn btn-primary pull-left' %>
+ <% else %>
+ <%= add_button cms_new_path_for(dynamic_view_type), bootstrap: true %>
+ <%= edit_button(bootstrap: true) %>
+ <%= delete_menu_button nil, :title => "Are you sure you want to delete this #{dynamic_view_type.title}?", class: ["pull-left"] %>
+ <% end %>
+
+<% end %>
3  app/views/cms/dynamic_views/edit.html.erb
View
@@ -1,3 +1,2 @@
-<% @page_title = @toolbar_title = "Edit '#{@view.name}' #{dynamic_view_type.name.titleize}" %>
-<%= content_for :functions, link_to(span_tag("List All"), cms_index_path_for(dynamic_view_type), :class => "button") %>
+<% page_title "Edit '#{@view.name}' #{dynamic_view_type.title}" %>
<%= render :partial => 'form' %>
7 app/views/cms/dynamic_views/index.html.erb
View
@@ -19,12 +19,7 @@
<% end %>
<% end %>
-<%= content_for :functions do %>
- <%= add_button cms_new_path_for(dynamic_view_type) %>
- <%= edit_button %>
- <%= delete_button :title => "Are you sure you want to delete this #{dynamic_view_type.name.demodulize.underscore.titleize}?" %>
-<% end %>