Skip to content

Commit

Permalink
Merge branch 'master' of git@github.com:resolve/refinerycms
Browse files Browse the repository at this point in the history
  • Loading branch information
djones committed May 2, 2010
2 parents 54427e7 + fe1e91e commit 4604c1d
Show file tree
Hide file tree
Showing 9 changed files with 125 additions and 136 deletions.
20 changes: 0 additions & 20 deletions contributors.md

This file was deleted.

2 changes: 1 addition & 1 deletion readme.md
Expand Up @@ -92,7 +92,7 @@ If you're using [Heroku](http://heroku.com/) you will want to put

Refinery.s3_backend = true

in your ``config/production.rb`` file to make Refinery store files uploaded on Amazon S3.
in your ``config/environments/production.rb`` file to make Refinery store files uploaded on Amazon S3.

## Updating to the latest Refinery

Expand Down
2 changes: 1 addition & 1 deletion vendor/plugins/pages/app/controllers/pages_controller.rb
Expand Up @@ -18,4 +18,4 @@ def show
end
end

end
end
98 changes: 6 additions & 92 deletions vendor/plugins/pages/app/views/admin/pages/_form.html.erb
@@ -1,6 +1,5 @@
<%= error_messages_for :page %>
<% form_for [:admin, @page] do |f| %>
<%= f.error_messages %>
<div class="field">
<%= f.label :title %>
<%= f.text_field :title, :class => "larger", :style => 'width: 954px' %>
Expand Down Expand Up @@ -35,97 +34,12 @@
<% end %>
</div>
</div>
<p>
<a href="#" id="toggle_advanced_options" rel="Click to access meta tag settings and menu options">&raquo; Hide/Show Advanced Options</a>
</p>
<div id='more_options' style="display:none;">
<div class='field'>
<%= f.label :parent_id %>
<%= f.collection_select :parent_id, @pages_for_parents_list, :id, :indented_title, :include_blank => true %>
</div>
<div class='field'>
<%= label_tag :custom_title %>
<%= label_tag "", 'Type:', :class => "stripped" %>
<% ["none", "text"].each do |type| %>
<%= f.radio_button :custom_title_type, "#{type}" %>
<%= label_tag "page_custom_title_type_#{type}", "#{type.titleize}", :class => "stripped" %>
<% end %>
<br/>
<div id='custom_title_none'></div>
<div id='custom_title_text' style='display: <%= @page.custom_title_type == 'text' ? 'block' : 'none' %>'>
<p>
<%= f.text_field :custom_title, {:size => 103} %><br/>
<small>
If you want the page to have a different title than the one that shows in the menu and browser title then enter it here.<br/>
</small>
</p>
</div>
</div>
<div class='field'>
<%= label_tag :skip_to_first_child? %>
<%= f.check_box :skip_to_first_child %>
<%= f.label :skip_to_first_child, "Check this box if you want the visitor to be redirected to this page's first child page if this page is selected.", :class => "stripped" %>
</div>
<div class='field'>
<%= f.label :link_url, "Custom URL" %>
<%= f.text_field :link_url, {:size => 103} %><br/>
<small>
Enter a URL if this page links to an external site or to a pre-existing resource e.g. a contact page.
<br/>
Note: This URL must point to a location that exists; a new one will not be created.
</small>
</div>
<h2>Search Engine Optimization</h2>
<div class='field'>
<%= f.label :browser_title %>
<%= f.text_field :browser_title, :size => 63 %><br/>
<small>
If you want to override the default browser title, do it here.
</small>
</div>
<div class='field'>
<%= f.label :meta_keywords %>
<%= f.text_field :meta_keywords, :size => 63 %><br/>
<small>
Enter 5-10 keywords that relate to this page. Separate keywords by a comma.
</small>
</div>
<div class='field'>
<%= f.label :meta_description %>
<%= f.text_area :meta_description, :cols => 95, :rows => 3 %><br/>
<small>
Enter a concise two or three sentences describing what this page is about.
</small>
</div>
<div class='field'>
<%= f.label :show_in_menu %>
<%= f.check_box :show_in_menu %>
<small>
<%= f.label :show_in_menu, "Check this box if this page should appear in the site menu" %>
</small>
</div>
</div>
<div class='field'>
<label>Draft</label>
<%= f.check_box :draft %>
<%= f.label :draft, "Save as Draft", :class => "stripped" %>
</div>

<%= render :partial => "form_advanced_options", :locals => {:f => f} %>
<%= render :partial => "/shared/admin/form_actions", :locals => {:f => f, :continue_editing => true} %>
<% if RefinerySetting.find_or_set(:new_page_parts, false) %>
<div id='new_page_part_dialog' style='display: none'>
<div class='field'>
<label for='new_page_part_title'>Title</label>
<input id='new_page_part_title' value='' class='larger' size='40' />
<input id='new_page_part_index' type='hidden' value='<%= @page.parts.size %>' />
</div>
<%= render :partial => "/shared/admin/form_actions", :locals => {
:f => f,
:continue_editing => false,
:submit_button_id => "new_page_part_save",
:cancel_button_id => "new_page_part_cancel"
} %>
</div>
<% end %>
<%= render :partial => "form_new_page_parts", :locals => {:f => f} if RefinerySetting.find_or_set(:new_page_parts, false) %>
<% end %>
<% content_for :head do %>
Expand Down
@@ -0,0 +1,48 @@
<p>
<a href="#" id="toggle_advanced_options" rel="Click to access meta tag settings and menu options">&raquo; Hide/Show Advanced Options</a>
</p>
<div id='more_options' style="display:none;">
<div class='field'>
<%= f.label :parent_id %>
<%= f.collection_select :parent_id, @pages_for_parents_list, :id, :indented_title, :include_blank => true %>
</div>
<div class='field'>
<%= label_tag :custom_title %>
<%= label_tag "", 'Type:', :class => "stripped" %>
<% ["none", "text"].each do |type| %>
<%= f.radio_button :custom_title_type, "#{type}" %>
<%= label_tag "page_custom_title_type_#{type}", "#{type.titleize}", :class => "stripped" %>
<% end %>
<br/>
<div id='custom_title_none'></div>
<div id='custom_title_text' style='display: <%= @page.custom_title_type == 'text' ? 'block' : 'none' %>'>
<p>
<%= f.text_field :custom_title, {:size => 103} %><br/>
<small>
If you want the page to have a different title than the one that shows in the menu and browser title then enter it here.<br/>
</small>
</p>
</div>
</div>
<div class='field'>
<%= label_tag :skip_to_first_child? %>
<%= f.check_box :skip_to_first_child %>
<%= f.label :skip_to_first_child, "Check this box if you want the visitor to be redirected to this page's first child page if this page is selected.", :class => "stripped" %>
</div>
<div class='field'>
<%= f.label :link_url, "Custom URL" %>
<%= f.text_field :link_url, {:size => 103} %><br/>
<small>
Enter a URL if this page links to an external site or to a pre-existing resource e.g. a contact page.
<br/>
Note: This URL must point to a location that exists; a new one will not be created.
</small>
</div>

<%= render :partial => "form_advanced_options_seo", :locals => {:f => f} if RefinerySetting.find_or_set(:pages_advanced_options_include_seo, true) %>
</div>
<div class='field'>
<label>Draft</label>
<%= f.check_box :draft %>
<%= f.label :draft, "Save as Draft", :class => "stripped" %>
</div>
@@ -0,0 +1,29 @@
<h2>Search Engine Optimization</h2>
<div class='field'>
<%= f.label :browser_title %>
<%= f.text_field :browser_title, :size => 63 %><br/>
<small>
If you want to override the default browser title, do it here.
</small>
</div>
<div class='field'>
<%= f.label :meta_keywords %>
<%= f.text_field :meta_keywords, :size => 63 %><br/>
<small>
Enter 5-10 keywords that relate to this page. Separate keywords by a comma.
</small>
</div>
<div class='field'>
<%= f.label :meta_description %>
<%= f.text_area :meta_description, :cols => 95, :rows => 3 %><br/>
<small>
Enter a concise two or three sentences describing what this page is about.
</small>
</div>
<div class='field'>
<%= f.label :show_in_menu %>
<%= f.check_box :show_in_menu %>
<small>
<%= f.label :show_in_menu, "Check this box if this page should appear in the site menu" %>
</small>
</div>
@@ -0,0 +1,13 @@
<div id='new_page_part_dialog' style='display: none'>
<div class='field'>
<label for='new_page_part_title'>Title</label>
<input id='new_page_part_title' value='' class='larger' size='40' />
<input id='new_page_part_index' type='hidden' value='<%= @page.parts.size %>' />
</div>
<%= render :partial => "/shared/admin/form_actions", :locals => {
:f => f,
:continue_editing => false,
:submit_button_id => "new_page_part_save",
:cancel_button_id => "new_page_part_cancel"
} %>
</div>
13 changes: 8 additions & 5 deletions vendor/plugins/refinery/lib/refinery/application_helper.rb
@@ -1,7 +1,7 @@
# Methods added to this helper will be available to all templates in the application.
module Refinery::ApplicationHelper

include Refinery::HtmlTruncationHelper
include Refinery::HtmlTruncationHelper rescue puts "#{__FILE__}:#{__LINE__} Could not load hpricot"

def browser_title(yield_title=nil)
[
Expand Down Expand Up @@ -76,7 +76,7 @@ def page_title(options = {})
when "text"
obj.custom_title
when "image"
image_fu obj.custom_title_image, nil, {:alt => obj.title} rescue obj.title
image_fu(obj.custom_title_image, nil, {:alt => obj.title}) rescue obj.title
else
obj.title
end
Expand All @@ -86,11 +86,12 @@ def page_title(options = {})
end

final_title = title.pop
if (options[:page_title][:wrap_if_not_chained] and title.empty?) and !options[:page_title][:tag].blank?
if (options[:page_title][:wrap_if_not_chained] and title.empty?) and options[:page_title][:tag].present?
css = options[:page_title][:class].present? ? " class='#{options[:page_title][:class]}'" : nil
final_title = "<#{options[:page_title][:tag]}#{css}>#{final_title}</#{options[:page_title][:tag]}>"
end
if (title.empty?)

if title.empty?
return final_title
else
return "<#{options[:ancestors][:tag]} class='#{options[:ancestors][:class]}'>#{title.join options[:ancestors][:separator]}#{options[:ancestors][:separator]}</#{options[:ancestors][:tag]}>#{final_title}"
Expand All @@ -102,7 +103,9 @@ def refinery_icon_tag(filename, options = {})
end

def selected_page?(page)
selected = current_page?(page) or (request.path =~ Regexp.new(page.menu_match) unless page.menu_match.blank?) or (request.path == page.link_url)
current_page?(page) or
(request.path =~ Regexp.new(page.menu_match) if page.menu_match.present?) or
(request.path == page.link_url)
end

def setup
Expand Down
36 changes: 19 additions & 17 deletions vendor/plugins/refinery/lib/refinery/html_truncation_helper.rb
@@ -1,32 +1,34 @@
# By Henrik Nyh <http://henrik.nyh.se> 2008-01-30.
# Free to modify and redistribute with credit.
=begin
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 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 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 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.
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.
removed rubygems requirement
=end

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 super unless ((arguments = args.dup).extract_options![:preserve_html_tags] == true) # don't ruin the current args object
return if text.nil?
return unless text.present?

options = args.extract_options!
max_length = options[:length] || 30
Expand Down

0 comments on commit 4604c1d

Please sign in to comment.