browsercms 3.1.0 → 3.1.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -48,7 +48,8 @@ class Cms::DynamicViewsController < Cms::BaseController
48
48
  protected
49
49
  def dynamic_view_type
50
50
  @dynamic_view_type ||= begin
51
- type = request.request_uri.split('/')[2].classify.constantize
51
+ uri = request.request_uri.sub(/\?.*/, '')
52
+ type = uri.split('/')[2].classify.constantize
52
53
  raise "Invalid Type" unless type.ancestors.include?(DynamicView)
53
54
  type
54
55
  end
@@ -38,6 +38,9 @@ class Cms::TasksController < Cms::BaseController
38
38
  end
39
39
  redirect_to @task.page.path
40
40
  end
41
+ rescue ActiveRecord::RecordNotFound
42
+ flash[:error] = "No tasks were marked for completion"
43
+ redirect_to cms_dashboard_path
41
44
  end
42
45
 
43
46
  private
@@ -21,6 +21,18 @@ module Cms
21
21
  end
22
22
  end
23
23
 
24
+ # Determine if a given container has any blocks within it. Useful for determine if markup should be conditionally included
25
+ # when a block is present, but not shown if no block was added. For example:
26
+ #
27
+ # <% unless container_has_block? :sidebar %>
28
+ # <div id="sidebar">
29
+ # <%= container :sidebar %>
30
+ # </div>
31
+ # <% end %>
32
+ #
33
+ # @param [Symbol] name The name of the container to check
34
+ # @param [Proc] block
35
+ # @return [Boolean] True if the container has one or more blocks, or if we are in edit mode. False otherwise.
24
36
  def container_has_block?(name, &block)
25
37
  has_block = (@mode == "edit") || current_page.connectable_count_for_container(name) > 0
26
38
  logger.info "mode = #{@mode}, has_block = #{has_block}"
@@ -19,7 +19,7 @@ class ContentType < ActiveRecord::Base
19
19
  # Given a 'key' like 'html_blocks' or 'portlet'
20
20
  # Raises exception if nothing was found.
21
21
  def self.find_by_key(key)
22
- class_name = key.tableize.classify
22
+ class_name = key.singularize.tableize.classify
23
23
  content_type = find_by_name(class_name)
24
24
  if content_type.nil?
25
25
  if class_name.constantize.ancestors.include?(Portlet)
data/app/models/page.rb CHANGED
@@ -41,6 +41,21 @@ class Page < ActiveRecord::Base
41
41
  :conditions => ['connectors.connectable_id = ? and connectors.connectable_type = ?', obj.id, obj.class.base_class.name] }
42
42
  end
43
43
  }
44
+
45
+ # currently_connected_to tightens the scope of connected_to by restricting to the
46
+ # results to matches on current versions of pages only. This renders obj versions
47
+ # useless, as the older objects will very likely have older versions of pages and
48
+ # thus return no results.
49
+ named_scope :currently_connected_to, lambda { |obj|
50
+ ver = obj.class.versioned? ? obj.version : nil
51
+ if ver
52
+ { :include => :connectors,
53
+ :conditions => ['connectors.connectable_id = ? and connectors.connectable_type = ? and connectors.connectable_version = ? and connectors.page_version = pages.version', obj.id, obj.class.base_class.name, ver] }
54
+ else
55
+ { :include => :connectors,
56
+ :conditions => ['connectors.connectable_id = ? and connectors.connectable_type = ? and connectors.page_version = pages.version', obj.id, obj.class.base_class.name] }
57
+ end
58
+ }
44
59
 
45
60
  has_one :section_node, :as => :node, :dependent => :destroy
46
61
 
@@ -80,18 +95,23 @@ class Page < ActiveRecord::Base
80
95
  if c.should_be_copied?
81
96
  connectable = c.connectable_type.constantize.versioned? ? c.connectable.as_of_version(c.connectable_version) : c.connectable
82
97
 
98
+ version = connectable.class.versioned? ? connectable.version : nil
99
+
83
100
  #If we are copying connectors from a previous version, that means we are reverting this page,
84
- #in which case we should create a new version of the block, and connect this page to that block
101
+ #in which case we should create a new version of the block, and connect this page to that block.
102
+ #If the connectable is versioned, the connector needs to reference the newly drafted connector
103
+ #that is created during the revert_to method
85
104
  if @copy_connectors_from_version && connectable.class.versioned? && (connectable.version != connectable.draft.version)
86
105
  connectable = connectable.class.find(connectable.id)
87
106
  connectable.updated_by_page = self
88
107
  connectable.revert_to(c.connectable_version)
108
+ version = connectable.class.versioned? ? connectable.draft.version : nil
89
109
  end
90
110
 
91
111
  new_connector = connectors.build(
92
112
  :page_version => options[:to_version_number],
93
113
  :connectable => connectable,
94
- :connectable_version => connectable.class.versioned? ? connectable.version : nil,
114
+ :connectable_version => version,
95
115
  :container => c.container,
96
116
  :position => c.position
97
117
  )
@@ -51,3 +51,8 @@
51
51
  <div class="bl"></div>
52
52
  <div class="br"></div>
53
53
  </div>
54
+ <% if @views.size == 0 && params[:key_word]%>
55
+ <div class="pagination">No results found for '<%= params[:key_word] %>'</div>
56
+ <% elsif @views.total_pages > 1 %>
57
+ <%= render_pagination @views, dynamic_view_type.name.pluralize.underscore.to_sym %>
58
+ <% end %>
data/browsercms.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{browsercms}
8
- s.version = "3.1.0"
8
+ s.version = "3.1.1"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["BrowserMedia"]
12
- s.date = %q{2010-03-03}
12
+ s.date = %q{2010-06-28}
13
13
  s.description = %q{General purpose Web Content Management in Rails.}
14
14
  s.email = %q{github@browsermedia.com}
15
15
  s.executables = ["browsercms", "bcms"]
@@ -1345,78 +1345,78 @@ Gem::Specification.new do |s|
1345
1345
  s.rubygems_version = %q{1.3.5}
1346
1346
  s.summary = %q{BrowserCMS is a general purpose, open source Web Content Management System (CMS) written in Ruby on Rails. Designed for web developers who want to create great looking websites while using standard Rails tools for customizing it.}
1347
1347
  s.test_files = [
1348
- "test/custom_assertions.rb",
1349
- "test/factories.rb",
1348
+ "test/integration/login_test.rb",
1349
+ "test/integration/cms/password_management_test.rb",
1350
+ "test/integration/cms/ckeditor_test.rb",
1351
+ "test/functional/tests/pretend_controller_test.rb",
1352
+ "test/functional/cms/links_controller_test.rb",
1353
+ "test/functional/cms/image_blocks_controller_test.rb",
1350
1354
  "test/functional/cms/cache_controller_test.rb",
1351
- "test/functional/cms/categories_controller_test.rb",
1352
- "test/functional/cms/connectors_controller_test.rb",
1353
- "test/functional/cms/content_block_controller_test.rb",
1354
- "test/functional/cms/content_controller_test.rb",
1355
- "test/functional/cms/content_types_controller_test.rb",
1356
- "test/functional/cms/dashboard_controller_test.rb",
1357
- "test/functional/cms/dynamic_views_controller_test.rb",
1358
- "test/functional/cms/file_blocks_controller_test.rb",
1359
- "test/functional/cms/groups_controller_test.rb",
1360
1355
  "test/functional/cms/home_controller_test.rb",
1361
- "test/functional/cms/html_blocks_controller_test.rb",
1362
- "test/functional/cms/image_blocks_controller_test.rb",
1363
- "test/functional/cms/links_controller_test.rb",
1364
1356
  "test/functional/cms/pages_controller_test.rb",
1357
+ "test/functional/cms/content_block_controller_test.rb",
1358
+ "test/functional/cms/dashboard_controller_test.rb",
1359
+ "test/functional/cms/content_types_controller_test.rb",
1365
1360
  "test/functional/cms/portlets_controller_test.rb",
1361
+ "test/functional/cms/html_blocks_controller_test.rb",
1366
1362
  "test/functional/cms/section_nodes_controller_test.rb",
1367
- "test/functional/cms/sections_controller_test.rb",
1368
- "test/functional/cms/sessions_controller_test.rb",
1369
1363
  "test/functional/cms/toolbar_controller_test.rb",
1364
+ "test/functional/cms/sessions_controller_test.rb",
1370
1365
  "test/functional/cms/users_controller_test.rb",
1371
- "test/functional/tests/pretend_controller_test.rb",
1372
- "test/integration/cms/ckeditor_test.rb",
1373
- "test/integration/cms/password_management_test.rb",
1374
- "test/integration/login_test.rb",
1375
- "test/test_helper.rb",
1376
- "test/test_logging.rb",
1366
+ "test/functional/cms/categories_controller_test.rb",
1367
+ "test/functional/cms/file_blocks_controller_test.rb",
1368
+ "test/functional/cms/content_controller_test.rb",
1369
+ "test/functional/cms/connectors_controller_test.rb",
1370
+ "test/functional/cms/dynamic_views_controller_test.rb",
1371
+ "test/functional/cms/sections_controller_test.rb",
1372
+ "test/functional/cms/groups_controller_test.rb",
1373
+ "test/unit/behaviors/searching_test.rb",
1377
1374
  "test/unit/behaviors/attaching_test.rb",
1378
1375
  "test/unit/behaviors/dynamic_attributes_test.rb",
1379
- "test/unit/behaviors/publishable_test.rb",
1380
- "test/unit/behaviors/searching_test.rb",
1381
1376
  "test/unit/behaviors/taggable_test.rb",
1382
- "test/unit/extensions/active_record/base_test.rb",
1377
+ "test/unit/behaviors/publishable_test.rb",
1383
1378
  "test/unit/extensions/hash_test.rb",
1384
1379
  "test/unit/extensions/integer_test.rb",
1385
- "test/unit/helpers/application_helper_test.rb",
1386
- "test/unit/helpers/form_builder_test.rb",
1387
- "test/unit/helpers/menu_helper_test.rb",
1388
- "test/unit/helpers/page_helper_test.rb",
1389
- "test/unit/helpers/path_helper_test.rb",
1390
- "test/unit/lib/acts_as_content_page_test.rb",
1391
- "test/unit/lib/cms/authentication/controller_test.rb",
1392
- "test/unit/lib/cms_domain_support_test.rb",
1393
- "test/unit/lib/command_line_test.rb",
1394
- "test/unit/lib/content_block_test.rb",
1395
- "test/unit/lib/content_rendering_support_test.rb",
1396
- "test/unit/lib/generators_test.rb",
1397
- "test/unit/lib/routes_test.rb",
1380
+ "test/unit/extensions/active_record/base_test.rb",
1381
+ "test/unit/models/page_test.rb",
1382
+ "test/unit/models/email_page_portlet_test.rb",
1398
1383
  "test/unit/models/attachment_test.rb",
1399
- "test/unit/models/category_test.rb",
1400
- "test/unit/models/category_type_test.rb",
1401
1384
  "test/unit/models/connector_test.rb",
1402
- "test/unit/models/content_type_test.rb",
1403
- "test/unit/models/email_page_portlet_test.rb",
1404
- "test/unit/models/file_block_test.rb",
1405
- "test/unit/models/group_test.rb",
1406
1385
  "test/unit/models/html_block_test.rb",
1407
- "test/unit/models/link_test.rb",
1408
- "test/unit/models/page_partial_test.rb",
1409
- "test/unit/models/page_route_test.rb",
1410
- "test/unit/models/page_template_test.rb",
1411
- "test/unit/models/page_test.rb",
1412
- "test/unit/models/permission_test.rb",
1413
1386
  "test/unit/models/portlet_test.rb",
1414
1387
  "test/unit/models/section_node_test.rb",
1415
- "test/unit/models/sections_test.rb",
1388
+ "test/unit/models/content_type_test.rb",
1389
+ "test/unit/models/group_test.rb",
1390
+ "test/unit/models/page_template_test.rb",
1416
1391
  "test/unit/models/site_test.rb",
1392
+ "test/unit/models/permission_test.rb",
1393
+ "test/unit/models/link_test.rb",
1417
1394
  "test/unit/models/task_test.rb",
1395
+ "test/unit/models/page_partial_test.rb",
1418
1396
  "test/unit/models/user_test.rb",
1419
- "test/unit/schema_statements_test.rb"
1397
+ "test/unit/models/file_block_test.rb",
1398
+ "test/unit/models/category_type_test.rb",
1399
+ "test/unit/models/page_route_test.rb",
1400
+ "test/unit/models/sections_test.rb",
1401
+ "test/unit/models/category_test.rb",
1402
+ "test/unit/schema_statements_test.rb",
1403
+ "test/unit/lib/acts_as_content_page_test.rb",
1404
+ "test/unit/lib/generators_test.rb",
1405
+ "test/unit/lib/routes_test.rb",
1406
+ "test/unit/lib/cms_domain_support_test.rb",
1407
+ "test/unit/lib/cms/authentication/controller_test.rb",
1408
+ "test/unit/lib/content_rendering_support_test.rb",
1409
+ "test/unit/lib/command_line_test.rb",
1410
+ "test/unit/lib/content_block_test.rb",
1411
+ "test/unit/helpers/menu_helper_test.rb",
1412
+ "test/unit/helpers/application_helper_test.rb",
1413
+ "test/unit/helpers/page_helper_test.rb",
1414
+ "test/unit/helpers/form_builder_test.rb",
1415
+ "test/unit/helpers/path_helper_test.rb",
1416
+ "test/custom_assertions.rb",
1417
+ "test/test_logging.rb",
1418
+ "test/factories.rb",
1419
+ "test/test_helper.rb"
1420
1420
  ]
1421
1421
 
1422
1422
  if s.respond_to? :specification_version then
@@ -135,7 +135,7 @@
135
135
  <div id="subCol">
136
136
  <h3 class="chapter"><img src="images/chapters_icon.gif" alt="" />Chapters</h3>
137
137
  <ol class="chapters">
138
- <li><a href="#introduction">Introduction</a><ul><li><a href="#typical-design-process">Typical Design Process</a></li><li><a href="#design-considerations">Design Considerations</a></li></ul></li><li><a href="#creating-a-page-template">Creating a Page Template</a><ul><li><a href="#files-or-content">Files or Content?</a></li><li><a href="#understanding-containers">Understanding Containers</a></li><li><a href="#adding-a-sidebar-container">Adding A Sidebar Container</a></li></ul></li><li><a href="#tags-quick-reference">Tags Quick Reference</a><ul><li><a href="#required-tags">Required Tags</a></li><li><a href="#container-tag"><tt>container</tt> Tag</a></li><li><a href="#cms-toolbar-tag"><tt>cms_toolbar</tt> Tag</a></li><li><a href="#html-head-tag"><span class="caps">HTML</span> Head Tag</a></li><li><a href="#page-title-tag"><tt>page_title</tt> Tag</a></li><li><a href="#current-page-tag"><tt>current_page</tt> Tag</a></li><li><a href="#render-portlet-tag"><tt>render_portlet</tt> Tag</a></li><li><a href="#render-connectable-tag"><tt>render_connectable</tt> Tag</a></li></ul></li><li><a href="#navigation">Navigation</a><ul><li><a href="#basic-rules-of-menus">Basic Rules of Menus</a></li><li><a href="#using-menus">Using Menus</a></li><li><a href="#how-deep-should-menus-be">How Deep Should Menus Be?</a></li><li><a href="#primary-navigation">Primary Navigation</a></li><li><a href="#sub-navigation">Sub Navigation</a></li><li><a href="#site-maps-and-flyout-menus">Site Maps and Flyout Menus</a></li><li><a href="#using-breadcrumbs">Using Breadcrumbs</a></li></ul></li><li><a href="#using-partials">Using Partials</a><ul></ul></li></ol></div>
138
+ <li><a href="#introduction">Introduction</a><ul><li><a href="#typical-design-process">Typical Design Process</a></li><li><a href="#design-considerations">Design Considerations</a></li></ul></li><li><a href="#creating-a-page-template">Creating a Page Template</a><ul><li><a href="#files-or-content">Files or Content?</a></li><li><a href="#understanding-containers">Understanding Containers</a></li><li><a href="#adding-a-sidebar-container">Adding A Sidebar Container</a></li></ul></li><li><a href="#tags-quick-reference">Tags Quick Reference</a><ul><li><a href="#required-tags">Required Tags</a></li><li><a href="#container-tag"><tt>container</tt> Tag</a></li><li><a href="#container-has-block-tag"><tt>container_has_block?</tt> Tag</a></li><li><a href="#cms-toolbar-tag"><tt>cms_toolbar</tt> Tag</a></li><li><a href="#html-head-tag"><span class="caps">HTML</span> Head Tag</a></li><li><a href="#page-title-tag"><tt>page_title</tt> Tag</a></li><li><a href="#current-page-tag"><tt>current_page</tt> Tag</a></li><li><a href="#render-portlet-tag"><tt>render_portlet</tt> Tag</a></li><li><a href="#render-connectable-tag"><tt>render_connectable</tt> Tag</a></li></ul></li><li><a href="#navigation">Navigation</a><ul><li><a href="#basic-rules-of-menus">Basic Rules of Menus</a></li><li><a href="#using-menus">Using Menus</a></li><li><a href="#how-deep-should-menus-be">How Deep Should Menus Be?</a></li><li><a href="#primary-navigation">Primary Navigation</a></li><li><a href="#sub-navigation">Sub Navigation</a></li><li><a href="#site-maps-and-flyout-menus">Site Maps and Flyout Menus</a></li><li><a href="#using-breadcrumbs">Using Breadcrumbs</a></li></ul></li><li><a href="#using-partials">Using Partials</a><ul></ul></li></ol></div>
139
139
  </td>
140
140
  <td class="guides">
141
141
  <h2>Templates Guide</h2>
@@ -229,14 +229,15 @@
229
229
  <p>This section covers a reference for all the tags (aka Helper Methods) that can be used in Page Templates to render various elements. Here is a quick list of the available tags, their purpose and whether they are required or not.</p>
230
230
  <p>._ Name |<em>. Purpose | Required? |
231
231
  | <tt>container</tt> | A named area that allows users to add/edit content | Yes |
232
- | <tt>cms</em>toolbar</tt></notextile> | Renders the <span class="caps">CMS</span> toolbar controller required for editing and navigation. Should be very first element in <tt>body</tt> | Yes |
232
+ | <tt>container_has_block</tt> | To hide markup if a container is empty | No |
233
+ | <tt>cms_toolbar</tt> | Renders the <span class="caps">CMS</span> toolbar controller required for editing and navigation. Should be very first element in <tt>body</tt> | Yes |
233
234
  | <tt>yield :html_head | This allows the CMS to insert javascript and other information into the page. Should be last element in </tt>head+ | Yes |
234
235
  | <tt>page_title</tt> | Inserts the &#8216;Name&#8217; of the page (or &#8216;Title&#8217; if it exists) | No |
235
236
  | <tt>current_page</tt> | Returns a reference to the <tt>Page</tt> object that is currently being rendered | No |
236
237
  | <tt>render_breadcrumbs</tt> | Generates breadcrumbs based on the current page and its location in the sitemap | No |
237
238
  | <tt>render_menu</tt> | Generates a menu based on the current page and its location in the sitemap | No |
238
239
  | <tt>render_portlet</tt> | Renders a specific portlet by name | No |
239
- | <tt>render_connectable</tt> | Renders a specific content block | No |</p>
240
+ | <tt>render</em>connectable</tt></notextile> | Renders a specific content block | No |</p>
240
241
  <p>In addition, since Page Templates are Rails layouts, you can make use of any of the Asset Tags&quot;:http://guides.rubyonrails.org/layouts_and_rendering.html#structuring-layouts like <tt>stylesheet_link_tag</tt> or <tt>image_tag</tt>.</p>
241
242
  <h4 id="required-tags">3.1 Required Tags</h4>
242
243
  <p>While most of the tags are optional, there are several tags which must be included or page template just won&#8217;t work correctly. Here&#8217;s the minimum necessary tags required.</p>
@@ -249,7 +250,13 @@
249
250
  &lt;div&gt;&lt;%= container :footer %&gt;&lt;/div&gt;</code></div>
250
251
  <p>Container names are just labels. So if you defined 5 containers on a template (header, footer, left, main, right), you could swap between any two templates which defined all those containers.</p>
251
252
  <div class='note'><p>Be aware that if you add content to a page in a container (like <tt>:sidebar</tt>) then change a pages template to one which does not have that container, the content will be &#8216;orphaned&#8217;. To remove that content, you would need to swap back to the previous template, remove the content, then change back to the new template again.</p></div>
252
- <h4 id="cms-toolbar-tag">3.3 <tt>cms_toolbar</tt> Tag</h4>
253
+ <h4 id="container-has-block-tag">3.3 <tt>container_has_block?</tt> Tag</h4>
254
+ <p>This tag can be used to hide or show containers based on whether a user has placed content in them. While an empty <tt>container</tt> tag won&#8217;t show anything, very frequently template builders will create &#8216;wrapper&#8217; markup around containers that shouldn&#8217;t appear when nothing is placed there. For example, suppose we have a sidebar container that we want to have a styled border on, but we only want it to appear when something is in that container. Here&#8217;s how you would do that:</p>
255
+ <div class="code_container"><code class="html">&lt;% unless container_has_block? :sidebar %&gt;
256
+ &lt;div id=&quot;sidebar&quot;&gt;&lt;%= container :sidebar %&gt;&lt;/div&gt;
257
+ &lt;% end %&gt;</code></div>
258
+ <p>This tag returns true if the user is in edit mode as well, regardless of whether there is content within the container. This is important, because otherwise, an editor would never be able to select the container to add content to!</p>
259
+ <h4 id="cms-toolbar-tag">3.4 <tt>cms_toolbar</tt> Tag</h4>
253
260
  <p>This tag is how the toolbar is inserted into templates. It should be the first element in the <tt>body</tt> element of a page. In most cases, you can just use it as follows:</p>
254
261
  <div class="code_container"><code class="html">&lt;body&gt;
255
262
  &lt;%= cms_toolbar %&gt;
@@ -257,20 +264,20 @@
257
264
  &lt;!-- Text goes here --&gt;
258
265
  &lt;/body&gt;</code></div>
259
266
  <p>The toolbar is written out as an iframe which makes its less likely that styles/javascript will clash with the page being editted.</p>
260
- <h4 id="html-head-tag">3.4 <span class="caps">HTML</span> Head Tag</h4>
267
+ <h4 id="html-head-tag">3.5 <span class="caps">HTML</span> Head Tag</h4>
261
268
  <p>This tag is technically a standard <tt>yield</tt> call, with a particularly named <tt>:html_head</tt>. This tag must be included in all <span class="caps">CMS</span> templates to allow it to insert the necessary javascript and style elements. It should probably be the last element in <tt>head</tt> element of a page.</p>
262
269
  <div class="code_container"><code class="html">&lt;head&gt;
263
270
  &lt;title&gt;&lt;%= page_title %&gt;&lt;/title&gt;
264
271
  &lt;%= yield :html_head %&gt;
265
272
  &lt;/head&gt;</code></div>
266
- <h4 id="page-title-tag">3.5 <tt>page_title</tt> Tag</h4>
273
+ <h4 id="page-title-tag">3.6 <tt>page_title</tt> Tag</h4>
267
274
  <p>This tag will output the <tt>name</tt> attribute of the current page. If the <tt>title</tt> attribute is specified, it will output that instead. This allows users to have one label for a page appear in the navigation (navigation and the sitemap always use <tt>name</tt>) and another in the header or title bar on a page.</p>
268
275
  <p>Example:</p>
269
276
  <div class="code_container"><code class="html">&lt;title&gt;My Site | &lt;%= page_title %&gt;&lt;/title&gt;</code></div>
270
277
  <p>This is using the page_title tag to title element of a page.</p>
271
278
  <div class="code_container"><code class="html">&lt;h1&gt;&lt;%= page_title %&gt;&lt;/h1&gt;</code></div>
272
279
  <p>Another common usage of <tt>page_title</tt> is for the H1 or H2 on a page.</p>
273
- <h4 id="current-page-tag">3.6 <tt>current_page</tt> Tag</h4>
280
+ <h4 id="current-page-tag">3.7 <tt>current_page</tt> Tag</h4>
274
281
  <p>This doesn&#8217;t render anything, but returns a reference to the current <tt>Page</tt> object that is being rendered. It can be used to access other attributes of the page, like the name of the section or the <tt>description</tt> of the Page. Here are some common examples:</p>
275
282
  <div class="code_container"><code class="html">&lt;%= current_page.name %&gt;</code></div>
276
283
  <p>This outputs the <tt>name</tt> attribute of the page, similar to how <tt>page_title</tt> works. You might do this if you had specified a <tt>title</tt> attribute for pages which was different than the <tt>name</tt>, but wanted to compare names.</p>
@@ -281,11 +288,11 @@
281
288
  &lt;% end %&gt;</code></div>
282
289
  <p>This renders a specific image if the page is within the top level &#8216;About Us&#8217; section. The <tt>top_level_section</tt> method finds the very top level section for a give page, regardless of how far down it is in the sitemap. Useful for making comparisons based on the first level of navigation.</p>
283
290
  <div class='note'><p>Any page or section attribute is reachable in the way. You will need to look at the <span class="caps">API</span> documentation for <tt>Page</tt> and <tt>Section</tt> to see all the available attributes.</p></div>
284
- <h4 id="render-portlet-tag">3.7 <tt>render_portlet</tt> Tag</h4>
291
+ <h4 id="render-portlet-tag">3.8 <tt>render_portlet</tt> Tag</h4>
285
292
  <p>This tag will render a portlet from a template. Normally portlets are placed individually on each page by users. This tag is useful for common elements that might appear on multiple pages throughout the site. An example of this might be a Login Portlet which should appear as part of the header on all pages. Here&#8217;s an example:</p>
286
293
  <div class="code_container"><code class="html">&lt;%= render_portlet &quot;Nav Login Form&quot; %&gt;</code></div>
287
294
  <p>The only argument to <tt>render_portlet</tt> is a name. This name will match the name specified in the UI when you add a portlet. You will need to create the portlet and name in appropriately for this tag to work. The portlet will render itself based on its template.</p>
288
- <h4 id="render-connectable-tag">3.8 <tt>render_connectable</tt> Tag</h4>
295
+ <h4 id="render-connectable-tag">3.9 <tt>render_connectable</tt> Tag</h4>
289
296
  <p>This tag can render a specific block in a page. It takes one argument, the block itself. This could be used to automatically include, say a footer, into a page as part of the template. For instance:</p>
290
297
  <div class="code_container"><code class="html">&lt;% footer = HtmlBlock.find(12) %&gt;
291
298
  &lt;%= render_connectable(footer) %&gt;</code></div>
@@ -209,12 +209,11 @@ end</code></div>
209
209
  <p>Now each instance of the RecentProducts can have its own unique template. Each time a new portlet is created, the contents of
210
210
  the &#8216;render.html.erb&#8217; will be copied into the template attribute of the portlet and used to display the portlet. Users can
211
211
  update these views as they see fit.</p>
212
- <p><strong>Gotcha:</strong> It&#8217;s important to remember that once a portlet has a saved template, it will ignore what&#8217;s in the render.html.erb. So changes made there won&#8217;t
213
- be reflected until the portlet&#8217;s template has been updated again.</p>
212
+ <p><strong>Gotcha:</strong> It&#8217;s important to remember that once a portlet has a saved template, it will ignore what&#8217;s in the render.html.erb. So changes made there won&#8217;t be reflected until the portlet&#8217;s template has been updated again.</p>
214
213
  <h4 id="default-template-handlers">1.2 Default Template Handlers</h4>
215
214
  <p>By default, templates are treated as erb views. The template editor has a drop down that allows users to choose other types like &#8216;builder&#8217; or &#8216;rhtml&#8217;. To set the default handler
216
215
  to something other than erb, modify the _form.html.erb to the following:</p>
217
- <div class="code_container"><code class="html">&lt;%= f.template_editor :template, :default_handler=&gt;&quot;builder&quot; %&gt;</code></div>
216
+ <div class="code_container"><code class="html">&lt;%= f.cms_template_editor :template, :default_handler=&gt;&quot;builder&quot; %&gt;</code></div>
218
217
  <h4 id="alternative-handlers-for-non-editable-templates">1.3 Alternative handlers for non-editable templates</h4>
219
218
  <p>If the template_editor is disabled, you can also set the handler directly on the portlet like so:</p>
220
219
  <div class="code_container"><code class="ruby">class RecentProducts &lt; Portlet
@@ -223,7 +222,7 @@ to something other than erb, modify the _form.html.erb to the following:</p>
223
222
  end</code></div>
224
223
  <h4 id="using-haml-templates">1.4 Using <span class="caps">HAML</span> templates</h4>
225
224
  <p>The default list of handlers does not include Haml. To do that, install the <span class="caps">HAML</span> gem and set the default_value to &#8216;haml&#8217; like so:</p>
226
- <div class="code_container"><code class="html">&lt;%= f.template_editor :template, :default_handler=&gt;&quot;haml&quot; %&gt;</code></div>
225
+ <div class="code_container"><code class="html">&lt;%= f.cms_template_editor :template, :default_handler=&gt;&quot;haml&quot; %&gt;</code></div>
227
226
  </td>
228
227
  </tr>
229
228
  </table>
@@ -39,11 +39,11 @@ module Cms
39
39
  module InstanceMethods
40
40
 
41
41
  def connected_pages
42
- Page.connected_to(self)
42
+ Page.currently_connected_to(self)
43
43
  end
44
44
 
45
45
  def connected_page_count
46
- Page.connected_to(self).count
46
+ Page.currently_connected_to(self).count
47
47
  end
48
48
 
49
49
  def content_block_type
data/lib/cms/version.rb CHANGED
@@ -2,5 +2,5 @@
2
2
  # Allows the precise version of BrowserCMS to be determined programmatically.
3
3
  #
4
4
  module Cms
5
- VERSION = "3.1.0"
6
- end
5
+ VERSION = "3.2.0"
6
+ end
@@ -24,5 +24,31 @@ class Cms::DynamicViewsControllerTest < ActionController::TestCase
24
24
  assert_select "#page_template_#{@deleted_page_template.id} div",
25
25
  :text => "Deleted (html/erb)", :count => 0
26
26
  end
27
+
28
+ def test_index_paging
29
+ @page_templates = []
30
+ 20.times do |i|
31
+ @page_templates << Factory(:page_template, :name => "test_#{i}")
32
+ end
33
+
34
+ def @request.request_uri
35
+ "/cms/page_templates?page=1"
36
+ end
37
+
38
+ get :index, :page => 1
39
+ assert_response :success
40
+ # 15 on first page
41
+ assert_equal 15, assigns['views'].length
42
+
43
+ def @request.request_uri
44
+ "/cms/page_templates?page=2"
45
+ end
46
+
47
+ get :index, :page => 2
48
+ assert_response :success
49
+ # count minus 15 on second page
50
+ should_have = PageTemplate.all.length - 15
51
+ assert_equal should_have, assigns['views'].length
52
+ end
27
53
 
28
54
  end
@@ -150,7 +150,8 @@ class Cms::HtmlBlocksControllerTest < ActionController::TestCase
150
150
  @page = Factory(:page, :section => root_section, :name => "Included")
151
151
  @page2 = Factory(:page, :section => root_section, :path => "/other_path", :name => "Excluded")
152
152
  @block = Factory(:html_block, :connect_to_page_id => @page.id, :connect_to_container => "main")
153
-
153
+ @page.publish! # usages are only relevant when page is published
154
+
154
155
  get :usages, :id => @block.id
155
156
 
156
157
  assert_response :success
@@ -160,4 +161,4 @@ class Cms::HtmlBlocksControllerTest < ActionController::TestCase
160
161
  assert_select "h3", "Content Types"
161
162
  end
162
163
 
163
- end
164
+ end
@@ -50,6 +50,7 @@ class Cms::PortletsControllerTest < ActionController::TestCase
50
50
  @page = Factory(:page, :section => root_section, :name => "Test Page", :path => "test")
51
51
  @page.create_connector(@block, "main")
52
52
  @page.reload
53
+ @page.publish! # usages are only relevant when page is published
53
54
 
54
55
  get :usages, :id => @block.id
55
56
 
@@ -64,4 +65,4 @@ class Cms::PortletsControllerTest < ActionController::TestCase
64
65
  assert_select "div.instructions", "Leave blank to send the user to the page they were trying to access"
65
66
 
66
67
  end
67
- end
68
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: browsercms
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.1.0
4
+ version: 3.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - BrowserMedia
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2010-03-03 00:00:00 -05:00
12
+ date: 2010-06-28 00:00:00 -04:00
13
13
  default_executable:
14
14
  dependencies: []
15
15
 
@@ -1374,75 +1374,75 @@ signing_key:
1374
1374
  specification_version: 3
1375
1375
  summary: BrowserCMS is a general purpose, open source Web Content Management System (CMS) written in Ruby on Rails. Designed for web developers who want to create great looking websites while using standard Rails tools for customizing it.
1376
1376
  test_files:
1377
- - test/custom_assertions.rb
1378
- - test/factories.rb
1377
+ - test/integration/login_test.rb
1378
+ - test/integration/cms/password_management_test.rb
1379
+ - test/integration/cms/ckeditor_test.rb
1380
+ - test/functional/tests/pretend_controller_test.rb
1381
+ - test/functional/cms/links_controller_test.rb
1382
+ - test/functional/cms/image_blocks_controller_test.rb
1379
1383
  - test/functional/cms/cache_controller_test.rb
1380
- - test/functional/cms/categories_controller_test.rb
1381
- - test/functional/cms/connectors_controller_test.rb
1382
- - test/functional/cms/content_block_controller_test.rb
1383
- - test/functional/cms/content_controller_test.rb
1384
- - test/functional/cms/content_types_controller_test.rb
1385
- - test/functional/cms/dashboard_controller_test.rb
1386
- - test/functional/cms/dynamic_views_controller_test.rb
1387
- - test/functional/cms/file_blocks_controller_test.rb
1388
- - test/functional/cms/groups_controller_test.rb
1389
1384
  - test/functional/cms/home_controller_test.rb
1390
- - test/functional/cms/html_blocks_controller_test.rb
1391
- - test/functional/cms/image_blocks_controller_test.rb
1392
- - test/functional/cms/links_controller_test.rb
1393
1385
  - test/functional/cms/pages_controller_test.rb
1386
+ - test/functional/cms/content_block_controller_test.rb
1387
+ - test/functional/cms/dashboard_controller_test.rb
1388
+ - test/functional/cms/content_types_controller_test.rb
1394
1389
  - test/functional/cms/portlets_controller_test.rb
1390
+ - test/functional/cms/html_blocks_controller_test.rb
1395
1391
  - test/functional/cms/section_nodes_controller_test.rb
1396
- - test/functional/cms/sections_controller_test.rb
1397
- - test/functional/cms/sessions_controller_test.rb
1398
1392
  - test/functional/cms/toolbar_controller_test.rb
1393
+ - test/functional/cms/sessions_controller_test.rb
1399
1394
  - test/functional/cms/users_controller_test.rb
1400
- - test/functional/tests/pretend_controller_test.rb
1401
- - test/integration/cms/ckeditor_test.rb
1402
- - test/integration/cms/password_management_test.rb
1403
- - test/integration/login_test.rb
1404
- - test/test_helper.rb
1405
- - test/test_logging.rb
1395
+ - test/functional/cms/categories_controller_test.rb
1396
+ - test/functional/cms/file_blocks_controller_test.rb
1397
+ - test/functional/cms/content_controller_test.rb
1398
+ - test/functional/cms/connectors_controller_test.rb
1399
+ - test/functional/cms/dynamic_views_controller_test.rb
1400
+ - test/functional/cms/sections_controller_test.rb
1401
+ - test/functional/cms/groups_controller_test.rb
1402
+ - test/unit/behaviors/searching_test.rb
1406
1403
  - test/unit/behaviors/attaching_test.rb
1407
1404
  - test/unit/behaviors/dynamic_attributes_test.rb
1408
- - test/unit/behaviors/publishable_test.rb
1409
- - test/unit/behaviors/searching_test.rb
1410
1405
  - test/unit/behaviors/taggable_test.rb
1411
- - test/unit/extensions/active_record/base_test.rb
1406
+ - test/unit/behaviors/publishable_test.rb
1412
1407
  - test/unit/extensions/hash_test.rb
1413
1408
  - test/unit/extensions/integer_test.rb
1414
- - test/unit/helpers/application_helper_test.rb
1415
- - test/unit/helpers/form_builder_test.rb
1416
- - test/unit/helpers/menu_helper_test.rb
1417
- - test/unit/helpers/page_helper_test.rb
1418
- - test/unit/helpers/path_helper_test.rb
1419
- - test/unit/lib/acts_as_content_page_test.rb
1420
- - test/unit/lib/cms/authentication/controller_test.rb
1421
- - test/unit/lib/cms_domain_support_test.rb
1422
- - test/unit/lib/command_line_test.rb
1423
- - test/unit/lib/content_block_test.rb
1424
- - test/unit/lib/content_rendering_support_test.rb
1425
- - test/unit/lib/generators_test.rb
1426
- - test/unit/lib/routes_test.rb
1409
+ - test/unit/extensions/active_record/base_test.rb
1410
+ - test/unit/models/page_test.rb
1411
+ - test/unit/models/email_page_portlet_test.rb
1427
1412
  - test/unit/models/attachment_test.rb
1428
- - test/unit/models/category_test.rb
1429
- - test/unit/models/category_type_test.rb
1430
1413
  - test/unit/models/connector_test.rb
1431
- - test/unit/models/content_type_test.rb
1432
- - test/unit/models/email_page_portlet_test.rb
1433
- - test/unit/models/file_block_test.rb
1434
- - test/unit/models/group_test.rb
1435
1414
  - test/unit/models/html_block_test.rb
1436
- - test/unit/models/link_test.rb
1437
- - test/unit/models/page_partial_test.rb
1438
- - test/unit/models/page_route_test.rb
1439
- - test/unit/models/page_template_test.rb
1440
- - test/unit/models/page_test.rb
1441
- - test/unit/models/permission_test.rb
1442
1415
  - test/unit/models/portlet_test.rb
1443
1416
  - test/unit/models/section_node_test.rb
1444
- - test/unit/models/sections_test.rb
1417
+ - test/unit/models/content_type_test.rb
1418
+ - test/unit/models/group_test.rb
1419
+ - test/unit/models/page_template_test.rb
1445
1420
  - test/unit/models/site_test.rb
1421
+ - test/unit/models/permission_test.rb
1422
+ - test/unit/models/link_test.rb
1446
1423
  - test/unit/models/task_test.rb
1424
+ - test/unit/models/page_partial_test.rb
1447
1425
  - test/unit/models/user_test.rb
1426
+ - test/unit/models/file_block_test.rb
1427
+ - test/unit/models/category_type_test.rb
1428
+ - test/unit/models/page_route_test.rb
1429
+ - test/unit/models/sections_test.rb
1430
+ - test/unit/models/category_test.rb
1448
1431
  - test/unit/schema_statements_test.rb
1432
+ - test/unit/lib/acts_as_content_page_test.rb
1433
+ - test/unit/lib/generators_test.rb
1434
+ - test/unit/lib/routes_test.rb
1435
+ - test/unit/lib/cms_domain_support_test.rb
1436
+ - test/unit/lib/cms/authentication/controller_test.rb
1437
+ - test/unit/lib/content_rendering_support_test.rb
1438
+ - test/unit/lib/command_line_test.rb
1439
+ - test/unit/lib/content_block_test.rb
1440
+ - test/unit/helpers/menu_helper_test.rb
1441
+ - test/unit/helpers/application_helper_test.rb
1442
+ - test/unit/helpers/page_helper_test.rb
1443
+ - test/unit/helpers/form_builder_test.rb
1444
+ - test/unit/helpers/path_helper_test.rb
1445
+ - test/custom_assertions.rb
1446
+ - test/test_logging.rb
1447
+ - test/factories.rb
1448
+ - test/test_helper.rb