forked from refinery/refinerycms
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Updated images and resources plugin to group files by date uploaded i…
…n list view if a refinery setting is set to true to allow them. Fixed the HTML Truncation on the news section by adding a third party library and integrating it into the Refinery core. Updated WYMeditor to fix an issue where highlighting a link would not recognise it as a link when using dialogues (only for mozilla browsers currently -- Safari already worked). Improved refinery-update-core task by allowing it to hook into the environment file to add any new gems used by Refinery. Added dependency to Hpricot gem for use with the HTML parser (hpricot version 0.8.1).
- Loading branch information
Showing
12 changed files
with
253 additions
and
65 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 12 additions & 21 deletions
33
vendor/plugins/images/app/views/admin/images/_list_view.html.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,12 @@ | ||
<ul> | ||
<% @images.each do |image| -%> | ||
<% if image.parent_id.nil? %> | ||
<li id="sortable_<%= image.id %>" class='clearfix record <%= cycle("on", "on-hover") %>'> | ||
<span class='title'> | ||
<span class='actions'> | ||
<%= link_to refinery_icon_tag('eye.png'), image.public_filename, | ||
:target => "_blank", :title => "#{image_fu image, :preview}" %> | ||
<%= link_to refinery_icon_tag('application_edit.png'), edit_admin_image_path(image), | ||
:title => 'Edit this image' %> | ||
<%= link_to refinery_icon_tag('delete.png'), admin_image_path(image), | ||
:confirm => "Are you sure you want to delete #{image.title}?", | ||
:class => "cancel", :method => :delete, | ||
:title => "Remove this image forever" %> | ||
</span> | ||
<%= image.title %> <span class="preview"> </span> | ||
</span> | ||
</li> | ||
<% end %> | ||
<% end -%> | ||
</ul> | ||
<% if RefinerySetting.find_or_set(:group_images_by_date_uploaded, false) %> | ||
<% @grouped_images.each do |container| %> | ||
<h3><%= (image_group = container.last).first.created_at.strftime("%A, %d %B %Y") %></h3> | ||
<ul> | ||
<%= render :partial => 'list_view_image', :collection => image_group %> | ||
</ul> | ||
<% end %> | ||
<% else %> | ||
<ul> | ||
<%= render :partial => 'list_view_image', :collection => @images %> | ||
</ul> | ||
<% end %> |
17 changes: 17 additions & 0 deletions
17
vendor/plugins/images/app/views/admin/images/_list_view_image.html.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<% if list_view_image.parent_id.nil? %> | ||
<li id="sortable_<%= list_view_image.id %>" class='clearfix record <%= cycle("on", "on-hover") %>'> | ||
<span class='title'> | ||
<span class='actions'> | ||
<%= link_to refinery_icon_tag('eye.png'), list_view_image.public_filename, | ||
:target => "_blank", :title => "#{image_fu list_view_image, :preview}" %> | ||
<%= link_to refinery_icon_tag('application_edit.png'), edit_admin_image_path(list_view_image), | ||
:title => 'Edit this image' %> | ||
<%= link_to refinery_icon_tag('delete.png'), admin_image_path(list_view_image), | ||
:confirm => "Are you sure you want to delete #{list_view_image.title}?", | ||
:class => "cancel", :method => :delete, | ||
:title => "Remove this image forever" %> | ||
</span> | ||
<%= list_view_image.title %> <span class="preview"> </span> | ||
</span> | ||
</li> | ||
<% end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
114 changes: 114 additions & 0 deletions
114
vendor/plugins/refinery/lib/refinery/html_truncation_helper.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
# By Henrik Nyh <http://henrik.nyh.se> 2008-01-30. | ||
# Free to modify and redistribute with credit. | ||
|
||
# modified by Dave Nolan <http://textgoeshere.org.uk> 2008-02-06 | ||
# Ellipsis appended to text of last HTML node | ||
# Ellipsis inserted after final word break | ||
|
||
# modified by Mark Dickson <mark@sitesteaders.com> 2008-12-18 | ||
# Option to truncate to last full word | ||
# Option to include a 'more' link | ||
# Check for nil last child | ||
|
||
# modified by Ken-ichi Ueda <http://kueda.net> 2009-09-02 | ||
# Rails 2.3 compatability (chars -> mb_chars), via Henrik | ||
# Hpricot 0.8 compatability (avoid dup on Hpricot::Elem) | ||
|
||
# modified by Philip Arndt <http://www.resolvedigital.co.nz> 2009-11-18 | ||
# renamed function to truncate and activated html truncation when :preserve_html_tags is supplied and true. | ||
# modified namespace to Refinery namespace and renamed module. | ||
|
||
require "rubygems" | ||
require "hpricot" | ||
|
||
module Refinery::HtmlTruncationHelper | ||
|
||
# Like the Rails _truncate_ helper but doesn't break HTML tags, entities, and optionally. words. | ||
def truncate(text, *args) | ||
return if text.nil? | ||
options = args.extract_options! | ||
unless (options[:preserve_html_tags] == true) | ||
return super | ||
else | ||
max_length = options[:length] || 30 | ||
omission = options[:omission] || "..." | ||
# use :link => link_to('more', post_path), or something to that effect | ||
|
||
doc = Hpricot(text.to_s) | ||
omission_length = Hpricot(omission).inner_text.mb_chars.length | ||
content_length = doc.inner_text.mb_chars.length | ||
actual_length = max_length - omission_length | ||
|
||
if content_length > max_length | ||
truncated_doc = doc.truncate(actual_length) | ||
|
||
if (options[:preserve_full_words] || false) | ||
word_length = actual_length - (truncated_doc.inner_html.mb_chars.length - truncated_doc.inner_html.rindex(' ')) | ||
truncated_doc = doc.truncate(word_length) | ||
end | ||
|
||
last_child = truncated_doc.children.last | ||
if last_child.inner_html.nil? | ||
truncated_doc.inner_html + omission + options[:link] if options[:link] | ||
else | ||
last_child.inner_html = last_child.inner_html.gsub(/\W.[^\s]+$/, "") + omission | ||
last_child.inner_html += options[:link] if options[:link] | ||
truncated_doc | ||
end | ||
else | ||
if options[:link] | ||
last_child = doc.children.last | ||
if last_child.inner_html.nil? | ||
doc.inner_html + options[:link] | ||
else | ||
last_child.inner_html = last_child.inner_html.gsub(/\W.[^\s]+$/, "") + options[:link] | ||
doc | ||
end | ||
else | ||
text.to_s | ||
end | ||
end | ||
end | ||
end | ||
|
||
|
||
end | ||
|
||
module HpricotTruncator | ||
module NodeWithChildren | ||
def truncate(max_length) | ||
return self if inner_text.mb_chars.length <= max_length | ||
truncated_node = if self.is_a?(Hpricot::Doc) | ||
self.dup | ||
else | ||
self.class.send(:new, self.name, self.attributes) | ||
end | ||
truncated_node.children = [] | ||
each_child do |node| | ||
remaining_length = max_length - truncated_node.inner_text.mb_chars.length | ||
break if remaining_length <= 0 | ||
truncated_node.children << node.truncate(remaining_length) | ||
end | ||
truncated_node | ||
end | ||
end | ||
|
||
module TextNode | ||
def truncate(max_length) | ||
# We're using String#scan because Hpricot doesn't distinguish entities. | ||
Hpricot::Text.new(content.scan(/&#?[^\W_]+;|./).first(max_length).join) | ||
end | ||
end | ||
|
||
module IgnoredTag | ||
def truncate(max_length) | ||
self | ||
end | ||
end | ||
end | ||
|
||
Hpricot::Doc.send(:include, HpricotTruncator::NodeWithChildren) | ||
Hpricot::Elem.send(:include, HpricotTruncator::NodeWithChildren) | ||
Hpricot::Text.send(:include, HpricotTruncator::TextNode) | ||
Hpricot::BogusETag.send(:include, HpricotTruncator::IgnoredTag) | ||
Hpricot::Comment.send(:include, HpricotTruncator::IgnoredTag) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters