refinerycms 0.9.5.9 → 0.9.5.10
Sign up to get free protection for your applications and to get access to all the features.
- data/bin/refinery-update-core +28 -0
- data/config/environment.rb +7 -2
- data/public/javascripts/wymeditor/jquery.refinery.wymeditor.js +14 -0
- data/vendor/plugins/images/app/controllers/admin/images_controller.rb +22 -0
- data/vendor/plugins/images/app/views/admin/images/_list_view.html.erb +12 -21
- data/vendor/plugins/images/app/views/admin/images/_list_view_image.html.erb +17 -0
- data/vendor/plugins/refinery/lib/refinery/application_helper.rb +1 -35
- data/vendor/plugins/refinery/lib/refinery/html_truncation_helper.rb +114 -0
- data/vendor/plugins/resources/app/controllers/admin/resources_controller.rb +20 -0
- data/vendor/plugins/resources/app/views/admin/resources/index.html.erb +12 -3
- metadata +4 -2
data/bin/refinery-update-core
CHANGED
@@ -20,10 +20,38 @@ unless RAILS_ROOT.nil? or RAILS_ROOT.length == 0
|
|
20
20
|
# copy any rake tasks from plugins to the main lib directory so they can be run.
|
21
21
|
FileUtils::cp Dir[File.join(REFINERY_ROOT, %w(** tasks *.rake))], File.join(RAILS_ROOT, %w(lib tasks))
|
22
22
|
|
23
|
+
# read in the config files
|
24
|
+
app_config = File.open(File.join(RAILS_ROOT, %w(config environment.rb)), "r").read
|
25
|
+
environment_updated = false
|
26
|
+
|
27
|
+
# backup app's environment.rb
|
28
|
+
unless (app_refinery_gems_section = app_config.scan(/(#===REFINERY REQUIRED GEMS===)([^#]*)(#===REFINERY END OF REQUIRED GEMS===)/).join("")).length == 0
|
29
|
+
# read in the config file in the gem
|
30
|
+
refinery_config = File.open(File.join(REFINERY_ROOT, %w(config environment.rb)), "r").read
|
31
|
+
FileUtils.cp File.join(RAILS_ROOT, %w(config environment.rb)), File.join(RAILS_ROOT, %w(config environment.autobackupbyrefinery.rb))
|
32
|
+
|
33
|
+
# write the new content into the file.
|
34
|
+
File.open(File.join(RAILS_ROOT, %w(config environment.rb)), "w").puts(app_config.gsub!(
|
35
|
+
app_refinery_gems_section,
|
36
|
+
refinery_config.scan(/(#===REFINERY REQUIRED GEMS===)([^#]*)(#===REFINERY END OF REQUIRED GEMS===)/).join("")
|
37
|
+
))
|
38
|
+
|
39
|
+
environment_updated = true
|
40
|
+
end
|
41
|
+
|
23
42
|
unless ARGV.include?("--from-refinery-installer")
|
24
43
|
puts "---------"
|
25
44
|
puts "Copied new Refinery core assets."
|
45
|
+
if environment_updated
|
46
|
+
puts "I've made a backup of your current config/environment.rb file as it has been updated with the latest Refinery RubyGem requirements."
|
47
|
+
puts "The backup is located at config/environment.autobackupbyrefinery.rb incase you need it."
|
48
|
+
end
|
49
|
+
puts ""
|
50
|
+
puts "=== ACTION REQUIRED ==="
|
26
51
|
puts "Please run rake db:migrate to ensure your database is at the correct version."
|
52
|
+
puts "Please also run rake gems:install to ensure you have the currently specified gems." if environment_updated
|
53
|
+
|
54
|
+
puts ""
|
27
55
|
end
|
28
56
|
else
|
29
57
|
unless ARGV.include?("--from-refinery-installer")
|
data/config/environment.rb
CHANGED
@@ -7,7 +7,7 @@
|
|
7
7
|
# Specifies gem version of Rails to use when vendor/rails is not present
|
8
8
|
RAILS_GEM_VERSION = '2.3.4' unless defined? RAILS_GEM_VERSION
|
9
9
|
# Freeze to a specific version of refinerycms when running as a gem
|
10
|
-
# REFINERY_GEM_VERSION = 0.9.5.
|
10
|
+
# REFINERY_GEM_VERSION = 0.9.5.10 unless defined? REFINERY_GEM_VERSION
|
11
11
|
|
12
12
|
# Bootstrap the Rails environment, frameworks, and default configuration
|
13
13
|
require File.join(File.dirname(__FILE__), 'boot')
|
@@ -59,7 +59,10 @@ eval("#{(defined? Refinery::Initializer) ? Refinery : Rails}::Initializer").run
|
|
59
59
|
# Make Active Record use UTC-base instead of local time
|
60
60
|
# config.active_record.default_timezone = :utc
|
61
61
|
#
|
62
|
-
|
62
|
+
|
63
|
+
# Please add your gems above the Refinery required gems here:
|
64
|
+
|
65
|
+
#===REFINERY REQUIRED GEMS===
|
63
66
|
config.gem "rake", :version => ">= 0.8.3", :lib => "rake"
|
64
67
|
config.gem "friendly_id", :version => ">= 2.2.2", :lib => "friendly_id"
|
65
68
|
config.gem "will_paginate", :version => ">= 2.3.11", :lib => "will_paginate", :source => "http://gemcutter.org"
|
@@ -67,4 +70,6 @@ eval("#{(defined? Refinery::Initializer) ? Refinery : Rails}::Initializer").run
|
|
67
70
|
config.gem "aasm", :version => ">= 2.1.3", :lib => "aasm", :source => "http://gemcutter.org"
|
68
71
|
config.gem "unicode", :version => ">= 0.1", :lib => "unicode"
|
69
72
|
config.gem "slim_scrooge", :source => "http://gemcutter.org"
|
73
|
+
config.gem "hpricot", :version => "0.8.1", :lib => "hpricot", :source => "http://gemcutter.org"
|
74
|
+
#===REFINERY END OF REQUIRED GEMS===
|
70
75
|
end
|
@@ -1222,6 +1222,20 @@ WYMeditor.editor.prototype.dialog = function( dialogType ) {
|
|
1222
1222
|
}
|
1223
1223
|
|
1224
1224
|
selected = this.selected();
|
1225
|
+
if (dialogType == WYMeditor.DIALOG_LINK && jQuery.browser.mozilla) {
|
1226
|
+
selection = this._iframe.contentWindow.getSelection();
|
1227
|
+
matches = selected.innerHTML.match(new RegExp(selection.anchorNode.textContent + "(.*)" + selection.focusNode.textContent));
|
1228
|
+
if (matches != null && matches.length > 0 && (possible_anchor_tag = matches.last()) != null) {
|
1229
|
+
if ((href = possible_anchor_tag.match(/href="([^"]*)"/).last()) != null) {
|
1230
|
+
possible_anchors = this._iframe.document().getElementsByTagName('a');
|
1231
|
+
for (i=0;i<possible_anchors.length;i++) {
|
1232
|
+
if ((possible_match = possible_anchors[i]).innerHTML == selection) {
|
1233
|
+
selected = possible_match;
|
1234
|
+
}
|
1235
|
+
}
|
1236
|
+
}
|
1237
|
+
}
|
1238
|
+
}
|
1225
1239
|
|
1226
1240
|
// set up handlers.
|
1227
1241
|
imageGroup = null;
|
@@ -5,6 +5,28 @@ class Admin::ImagesController < Admin::BaseController
|
|
5
5
|
crudify :image, :order => "created_at DESC", :conditions => "parent_id is NULL", :sortable => false
|
6
6
|
before_filter :change_list_mode_if_specified
|
7
7
|
|
8
|
+
def index
|
9
|
+
if searching?
|
10
|
+
@images = Image.paginate_search params[:search],
|
11
|
+
:page => params[:page],
|
12
|
+
:order => "created_at DESC",
|
13
|
+
:conditions => "parent_id IS NULL"
|
14
|
+
else
|
15
|
+
@images = Image.paginate :page => params[:page],
|
16
|
+
:order => "created_at DESC",
|
17
|
+
:conditions => "parent_id IS NULL"
|
18
|
+
end
|
19
|
+
|
20
|
+
if RefinerySetting.find_or_set(:group_images_by_date_uploaded, false)
|
21
|
+
@grouped_images = []
|
22
|
+
@images.each do |image|
|
23
|
+
key = image.created_at.strftime("%Y-%m-%d")
|
24
|
+
image_group = @grouped_images.collect{|images| images.last if images.first == key }.flatten.compact << image
|
25
|
+
(@grouped_images.delete_if {|i| i.first == key}) << [key, image_group]
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
8
30
|
def new
|
9
31
|
@image = Image.new
|
10
32
|
@url_override = admin_images_url(:dialog => from_dialog?)
|
@@ -1,21 +1,12 @@
|
|
1
|
-
|
2
|
-
<% @
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
:class => "cancel", :method => :delete,
|
14
|
-
:title => "Remove this image forever" %>
|
15
|
-
</span>
|
16
|
-
<%= image.title %> <span class="preview"> </span>
|
17
|
-
</span>
|
18
|
-
</li>
|
19
|
-
<% end %>
|
20
|
-
<% end -%>
|
21
|
-
</ul>
|
1
|
+
<% if RefinerySetting.find_or_set(:group_images_by_date_uploaded, false) %>
|
2
|
+
<% @grouped_images.each do |container| %>
|
3
|
+
<h3><%= (image_group = container.last).first.created_at.strftime("%A, %d %B %Y") %></h3>
|
4
|
+
<ul>
|
5
|
+
<%= render :partial => 'list_view_image', :collection => image_group %>
|
6
|
+
</ul>
|
7
|
+
<% end %>
|
8
|
+
<% else %>
|
9
|
+
<ul>
|
10
|
+
<%= render :partial => 'list_view_image', :collection => @images %>
|
11
|
+
</ul>
|
12
|
+
<% end %>
|
@@ -0,0 +1,17 @@
|
|
1
|
+
<% if list_view_image.parent_id.nil? %>
|
2
|
+
<li id="sortable_<%= list_view_image.id %>" class='clearfix record <%= cycle("on", "on-hover") %>'>
|
3
|
+
<span class='title'>
|
4
|
+
<span class='actions'>
|
5
|
+
<%= link_to refinery_icon_tag('eye.png'), list_view_image.public_filename,
|
6
|
+
:target => "_blank", :title => "#{image_fu list_view_image, :preview}" %>
|
7
|
+
<%= link_to refinery_icon_tag('application_edit.png'), edit_admin_image_path(list_view_image),
|
8
|
+
:title => 'Edit this image' %>
|
9
|
+
<%= link_to refinery_icon_tag('delete.png'), admin_image_path(list_view_image),
|
10
|
+
:confirm => "Are you sure you want to delete #{list_view_image.title}?",
|
11
|
+
:class => "cancel", :method => :delete,
|
12
|
+
:title => "Remove this image forever" %>
|
13
|
+
</span>
|
14
|
+
<%= list_view_image.title %> <span class="preview"> </span>
|
15
|
+
</span>
|
16
|
+
</li>
|
17
|
+
<% end %>
|
@@ -1,5 +1,6 @@
|
|
1
1
|
# Methods added to this helper will be available to all templates in the application.
|
2
2
|
module Refinery::ApplicationHelper
|
3
|
+
include Refinery::HtmlTruncationHelper
|
3
4
|
|
4
5
|
def add_meta_tags
|
5
6
|
content_for :head, "<meta name=\"keywords\" content=\"#{@page.meta_keywords}\" />" unless @page.meta_keywords.blank?
|
@@ -80,41 +81,6 @@ module Refinery::ApplicationHelper
|
|
80
81
|
def refinery_icon_tag(filename, options = {})
|
81
82
|
image_tag "refinery/icons/#{filename}", {:width => 16, :height => 16}.merge!(options)
|
82
83
|
end
|
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
85
|
# replace all system images with a thumbnail version of them (handy for all images inside a page part)
|
120
86
|
def content_fu(content, thumbnail)
|
@@ -0,0 +1,114 @@
|
|
1
|
+
# By Henrik Nyh <http://henrik.nyh.se> 2008-01-30.
|
2
|
+
# Free to modify and redistribute with credit.
|
3
|
+
|
4
|
+
# modified by Dave Nolan <http://textgoeshere.org.uk> 2008-02-06
|
5
|
+
# Ellipsis appended to text of last HTML node
|
6
|
+
# Ellipsis inserted after final word break
|
7
|
+
|
8
|
+
# modified by Mark Dickson <mark@sitesteaders.com> 2008-12-18
|
9
|
+
# Option to truncate to last full word
|
10
|
+
# Option to include a 'more' link
|
11
|
+
# Check for nil last child
|
12
|
+
|
13
|
+
# modified by Ken-ichi Ueda <http://kueda.net> 2009-09-02
|
14
|
+
# Rails 2.3 compatability (chars -> mb_chars), via Henrik
|
15
|
+
# Hpricot 0.8 compatability (avoid dup on Hpricot::Elem)
|
16
|
+
|
17
|
+
# modified by Philip Arndt <http://www.resolvedigital.co.nz> 2009-11-18
|
18
|
+
# renamed function to truncate and activated html truncation when :preserve_html_tags is supplied and true.
|
19
|
+
# modified namespace to Refinery namespace and renamed module.
|
20
|
+
|
21
|
+
require "rubygems"
|
22
|
+
require "hpricot"
|
23
|
+
|
24
|
+
module Refinery::HtmlTruncationHelper
|
25
|
+
|
26
|
+
# Like the Rails _truncate_ helper but doesn't break HTML tags, entities, and optionally. words.
|
27
|
+
def truncate(text, *args)
|
28
|
+
return if text.nil?
|
29
|
+
options = args.extract_options!
|
30
|
+
unless (options[:preserve_html_tags] == true)
|
31
|
+
return super
|
32
|
+
else
|
33
|
+
max_length = options[:length] || 30
|
34
|
+
omission = options[:omission] || "..."
|
35
|
+
# use :link => link_to('more', post_path), or something to that effect
|
36
|
+
|
37
|
+
doc = Hpricot(text.to_s)
|
38
|
+
omission_length = Hpricot(omission).inner_text.mb_chars.length
|
39
|
+
content_length = doc.inner_text.mb_chars.length
|
40
|
+
actual_length = max_length - omission_length
|
41
|
+
|
42
|
+
if content_length > max_length
|
43
|
+
truncated_doc = doc.truncate(actual_length)
|
44
|
+
|
45
|
+
if (options[:preserve_full_words] || false)
|
46
|
+
word_length = actual_length - (truncated_doc.inner_html.mb_chars.length - truncated_doc.inner_html.rindex(' '))
|
47
|
+
truncated_doc = doc.truncate(word_length)
|
48
|
+
end
|
49
|
+
|
50
|
+
last_child = truncated_doc.children.last
|
51
|
+
if last_child.inner_html.nil?
|
52
|
+
truncated_doc.inner_html + omission + options[:link] if options[:link]
|
53
|
+
else
|
54
|
+
last_child.inner_html = last_child.inner_html.gsub(/\W.[^\s]+$/, "") + omission
|
55
|
+
last_child.inner_html += options[:link] if options[:link]
|
56
|
+
truncated_doc
|
57
|
+
end
|
58
|
+
else
|
59
|
+
if options[:link]
|
60
|
+
last_child = doc.children.last
|
61
|
+
if last_child.inner_html.nil?
|
62
|
+
doc.inner_html + options[:link]
|
63
|
+
else
|
64
|
+
last_child.inner_html = last_child.inner_html.gsub(/\W.[^\s]+$/, "") + options[:link]
|
65
|
+
doc
|
66
|
+
end
|
67
|
+
else
|
68
|
+
text.to_s
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
|
75
|
+
end
|
76
|
+
|
77
|
+
module HpricotTruncator
|
78
|
+
module NodeWithChildren
|
79
|
+
def truncate(max_length)
|
80
|
+
return self if inner_text.mb_chars.length <= max_length
|
81
|
+
truncated_node = if self.is_a?(Hpricot::Doc)
|
82
|
+
self.dup
|
83
|
+
else
|
84
|
+
self.class.send(:new, self.name, self.attributes)
|
85
|
+
end
|
86
|
+
truncated_node.children = []
|
87
|
+
each_child do |node|
|
88
|
+
remaining_length = max_length - truncated_node.inner_text.mb_chars.length
|
89
|
+
break if remaining_length <= 0
|
90
|
+
truncated_node.children << node.truncate(remaining_length)
|
91
|
+
end
|
92
|
+
truncated_node
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
module TextNode
|
97
|
+
def truncate(max_length)
|
98
|
+
# We're using String#scan because Hpricot doesn't distinguish entities.
|
99
|
+
Hpricot::Text.new(content.scan(/&#?[^\W_]+;|./).first(max_length).join)
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
module IgnoredTag
|
104
|
+
def truncate(max_length)
|
105
|
+
self
|
106
|
+
end
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
Hpricot::Doc.send(:include, HpricotTruncator::NodeWithChildren)
|
111
|
+
Hpricot::Elem.send(:include, HpricotTruncator::NodeWithChildren)
|
112
|
+
Hpricot::Text.send(:include, HpricotTruncator::TextNode)
|
113
|
+
Hpricot::BogusETag.send(:include, HpricotTruncator::IgnoredTag)
|
114
|
+
Hpricot::Comment.send(:include, HpricotTruncator::IgnoredTag)
|
@@ -29,6 +29,26 @@ class Admin::ResourcesController < Admin::BaseController
|
|
29
29
|
end
|
30
30
|
end
|
31
31
|
|
32
|
+
def index
|
33
|
+
if searching?
|
34
|
+
@resources = Resource.paginate_search params[:search],
|
35
|
+
:page => params[:page],
|
36
|
+
:order => "created_at DESC"
|
37
|
+
else
|
38
|
+
@resources = Resource.paginate :page => params[:page],
|
39
|
+
:order => "created_at DESC"
|
40
|
+
end
|
41
|
+
|
42
|
+
if RefinerySetting.find_or_set(:group_resources_by_date_uploaded, false)
|
43
|
+
@grouped_resources = []
|
44
|
+
@resources.each do |resource|
|
45
|
+
key = resource.created_at.strftime("%Y-%m-%d")
|
46
|
+
resource_group = @grouped_resources.collect{|resources| resources.last if resources.first == key }.flatten.compact << resource
|
47
|
+
(@grouped_resources.delete_if {|i| i.first == key}) << [key, resource_group]
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
32
52
|
def insert
|
33
53
|
self.new if @resource.nil?
|
34
54
|
@dialog = from_dialog?
|
@@ -19,9 +19,18 @@
|
|
19
19
|
<% else %>
|
20
20
|
<% if @resources.size > 0 -%>
|
21
21
|
<%= will_paginate @resources, :previous_label => '«', :next_label => '»' %>
|
22
|
-
|
23
|
-
|
24
|
-
|
22
|
+
<% if RefinerySetting.find_or_set(:group_resources_by_date_uploaded, false) %>
|
23
|
+
<% @grouped_resources.each do |container| %>
|
24
|
+
<h3><%= (resource_group = container.last).first.created_at.strftime("%A, %d %B %Y") %></h3>
|
25
|
+
<ul>
|
26
|
+
<%= render :partial => "resource", :collection => resource_group %>
|
27
|
+
</ul>
|
28
|
+
<% end %>
|
29
|
+
<% else %>
|
30
|
+
<ul>
|
31
|
+
<%= render :partial => "resource", :collection => @resources %>
|
32
|
+
</ul>
|
33
|
+
<% end %>
|
25
34
|
<%= will_paginate @resources, :previous_label => '«', :next_label => '»' %>
|
26
35
|
<% else -%>
|
27
36
|
<p>
|
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.5.
|
4
|
+
version: 0.9.5.10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Resolve Digital
|
@@ -11,7 +11,7 @@ autorequire:
|
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
13
|
|
14
|
-
date: 2009-11-
|
14
|
+
date: 2009-11-18 00:00:00 +13:00
|
15
15
|
default_executable: refinery
|
16
16
|
dependencies: []
|
17
17
|
|
@@ -346,6 +346,7 @@ files:
|
|
346
346
|
- vendor/plugins/images/app/views/admin/images/_form.html.erb
|
347
347
|
- vendor/plugins/images/app/views/admin/images/_grid_view.html.erb
|
348
348
|
- vendor/plugins/images/app/views/admin/images/_list_view.html.erb
|
349
|
+
- vendor/plugins/images/app/views/admin/images/_list_view_image.html.erb
|
349
350
|
- vendor/plugins/images/app/views/admin/images/edit.html.erb
|
350
351
|
- vendor/plugins/images/app/views/admin/images/index.html.erb
|
351
352
|
- vendor/plugins/images/app/views/admin/images/insert.html.erb
|
@@ -455,6 +456,7 @@ files:
|
|
455
456
|
- vendor/plugins/refinery/lib/refinery/activity.rb
|
456
457
|
- vendor/plugins/refinery/lib/refinery/application_controller.rb
|
457
458
|
- vendor/plugins/refinery/lib/refinery/form_helpers.rb
|
459
|
+
- vendor/plugins/refinery/lib/refinery/html_truncation_helper.rb
|
458
460
|
- vendor/plugins/refinery/lib/refinery/initializer.rb
|
459
461
|
- vendor/plugins/refinery/lib/refinery/link_renderer.rb
|
460
462
|
- vendor/plugins/refinery/lib/refinery/plugin.rb
|