refinerycms-portfolio 0.9.3.8 → 0.9.5.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -15,13 +15,17 @@ protected
15
15
 
16
16
  # This finds all of the entries that could possibly be assigned as the current entry's parent.
17
17
  def find_portfolio_entries_for_parents_list
18
- @portfolio_entries_for_parents_list = PortfolioEntry.find(:all, :order => "parent_id, position ASC")
18
+ if RefinerySetting.find_or_set(:multi_level_portfolio, true)
19
+ @portfolio_entries_for_parents_list = PortfolioEntry.find(:all, :order => "parent_id, position ASC")
19
20
 
20
- # We need to remove all references to the current entry or any of its decendants or we get a nightmare.
21
- unless @portfolio_entry.nil? or @portfolio_entry.new_record?
22
- @portfolio_entries_for_parents_list.reject! do |entry|
23
- entry.id == @portfolio_entry.id or @portfolio_entry.descendants.include?(entry)
21
+ # We need to remove all references to the current entry or any of its decendants or we get a nightmare.
22
+ unless @portfolio_entry.nil? or @portfolio_entry.new_record?
23
+ @portfolio_entries_for_parents_list.reject! do |entry|
24
+ entry.id == @portfolio_entry.id or @portfolio_entry.descendants.include?(entry)
25
+ end
24
26
  end
27
+ else
28
+ @portfolio_entries_for_parents_list = []
25
29
  end
26
30
  end
27
31
 
@@ -14,11 +14,15 @@ class PortfolioController < ApplicationController
14
14
  @master_entry = PortfolioEntry.find_by_parent_id(nil, :order => "position ASC")
15
15
  end
16
16
 
17
- if params[:portfolio_id]
18
- @portfolio_entry = @master_entry.children.find(params[:portfolio_id])
19
- else
20
- @portfolio_entry = @master_entry.children.first
21
- end
17
+ if RefinerySetting.find_or_set(:multi_level_portfolio, true)
18
+ if params[:portfolio_id]
19
+ @portfolio_entry = @master_entry.children.find(params[:portfolio_id])
20
+ else
21
+ @portfolio_entry = @master_entry.children.first
22
+ end
23
+ else
24
+ @portfolio_entry = @master_entry
25
+ end
22
26
 
23
27
  begin
24
28
  if params[:image_id]
@@ -0,0 +1,17 @@
1
+ module PortfolioHelper
2
+
3
+ def portfolio_image_link(master, portfolio, image_index)
4
+ if RefinerySetting.find_or_set(:multi_level_portfolio, true)
5
+ portfolio_image_url(master, portfolio, image_index)
6
+ else
7
+ portfolio_image_url(master, image_index)
8
+ end
9
+ end
10
+
11
+ def link_to_portfolio_image(master, portfolio, image, index)
12
+ link_to image_fu(image, :portfolio_thumb),
13
+ portfolio_image_link(master, portfolio, index),
14
+ :class => ( (index == params[:image_id].to_i) ? "selected" : "pale" )
15
+ end
16
+
17
+ end
@@ -27,4 +27,5 @@
27
27
  </p>
28
28
  <% end %>
29
29
  </div>
30
- <%= render :partial => "/shared/admin/make_sortable", :locals => {:tree => true } if PortfolioEntry.count > 1 %>
30
+ <%= render :partial => "/shared/admin/make_sortable",
31
+ :locals => { :tree => RefinerySetting.find_or_set(:multi_level_portfolio, true) } if PortfolioEntry.count > 1 %>
@@ -4,7 +4,7 @@
4
4
  <div id='body_content_left' class='clearfix'>
5
5
  <h1 class='clearfix'>
6
6
  <span><%= @master_entry.title %></span>
7
- <%= select :portfolio_entry, :to_param, @master_entry.children.collect{|entry| [entry.title, entry.to_param] } %>
7
+ <%= select :portfolio_entry, :to_param, @master_entry.children.collect{|entry| [entry.title, entry.to_param] } if RefinerySetting.find_or_set(:multi_level_portfolio, true) %>
8
8
  </h1>
9
9
 
10
10
  <%= render :partial => "main_image" %>
@@ -12,11 +12,9 @@
12
12
  <div id='body_content_right' class='clearfix'>
13
13
  <h2><%= @portfolio_entry.title %></h2>
14
14
  <ul id='portfolio_images'>
15
- <% (images = @portfolio_entry.images).each do |image| %>
15
+ <% @portfolio_entry.images.each_with_index do |image, index| %>
16
16
  <li class='<%= cycle("odd", "even") %>'>
17
- <% className = (selected = images.index(image) == params[:image_id].to_i) ? "selected" : "pale" %>
18
- <%= link_to image_fu(image, :portfolio_thumb),
19
- portfolio_image_url(@master_entry, @portfolio_entry, images.index(image)), :class => className %>
17
+ <%= link_to_portfolio_image @master_entry, @portfolio_entry, image, index %>
20
18
  </li>
21
19
  <% end %>
22
20
  </ul>
@@ -31,7 +29,7 @@
31
29
  $("ul#portfolio_images li a.pale img").fadeTo(0, 0.3);
32
30
 
33
31
  $('#portfolio_entry_to_param').change(function() {
34
- window.location = "<%= portfolio_project_url(@master_entry, nil) %>" + this.value;
32
+ window.location = "<%= RefinerySetting.find_or_set(:multi_level_portfolio, true) ? portfolio_project_url(@master_entry, nil) : portfolio_project_url(@master_entry) %>" + this.value;
35
33
  });
36
34
 
37
35
  var clicked_on = null;
data/config/routes.rb CHANGED
@@ -1,7 +1,13 @@
1
1
  ActionController::Routing::Routes.draw do |map|
2
2
 
3
- map.portfolio_project "/portfolio/:id/projects/:portfolio_id", :controller => "portfolio", :action => "show"
4
- map.portfolio_image "/portfolio/:id/projects/:portfolio_id/:image_id", :controller => "portfolio", :action => "show"
3
+ if RefinerySetting.table_exists? and RefinerySetting.find_or_set(:multi_level_portfolio, true)
4
+ map.portfolio_project "/portfolio/:id/projects/:portfolio_id", :controller => "portfolio", :action => "show"
5
+ map.portfolio_image "/portfolio/:id/projects/:portfolio_id/:image_id", :controller => "portfolio", :action => "show"
6
+ else
7
+ map.portfolio_project "/portfolio/:id", :controller => "portfolio", :action => "show"
8
+ map.portfolio_image "/portfolio/:id/:image_id", :controller => "portfolio", :action => "show"
9
+ end
10
+
5
11
  map.portfolio "/portfolio/:id/", :controller => 'portfolio', :action => 'show'
6
12
 
7
13
  map.resources :portfolio do |portfolio|
@@ -16,32 +16,33 @@ class CreatePortfolioStructure < ActiveRecord::Migration
16
16
  t.datetime :created_at
17
17
  t.datetime :updated_at
18
18
  end
19
-
19
+
20
20
  User.find(:all).each do |user|
21
21
  user.plugins.create(:title => "Portfolio", :position => (user.plugins.maximum(:position) || -1) +1)
22
22
  end
23
-
23
+
24
24
  page = Page.create(:title => "Portfolio", :link_url => "/portfolio", :deletable => false, :position => ((Page.maximum(:position, :conditions => "parent_id IS NULL") || -1)+1))
25
25
  RefinerySetting.find_or_set(:default_page_parts, ["body", "side_body"]).each do |default_page_part|
26
26
  page.parts.create(:title => default_page_part, :body => nil)
27
27
  end
28
-
28
+
29
+ # we need to retrieve the value, merge it in and then save it back because it's a frozen hash.
29
30
  image_thumbnails = RefinerySetting.find_or_set(:image_thumbnails, {})
30
31
  RefinerySetting[:image_thumbnails] = image_thumbnails.merge({:portfolio_thumb => 'c96x96', :portfolio => '600x512'})
31
32
  end
32
33
 
33
34
  def self.down
34
35
  UserPlugin.destroy_all({:title => "Portfolio"})
35
-
36
+
36
37
  Page.find_all_by_link_url("/portfolio").each do |page|
37
38
  page.link_url, page.menu_match, page.deletable = nil
38
39
  page.destroy
39
40
  end
40
41
  Page.destroy_all({:link_url => "/portfolio"})
41
-
42
+
42
43
  image_thumbnails = RefinerySetting.find_or_set(:image_thumbnails, {})
43
44
  RefinerySetting[:image_thumbnails] = image_thumbnails.delete_if {|key, value| key == :portfolio_thumb or key == :portfolio }
44
-
45
+
45
46
  drop_table :images_portfolio_entries
46
47
  drop_table :portfolio_entries
47
48
  end
data/rails/init.rb CHANGED
@@ -3,7 +3,7 @@ Refinery::Plugin.register do |plugin|
3
3
  plugin.title = "Portfolio"
4
4
  plugin.description = "Manage a portfolio"
5
5
  plugin.url = "/admin/#{plugin.title.downcase}"
6
- plugin.version = '0.9.3.8'
6
+ plugin.version = '0.9.5.2'
7
7
  plugin.menu_match = /admin\/portfolio(_entries)?/
8
8
  plugin.activity = {
9
9
  :class => PortfolioEntry,
data/readme.md CHANGED
@@ -6,10 +6,12 @@ By: [Resolve Digital](http://www.resolvedigital.com)
6
6
  ## Plugin Installation
7
7
 
8
8
  Just 'git clone' Refinery, install this as a plugin using:
9
- script/plugin install git://github.com/resolve/refinerycms-portfolio.git
9
+
10
+ script/plugin install git://github.com/resolve/refinerycms-portfolio.git
10
11
 
11
12
  Then run:
12
- rake refinery:portfolio:install
13
+
14
+ rake refinery:portfolio:install
13
15
 
14
16
  ..and follow the instructions!
15
17
 
@@ -17,24 +19,34 @@ Then run:
17
19
 
18
20
  ### Method One
19
21
  Just install the gem 'portfolio' with the command:
20
- gem install refinerycms-portfolio --source http://gemcutter.org
22
+
23
+ gem install refinerycms-portfolio --source http://gemcutter.org
21
24
 
22
25
  Then run:
23
- refinerycms-portfolio-install /path/to/your/refinery/application
26
+
27
+ refinerycms-portfolio-install /path/to/your/refinery/application
24
28
 
25
29
  Then place in your config/environment.rb (or config/application.rb for refinery 0.9.6.x) file before all other Refinery gem calls:
26
- config.gem "refinerycms-portfolio", :version => ">= 0.9.3.8", :lib => "portfolio", :source => "http://gemcutter.org"
30
+
31
+ config.gem "refinerycms-portfolio", :version => ">= 0.9.5.2", :lib => "portfolio", :source => "http://gemcutter.org"
27
32
 
28
33
  ..and follow the instructions!
29
34
 
30
35
  ### Method Two
31
36
  Place in your config/environment.rb (or config/application.rb for refinery 0.9.6.x) file before all other Refinery gem calls:
32
- config.gem "refinerycms-portfolio", :version => ">= 0.9.3.8", :lib => "portfolio", :source => "http://gemcutter.org"
37
+
38
+ config.gem "refinerycms-portfolio", :version => ">= 0.9.5.2", :lib => "portfolio", :source => "http://gemcutter.org"
33
39
 
34
40
  Then run in your application's directory:
35
- rake gems:install
41
+
42
+ rake gems:install
36
43
 
37
44
  Then run:
38
- refinerycms-portfolio-install /path/to/your/refinery/application
39
45
 
40
- ..and follow the instructions!
46
+ refinerycms-portfolio-install /path/to/your/refinery/application
47
+
48
+ ..and follow the instructions!
49
+
50
+ ## Single or Multiple Level Portfolios
51
+
52
+ The standard setup for portfolios is multi-level, with a parent portfolio having child portfolios. If your needs are simpler, you can switch to a single level of portfolios by changing the Refinery Setting for 'Multi Level Portfolio' to false.
metadata CHANGED
@@ -5,9 +5,9 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 9
8
- - 3
9
- - 8
10
- version: 0.9.3.8
8
+ - 5
9
+ - 2
10
+ version: 0.9.5.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - Resolve Digital
@@ -16,7 +16,7 @@ autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
18
 
19
- date: 2010-02-27 00:00:00 +13:00
19
+ date: 2010-04-13 00:00:00 +12:00
20
20
  default_executable: refinerycms-portfolio-install
21
21
  dependencies: []
22
22
 
@@ -34,6 +34,7 @@ files:
34
34
  - readme.md
35
35
  - app/controllers/admin/portfolio_entries_controller.rb
36
36
  - app/controllers/portfolio_controller.rb
37
+ - app/helpers/portfolio_helper.rb
37
38
  - app/models/portfolio_entry.rb
38
39
  - app/views/admin/portfolio_entries/_form.html.erb
39
40
  - app/views/admin/portfolio_entries/_list.html.erb