noodall-ui 0.0.22 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -97,7 +97,6 @@ module Noodall
97
97
  end
98
98
 
99
99
  def create
100
- logger.debug request.inspect
101
100
  @asset = Asset.new(params[:asset])
102
101
 
103
102
  respond_to do |format|
@@ -1,12 +1,19 @@
1
1
  module Noodall
2
2
  class NodesController < ApplicationController
3
+ include Canable::Enforcers
3
4
  rescue_from MongoMapper::DocumentNotFound, ActionView::MissingTemplate, :with => :render_404
5
+ rescue_from Canable::Transgression, :with => :permission_denied
4
6
 
5
7
  def show
6
8
  if flash.any? or published_states_changed_since_global_update? or stale?(:last_modified => GlobalUpdateTime::Stamp.read, :public => true)
7
9
  permalink = params[:permalink].is_a?(String) ? params[:permalink] : params[:permalink].join('/')
8
-
9
10
  @node = Node.find_by_permalink(permalink)
11
+
12
+ #Check view permissions
13
+ enforce_view_permission(@node) if anybody_signed_in?
14
+ #Set cache control to private if this page has restricted permisions
15
+ response.cache_control[:public] = false if @node.viewable_groups.any?
16
+
10
17
  @page_title = @node.title
11
18
  @page_description = @node.description
12
19
  @page_keywords = @node.keywords
@@ -16,7 +23,6 @@ module Noodall
16
23
  format.any { render "nodes/#{@node.class.name.underscore}" }
17
24
  end
18
25
  end
19
-
20
26
  end
21
27
 
22
28
  def sitemap
@@ -32,7 +38,7 @@ module Noodall
32
38
  @page_title = 'Searching: '+ params[:q]
33
39
  end
34
40
 
35
- protected
41
+ protected
36
42
 
37
43
  def published_states_changed_since_global_update?
38
44
  if Node.count(:published_at => { :$gte => GlobalUpdateTime::Stamp.read, :$lte => Time.zone.now }).zero? and Node.count(:published_to => { :$gte => GlobalUpdateTime::Stamp.read, :$lte => Time.zone.now }).zero?
@@ -45,11 +51,15 @@ module Noodall
45
51
 
46
52
  def render_404(exception = nil)
47
53
  if exception
48
- logger.info "Rendering 404: #{exception.message}"
54
+ logger.info "Rendering 404: #{exception.message}"
49
55
  end
50
56
 
51
57
  render :file => "#{Rails.root}/public/404.html", :status => 404, :layout => false, :content_type => "text/html"
52
58
  end
53
59
 
60
+ def permission_denied
61
+ flash[:error] = "You do not have permission to do that"
62
+ redirect_to root_url
63
+ end
54
64
  end
55
65
  end
@@ -105,6 +105,10 @@
105
105
  <th><%= f.label :destroyable_groups_list, "Delete" %></th>
106
106
  <td><%= f.text_field :destroyable_groups_list, :class => "groups-completer" %></td>
107
107
  </tr>
108
+ <tr>
109
+ <th><%= f.label :viewable_groups_list, "View" %></th>
110
+ <td><%= f.text_field :viewable_groups_list, :class => "groups-completer" %></td>
111
+ </tr>
108
112
  </tbody>
109
113
  </table>
110
114
  </span>
@@ -19,4 +19,8 @@ class ApplicationController < ActionController::Base
19
19
  def authenticate_user!
20
20
  true
21
21
  end
22
+
23
+ def anybody_signed_in?
24
+ true
25
+ end
22
26
  end
@@ -6,4 +6,5 @@ class PageA < Noodall::Node
6
6
  small_slots 4
7
7
  wide_slots 3
8
8
 
9
+ searchable_keys :title, :body, :description, :keywords
9
10
  end
@@ -1,4 +1,5 @@
1
1
  class PageB < Noodall::Node
2
2
  main_slots 1
3
3
  wide_slots 3
4
+ searchable_keys :title, :body, :description, :keywords
4
5
  end
@@ -4,4 +4,5 @@ class PageC < Noodall::Node
4
4
 
5
5
  main_slots 1
6
6
  wide_slots 3
7
+ searchable_keys :title, :body, :description, :keywords
7
8
  end
data/demo/seeds.rb CHANGED
@@ -3,6 +3,6 @@ Factory(:page_a, :title => "Home", :publish => true)
3
3
  5.times do |i|
4
4
  page = Factory(:page_c, :publish => true)
5
5
  4.times do |i|
6
- Factory(:page_b, :publish => true, :parent => page)
6
+ Factory(:page_c, :publish => true, :parent => page)
7
7
  end
8
8
  end
@@ -3,7 +3,7 @@
3
3
  <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
4
4
 
5
5
  <!--
6
- HTML5 - When your ready to do so
6
+ HTML5 - When your ready to do so
7
7
  <!doctype html>
8
8
  <html lang="en">
9
9
  -->
@@ -12,12 +12,12 @@
12
12
 
13
13
  <title><%#= Settings.site_name %> - <%= page_title %></title>
14
14
 
15
- <!-- Always force latest IE rendering engine (even in intranet) & Chrome Frame
15
+ <!-- Always force latest IE rendering engine (even in intranet) & Chrome Frame
16
16
  Remove this if you use the .htaccess -->
17
17
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
18
18
 
19
19
  <!-- Mobile Viewport Fix
20
- j.mp/mobileviewport & davidbcalhoun.com/2010/viewport-metatag
20
+ j.mp/mobileviewport & davidbcalhoun.com/2010/viewport-metatag
21
21
  device-width : Occupy full width of the screen in its current orientation
22
22
  initial-scale = 1.0 retains dimensions instead of zooming out if page height > device height
23
23
  maximum-scale = 1.0 retains dimensions instead of zooming in if page width < device width
@@ -52,16 +52,16 @@ maximum-scale = 1.0 retains dimensions instead of zooming in if page width < dev
52
52
  google.load("jquery", "1.4");
53
53
  google.load("swfobject", "2.2");
54
54
  </script>
55
-
55
+
56
56
  <%= javascript_include_tag 'rails', 'cufon-yui', 'fancybox', 'carousel.lite', 'application' %>
57
57
  <%= csrf_meta_tag %>
58
-
58
+
59
59
  <!-- so:JavaScripts -->
60
60
 
61
61
  <%= yield :head %>
62
62
 
63
- <!--
64
- Asynchronous google analytics: mathiasbynens.be/notes/async-analytics-snippet
63
+ <!--
64
+ Asynchronous google analytics: mathiasbynens.be/notes/async-analytics-snippet
65
65
  change the UA-XXXXX-X to be your site's ID
66
66
  Now at the top cos google said so!
67
67
  -->
@@ -95,6 +95,7 @@ maximum-scale = 1.0 retains dimensions instead of zooming in if page width < dev
95
95
  <!-- so:main-navigation -->
96
96
 
97
97
  <div id="content">
98
+ <%= flash_messages %>
98
99
  <%= yield %>
99
100
  </div>
100
101
 
@@ -102,7 +103,7 @@ maximum-scale = 1.0 retains dimensions instead of zooming in if page width < dev
102
103
  <%= text_field_tag :q, params[:q], :value => 'Enter keyword(s) here' %>
103
104
  <%= submit_tag 'Search' %>
104
105
  <% end %>
105
-
106
+
106
107
  <div id="footer">
107
108
  <!-- so:main-navigation -->
108
109
  <ul class="nav" id="footer-nav">
@@ -55,6 +55,7 @@ When /^I click the editor "([^"]*)" button$/ do |button_name|
55
55
  end
56
56
 
57
57
  When /^I click "([^"]*)" on an Asset$/ do |button_name|
58
+ sleep 3
58
59
  within('#browser-list ul li:first') do
59
60
  click_link button_name
60
61
  end
@@ -20,7 +20,7 @@ When /^(?:|I )fill in the following within the component:$/ do |fields|
20
20
  within "#fancybox-inner" do
21
21
  fields.rows_hash.each do |name, value|
22
22
  When %{I fill in "#{name}" with "#{value}"}
23
- end
23
+ end
24
24
  end
25
25
  end
26
26
 
@@ -28,6 +28,7 @@ When /^(?:|I )press "([^"]*)" within the component$/ do |button|
28
28
  within "#fancybox-inner" do
29
29
  click_button(button)
30
30
  end
31
+ sleep 3
31
32
  end
32
33
 
33
34
  When /^(?:|I )select an image from the asset library$/ do
@@ -59,7 +60,7 @@ Then /^I add some images to from the asset library$/ do
59
60
  5.times do |i|
60
61
  Factory(:asset, :title => "Image #{i}")
61
62
  end
62
- page.find(:css, 'span.add-multi-asset').click
63
+ page.find(:css, 'span.add-multi-asset').click
63
64
  3.times do |i|
64
65
  within "#asset-browser li:nth(#{i + 1})" do
65
66
  click_link "Add"
@@ -2,15 +2,17 @@ Then /^I should be able to set the permissions on that content$/ do
2
2
  fill_in "Update", :with => "Them, Us, Things"
3
3
  fill_in "Delete", :with => "Us, Things, Stuff"
4
4
  fill_in "Publish", :with => "Us, Stuff"
5
+ fill_in "View", :with => "Us, Stuff"
5
6
  click_button "Publish"
6
7
  @_content.reload
7
8
  @_content.updatable_groups.should == ['Them', 'Us', 'Things']
8
9
  @_content.destroyable_groups.should == ['Us', 'Things', 'Stuff']
9
10
  @_content.publishable_groups.should == ['Us', 'Stuff']
11
+ @_content.viewable_groups.should == ['Us', 'Stuff']
10
12
  end
11
13
 
12
14
  Given(/^content's ([^\"]*) is set to "([^\"]*)" and "([^\"]*)"$/) do |permission, group1, group2|
13
- @_content = Factory(:page_a, "#{permission.downcase.gsub(/e$/,'')}able_groups" => [group1, group2], :hide => true)
15
+ @_content = Factory(:page_a, "#{permission.downcase.gsub(/e$/,'')}able_groups" => [group1, group2], :publish => true)
14
16
  end
15
17
 
16
18
  Then(/^only users in the "([^\"]*)" and "([^\"]*)" should be able to ([^\"]*) content$/) do |group1, group2, actions|
@@ -37,6 +39,10 @@ Then(/^only users in the "([^\"]*)" and "([^\"]*)" should be able to ([^\"]*) co
37
39
  rescue Capybara::ElementNotFound => e
38
40
  raise Canable::Transgression # Raise this if we can't find the button
39
41
  end
42
+ when "View"
43
+ # Create a home page so there is something to redirect to
44
+ Factory(:home, :title => 'Home', :publish => true, :body => "Hello this is home")
45
+ visit node_path(@_content)
40
46
  end
41
47
  end
42
48
  Then %{I sign out} #Neeed to do this or remeber cookie gets in the way
@@ -60,6 +66,9 @@ Then(/^users not in the "([^\"]*)" and "([^\"]*)" should not be able to ([^\"]*)
60
66
  when "Publish"
61
67
  visit noodall_admin_node_path(@_content)
62
68
  lambda { click_button "Publish" }.should raise_error(Capybara::ElementNotFound)
69
+ when "View"
70
+ visit node_path(@_content)
71
+ page.should have_content("You do not have permission to do that")
63
72
  end
64
73
  end
65
74
 
@@ -1,5 +1,5 @@
1
1
  module Noodall
2
2
  module UI
3
- VERSION = "0.0.22"
3
+ VERSION = "0.1.0"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: noodall-ui
3
3
  version: !ruby/object:Gem::Version
4
- hash: 51
4
+ hash: 27
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
+ - 1
8
9
  - 0
9
- - 22
10
- version: 0.0.22
10
+ version: 0.1.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Steve England
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-01-06 00:00:00 +00:00
18
+ date: 2011-01-12 00:00:00 +00:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency