Permalink
Browse files

Updated to version 0.9.6, this release fixes most of the issue we wer…

…e having with the latest version of Refinery v0.9.7
  • Loading branch information...
1 parent d770276 commit e5cbb1464173a2e5ba08842d5ca6fde8520acc84 @parndt parndt committed Jun 30, 2010
@@ -15,7 +15,7 @@ def emancipate
# This finds all of the entries that could possibly be assigned as the current entry's parent.
def find_portfolio_entries_for_parents_list
- if RefinerySetting.find_or_set(:multi_level_portfolio, true)
+ if ::Refinery::Portfolio.multi_level?
@portfolio_entries_for_parents_list = PortfolioEntry.find(:all, :order => "parent_id, position ASC")
# We need to remove all references to the current entry or any of its decendants or we get a nightmare.
@@ -14,7 +14,7 @@ def show
@master_entry = PortfolioEntry.find_by_parent_id(nil, :order => "position ASC")
end
- if RefinerySetting.find_or_set(:multi_level_portfolio, true)
+ if ::Refinery::Portfolio.multi_level?
if params[:portfolio_id]
@portfolio_entry = @master_entry.children.find(params[:portfolio_id])
else
@@ -1,17 +1,17 @@
module PortfolioHelper
def portfolio_image_link(master, portfolio, image_index)
- if RefinerySetting.find_or_set(:multi_level_portfolio, true)
+ if ::Refinery::Portfolio.multi_level?
portfolio_image_url(master, portfolio, image_index)
else
portfolio_image_url(master, image_index)
end
end
def link_to_portfolio_image(master, portfolio, image, index)
- link_to image_fu(image, :portfolio_thumb),
- portfolio_image_link(master, portfolio, index),
- :class => ( (index == params[:image_id].to_i) ? "selected" : "pale" )
+ link_to(image_fu(image, :portfolio_thumb),
+ portfolio_image_link(master, portfolio, index),
+ :class => ((index == params[:image_id].to_i) ? "selected" : "pale"))
end
end
@@ -1,19 +1,28 @@
+<% content_for :head do %>
+ <%= stylesheet_link_tag 'portfolio' %>
+ <%= javascript_include_tag 'portfolio' %>
+<% end %>
+
<%= error_messages_for :portfolio_entry %>
<% form_for [:admin, @portfolio_entry] do |f| %>
<div class='field'>
- <%= f.label :title %>
- <%= f.text_field :title, :class => "larger", :style => 'width: 954px' %>
+ <%= f.required_label :title %>
+ <%= f.text_field :title, :class => "larger widest" %>
</div>
<div class='field images_field'>
<span class='clearfix label_inline_with_link'>
<%= label_tag('portfolio_entry_image_ids', 'Images') %>
- <%= link_to "#{refinery_icon_tag "add.png"} Add", "#{insert_admin_images_url(:dialog => true, :width => 950, :height => 510, :callback => "image_added")}", :name => "Add Another Image", :id => "add_image_link" %>
+ <%= link_to "#{refinery_icon_tag "add.png"} Add",
+ insert_admin_images_url(:dialog => true, :width => 950, :height => 510, :callback => "image_added"),
+ :name => "Add Another Image",
+ :id => "add_image_link" %>
</span>
<ul id='portfolio_images' class='clearfix portfolio_entry_images'>
<% @portfolio_entry.images.each do |image| %>
<li id='image_<%= image.id %>'>
<%= image_fu image, :grid %>
- <%= hidden_field_tag 'portfolio_entry[image_ids][]', image.id, :id => "portfolio_entry_image_id_#{image.id}" %>
+ <%= hidden_field_tag 'portfolio_entry[image_ids][]', image.id,
+ :id => "portfolio_entry_image_id_#{image.id}" %>
</li>
<% end %>
<li class='empty'>
@@ -22,23 +31,21 @@
</li>
</ul>
</div>
- <div class='field clearfix' style='width: 963px'>
+ <div class='field clearfix'>
<%= f.label :body, 'Content' %>
- <%= f.text_area :body, :class => "wymeditor", :rows => 7 %>
+ <%= f.text_area :body, :class => "wymeditor widest", :rows => 7 %>
</div>
<% if @portfolio_entries_for_parents_list.any? %>
<div class='field'>
<%= f.label :parent_id %>
<%= f.collection_select :parent_id, @portfolio_entries_for_parents_list, :id, :indented_title, :include_blank => true %>
</div>
<% end %>
- <div class='form-actions'>
- <%= f.submit 'Save', :class => "wymupdate" %>
- or
- <%= link_to "Cancel", admin_portfolio_entries_url, :title => "Cancelling will lose all changes you've made to this entry" %>
- </div>
-<% end %>
-<% content_for :head do %>
- <%= stylesheet_link_tag 'portfolio' %>
- <%= javascript_include_tag 'portfolio' %>
+
+ <%= render :partial => "/shared/admin/form_actions",
+ :locals => {
+ :f => f,
+ :continue_editing => true
+ } -%>
+
<% end %>
@@ -8,13 +8,13 @@
<li class='clearfix record<%= " #{branch}" %>' id="<%= dom_id(list) -%>">
<div class='clearfix'>
<span class='actions'>
- <% url = list.parent ? portfolio_project_url(list.parent, list) : portfolio_url(list) %>
+ <% url = (::Refinery::Portfolio.multi_level? && list.parent ? portfolio_project_url(list.parent, list) : portfolio_url(list)) %>
<%= link_to refinery_icon_tag('application_go.png'), url, :target => "_blank",
:title => "View this entry live <br/><em>(opens in a new window)</em>" %>
<%= link_to refinery_icon_tag('application_edit.png'), edit_admin_portfolio_entry_path(list),
:title => "Edit this entry" %>
<%= link_to refinery_icon_tag('arrow_up.png'),
- {:controller => "/admin/portfolio_entries", :action => "emancipate", :id => list.id},
+ emancipate_admin_portfolio_entry_url(list),
:title => "Move this entry up one level" if list.parent.present? %>
<%= link_to refinery_icon_tag('delete.png'), admin_portfolio_entry_path(list),
:class => "cancel confirm-delete",
@@ -28,4 +28,4 @@
<% end %>
</div>
<%= render :partial => "/shared/admin/make_sortable",
- :locals => { :tree => RefinerySetting.find_or_set(:multi_level_portfolio, true) } if PortfolioEntry.count > 1 %>
+ :locals => { :tree => ::Refinery::Portfolio.multi_level? } if PortfolioEntry.count > 1 %>
@@ -1,13 +1,20 @@
+<% ::ActionController::Routing::Routes.reload! %>
<% content_for :title, "#{@portfolio_entry.title} - " %>
<% content_for :head, stylesheet_link_tag('portfolio') %>
<div id='body_content' class='clearfix portfolio'>
<div id='body_content_left' class='clearfix'>
<h1 class='clearfix'>
<span><%= @master_entry.title %></span>
- <%= select :portfolio_entry, :to_param, @master_entry.children.collect{|entry| [entry.title, entry.to_param] } if RefinerySetting.find_or_set(:multi_level_portfolio, true) %>
+ <% if ::Refinery::Portfolio.multi_level? %>
+ <%= select :portfolio_entry, :to_param, @master_entry.children.collect{|entry| [entry.title, entry.to_param] } %>
+ <% else %>
+ <%= select :portfolio_entry, :to_param, PortfolioEntry.all.collect{|entry| [entry.title, entry.to_param] } %>
+ <% end %>
</h1>
- <%= render :partial => "main_image" %>
+ <div id='portfolio_main_image_container'>
+ <%= render :partial => "main_image" %>
+ </div>
</div>
<div id='body_content_right' class='clearfix'>
<h2><%= @portfolio_entry.title %></h2>
@@ -26,6 +33,6 @@
<%= jquery_include_tags(:include_ui => false) %>
<%= javascript_include_tag 'portfolio' %>
<script type='text/javascript'>
- var portfolio_entry_url = "<%= RefinerySetting.find_or_set(:multi_level_portfolio, true) ? portfolio_project_url(@master_entry, nil) : portfolio_project_url(@master_entry) %>";
+ var portfolio_entry_url = "<%= portfolio_project_url(@master_entry, '') if ::Refinery::Portfolio.multi_level? %>";
</script>
<% end %>
@@ -1,39 +0,0 @@
-#!/usr/bin/env ruby
-require 'pathname'
-require 'fileutils'
-
-portfolio_root = Pathname.new(File.expand_path(File.dirname(__FILE__) << "/.."))
-rails_root = if defined?(Rails.root)
- Rails.root
-elsif defined?(RAILS_ROOT)
- Pathname.new(RAILS_ROOT)
-else
- Pathname.new(ARGV.first)
-end
-if rails_root.exist?
- [%w(db migrate), %w(public stylesheets), %w(public javascripts)].each do |dir|
- rails_root.join(dir.join(File::SEPARATOR)).mkpath
- end
-
- copies = [
- {:from => %w(db migrate), :to => %w(db migrate), :filename => "20090917224823_create_portfolio_structure.rb"},
- {:from => %w(db migrate),:to => %w(db migrate), :filename => "20091121033434_add_position_to_images_portfolio_entries.rb"},
- {:from => %w(public stylesheets), :to => %w(public stylesheets), :filename => "portfolio.css"},
- {:from => %w(public javascripts), :to => %w(public javascripts), :filename => "portfolio.js"}
- ]
- copies.each do |copy|
- copy_from = portfolio_root.join(copy[:from].join(File::SEPARATOR), copy[:filename])
- copy_to = rails_root.join(copy[:to].join(File::SEPARATOR), copy[:filename])
- unless copy_to.exist?
- FileUtils::copy_file copy_from.to_s, copy_to.to_s
- else
- puts "'#{File.join copy[:to], copy[:filename]}' already existed in your application so your existing file was not overwritten."
- end
- end
-
- puts "---------"
- puts "Copied all refinerycms-portfolio files."
- puts "Now, run rake db:migrate and then rake images:regenerate"
-else
- puts "Please specify the path of the project that you want to use the portfolio with, i.e. refinerycms-portfolio-install /path/to/project"
-end
View
@@ -1,14 +1,9 @@
-ActionController::Routing::Routes.draw do |map|
+require File.expand_path("../../lib/portfolio.rb", __FILE__)
- map.resources :portfolio do |portfolio|
- portfolio.resources :portfolio, :as => :portfolio
- end
-
- map.namespace(:admin, :path_prefix => 'refinery') do |admin|
- admin.resources :portfolio_entries, :as => :portfolio, :collection => {:emancipate => :get}
- end
+ActionController::Routing::Routes.draw do |map|
- if RefinerySetting.table_exists? and RefinerySetting.find_or_set(:multi_level_portfolio, true)
+ # Make sure you restart your web server after changing the multi level setting.
+ if ::Refinery::Portfolio.multi_level?
map.portfolio_project "/portfolio/:id/projects/:portfolio_id", :controller => "portfolio", :action => "show"
map.portfolio_image "/portfolio/:id/projects/:portfolio_id/:image_id", :controller => "portfolio", :action => "show"
else
@@ -18,4 +13,12 @@
map.portfolio "/portfolio/:id/", :controller => 'portfolio', :action => 'show'
+ map.resources :portfolio do |portfolio|
+ portfolio.resources :portfolio, :as => :portfolio
+ end
+
+ map.namespace(:admin, :path_prefix => (defined?(REFINERY_GEM_VERSION) ? 'admin' : 'refinery')) do |admin|
+ admin.resources :portfolio_entries, :as => :portfolio, :member => {:emancipate => :get}, :collection => {:update_positions => :post}
+ end
+
end
@@ -1,9 +0,0 @@
-class AddPositionToImagesPortfolioEntries < ActiveRecord::Migration
- def self.up
- add_column :images_portfolio_entries, :position, :integer
- end
-
- def self.down
- remove_column :images_portfolio_entries, :position
- end
-end
@@ -0,0 +1,23 @@
+class PortfolioGenerator < Rails::Generator::NamedBase
+
+ def initialize(*runtime_args)
+ # set first argument to the table's name so that the user doesn't have to pass it in.
+ runtime_args[0] = ["portfolio_entries"]
+ super(*runtime_args)
+ end
+
+ def banner
+ "Usage: script/generate portfolio"
+ end
+
+ def manifest
+ record do |m|
+ m.migration_template 'migration.rb', 'db/migrate',
+ :migration_file_name => "create_structure_for_portfolio",
+ :assigns => {
+ :migration_name => "CreateStructureForPortfolio"
+ }
+ end
+ end
+
+end if defined?(Rails::Generator::NamedBase)
@@ -1,28 +1,32 @@
-class CreatePortfolioStructure < ActiveRecord::Migration
+class <%= migration_name %> < ActiveRecord::Migration
+
def self.up
create_table :images_portfolio_entries, :id => false, :force => true do |t|
t.integer :image_id
t.integer :portfolio_entry_id
+ t.integer :position
end
# people should be allowed to have the same image twice, if they really want to.
- #add_index :images_portfolio_entries, [:image_id, :portfolio_entry_id], :name => :composite_key_index, :unique => true
+ add_index :images_portfolio_entries, [:image_id, :portfolio_entry_id], :name => 'composite_key_index', :unique => false
create_table :portfolio_entries, :force => true do |t|
t.string :title
t.text :body
t.integer :position
t.integer :parent_id
- t.datetime :created_at
- t.datetime :updated_at
+ t.timestamps
end
+ add_index :portfolio_entries, :id
+ add_index :portfolio_entries, :parent_id
+
User.find(:all).each do |user|
user.plugins.create(:title => "Portfolio", :position => (user.plugins.maximum(:position) || -1) +1)
end
- page = Page.create(:title => "Portfolio", :link_url => "/portfolio", :deletable => false, :position => ((Page.maximum(:position, :conditions => "parent_id IS NULL") || -1)+1))
- RefinerySetting.find_or_set(:default_page_parts, ["body", "side_body"]).each do |default_page_part|
+ page = Page.create(:title => "Portfolio", :link_url => "/portfolio", :menu_match => "\/portfolio(|\/.+?)", :deletable => false, :position => ((Page.maximum(:position, :conditions => {:parent_id => nil}) || -1)+1))
+ RefinerySetting.find_or_set(:default_page_parts, ["Body", "Side Body"]).each do |default_page_part|
page.parts.create(:title => default_page_part, :body => nil)
end
@@ -35,15 +39,14 @@ def self.down
UserPlugin.destroy_all({:title => "Portfolio"})
Page.find_all_by_link_url("/portfolio").each do |page|
- page.link_url, page.menu_match, page.deletable = nil
- page.destroy
+ page.destroy!
end
- Page.destroy_all({:link_url => "/portfolio"})
- image_thumbnails = RefinerySetting.find_or_set(:image_thumbnails, {})
+ image_thumbnails = RefinerySetting.find_or_set(:image_thumbnails, {}).dup
RefinerySetting[:image_thumbnails] = image_thumbnails.delete_if {|key, value| key == :portfolio_thumb or key == :portfolio }
drop_table :images_portfolio_entries
drop_table :portfolio_entries
end
+
end
View
@@ -3,7 +3,7 @@
version = Refinery::Portfolio::Version::STRING
raise "Could not get version so gemspec can not be built" if version.nil?
files = %w( readme.md license.md )
-%w(app bin config db lib public rails test vendor).each do |dir|
+%w(app config generators lib public rails test vendor).each do |dir|
files += Dir.glob("#{dir}/**/*") if File.directory?(dir)
end
@@ -18,7 +18,6 @@
s.homepage = %q{http://refinerycms.com}
s.authors = %w(Resolve\\ Digital Philip\\ Arndt)
s.require_paths = %w(lib)
- s.executables = %w(refinerycms-portfolio-install)
s.files = [
'#{files.join("',\n '")}'
View
@@ -8,5 +8,14 @@ class Version
STRING = [MAJOR, MINOR, TINY, BUILD].compact.join('.')
end
+
+ class << self
+ def multi_level?
+ RefinerySetting.table_exists? and RefinerySetting.find_or_set(:multi_level_portfolio, true, {
+ :callback_proc_as_string => %q{::ActionController::Routing::Routes.reload!},
+ :restricted => true
+ })
+ end
+ end
end
-end
+end
View
@@ -3,7 +3,35 @@ namespace :refinery do
desc "Install extra files from the portfolio plugin"
task :install do
- puts `ruby #{File.expand_path(File.dirname(__FILE__) << '/../..')}/bin/refinerycms-portfolio-install #{Rails.root.to_s}`
+ [%w(db migrate), %w(public stylesheets), %w(public javascripts)].each do |dir|
+ Rails.root.join(dir.join(File::SEPARATOR)).mkpath
+ end
+
+ portfolio_root = Pathname.new(File.expand_path("../../../", __FILE__))
+ copies = [
+ {:from => %w(public stylesheets), :to => %w(public stylesheets), :filename => "portfolio.css"},
+ {:from => %w(public javascripts), :to => %w(public javascripts), :filename => "portfolio.js"}
+ ]
+ puts "\nCopying files...\n\n"
+ copies.each do |copy|
+ copy_from = portfolio_root.join(copy[:from].join(File::SEPARATOR), copy[:filename])
+ copy_to = Rails.root.join(copy[:to].join(File::SEPARATOR), copy[:filename])
+ unless copy_to.exist? and ENV["force"].presence.to_s != "true"
+ FileUtils::cp copy_from.to_s, copy_to.to_s
+ puts "Copied to #{copy_to}"
+ else
+ puts "'#{File.join copy[:to], copy[:filename]}' already existed in your application so your existing file was not overwritten - use force=true to overwrite."
+ puts "Without this file being up to date, the portfolio may not function properly."
+ end
+ end
+
+ puts "\nCopied all files."
+ puts "\nGenerating migration..."
+ puts `ruby #{Rails.root.join('script', 'generate').cleanpath.to_s.gsub(/\/$/, '')} portfolio`
+ puts "\nNow, run these tasks:"
+ puts " rake db:migrate"
+ puts " rake images:regenerate"
+ puts "\nWe hope you enjoy using our portfolio plugin!\n\n"
end
end
end
Oops, something went wrong.

0 comments on commit e5cbb14

Please sign in to comment.