refinerycms 0.9.4.3 → 0.9.4.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -59,7 +59,7 @@ eval("#{(defined? Refinery::Initializer) ? Refinery::Initializer : Rails::Initia
59
59
  #
60
60
 
61
61
  config.gem "rake", :version => ">= 0.8.3", :lib => "rake"
62
- config.gem "friendly_id", :version => ">= 2.1.4", :lib => "friendly_id"
62
+ config.gem "friendly_id", :version => ">= 2.2.2", :lib => "friendly_id"
63
63
  config.gem "mislav-will_paginate", :version => ">= 2.3.11", :lib => "will_paginate", :source => "http://gems.github.com"
64
64
  config.gem "rails", :version => ">= 2.3.4", :lib => "rails"
65
65
  config.gem "rubyist-aasm", :version => ">= 2.1.1", :lib => "aasm", :source => "http://gems.github.com"
@@ -14,6 +14,4 @@ config.action_view.debug_rjs = true
14
14
  config.action_controller.perform_caching = false
15
15
 
16
16
  # Don't care if the mailer can't send
17
- config.action_mailer.raise_delivery_errors = false
18
-
19
- ActionMailer::Base.delivery_method = :sendmail
17
+ config.action_mailer.raise_delivery_errors = false
@@ -9,7 +9,7 @@
9
9
  #
10
10
  # It's strongly recommended to check this file into your version control system.
11
11
 
12
- ActiveRecord::Schema.define(:version => 20090916055243) do
12
+ ActiveRecord::Schema.define(:version => 20091029034951) do
13
13
 
14
14
  create_table "images", :force => true do |t|
15
15
  t.integer "parent_id"
@@ -49,7 +49,6 @@ ActiveRecord::Schema.define(:version => 20090916055243) do
49
49
  t.datetime "created_at"
50
50
  t.datetime "updated_at"
51
51
  t.datetime "publish_date"
52
- t.text "blurb"
53
52
  end
54
53
 
55
54
  create_table "page_parts", :force => true do |t|
@@ -1,6 +1,6 @@
1
1
  [{:name => "site_name", :value => "Company Name"},
2
2
  {:name => "new_page_parts", :value => false},
3
- {:name => "activity_show_limit", :value => 10},
3
+ {:name => "activity_show_limit", :value => 25},
4
4
  {:name => "preferred_image_view", :value => :grid},
5
5
  {:name => "analytics_page_code", :value => "UA-xxxxxx-x"},
6
6
  {:name => "image_thumbnails", :value => {
@@ -86,6 +86,10 @@ class User < ActiveRecord::Base
86
86
  end
87
87
  end
88
88
  end
89
+
90
+ def authorized_plugins
91
+ self.plugins.collect {|p| p.title} | Refinery::Plugins.always_allowed.titles
92
+ end
89
93
 
90
94
  def remember_token?
91
95
  remember_token_expires_at && Time.now.utc < remember_token_expires_at
@@ -9,16 +9,6 @@
9
9
  <%= f.datetime_select :publish_date %>
10
10
  </div>
11
11
  <div class='clearfix' style='width:963px'>
12
- <div class='field'>
13
- <%= f.label :blurb %>
14
- <p>
15
- <small>
16
- Write something that leads the reader into wanting to read the full article.
17
- This should just be a 1 paragraph max intro into the article.
18
- </small>
19
- </p>
20
- <%= f.text_area :blurb, :rows => "5", :class => "wymeditor"%>
21
- </div>
22
12
  <div class='field'>
23
13
  <%= f.label :content %>
24
14
  <%= f.text_area :content, :rows => "20", :class => "wymeditor" %>
@@ -9,9 +9,7 @@
9
9
  <p>
10
10
  <small>Published <%= item.publish_date.strftime("%A %d of %B, %Y") %></small>
11
11
  </p>
12
- <p>
13
- <%= item.blurb %> <%= link_to "Read more", news_item_url(item) %>
14
- </p>
12
+ <%= truncate(item.body, :length => 200, :omission => " ... #{link_to "Read more", news_item_url(item)}", :preserve_html_tags => true) %>
15
13
  <% end %>
16
14
  <% else %>
17
15
  <p><em>Sorry we haven't posted up any news yet.</em></p>
@@ -1,20 +1,20 @@
1
1
  class PagesController < ApplicationController
2
2
 
3
3
  def home
4
- @page = Page.find_by_link_url("/", :include => [:parts, :slugs])
5
- error_404 if @page.nil?
4
+ @page = Page.find_by_link_url("/", :include => [:parts, :slugs])
5
+ error_404 if @page.nil?
6
6
  end
7
7
 
8
- def show
9
- @page = Page.find(params[:id], :include => [:parts, :slugs])
8
+ def show
9
+ @page = Page.find(params[:id], :include => [:parts, :slugs])
10
10
 
11
- error_404 unless @page.live?
11
+ error_404 unless @page.live? or (logged_in? and current_user.authorized_plugins.include?("Pages"))
12
12
 
13
- # if the admin wants this to be a "placeholder" page which goes to its first child, go to that instead.
14
- if @page.skip_to_first_child
15
- first_live_child = @page.children.find_by_draft(false, :order => "position ASC")
16
- redirect_to first_live_child.url unless first_live_child.nil?
17
- end
18
- end
13
+ # if the admin wants this to be a "placeholder" page which goes to its first child, go to that instead.
14
+ if @page.skip_to_first_child
15
+ first_live_child = @page.children.find_by_draft(false, :order => "position ASC")
16
+ redirect_to first_live_child.url unless first_live_child.nil?
17
+ end
18
+ end
19
19
 
20
20
  end
@@ -7,4 +7,9 @@
7
7
  <div id='body_content_right' class='clearfix'>
8
8
  <%= @page[:side_body] %>
9
9
  </div>
10
- </div>
10
+ </div>
11
+ <% unless @page.live? %>
12
+ <div style='border: 1px solid #A00027;color: #A00027;background: #FFB1B1;padding:3px 9px;font-weight:bold;width:auto'>
13
+ This page is NOT live for public viewing.
14
+ </div>
15
+ <% end %>
@@ -1,22 +1,21 @@
1
1
  module Refinery
2
2
 
3
- def self.add_gems
4
- ActiveRecord::Base.module_eval do
5
- begin
6
- require 'friendly_id'
7
- require 'will_paginate'
8
- require 'aasm'
9
- rescue LoadError => load_error
10
- # this will stop us running rake gems:install which we don't really want so just trap this error.
11
- end
3
+ def self.add_gems
4
+ ActiveRecord::Base.module_eval do
5
+ begin
6
+ require 'friendly_id'
7
+ require 'will_paginate'
8
+ require 'aasm'
9
+ rescue LoadError => load_error
10
+ # this will stop us running rake gems:install which we don't really want so just trap this error.
11
+ end
12
+
13
+ # Stub has_friendly_id. This will get overriden when/if included.
14
+ # The config will still complain that the gem is missing but this allows it to do so.
15
+ def self.has_friendly_id(column, options = {}, &block)
16
+ super if defined? super and table_exists?
17
+ end
12
18
  end
13
-
14
- # Stub has_friendly_id unless it is already included.
15
- # The config will still complain that the gem is missing but this allows it to do so.
16
- ActiveRecord::Base.class_eval do
17
- def self.has_friendly_id(column, options = {}, &block)
18
- end
19
- end unless ActiveRecord::Base.methods.include? 'has_friendly_id'
20
19
  end
21
20
 
22
21
  end
@@ -23,7 +23,7 @@ protected
23
23
  end
24
24
 
25
25
  def restrict_plugins
26
- Refinery::Plugins.set_active( current_user.plugins.collect {|p| p.title} | Refinery::Plugins.always_allowed.titles ) if current_user.respond_to? :plugins
26
+ Refinery::Plugins.set_active( current_user.authorized_plugins ) if current_user.respond_to? :plugins
27
27
  end
28
28
 
29
29
  def restrict_controller
@@ -81,4 +81,39 @@ module Refinery::ApplicationHelper
81
81
  image_tag "refinery/icons/#{filename}", {:width => 16, :height => 16}.merge!(options)
82
82
  end
83
83
 
84
+ def truncate(text, *args)
85
+ truncated = super
86
+ unless truncated === text
87
+ options = args.extract_options!
88
+ if options[:preserve_html_tags]
89
+ truncated = truncated[0, truncated.length - options[:omission].length]
90
+ # scan for all HTML tags then the last tag
91
+ unless (tag_matches = truncated.scan(/<[^<>]{1,}>?/)).empty? or
92
+ (last_tag = tag_matches.last.gsub(/<|\/|\>/, "").split(" ").first).nil? or
93
+ last_tag.downcase == "p" or (tag_matches.last.split("<").last.first == "/")
94
+
95
+ # scan until we find the exact tag we're looking for.
96
+ full_tag = text.scan(Regexp.new("(#{tag_matches.last})([^<]*)(<\/#{last_tag}>)"))[0..2].join("") # 0..2 because it'll be found as 3 tags together.
97
+ truncated.gsub!(tag_matches.last, full_tag)
98
+
99
+ end
100
+
101
+ truncated = truncated[0, truncated.length-1] if truncated.last == "<" # If a tag almost started, get rid of it.
102
+
103
+ # add back on the omission
104
+ truncated = "#{truncated}#{options[:omission]}"
105
+
106
+ # close the paragraph unless it closes already.
107
+ start_index = truncated.length-"</p>".length-options[:omission].length
108
+ length = (end_index = options[:omission].length + "</p>".length)
109
+ unless truncated[start_index, length].downcase == "</p>"
110
+ truncated = "#{truncated}</p>"
111
+ end
112
+
113
+ end
114
+ end
115
+
116
+ truncated
117
+ end
118
+
84
119
  end
@@ -4,50 +4,50 @@ module Refinery
4
4
  def initialize
5
5
  @plugins = []
6
6
  end
7
-
7
+
8
8
  def find_by_title(title)
9
9
  self.reject { |plugin| plugin.title != title }.first
10
10
  end
11
-
11
+
12
12
  def find_by_model(model)
13
13
  self.reject { |plugin| plugin.activity.reject {|activity| activity.class != model }.empty? }.first
14
14
  end
15
-
15
+
16
16
  def find_activity_by_model(model)
17
17
  plugin = find_by_model(model)
18
18
  plugin.activity.reject {|activity| activity.class != model}.first unless plugin.nil?
19
19
  end
20
-
20
+
21
21
  def [](title)
22
22
  self.find { |plugin| plugin.title == title }
23
23
  end
24
24
 
25
- def self.registered
26
- @registered_plugins ||= self.new
27
- end
28
-
29
- def titles
30
- self.collect { |p| p.title }
31
- end
32
-
33
- def in_menu
34
- self.reject{ |p| p.hide_from_menu }
35
- end
36
-
37
- def self.active
38
- @active_plugins ||= self.new
39
- end
40
-
41
- def self.always_allowed
42
- registered.reject { |p| !p.always_allow_access }
43
- end
44
-
45
- def self.set_active(titles)
46
- active.clear
47
- titles.each do |title|
48
- active << registered[title] if registered[title]
49
- end
50
- end
25
+ def self.registered
26
+ @registered_plugins ||= self.new
27
+ end
28
+
29
+ def titles
30
+ self.collect { |p| p.title }
31
+ end
32
+
33
+ def in_menu
34
+ self.reject{ |p| p.hide_from_menu }
35
+ end
36
+
37
+ def self.active
38
+ @active_plugins ||= self.new
39
+ end
40
+
41
+ def self.always_allowed
42
+ registered.reject { |p| !p.always_allow_access }
43
+ end
44
+
45
+ def self.set_active(titles)
46
+ active.clear
47
+ titles.each do |title|
48
+ active << registered[title] if registered[title]
49
+ end
50
+ end
51
51
 
52
52
  end
53
53
  end
@@ -19,7 +19,6 @@ namespace :refinery do
19
19
 
20
20
  NewsItem.all.each do |ni|
21
21
  ni.update_attribute(:body, ni.body.gsub(/\/images\/system\//, "/system/images/"))
22
- ni.update_attribute(:blurb, ni.body.gsub(/\/images\/system\//, "/system/images/"))
23
22
  end
24
23
 
25
24
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: refinerycms
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.4.3
4
+ version: 0.9.4.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Resolve Digital