refinerycms-portfolio 0.9.5.3 → 0.9.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -15,7 +15,7 @@ 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
- if RefinerySetting.find_or_set(:multi_level_portfolio, true)
18
+ if ::Refinery::Portfolio.multi_level?
19
19
  @portfolio_entries_for_parents_list = PortfolioEntry.find(:all, :order => "parent_id, position ASC")
20
20
 
21
21
  # We need to remove all references to the current entry or any of its decendants or we get a nightmare.
@@ -29,4 +29,4 @@ protected
29
29
  end
30
30
  end
31
31
 
32
- end
32
+ end
@@ -7,37 +7,37 @@ class PortfolioController < ApplicationController
7
7
  end
8
8
 
9
9
  def show
10
- begin
11
- if params[:id]
12
- @master_entry = PortfolioEntry.find(params[:id])
13
- else
14
- @master_entry = PortfolioEntry.find_by_parent_id(nil, :order => "position ASC")
15
- end
16
-
17
- if RefinerySetting.find_or_set(:multi_level_portfolio, true)
10
+ begin
11
+ if params[:id]
12
+ @master_entry = PortfolioEntry.find(params[:id])
13
+ else
14
+ @master_entry = PortfolioEntry.find_by_parent_id(nil, :order => "position ASC")
15
+ end
16
+
17
+ if ::Refinery::Portfolio.multi_level?
18
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
26
-
27
- begin
28
- if params[:image_id]
29
- @image = @portfolio_entry.images[params[:image_id].to_i]
30
- else
31
- @image = @portfolio_entry.images.first
32
- end
33
- rescue
34
- render :action => "empty"
35
- end
36
- rescue
37
- error_404
38
- end
39
-
40
- render :partial => "main_image", :layout => false if request.xhr?
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
26
+
27
+ begin
28
+ if params[:image_id]
29
+ @image = @portfolio_entry.images[params[:image_id].to_i]
30
+ else
31
+ @image = @portfolio_entry.images.first
32
+ end
33
+ rescue
34
+ render :action => "empty"
35
+ end
36
+ rescue
37
+ error_404
38
+ end
39
+
40
+ render :partial => "main_image", :layout => false if request.xhr?
41
41
  end
42
42
 
43
43
  protected
@@ -46,4 +46,4 @@ protected
46
46
  @page = Page.find_by_link_url('/portfolio', :include => [:parts])
47
47
  end
48
48
 
49
- end
49
+ end
@@ -1,17 +1,17 @@
1
1
  module PortfolioHelper
2
-
2
+
3
3
  def portfolio_image_link(master, portfolio, image_index)
4
- if RefinerySetting.find_or_set(:multi_level_portfolio, true)
4
+ if ::Refinery::Portfolio.multi_level?
5
5
  portfolio_image_url(master, portfolio, image_index)
6
6
  else
7
7
  portfolio_image_url(master, image_index)
8
8
  end
9
9
  end
10
-
10
+
11
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" )
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
15
  end
16
-
17
- end
16
+
17
+ end
@@ -3,7 +3,7 @@ class PortfolioEntry < ActiveRecord::Base
3
3
  validates_presence_of :title
4
4
 
5
5
  # call to gems included in refinery.
6
- has_friendly_id :title, :use_slug => true, :strip_diacritics => true
6
+ has_friendly_id :title, :use_slug => true
7
7
  acts_as_tree :order => "position"
8
8
 
9
9
  has_and_belongs_to_many :images
@@ -16,17 +16,17 @@ class PortfolioEntry < ActiveRecord::Base
16
16
  self.body = value
17
17
  end
18
18
 
19
- def image_ids=(ids)
20
- self.images.clear
19
+ def image_ids=(ids)
20
+ self.images.clear
21
21
 
22
- ids.reject{|id| id.blank? }.each do |image_id|
23
- image = Image.find(image_id.to_i) rescue nil
24
- self.images << image unless image.nil?
25
- end
26
- end
22
+ ids.reject{|id| id.blank? }.each do |image_id|
23
+ image = Image.find(image_id.to_i) rescue nil
24
+ self.images << image unless image.nil?
25
+ end
26
+ end
27
27
 
28
- def indented_title
28
+ def indented_title
29
29
  "#{"--" * self.ancestors.size} #{self.title}".chomp
30
30
  end
31
31
 
32
- end
32
+ end
@@ -1,30 +1,39 @@
1
+ <% content_for :head do %>
2
+ <%= stylesheet_link_tag 'portfolio' %>
3
+ <%= javascript_include_tag 'portfolio' %>
4
+ <% end %>
5
+
1
6
  <%= error_messages_for :portfolio_entry %>
2
7
  <% form_for [:admin, @portfolio_entry] do |f| %>
3
8
  <div class='field'>
4
- <%= f.label :title %>
5
- <%= f.text_field :title, :class => "larger", :style => 'width: 954px' %>
9
+ <%= f.required_label :title %>
10
+ <%= f.text_field :title, :class => "larger widest" %>
6
11
  </div>
7
12
  <div class='field images_field'>
8
- <span class='clearfix label_inline_with_link'>
9
- <%= label_tag('portfolio_entry_image_ids', 'Images') %>
10
- <%= 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" %>
11
- </span>
12
- <ul id='portfolio_images' class='clearfix portfolio_entry_images'>
13
- <% @portfolio_entry.images.each do |image| %>
14
- <li id='image_<%= image.id %>'>
15
- <%= image_fu image, :grid %>
16
- <%= hidden_field_tag 'portfolio_entry[image_ids][]', image.id, :id => "portfolio_entry_image_id_#{image.id}" %>
17
- </li>
18
- <% end %>
19
- <li class='empty'>
20
- <img id="current_portfolio_entry_image" src="" alt="" style='display: none' />
21
- <input type='hidden' id='portfolio_entry_image_id' name='portfolio_entry[image_ids][]' />
22
- </li>
23
- </ul>
24
- </div>
25
- <div class='field clearfix' style='width: 963px'>
13
+ <span class='clearfix label_inline_with_link'>
14
+ <%= label_tag('portfolio_entry_image_ids', 'Images') %>
15
+ <%= link_to "#{refinery_icon_tag "add.png"} Add",
16
+ insert_admin_images_url(:dialog => true, :width => 950, :height => 510, :callback => "image_added"),
17
+ :name => "Add Another Image",
18
+ :id => "add_image_link" %>
19
+ </span>
20
+ <ul id='portfolio_images' class='clearfix portfolio_entry_images'>
21
+ <% @portfolio_entry.images.each do |image| %>
22
+ <li id='image_<%= image.id %>'>
23
+ <%= image_fu image, :grid %>
24
+ <%= hidden_field_tag 'portfolio_entry[image_ids][]', image.id,
25
+ :id => "portfolio_entry_image_id_#{image.id}" %>
26
+ </li>
27
+ <% end %>
28
+ <li class='empty'>
29
+ <img id="current_portfolio_entry_image" src="" alt="" style='display: none' />
30
+ <input type='hidden' id='portfolio_entry_image_id' name='portfolio_entry[image_ids][]' />
31
+ </li>
32
+ </ul>
33
+ </div>
34
+ <div class='field clearfix'>
26
35
  <%= f.label :body, 'Content' %>
27
- <%= f.text_area :body, :class => "wymeditor", :rows => 7 %>
36
+ <%= f.text_area :body, :class => "wymeditor widest", :rows => 7 %>
28
37
  </div>
29
38
  <% if @portfolio_entries_for_parents_list.any? %>
30
39
  <div class='field'>
@@ -32,13 +41,11 @@
32
41
  <%= f.collection_select :parent_id, @portfolio_entries_for_parents_list, :id, :indented_title, :include_blank => true %>
33
42
  </div>
34
43
  <% end %>
35
- <div class='form-actions'>
36
- <%= f.submit 'Save', :class => "wymupdate" %>
37
- or
38
- <%= link_to "Cancel", admin_portfolio_entries_url, :title => "Cancelling will lose all changes you've made to this entry" %>
39
- </div>
44
+
45
+ <%= render :partial => "/shared/admin/form_actions",
46
+ :locals => {
47
+ :f => f,
48
+ :continue_editing => true
49
+ } -%>
50
+
40
51
  <% end %>
41
- <% content_for :head do %>
42
- <%= stylesheet_link_tag 'portfolio' %>
43
- <%= javascript_include_tag 'portfolio' %>
44
- <% end %>
@@ -1,22 +1,22 @@
1
1
  <%
2
- branch = if list === @portfolio_entries.first
3
- "branch_start"
4
- elsif list === @portfolio_entries.last or (list.parent and list === list.parent.children.last)
5
- "branch_end"
6
- end
2
+ branch = if list === @portfolio_entries.first
3
+ "branch_start"
4
+ elsif list === @portfolio_entries.last or (list.parent and list === list.parent.children.last)
5
+ "branch_end"
6
+ end
7
7
  -%>
8
8
  <li class='clearfix record<%= " #{branch}" %>' id="<%= dom_id(list) -%>">
9
9
  <div class='clearfix'>
10
10
  <span class='actions'>
11
- <% url = list.parent ? portfolio_project_url(list.parent, list) : portfolio_url(list) %>
12
- <%= link_to refinery_icon_tag('application_go.png'), url, :target => "_blank",
11
+ <% url = (::Refinery::Portfolio.multi_level? && list.parent ? portfolio_project_url(list.parent, list) : portfolio_url(list)) %>
12
+ <%= link_to refinery_icon_tag('application_go.png'), url, :target => "_blank",
13
13
  :title => "View this entry live <br/><em>(opens in a new window)</em>" %>
14
- <%= link_to refinery_icon_tag('application_edit.png'), edit_admin_portfolio_entry_path(list),
14
+ <%= link_to refinery_icon_tag('application_edit.png'), edit_admin_portfolio_entry_path(list),
15
15
  :title => "Edit this entry" %>
16
16
  <%= link_to refinery_icon_tag('arrow_up.png'),
17
- {:controller => "/admin/portfolio_entries", :action => "emancipate", :id => list.id},
17
+ emancipate_admin_portfolio_entry_url(list),
18
18
  :title => "Move this entry up one level" if list.parent.present? %>
19
- <%= link_to refinery_icon_tag('delete.png'), admin_portfolio_entry_path(list),
19
+ <%= link_to refinery_icon_tag('delete.png'), admin_portfolio_entry_path(list),
20
20
  :class => "cancel confirm-delete",
21
21
  :title => "Remove this entry forever" %>
22
22
  </span>
@@ -27,4 +27,4 @@
27
27
  <%= render :partial => 'list', :collection => children %>
28
28
  </ul>
29
29
  <% end %>
30
- </li>
30
+ </li>
@@ -1,2 +1,2 @@
1
1
  <%= render :partial => 'list', :collection => @portfolio_entries %>
2
- <%= render :partial => "/shared/admin/sortable_list", :locals => {:continue_reordering => (defined?(continue_reordering) ? continue_reordering : true)} %>
2
+ <%= render :partial => "/shared/admin/sortable_list", :locals => {:continue_reordering => (defined?(continue_reordering) ? continue_reordering : true)} %>
@@ -1 +1 @@
1
- <%= render :partial => "form" %>
1
+ <%= render :partial => "form" %>
@@ -5,27 +5,27 @@
5
5
  <%= link_to "Create New Portfolio Entry", new_admin_portfolio_entry_url, :class => "add_icon" %>
6
6
  </li>
7
7
  <% if PortfolioEntry.count > 1 %>
8
- <li>
9
- <%= link_to "Reorder Portfolio", "", :id => "reorder_action", :class => "reorder_icon" %>
10
- <%= link_to "Done Reordering Portfolio", "", :id => "reorder_action_done", :style => "display: none;", :class => "reorder_icon" %>
11
- </li>
8
+ <li>
9
+ <%= link_to "Reorder Portfolio", "", :id => "reorder_action", :class => "reorder_icon" %>
10
+ <%= link_to "Done Reordering Portfolio", "", :id => "reorder_action_done", :style => "display: none;", :class => "reorder_icon" %>
11
+ </li>
12
12
  <% end %>
13
13
  </ul>
14
14
  </div>
15
15
  <div id='records' class='tree'>
16
16
  <% if @portfolio_entries.any? %>
17
- <h2>Portfolio</h2>
18
- <ul id='sortable_list'>
19
- <%= render :partial => 'sortable_list' %>
20
- </ul>
21
- <% else %>
22
- <p>
23
- <strong>
24
- There are no portfolio entries yet.
25
- Click "Create New Portfolio Entry" to add your first portfolio entries.
26
- </strong>
27
- </p>
17
+ <h2>Portfolio</h2>
18
+ <ul id='sortable_list'>
19
+ <%= render :partial => 'sortable_list' %>
20
+ </ul>
21
+ <% else %>
22
+ <p>
23
+ <strong>
24
+ There are no portfolio entries yet.
25
+ Click "Create New Portfolio Entry" to add your first portfolio entries.
26
+ </strong>
27
+ </p>
28
28
  <% end %>
29
29
  </div>
30
- <%= render :partial => "/shared/admin/make_sortable",
31
- :locals => { :tree => RefinerySetting.find_or_set(:multi_level_portfolio, true) } if PortfolioEntry.count > 1 %>
30
+ <%= render :partial => "/shared/admin/make_sortable",
31
+ :locals => { :tree => ::Refinery::Portfolio.multi_level? } if PortfolioEntry.count > 1 %>
@@ -1 +1 @@
1
- <%= render :partial => "form" %>
1
+ <%= render :partial => "form" %>
@@ -1 +1 @@
1
- <%= image_fu @image, :portfolio, :id => "portfolio_main_image" unless @image.nil? %>
1
+ <%= image_fu @image, :portfolio, :id => "portfolio_main_image" unless @image.nil? %>
@@ -1,10 +1,10 @@
1
1
  <% content_for :title, "#{@master_entry.title} - " %>
2
2
  <% content_for :head, stylesheet_link_tag('portfolio') %>
3
3
  <div id='body_content' class='clearfix'>
4
- <div id='body_content_left' class='clearfix'>
5
- <h1><%= @master_entry.title %></h1>
6
- <p>
7
- <em><%= t(:portfolio_no_entries, :default => "We haven't entered anything in for this project yet.") %></em>
8
- </p>
9
- </div>
10
- </div>
4
+ <div id='body_content_left' class='clearfix'>
5
+ <h1><%= @master_entry.title %></h1>
6
+ <p>
7
+ <em><%= t(:portfolio_no_entries, :default => "We haven't entered anything in for this project yet.") %></em>
8
+ </p>
9
+ </div>
10
+ </div>
@@ -1,57 +1,38 @@
1
+ <% ::ActionController::Routing::Routes.reload! %>
1
2
  <% content_for :title, "#{@portfolio_entry.title} - " %>
2
3
  <% content_for :head, stylesheet_link_tag('portfolio') %>
3
4
  <div id='body_content' class='clearfix portfolio'>
4
- <div id='body_content_left' class='clearfix'>
5
- <h1 class='clearfix'>
6
- <span><%= @master_entry.title %></span>
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
- </h1>
5
+ <div id='body_content_left' class='clearfix'>
6
+ <h1 class='clearfix'>
7
+ <span><%= @master_entry.title %></span>
8
+ <% if ::Refinery::Portfolio.multi_level? %>
9
+ <%= select :portfolio_entry, :to_param, @master_entry.children.collect{|entry| [entry.title, entry.to_param] } %>
10
+ <% else %>
11
+ <%= select :portfolio_entry, :to_param, PortfolioEntry.all.collect{|entry| [entry.title, entry.to_param] } %>
12
+ <% end %>
13
+ </h1>
9
14
 
10
- <%= render :partial => "main_image" %>
11
- </div>
12
- <div id='body_content_right' class='clearfix'>
13
- <h2><%= @portfolio_entry.title %></h2>
14
- <ul id='portfolio_images'>
15
- <% @portfolio_entry.images.each_with_index do |image, index| %>
16
- <li class='<%= cycle("odd", "even") %>'>
17
- <%= link_to_portfolio_image @master_entry, @portfolio_entry, image, index %>
18
- </li>
19
- <% end %>
20
- </ul>
21
- </div>
15
+ <div id='portfolio_main_image_container'>
16
+ <%= render :partial => "main_image" %>
17
+ </div>
18
+ </div>
19
+ <div id='body_content_right' class='clearfix'>
20
+ <h2><%= @portfolio_entry.title %></h2>
21
+ <ul id='portfolio_images'>
22
+ <% @portfolio_entry.images.each_with_index do |image, index| %>
23
+ <li class='<%= cycle("odd", "even") %>'>
24
+ <%= link_to_portfolio_image @master_entry, @portfolio_entry, image, index %>
25
+ </li>
26
+ <% end %>
27
+ </ul>
28
+ </div>
22
29
  </div>
23
30
  <% content_for :head do %>
24
- <%# remove these javascript_include_tag calls if they are included in your layout.
25
- %>
26
- <%= javascript_include_tag 'jquery' %>
27
- <script type='text/javascript'>
28
- $(document).ready(function(){
29
- $("ul#portfolio_images li a.pale img").fadeTo(0, 0.3);
30
-
31
- $('#portfolio_entry_to_param').change(function() {
32
- window.location = "<%= RefinerySetting.find_or_set(:multi_level_portfolio, true) ? portfolio_project_url(@master_entry, nil) : portfolio_project_url(@master_entry) %>" + this.value;
33
- });
34
-
35
- var clicked_on = null;
36
- $("ul#portfolio_images li a").click(function(event) {
37
- if (!$(this).hasClass('selected')) {
38
- clicked_on = $(this);
39
- $.get($(this).attr('href'), function(data, textStatus) {
40
- if (textStatus == "success") {
41
- $('#portfolio_main_image').before(data).remove();
42
-
43
- $('ul#portfolio_images li a.selected').removeClass('selected').addClass('pale');
44
-
45
- clicked_on.removeClass('pale').addClass('selected');
46
- clicked_on.find('img').fadeTo(0, 1);
47
-
48
- $("ul#portfolio_images li a.pale img").fadeTo(0, 0.3);
49
- }
50
- });
51
- }
52
-
53
- return false;
54
- });
55
- });
56
- </script>
57
- <% end %>
31
+ <%# remove the jquery_include_tags call if jquery is included in your layout.
32
+ %>
33
+ <%= jquery_include_tags(:include_ui => false) %>
34
+ <%= javascript_include_tag 'portfolio' %>
35
+ <script type='text/javascript'>
36
+ var portfolio_entry_url = "<%= portfolio_project_url(@master_entry, '') if ::Refinery::Portfolio.multi_level? %>";
37
+ </script>
38
+ <% end %>
@@ -1,16 +1,11 @@
1
- ActionController::Routing::Routes.draw do |map|
2
-
3
- map.resources :portfolio do |portfolio|
4
- portfolio.resources :portfolio, :as => :portfolio
5
- end
1
+ require File.expand_path("../../lib/portfolio.rb", __FILE__)
6
2
 
7
- map.namespace(:admin) do |admin|
8
- admin.resources :portfolio_entries, :as => :portfolio, :collection => {:emancipate => :get}
9
- end
3
+ ActionController::Routing::Routes.draw do |map|
10
4
 
11
- if RefinerySetting.table_exists? and RefinerySetting.find_or_set(:multi_level_portfolio, true)
12
- map.portfolio_project "/portfolio/:id/projects/:portfolio_id", :controller => "portfolio", :action => "show"
13
- map.portfolio_image "/portfolio/:id/projects/:portfolio_id/:image_id", :controller => "portfolio", :action => "show"
5
+ # Make sure you restart your web server after changing the multi level setting.
6
+ if ::Refinery::Portfolio.multi_level?
7
+ map.portfolio_project "/portfolio/:id/projects/:portfolio_id", :controller => "portfolio", :action => "show"
8
+ map.portfolio_image "/portfolio/:id/projects/:portfolio_id/:image_id", :controller => "portfolio", :action => "show"
14
9
  else
15
10
  map.portfolio_project "/portfolio/:id", :controller => "portfolio", :action => "show"
16
11
  map.portfolio_image "/portfolio/:id/:image_id", :controller => "portfolio", :action => "show"
@@ -18,4 +13,12 @@ ActionController::Routing::Routes.draw do |map|
18
13
 
19
14
  map.portfolio "/portfolio/:id/", :controller => 'portfolio', :action => 'show'
20
15
 
21
- end
16
+ map.resources :portfolio do |portfolio|
17
+ portfolio.resources :portfolio, :as => :portfolio
18
+ end
19
+
20
+ map.namespace(:admin, :path_prefix => (defined?(REFINERY_GEM_VERSION) ? 'admin' : 'refinery')) do |admin|
21
+ admin.resources :portfolio_entries, :as => :portfolio, :member => {:emancipate => :get}, :collection => {:update_positions => :post}
22
+ end
23
+
24
+ end
@@ -0,0 +1,23 @@
1
+ class PortfolioGenerator < Rails::Generator::NamedBase
2
+
3
+ def initialize(*runtime_args)
4
+ # set first argument to the table's name so that the user doesn't have to pass it in.
5
+ runtime_args[0] = ["portfolio_entries"]
6
+ super(*runtime_args)
7
+ end
8
+
9
+ def banner
10
+ "Usage: script/generate portfolio"
11
+ end
12
+
13
+ def manifest
14
+ record do |m|
15
+ m.migration_template 'migration.rb', 'db/migrate',
16
+ :migration_file_name => "create_structure_for_portfolio",
17
+ :assigns => {
18
+ :migration_name => "CreateStructureForPortfolio"
19
+ }
20
+ end
21
+ end
22
+
23
+ end if defined?(Rails::Generator::NamedBase)
@@ -0,0 +1,52 @@
1
+ class <%= migration_name %> < ActiveRecord::Migration
2
+
3
+ def self.up
4
+ create_table :images_portfolio_entries, :id => false, :force => true do |t|
5
+ t.integer :image_id
6
+ t.integer :portfolio_entry_id
7
+ t.integer :position
8
+ end
9
+
10
+ # people should be allowed to have the same image twice, if they really want to.
11
+ add_index :images_portfolio_entries, [:image_id, :portfolio_entry_id], :name => 'composite_key_index', :unique => false
12
+
13
+ create_table :portfolio_entries, :force => true do |t|
14
+ t.string :title
15
+ t.text :body
16
+ t.integer :position
17
+ t.integer :parent_id
18
+ t.timestamps
19
+ end
20
+
21
+ add_index :portfolio_entries, :id
22
+ add_index :portfolio_entries, :parent_id
23
+
24
+ User.find(:all).each do |user|
25
+ user.plugins.create(:title => "Portfolio", :position => (user.plugins.maximum(:position) || -1) +1)
26
+ end
27
+
28
+ page = Page.create(:title => "Portfolio", :link_url => "/portfolio", :menu_match => "\/portfolio(|\/.+?)", :deletable => false, :position => ((Page.maximum(:position, :conditions => {:parent_id => nil}) || -1)+1))
29
+ RefinerySetting.find_or_set(:default_page_parts, ["Body", "Side Body"]).each do |default_page_part|
30
+ page.parts.create(:title => default_page_part, :body => nil)
31
+ end
32
+
33
+ # we need to retrieve the value, merge it in and then save it back because it's a frozen hash.
34
+ image_thumbnails = RefinerySetting.find_or_set(:image_thumbnails, {})
35
+ RefinerySetting[:image_thumbnails] = image_thumbnails.merge({:portfolio_thumb => 'c96x96', :portfolio => '600x512'})
36
+ end
37
+
38
+ def self.down
39
+ UserPlugin.destroy_all({:title => "Portfolio"})
40
+
41
+ Page.find_all_by_link_url("/portfolio").each do |page|
42
+ page.destroy!
43
+ end
44
+
45
+ image_thumbnails = RefinerySetting.find_or_set(:image_thumbnails, {}).dup
46
+ RefinerySetting[:image_thumbnails] = image_thumbnails.delete_if {|key, value| key == :portfolio_thumb or key == :portfolio }
47
+
48
+ drop_table :images_portfolio_entries
49
+ drop_table :portfolio_entries
50
+ end
51
+
52
+ end
@@ -0,0 +1,38 @@
1
+ #!/usr/bin/env ruby
2
+ require File.expand_path('../portfolio.rb', __FILE__)
3
+ version = Refinery::Portfolio::Version::STRING
4
+ raise "Could not get version so gemspec can not be built" if version.nil?
5
+ files = %w( readme.md license.md )
6
+ %w(app config generators lib public rails test vendor).each do |dir|
7
+ files += Dir.glob("#{dir}/**/*") if File.directory?(dir)
8
+ end
9
+
10
+ gemspec = <<EOF
11
+ Gem::Specification.new do |s|
12
+ s.name = %q{refinerycms-portfolio}
13
+ s.version = %q{#{version}}
14
+ s.description = %q{A really straightforward open source Ruby on Rails portfolio plugin designed for integration with RefineryCMS}
15
+ s.date = %q{#{Time.now.strftime('%Y-%m-%d')}}
16
+ s.summary = %q{Ruby on Rails portfolio plugin for RefineryCMS.}
17
+ s.email = %q{info@refinerycms.com}
18
+ s.homepage = %q{http://refinerycms.com}
19
+ s.authors = %w(Resolve\\ Digital Philip\\ Arndt)
20
+ s.require_paths = %w(lib)
21
+
22
+ s.files = [
23
+ '#{files.join("',\n '")}'
24
+ ]
25
+ #{"s.test_files = [
26
+ '#{Dir.glob("test/**/*.rb").join("',\n '")}'
27
+ ]" if File.directory?("test")}
28
+ end
29
+ EOF
30
+
31
+ if (save = ARGV.delete('-s'))
32
+ if File.exist?(file = File.expand_path("../../refinerycms-portfolio.gemspec", __FILE__))
33
+ File.delete(file)
34
+ end
35
+ File.open(file, 'w') { |f| f.puts gemspec }
36
+ else
37
+ puts gemspec
38
+ end
@@ -1 +1,21 @@
1
- # empty as yet
1
+ module Refinery
2
+ module Portfolio
3
+ class Version
4
+ MAJOR = 0
5
+ MINOR = 9
6
+ TINY = 6
7
+ BUILD = nil
8
+
9
+ STRING = [MAJOR, MINOR, TINY, BUILD].compact.join('.')
10
+ end
11
+
12
+ class << self
13
+ def multi_level?
14
+ RefinerySetting.table_exists? and RefinerySetting.find_or_set(:multi_level_portfolio, true, {
15
+ :callback_proc_as_string => %q{::ActionController::Routing::Routes.reload!},
16
+ :restricted => true
17
+ })
18
+ end
19
+ end
20
+ end
21
+ end
@@ -3,7 +3,35 @@ namespace :refinery do
3
3
  desc "Install extra files from the portfolio plugin"
4
4
 
5
5
  task :install do
6
- puts `ruby #{File.expand_path(File.dirname(__FILE__) << '/../..')}/bin/refinerycms-portfolio-install #{Rails.root.to_s}`
6
+ [%w(db migrate), %w(public stylesheets), %w(public javascripts)].each do |dir|
7
+ Rails.root.join(dir.join(File::SEPARATOR)).mkpath
8
+ end
9
+
10
+ portfolio_root = Pathname.new(File.expand_path("../../../", __FILE__))
11
+ copies = [
12
+ {:from => %w(public stylesheets), :to => %w(public stylesheets), :filename => "portfolio.css"},
13
+ {:from => %w(public javascripts), :to => %w(public javascripts), :filename => "portfolio.js"}
14
+ ]
15
+ puts "\nCopying files...\n\n"
16
+ copies.each do |copy|
17
+ copy_from = portfolio_root.join(copy[:from].join(File::SEPARATOR), copy[:filename])
18
+ copy_to = Rails.root.join(copy[:to].join(File::SEPARATOR), copy[:filename])
19
+ unless copy_to.exist? and ENV["force"].presence.to_s != "true"
20
+ FileUtils::cp copy_from.to_s, copy_to.to_s
21
+ puts "Copied to #{copy_to}"
22
+ else
23
+ puts "'#{File.join copy[:to], copy[:filename]}' already existed in your application so your existing file was not overwritten - use force=true to overwrite."
24
+ puts "Without this file being up to date, the portfolio may not function properly."
25
+ end
26
+ end
27
+
28
+ puts "\nCopied all files."
29
+ puts "\nGenerating migration..."
30
+ puts `ruby #{Rails.root.join('script', 'generate').cleanpath.to_s.gsub(/\/$/, '')} portfolio`
31
+ puts "\nNow, run these tasks:"
32
+ puts " rake db:migrate"
33
+ puts " rake images:regenerate"
34
+ puts "\nWe hope you enjoy using our portfolio plugin!\n\n"
7
35
  end
8
36
  end
9
37
  end
@@ -1,3 +1,5 @@
1
+ var portfolio_entry_url = null;
2
+
1
3
  reset_functionality = function() {
2
4
  $("#portfolio_images").sortable({
3
5
  'tolerance': 'pointer'
@@ -6,7 +8,7 @@ reset_functionality = function() {
6
8
  , 'items': 'li'
7
9
  });
8
10
 
9
- $('#portfolio_images li:not(.empty)').each(function(index, li) {
11
+ $('#content portfolio_images li:not(.empty)').each(function(index, li) {
10
12
  $(li).mouseover(function(e){
11
13
  if ((image_actions = $(this).find('.image_actions')).length == 0) {
12
14
  image_actions = $("<div class='image_actions'></div>");
@@ -44,4 +46,33 @@ image_added = function(image) {
44
46
  reset_functionality();
45
47
  }
46
48
 
47
- $(document).ready(reset_functionality);
49
+ $(document).ready(function() {
50
+ reset_functionality();
51
+
52
+ $("ul#portfolio_images li a.pale img").fadeTo(0, 0.3);
53
+
54
+ $('#portfolio_entry_to_param').change(function() {
55
+ window.location = portfolio_entry_url + this.value;
56
+ });
57
+
58
+ var clicked_on = null;
59
+ $("ul#portfolio_images li a").click(function(event) {
60
+ if (!$(this).hasClass('selected')) {
61
+ clicked_on = $(this);
62
+ $.get($(this).attr('href'), function(data, textStatus) {
63
+ if (textStatus == "success") {
64
+ $('#portfolio_main_image').before(data).remove();
65
+
66
+ $('ul#portfolio_images li a.selected').removeClass('selected').addClass('pale');
67
+
68
+ clicked_on.removeClass('pale').addClass('selected');
69
+ clicked_on.find('img').fadeTo(0, 1);
70
+
71
+ $("ul#portfolio_images li a.pale img").fadeTo(0, 0.3);
72
+ }
73
+ });
74
+ }
75
+
76
+ return false;
77
+ });
78
+ });
@@ -10,7 +10,6 @@
10
10
  }
11
11
  #body_content.portfolio #body_content_left h1 select {
12
12
  margin-left: 12px;
13
- min-width: 200px;
14
13
  float: right;
15
14
  margin-top: 3px;
16
15
  display: block;
@@ -24,9 +23,10 @@
24
23
  font-size: 15px;
25
24
  font-weight: normal;
26
25
  }
27
-
28
- #portfolio_main_image {
29
- border: 3px solid #d4cabc;
26
+ #portfolio_main_image_container {
27
+ border: 3px solid #d4cabc;
28
+ width: 100%;
29
+ text-align: center;
30
30
  }
31
31
  #portfolio_images {
32
32
  margin: 0px;
@@ -42,7 +42,6 @@
42
42
  #portfolio_images li.odd {
43
43
  margin-right: 18px;
44
44
  }
45
-
46
45
  #portfolio_images.portfolio_entry_images {
47
46
  width: 100%;
48
47
  }
@@ -65,12 +64,10 @@
65
64
  #portfolio_images.portfolio_entry_images li .image_actions * {
66
65
  cursor: pointer;
67
66
  }
68
-
69
67
  #content ul.ui-sortable li {
70
68
  border: 0px none;
71
69
  background: none !important;
72
70
  }
73
-
74
71
  #content #portfolio_images.ui-sortable li.placeholder {
75
72
  width: 135px;
76
73
  height: 135px;
@@ -1,15 +1,17 @@
1
1
  Refinery::Plugin.register do |plugin|
2
- plugin.directory = directory
3
- plugin.title = "Portfolio"
4
- plugin.description = "Manage a portfolio"
5
- plugin.url = "/admin/#{plugin.title.downcase}"
6
- plugin.version = '0.9.5.3'
7
- plugin.menu_match = /admin\/portfolio(_entries)?/
8
- plugin.activity = {
9
- :class => PortfolioEntry,
10
- :title => 'title',
11
- :url_prefix => 'edit',
12
- :created_image => "layout_add.png",
13
- :updated_image => "layout_edit.png"
14
- }
15
- end
2
+ plugin.directory = directory
3
+ plugin.title = "Portfolio"
4
+ plugin.description = "Manage a portfolio within RefineryCMS"
5
+ plugin.version = '0.9.6'
6
+ plugin.menu_match = /(admin|refinery)\/portfolio(_entries)?/
7
+ plugin.url = '/refinery/portfolio'
8
+ plugin.activity = {
9
+ :class => PortfolioEntry,
10
+ :title => 'title',
11
+ :url_prefix => 'edit',
12
+ :created_image => "layout_add.png",
13
+ :updated_image => "layout_edit.png"
14
+ }
15
+ # this tells refinery where this plugin is located on the filesystem and helps with urls.
16
+ plugin.directory = directory
17
+ end
data/readme.md CHANGED
@@ -1,49 +1,28 @@
1
- # Portfolio plugin for [RefineryCMS](http://www.refinerycms.com)
2
- [Github](http://github.com/resolve/refinerycms)
1
+ # Portfolio plugin for [RefineryCMS](http://www.refinerycms.com) ([Github](http://github.com/resolve/refinerycms))
3
2
 
4
3
  By: [Resolve Digital](http://www.resolvedigital.com)
5
4
 
6
- ## Plugin Installation
7
-
8
- Just 'git clone' Refinery, install this as a plugin using:
9
-
10
- script/plugin install git://github.com/resolve/refinerycms-portfolio.git
11
-
12
- Then run:
13
-
14
- rake refinery:portfolio:install
15
-
16
- ..and follow the instructions!
17
-
18
5
  ## Gem Installation
19
6
 
20
- ### Method One
21
- Just install the gem 'portfolio' with the command:
22
-
23
- gem install refinerycms-portfolio --source http://gemcutter.org
7
+ Open your ``Gemfile`` and add this line to the bottom:
24
8
 
25
- Then run:
9
+ gem 'refinerycms-portfolio', '= 0.9.6', :require => 'portfolio'
26
10
 
27
- refinerycms-portfolio-install /path/to/your/refinery/application
11
+ Now run ``bundle install`` and once bundler has installed the gem run:
28
12
 
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:
30
-
31
- config.gem "refinerycms-portfolio", :version => ">= 0.9.5.3", :lib => "portfolio", :source => "http://gemcutter.org"
13
+ rake refinery:portfolio:install
32
14
 
33
15
  ..and follow the instructions!
34
16
 
35
- ### Method Two
36
- Place in your config/environment.rb (or config/application.rb for refinery 0.9.6.x) file before all other Refinery gem calls:
37
-
38
- config.gem "refinerycms-portfolio", :version => ">= 0.9.5.3", :lib => "portfolio", :source => "http://gemcutter.org"
17
+ ## Plugin Installation
39
18
 
40
- Then run in your application's directory:
19
+ From within your Refinery directory at command line, install this as a plugin using:
41
20
 
42
- rake gems:install
21
+ script/plugin install git://github.com/resolve/refinerycms-portfolio.git
43
22
 
44
23
  Then run:
45
24
 
46
- refinerycms-portfolio-install /path/to/your/refinery/application
25
+ rake refinery:portfolio:install
47
26
 
48
27
  ..and follow the instructions!
49
28
 
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: refinerycms-portfolio
3
3
  version: !ruby/object:Gem::Version
4
+ hash: 55
4
5
  prerelease: false
5
6
  segments:
6
7
  - 0
7
8
  - 9
8
- - 5
9
- - 3
10
- version: 0.9.5.3
9
+ - 6
10
+ version: 0.9.6
11
11
  platform: ruby
12
12
  authors:
13
13
  - Resolve Digital
@@ -16,22 +16,21 @@ autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
18
 
19
- date: 2010-04-13 00:00:00 +12:00
20
- default_executable: refinerycms-portfolio-install
19
+ date: 2010-06-30 00:00:00 +12:00
20
+ default_executable:
21
21
  dependencies: []
22
22
 
23
- description: A really straightforward open source Ruby on Rails portfolio plugin designed for integration with RefineryCMS.
23
+ description: A really straightforward open source Ruby on Rails portfolio plugin designed for integration with RefineryCMS
24
24
  email: info@refinerycms.com
25
- executables:
26
- - refinerycms-portfolio-install
25
+ executables: []
26
+
27
27
  extensions: []
28
28
 
29
29
  extra_rdoc_files: []
30
30
 
31
31
  files:
32
- - contributors.md
33
- - license.md
34
32
  - readme.md
33
+ - license.md
35
34
  - app/controllers/admin/portfolio_entries_controller.rb
36
35
  - app/controllers/portfolio_controller.rb
37
36
  - app/helpers/portfolio_helper.rb
@@ -45,11 +44,11 @@ files:
45
44
  - app/views/portfolio/_main_image.html.erb
46
45
  - app/views/portfolio/empty.html.erb
47
46
  - app/views/portfolio/show.html.erb
48
- - bin/refinerycms-portfolio-install
49
47
  - config/locale/en.yml
50
48
  - config/routes.rb
51
- - db/migrate/20090917224823_create_portfolio_structure.rb
52
- - db/migrate/20091121033434_add_position_to_images_portfolio_entries.rb
49
+ - generators/portfolio/portfolio_generator.rb
50
+ - generators/portfolio/templates/migration.rb
51
+ - lib/gemspec.rb
53
52
  - lib/portfolio.rb
54
53
  - lib/tasks/portfolio.rake
55
54
  - public/javascripts/portfolio.js
@@ -65,23 +64,27 @@ rdoc_options: []
65
64
  require_paths:
66
65
  - lib
67
66
  required_ruby_version: !ruby/object:Gem::Requirement
67
+ none: false
68
68
  requirements:
69
69
  - - ">="
70
70
  - !ruby/object:Gem::Version
71
+ hash: 3
71
72
  segments:
72
73
  - 0
73
74
  version: "0"
74
75
  required_rubygems_version: !ruby/object:Gem::Requirement
76
+ none: false
75
77
  requirements:
76
78
  - - ">="
77
79
  - !ruby/object:Gem::Version
80
+ hash: 3
78
81
  segments:
79
82
  - 0
80
83
  version: "0"
81
84
  requirements: []
82
85
 
83
86
  rubyforge_project:
84
- rubygems_version: 1.3.6
87
+ rubygems_version: 1.3.7
85
88
  signing_key:
86
89
  specification_version: 3
87
90
  summary: Ruby on Rails portfolio plugin for RefineryCMS.
@@ -1,39 +0,0 @@
1
- #!/usr/bin/env ruby
2
- require 'pathname'
3
- require 'fileutils'
4
-
5
- portfolio_root = Pathname.new(File.expand_path(File.dirname(__FILE__) << "/.."))
6
- rails_root = if defined?(Rails.root)
7
- Rails.root
8
- elsif defined?(RAILS_ROOT)
9
- Pathname.new(RAILS_ROOT)
10
- else
11
- Pathname.new(ARGV.first)
12
- end
13
- if rails_root.exist?
14
- [%w(db migrate), %w(public stylesheets), %w(public javascripts)].each do |dir|
15
- rails_root.join(dir.join(File::SEPARATOR)).mkpath
16
- end
17
-
18
- copies = [
19
- {:from => %w(db migrate), :to => %w(db migrate), :filename => "20090917224823_create_portfolio_structure.rb"},
20
- {:from => %w(db migrate),:to => %w(db migrate), :filename => "20091121033434_add_position_to_images_portfolio_entries.rb"},
21
- {:from => %w(public stylesheets), :to => %w(public stylesheets), :filename => "portfolio.css"},
22
- {:from => %w(public javascripts), :to => %w(public javascripts), :filename => "portfolio.js"}
23
- ]
24
- copies.each do |copy|
25
- copy_from = portfolio_root.join(copy[:from].join(File::SEPARATOR), copy[:filename])
26
- copy_to = rails_root.join(copy[:to].join(File::SEPARATOR), copy[:filename])
27
- unless copy_to.exist?
28
- FileUtils::copy_file copy_from.to_s, copy_to.to_s
29
- else
30
- puts "'#{File.join copy[:to], copy[:filename]}' already existed in your application so your existing file was not overwritten."
31
- end
32
- end
33
-
34
- puts "---------"
35
- puts "Copied all refinerycms-portfolio files."
36
- puts "Now, run rake db:migrate and then rake images:regenerate"
37
- else
38
- puts "Please specify the path of the project that you want to use the portfolio with, i.e. refinerycms-portfolio-install /path/to/project"
39
- end
@@ -1,4 +0,0 @@
1
- # Contributors
2
-
3
- ## Major
4
- * parndt - Philip Arndt, [Resolve Digital](http://www.resolvedigital.co.nz)
@@ -1,49 +0,0 @@
1
- class CreatePortfolioStructure < ActiveRecord::Migration
2
- def self.up
3
- create_table :images_portfolio_entries, :id => false, :force => true do |t|
4
- t.integer :image_id
5
- t.integer :portfolio_entry_id
6
- end
7
-
8
- # people should be allowed to have the same image twice, if they really want to.
9
- #add_index :images_portfolio_entries, [:image_id, :portfolio_entry_id], :name => :composite_key_index, :unique => true
10
-
11
- create_table :portfolio_entries, :force => true do |t|
12
- t.string :title
13
- t.text :body
14
- t.integer :position
15
- t.integer :parent_id
16
- t.datetime :created_at
17
- t.datetime :updated_at
18
- end
19
-
20
- User.find(:all).each do |user|
21
- user.plugins.create(:title => "Portfolio", :position => (user.plugins.maximum(:position) || -1) +1)
22
- end
23
-
24
- page = Page.create(:title => "Portfolio", :link_url => "/portfolio", :deletable => false, :position => ((Page.maximum(:position, :conditions => "parent_id IS NULL") || -1)+1))
25
- RefinerySetting.find_or_set(:default_page_parts, ["body", "side_body"]).each do |default_page_part|
26
- page.parts.create(:title => default_page_part, :body => nil)
27
- end
28
-
29
- # we need to retrieve the value, merge it in and then save it back because it's a frozen hash.
30
- image_thumbnails = RefinerySetting.find_or_set(:image_thumbnails, {})
31
- RefinerySetting[:image_thumbnails] = image_thumbnails.merge({:portfolio_thumb => 'c96x96', :portfolio => '600x512'})
32
- end
33
-
34
- def self.down
35
- UserPlugin.destroy_all({:title => "Portfolio"})
36
-
37
- Page.find_all_by_link_url("/portfolio").each do |page|
38
- page.link_url, page.menu_match, page.deletable = nil
39
- page.destroy
40
- end
41
- Page.destroy_all({:link_url => "/portfolio"})
42
-
43
- image_thumbnails = RefinerySetting.find_or_set(:image_thumbnails, {})
44
- RefinerySetting[:image_thumbnails] = image_thumbnails.delete_if {|key, value| key == :portfolio_thumb or key == :portfolio }
45
-
46
- drop_table :images_portfolio_entries
47
- drop_table :portfolio_entries
48
- end
49
- end
@@ -1,9 +0,0 @@
1
- class AddPositionToImagesPortfolioEntries < ActiveRecord::Migration
2
- def self.up
3
- add_column :images_portfolio_entries, :position, :integer
4
- end
5
-
6
- def self.down
7
- remove_column :images_portfolio_entries, :position
8
- end
9
- end