Permalink
Browse files

Upgraded engine to run correctly on the latest version of RefineryCMS…

… which was 0.9.6.12 at the time.
  • Loading branch information...
1 parent f0f16cb commit 2f7a0e93d1fa55e6d9e893b655bb37d426dce815 @parndt parndt committed Feb 18, 2010
View
2 CONTRIBUTORS
@@ -1,2 +0,0 @@
-Major Contributors
-- parndt - Philip Arndt - http://www.resolvedigital.co.nz
View
46 README
@@ -1,46 +0,0 @@
-Portfolio plugin for RefineryCMS
-http://www.refinerycms.com
-http://github.com/resolve/Refinery
-
-By: Resolve Digital Ltd
-http://www.resolvedigital.com
-
-Plugin Installation
-===================
-
-Just 'git clone' Refinery, install this as a plugin using:
-script/plugin install git://github.com/resolve/portfolio.git
-
-Then run:
-rake portfolio:install
-
-..and follow the instructions!
-
-Gem Installation
-================
-
-METHOD ONE
-===========
-Just install the gem 'portfolio' with the command:
-gem install portfolio --source http://gemcutter.org
-
-Then run:
-portfolio-install /path/to/your/refinery/application
-
-Then place in your config/environment.rb file after other all other Refinery gem calls:
-config.gem "portfolio", :version => ">= 0.9.1.5", :lib => "portfolio", :source => "http://gemcutter.org"
-
-..and follow the instructions!
-
-METHOD TWO
-===========
-Place in your config/environment.rb file after other all other Refinery gem calls:
-config.gem "portfolio", :version => ">= 0.9.1.5", :lib => "portfolio", :source => "http://gemcutter.org"
-
-Then run in your application's directory:
-rake gems:install
-
-Then run:
-portfolio-install /path/to/your/refinery/application
-
-..and follow the instructions!
View
10 app/controllers/admin/portfolio_entries_controller.rb
@@ -1,5 +1,13 @@
class Admin::PortfolioEntriesController < Admin::BaseController
-
+
crudify :portfolio_entry, :order => 'position ASC', :conditions => "parent_id IS NULL"
+ def emancipate
+ if (entry = PortfolioEntry.find(params[:id])).present?
+ entry.update_attribute(:parent_id, (entry.parent.present? ? entry.parent.parent_id : nil))
+ end
+
+ redirect_to :action => "index"
+ end
+
end
View
6 app/views/admin/portfolio_entries/_form.html.erb
@@ -7,7 +7,7 @@
<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}?thickbox=true&modal=true&titlebar=true&field=portfolio_entry_image_id&callback=image_added&update_image=current_portfolio_entry_image&thumbnail=grid&KeepThis=true&TB_iframe=true&width=950&height=510", :class => "thickbox", :name => "Add Another Image", :id => "add_image_link" %>
+ <%= link_to "#{refinery_icon_tag "add.png"} Add", "#{insert_admin_images_url}?thickbox=true&amp;modal=true&amp;titlebar=true&amp;callback=image_added&amp;KeepThis=true&amp;TB_iframe=true&amp;width=950&amp;height=510", :class => "thickbox", :name => "Add Another Image", :id => "add_image_link" %>
</span>
<ul id='portfolio_images' class='clearfix portfolio_entry_images'>
<% @portfolio_entry.images.each do |image| %>
@@ -27,8 +27,8 @@
<%= f.text_area :body, :class => "wymeditor", :rows => 7 %>
</div>
<div class='form-actions'>
- <%= f.submit 'Save', :class => "wymupdate" %>
- or
+ <%= 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 %>
View
37 app/views/admin/portfolio_entries/_list.html.erb
@@ -1,29 +1,30 @@
-<%
- branch = if entry === @portfolio_entries.first
+<%
+ branch = if list === @portfolio_entries.first
"branch_start"
- elsif entry === @portfolio_entries.last or (entry.parent and entry === entry.parent.children.last)
+ elsif list === @portfolio_entries.last or (list.parent and list === list.parent.children.last)
"branch_end"
- end
+ end
-%>
-<li class='clearfix record<%= " #{branch}" %>' id="<%= dom_id(entry) -%>">
+<li class='clearfix record<%= " #{branch}" %>' id="<%= dom_id(list) -%>">
<div class='clearfix'>
<span class='actions'>
- <% url = entry.parent ? portfolio_project_url(entry.parent, entry) : portfolio_url(entry) %>
+ <% url = 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(entry),
+ <%= link_to refinery_icon_tag('application_edit.png'), edit_admin_portfolio_entry_path(list),
:title => "Edit this entry" %>
- <%= link_to refinery_icon_tag('delete.png'), admin_portfolio_entry_path(entry),
- :confirm => "Are you sure you want to delete '#{entry.title}'?", :class => "cancel",
- :method => :delete,
- :title => "Remove this entry forever" %>
+ <%= link_to refinery_icon_tag('arrow_up.png'),
+ {:controller => "/admin/portfolio_entries", :action => "emancipate", :id => list.id},
+ :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",
+ :title => "Remove this entry forever" %>
</span>
- <%=h entry.title %>
+ <%=h list.title %>
</div>
- <ul<%= " class='empty'" if entry.children.empty? %>>
- <% entry.children.each do |child| %>
- <%= render :partial => 'list', :locals => {:entry => child} %>
- <% end %>
- <span class='spacing'>&nbsp;</span>
- </ul>
+ <% if (children = list.children).any? %>
+ <ul<%= " class='nested'" %>>
+ <%= render :partial => 'list', :collection => children %>
+ </ul>
+ <% end %>
</li>
View
6 app/views/admin/portfolio_entries/_sortable_list.html.erb
@@ -1,4 +1,2 @@
-<% @portfolio_entries.each do |entry| %>
- <%= render :partial => 'list', :locals => {:entry => entry} %>
-<% end %>
-<%= render :partial => "/shared/admin/sortable_list" %>
+<%= render :partial => 'list', :collection => @portfolio_entries %>
+<%= render :partial => "/shared/admin/sortable_list", :locals => {:continue_reordering => (defined?(continue_reordering) ? continue_reordering : true)} %>
View
30 app/views/admin/portfolio_entries/index.html.erb
@@ -4,7 +4,7 @@
<li>
<%= link_to "Create New Portfolio Entry", new_admin_portfolio_entry_url, :class => "add_icon" %>
</li>
- <% if PortfolioEntry.count > 1 %>
+ <% if PortfolioEntry.any? %>
<li>
<%= link_to "Reorder Portfolio", "", :id => "reorder_action", :class => "reorder_icon" %>
<%= link_to "Done Reordering Portfolio", "", :id => "reorder_action_done", :style => "display: none;", :class => "reorder_icon" %>
@@ -13,18 +13,18 @@
</ul>
</div>
<div id='records' class='tree'>
-<% if @portfolio_entries.size > 0 %>
- <h2>Portfolio</h2>
- <ul id='sortable_list'>
- <%= render :partial => 'sortable_list' %>
- </ul>
- <% else %>
- <p>
- <strong>
- There are no portfolio entries yet.
- Click "Create New Portfolio Entry" to add your first portfolio entries.
- </strong>
- </p>
-<% end %>
+ <% if @portfolio_entries.any? %>
+ <h2>Portfolio</h2>
+ <ul id='sortable_list'>
+ <%= render :partial => 'sortable_list' %>
+ </ul>
+ <% else %>
+ <p>
+ <strong>
+ There are no portfolio entries yet.
+ Click "Create New Portfolio Entry" to add your first portfolio entries.
+ </strong>
+ </p>
+ <% end %>
</div>
-<%= render :partial => "/shared/admin/make_sortable", :locals => {:tree => true } if PortfolioEntry.count > 1 %>
+<%= render :partial => "/shared/admin/make_sortable", :locals => {:tree => true } if PortfolioEntry.any? %>
View
32 bin/portfolio-install
@@ -1,32 +0,0 @@
-#!/usr/bin/env ruby
-require 'fileutils'
-PORTFOLIO_ROOT = File.expand_path(File.dirname(__FILE__) << "/..")
-RAILS_ROOT = ARGV.first unless defined? RAILS_ROOT
-unless RAILS_ROOT.nil? or RAILS_ROOT.length == 0
- dirs = [['db', 'migrate'], ['public', 'stylesheets'], ['public', 'javascripts']]
- dirs.each do |dir|
- FileUtils::makedirs File.join(RAILS_ROOT, dir)
- end
-
- copies = [
- {:from => ["db", "migrate"],:to => ["db", "migrate"],:filename => "20090917224823_create_portfolio_structure.rb"},
- {:from => ["db", "migrate"],:to => ["db", "migrate"],:filename => "20091121033434_add_position_to_images_portfolio_entries.rb"},
- {:from => ["public", "stylesheets"],:to => ["public", "stylesheets"],:filename => "portfolio.css"},
- {:from => ["public", "javascripts"],:to => ["public", "javascripts"],:filename => "portfolio.js"}
- ]
- copies.each do |copy|
- copy_from = File.join(PORTFOLIO_ROOT, copy[:from], copy[:filename])
- copy_to = File.join(RAILS_ROOT, copy[:to], copy[:filename])
- unless File.exists?(copy_to)
- FileUtils::copy_file copy_from, copy_to
- 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 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. portfolio-install /path/to/project"
-end
View
39 bin/refinery-portfolio-install
@@ -0,0 +1,39 @@
+#!/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 refinery-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. refinery-portfolio-install /path/to/project"
+end
View
0 config/locale/en.yml
No changes.
View
4 config/routes.rb
@@ -8,8 +8,8 @@
portfolio.resources :portfolio, :as => :portfolio
end
- map.namespace(:admin) do |admin|
- admin.resources :portfolio_entries, :as => :portfolio
+ map.namespace(:admin) do |admin|
+ admin.resources :portfolio_entries, :as => :portfolio, :collection => {:emancipate => :get}
end
end
View
4 contributors.md
@@ -0,0 +1,4 @@
+# Contributors
+
+## Major
+* parndt - Philip Arndt, [Resolve Digital](http://www.resolvedigital.co.nz)
View
12 lib/tasks/portfolio.rake
@@ -1,7 +1,9 @@
-namespace :portfolio do
- desc "Install extra files from the portfolio plugin"
-
- task :install do
- puts `ruby #{File.expand_path(File.dirname(__FILE__) << '/../..')}/bin/portfolio-install #{RAILS_ROOT}`
+namespace :refinery do
+ namespace :portfolio do
+ desc "Install extra files from the portfolio plugin"
+
+ task :install do
+ puts `ruby #{File.expand_path(File.dirname(__FILE__) << '/../..')}/bin/refinery-portfolio-install #{Rails.root.to_s}`
+ end
end
end
View
6 LICENSE → license.md
@@ -1,6 +1,6 @@
-== MIT License
+# MIT License
-Copyright (c) 2005-2009 Resolve Digital Ltd.
+Copyright (c) 2005-2010 [Resolve Digital Ltd.](http://www.resolvedigital.co.nz)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
@@ -18,4 +18,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-SOFTWARE.
+SOFTWARE.
View
94 public/javascripts/portfolio.js
@@ -1,57 +1,47 @@
reset_functionality = function() {
- Sortable.destroy("portfolio_images");
- Sortable.create("portfolio_images", {
- constraint: false
- , hoverclass: 'hover'
- , scroll: window
- , tree: false
- });
-
- $$('#portfolio_images li:not([class=empty])').each(function(li) {
- li.observe('mouseover', function(){
- image_actions = this.down('.image_actions');
- if (image_actions == null) {
- image_actions = new Element("div").addClassName('image_actions');
- img_delete = new Element("img", {src: '/images/refinery/icons/delete.png', width: 16, height: 16});
- image_actions.insert(img_delete);
- img_delete.observe('click', function() {
- this.up('li').remove();
- });
-
- li.insert(image_actions);
- }
-
- image_actions.show();
- });
-
- li.observe('mouseout', function() {
- this.down('.image_actions').hide();
- });
- });
+ $("#portfolio_images").sortable({
+ 'tolerance': 'pointer'
+ , 'placeholder': 'placeholder'
+ , 'cursor': 'drag'
+ , 'items': 'li'
+ });
+
+ $('#portfolio_images li:not(.empty)').each(function(index, li) {
+ $(li).mouseover(function(e){
+ if ((image_actions = $(this).find('.image_actions')).length == 0) {
+ image_actions = $("<div class='image_actions'></div>");
+ img_delete = $("<img src='/images/refinery/icons/delete.png' width='16' height='16' />");
+ img_delete.appendTo(image_actions);
+ img_delete.click(function() {
+ $(this).parent().remove();
+ });
+
+ image_actions.appendTo($(li));
+ }
+
+ image_actions.show();
+ });
+
+ $(li).mouseout(function(e) {
+ $(this).find('.image_actions').hide();
+ });
+ });
}
-image_added = function() {
- last_portfolio_entry_image_id = "";
- $$('li.empty').each(function(empty) {
- hidden_identifier = empty.down('input[type=hidden]');
- hidden_identifier.id = '';
- image_id = hidden_identifier.value;
- empty.id = 'image_' + image_id;
- empty.removeClassName('empty');
- $(empty.down('img')).setStyle({display: ''}).removeAttribute('id');
- });
-
- new_list_item = new Element("li").addClassName("empty");
- img = new Element("img", {id: 'current_portfolio_entry_image', src: '', alt: '', style: 'display:none'});
-
- hidden_id = new Element("input", {'type': 'hidden', 'id' : "portfolio_entry_image_id", 'name':'portfolio_entry[image_ids][]'});
-
- new_list_item.insert(img);
- new_list_item.insert(hidden_id);
- $('portfolio_images').insert(new_list_item);
- reset_functionality();
+image_added = function(image) {
+ last_portfolio_entry_image_id = "";
+ image_id = $(image).attr('id').replace('image_', '');
+ hidden_identifier = $('li.empty').find('input:hidden');
+ hidden_identifier.attr('id', '').val(image_id);
+ $('li.empty').find('img').css('display', '').attr({'id': '', 'src': $(image).attr('src').replace('_dialog_thumb', '_grid'), 'title': $(image).attr('title'), 'alt': $(image).attr('alt')});
+ $('li.empty').attr('id', 'image_' + image_id).removeClass('empty');
+
+ new_list_item = $("<li class='empty'></li>");
+ $("<img id='current_portfolio_entry_image' src='' alt='' style='display:none;' />").appendTo(new_list_item);
+ $("<input type='hidden' id='portfolio_entry_image_id' name='portfolio_entry[image_ids][]' />").appendTo(new_list_item);
+
+ new_list_item.appendTo($('#portfolio_images'));
+ reset_functionality();
}
-FastInit.addOnLoad(function(){
- reset_functionality();
-});
+$(document).ready(reset_functionality);
View
10 public/stylesheets/portfolio.css
@@ -64,4 +64,14 @@
}
#portfolio_images.portfolio_entry_images li .image_actions * {
cursor: pointer;
+}
+
+#content ul.ui-sortable li {
+ border: 0px none;
+ background: none !important;
+}
+
+#content #portfolio_images.ui-sortable li.placeholder {
+ width: 135px;
+ height: 135px;
}
View
4 rails/init.rb
@@ -3,8 +3,8 @@
plugin.title = "Portfolio"
plugin.description = "Manage a portfolio"
plugin.url = "/admin/#{plugin.title.downcase}"
- plugin.version = '0.9.1.8'
- plugin.menu_match = /admin\/((portfolio)|(portfolio_entries))/
+ plugin.version = '0.9.2'
+ plugin.menu_match = /admin\/portfolio(_entries)?/
plugin.activity = {
:class => PortfolioEntry,
:title => 'title',
View
40 readme.md
@@ -0,0 +1,40 @@
+# Portfolio plugin for [RefineryCMS](http://www.refinerycms.com)
+[Github](http://github.com/resolve/refinerycms)
+
+By: [Resolve Digital](http://www.resolvedigital.com)
+
+## Plugin Installation
+
+Just 'git clone' Refinery, install this as a plugin using:
+ script/plugin install git://github.com/resolve/refinery-portfolio.git
+
+Then run:
+ rake refinery:portfolio:install
+
+..and follow the instructions!
+
+## Gem Installation
+
+### Method One
+Just install the gem 'portfolio' with the command:
+ gem install refinery-portfolio --source http://gemcutter.org
+
+Then run:
+ refinery-portfolio-install /path/to/your/refinery/application
+
+Then place in your config/environment.rb (or config/application.rb for refinery 0.9.6.x) file before all other Refinery gem calls:
+ config.gem "refinery-portfolio", :version => ">= 0.9.2", :lib => "portfolio", :source => "http://gemcutter.org"
+
+..and follow the instructions!
+
+### Method Two
+Place in your config/environment.rb (or config/application.rb for refinery 0.9.6.x) file before all other Refinery gem calls:
+ config.gem "refinery-portfolio", :version => ">= 0.9.2", :lib => "portfolio", :source => "http://gemcutter.org"
+
+Then run in your application's directory:
+ rake gems:install
+
+Then run:
+ refinery-portfolio-install /path/to/your/refinery/application
+
+..and follow the instructions!
View
22 portfolio.gemspec → refinery-portfolio.gemspec
@@ -1,27 +1,26 @@
Gem::Specification.new do |s|
- s.name = %q{portfolio}
+ s.name = %q{refinery-portfolio}
s.version = "0.9.2"
s.authors = ["Resolve Digital", "Philip Arndt"]
- s.date = %q{2010-01-19}
+ s.date = %q{2010-02-18}
s.description = %q{A really straightforward open source Ruby on Rails portfolio plugin designed for integration with RefineryCMS.}
s.summary = %q{Ruby on Rails portfolio plugin for RefineryCMS.}
- s.executables = ["portfolio-install"]
- s.default_executable = %q{portfolio-install}
+ s.executables = ["refinery-portfolio-install"]
+ s.default_executable = %q{refinery-portfolio-install}
s.email = %q{info@refinerycms.com}
- s.extra_rdoc_files = ["README", "CONTRIBUTORS", "LICENSE"]
s.homepage = %q{http://refinerycms.com}
s.rubygems_version = %q{1.3.4}
s.files = [
- "CONTRIBUTORS",
- "LICENSE",
- "README",
+ "contributors.md",
+ "license.md",
+ "readme.md",
"app",
"app/controllers",
"app/controllers/admin",
@@ -43,8 +42,10 @@ Gem::Specification.new do |s|
"app/views/portfolio/empty.html.erb",
"app/views/portfolio/show.html.erb",
"bin",
- "bin/portfolio-install",
+ "bin/refinery-portfolio-install",
"config",
+ "config/locale",
+ "config/locale/en.yml",
"config/routes.rb",
"db",
"db/migrate",
@@ -58,7 +59,8 @@ Gem::Specification.new do |s|
"public/javascripts",
"public/javascripts/portfolio.js",
"public/stylesheets",
- "public/stylesheets/portfolio.css","rails",
+ "public/stylesheets/portfolio.css",
+ "rails",
"rails/init.rb"
]

0 comments on commit 2f7a0e9

Please sign in to comment.