refinerycms-portfolio 0.9.7 → 0.9.8.rc1

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.
Files changed (33) hide show
  1. data/app/controllers/admin/portfolio_controller.rb +13 -0
  2. data/app/controllers/portfolio_controller.rb +24 -15
  3. data/app/helpers/portfolio_helper.rb +2 -3
  4. data/app/models/portfolio_entry.rb +6 -14
  5. data/app/views/admin/{portfolio_entries → portfolio}/_form.html.erb +17 -8
  6. data/app/views/admin/{portfolio_entries → portfolio}/_list.html.erb +0 -0
  7. data/app/views/admin/{portfolio_entries → portfolio}/_sortable_list.html.erb +0 -0
  8. data/app/views/admin/{portfolio_entries → portfolio}/edit.html.erb +0 -0
  9. data/app/views/admin/{portfolio_entries → portfolio}/index.html.erb +0 -0
  10. data/app/views/admin/{portfolio_entries → portfolio}/new.html.erb +0 -0
  11. data/app/views/portfolio/_main_image.html.erb +1 -1
  12. data/app/views/portfolio/empty.html.erb +9 -8
  13. data/app/views/portfolio/show.html.erb +30 -26
  14. data/config/locales/en.yml +5 -1
  15. data/config/locales/pt-BR.yml +25 -0
  16. data/config/locales/sl.yml +1 -1
  17. data/config/routes.rb +26 -12
  18. data/lib/gemspec.rb +4 -2
  19. data/lib/generators/portfolio/portfolio_generator.rb +59 -0
  20. data/lib/generators/portfolio/templates/db/migrate/migration_number_create_structure_for_portfolio.rb +42 -0
  21. data/lib/generators/portfolio/templates/db/seeds/portfolio.rb +30 -0
  22. data/lib/portfolio.rb +4 -22
  23. data/lib/portfolio/version.rb +7 -0
  24. data/lib/refinerycms-portfolio.rb +34 -0
  25. data/public/javascripts/portfolio.js +5 -4
  26. data/public/stylesheets/portfolio.css +8 -7
  27. data/readme.md +8 -16
  28. metadata +42 -22
  29. data/app/controllers/admin/portfolio_entries_controller.rb +0 -32
  30. data/generators/portfolio/portfolio_generator.rb +0 -23
  31. data/generators/portfolio/templates/migration.rb +0 -52
  32. data/lib/tasks/portfolio.rake +0 -37
  33. data/rails/init.rb +0 -17
@@ -0,0 +1,13 @@
1
+ class Admin::PortfolioController < Admin::BaseController
2
+
3
+ crudify :portfolio_entry, :order => 'lft ASC', :conditions => "parent_id IS NULL", :sortable => true
4
+
5
+ def emancipate
6
+ if (entry = PortfolioEntry.find(params[:id])).present?
7
+ entry.update_attribute(:parent_id, (entry.parent.present? ? entry.parent.parent_id : nil))
8
+ end
9
+
10
+ redirect_to :action => "index"
11
+ end
12
+
13
+ end
@@ -3,33 +3,28 @@ class PortfolioController < ApplicationController
3
3
  before_filter :load_page, :only => [:index, :show, :empty]
4
4
 
5
5
  def index
6
- redirect_to portfolio_url(PortfolioEntry.find_by_parent_id(nil, :order => "position ASC")) rescue error_404
6
+ if (first_entry = PortfolioEntry.where(:parent_id => nil).first).present?
7
+ redirect_to portfolio_url(first_entry)
8
+ end
7
9
  end
8
10
 
9
11
  def show
10
12
  begin
11
- if params[:id]
12
- @master_entry = PortfolioEntry.find(params[:id])
13
+ @master_entry = if params[:id]
14
+ PortfolioEntry.find(params[:id])
13
15
  else
14
- @master_entry = PortfolioEntry.find_by_parent_id(nil, :order => "position ASC")
16
+ PortfolioEntry.where(:parent_id => nil).first
15
17
  end
16
18
 
17
19
  if ::Refinery::Portfolio.multi_level?
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
20
+ multi_level
23
21
  else
24
- @portfolio_entry = @master_entry
22
+ single_level
25
23
  end
26
24
 
27
25
  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
26
+ image_index = (params[:image_id].presence || '0').to_i
27
+ @image = @portfolio_entry.images[image_index]
33
28
  rescue
34
29
  render :action => "empty"
35
30
  end
@@ -42,6 +37,20 @@ class PortfolioController < ApplicationController
42
37
 
43
38
  protected
44
39
 
40
+ def multi_level
41
+ @portfolio_entries = @master_entry.children
42
+ @portfolio_entry = if params[:portfolio_id]
43
+ @portfolio_entries.find(params[:portfolio_id])
44
+ else
45
+ @portfolio_entries.first
46
+ end
47
+ end
48
+
49
+ def single_level
50
+ @portfolio_entries = PortfolioEntry.all
51
+ @portfolio_entry = @master_entry
52
+ end
53
+
45
54
  def load_page
46
55
  @page = Page.find_by_link_url('/portfolio', :include => [:parts])
47
56
  end
@@ -9,9 +9,8 @@ module PortfolioHelper
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, '96x96#c'),
13
+ portfolio_image_link(master, portfolio, index))
15
14
  end
16
15
 
17
16
  end
@@ -4,25 +4,17 @@ class PortfolioEntry < ActiveRecord::Base
4
4
 
5
5
  # call to gems included in refinery.
6
6
  has_friendly_id :title, :use_slug => true
7
- acts_as_tree :order => "position"
7
+ acts_as_nested_set
8
+ default_scope :order => 'lft ASC'
8
9
 
9
10
  has_and_belongs_to_many :images
10
11
 
11
- def content
12
- self.body
13
- end
14
-
15
- def content=(value)
16
- self.body = value
17
- end
12
+ alias_attribute :content, :body
18
13
 
19
14
  def image_ids=(ids)
20
- self.images.clear
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
15
+ self.images = ids.reject{|id| id.blank?}.collect {|image_id|
16
+ Image.find(image_id.to_i) rescue nil
17
+ }.compact
26
18
  end
27
19
 
28
20
  def indented_title
@@ -3,8 +3,12 @@
3
3
  <%= javascript_include_tag 'portfolio' %>
4
4
  <% end %>
5
5
 
6
- <%= error_messages_for :portfolio_entry %>
7
- <% form_for [:admin, @portfolio_entry] do |f| %>
6
+ <%= form_for([:admin, @portfolio_entry]) do |f| %>
7
+ <%= render :partial => "/shared/admin/error_messages",
8
+ :locals => {
9
+ :object => f.object,
10
+ :include_object_name => true
11
+ } %>
8
12
  <div class='field'>
9
13
  <%= f.required_label t('.title') %>
10
14
  <%= f.text_field :title, :class => "larger widest" %>
@@ -12,15 +16,20 @@
12
16
  <div class='field images_field'>
13
17
  <span class='clearfix label_inline_with_link'>
14
18
  <%= label_tag('portfolio_entry_image_ids', t('.images')) %>
15
- <%= link_to "#{refinery_icon_tag "add.png"} #{t('.add')}",
16
- insert_admin_images_url(:dialog => true, :width => 950, :height => 510, :callback => "image_added"),
19
+ <%= link_to "#{refinery_icon_tag "add.png"} #{t('.add')}".html_safe,
20
+ insert_admin_images_url(
21
+ :dialog => true,
22
+ :width => 866,
23
+ :height => 510,
24
+ :callback => "image_added"
25
+ ),
17
26
  :name => t('.add_another_image'),
18
27
  :id => "add_image_link" %>
19
28
  </span>
20
29
  <ul id='portfolio_images' class='clearfix portfolio_entry_images'>
21
30
  <% @portfolio_entry.images.each do |image| %>
22
31
  <li id='image_<%= image.id %>'>
23
- <%= image_fu image, :grid %>
32
+ <%= image_fu image, '135x135#c' %>
24
33
  <%= hidden_field_tag 'portfolio_entry[image_ids][]', image.id,
25
34
  :id => "portfolio_entry_image_id_#{image.id}" %>
26
35
  </li>
@@ -31,14 +40,14 @@
31
40
  </li>
32
41
  </ul>
33
42
  </div>
34
- <div class='field clearfix'>
43
+ <div id='portfolio_body' class='field clearfix'>
35
44
  <%= f.label :body, t('.content') %>
36
45
  <%= f.text_area :body, :class => "wymeditor widest", :rows => 7 %>
37
46
  </div>
38
- <% if @portfolio_entries_for_parents_list.any? %>
47
+ <% if (nested_portfolios = nested_set_options(PortfolioEntry, @portfolio_entry) {|i| "#{'-' * i.level} #{i.title}" }).present? %>
39
48
  <div class='field'>
40
49
  <%= f.label t('.parent') %>
41
- <%= f.collection_select :parent_id, @portfolio_entries_for_parents_list, :id, :indented_title, :include_blank => true %>
50
+ <%= f.select :parent_id, nested_portfolios, :include_blank => true %>
42
51
  </div>
43
52
  <% end %>
44
53
 
@@ -1 +1 @@
1
- <%= image_fu @image, :portfolio, :id => "portfolio_main_image" unless @image.nil? %>
1
+ <%= image_fu @image, '600x512', :id => "portfolio_main_image" unless @image.nil? %>
@@ -1,10 +1,11 @@
1
1
  <% content_for :title, "#{@master_entry.title} - " %>
2
2
  <% content_for :head, stylesheet_link_tag('portfolio') %>
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>
3
+
4
+ <% content_for :body_content_title, @master_entry.title %>
5
+ <% content_for :body_content_left do %>
6
+ <p>
7
+ <em><%= t(:portfolio_no_entries, :default => "We haven't entered anything in for this project yet.") %></em>
8
+ </p>
9
+ <% end %>
10
+
11
+ <%= render :partial => "/shared/content_page" %>
@@ -1,33 +1,37 @@
1
- <% ::ActionController::Routing::Routes.reload! %>
2
- <% content_for :title, "#{@portfolio_entry.title} - " %>
3
- <% content_for :head, stylesheet_link_tag('portfolio') %>
4
- <div id='body_content' class='clearfix portfolio'>
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>
1
+ <% content_for :title, @portfolio_entry.title %>
14
2
 
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>
3
+ <% content_for :body_content_title do %>
4
+ <span><%= @master_entry.title %></span>
5
+
6
+ <%= select(:portfolio_entry, :to_param,
7
+ @portfolio_entries.collect{|entry|
8
+ [entry.title, entry.to_param]
9
+ }) if @portfolio_entries.many? %>
10
+ <% end %>
11
+
12
+ <% content_for :body_content_left do %>
13
+ <div id='portfolio_main_image_container'>
14
+ <%= render :partial => "main_image" %>
28
15
  </div>
16
+ <% end %>
17
+
18
+ <% content_for :body_content_right do %>
19
+ <h2><%= @portfolio_entry.title %></h2>
20
+ <ul id='portfolio_images'>
21
+ <% @portfolio_entry.images.each_with_index do |image, index| %>
22
+ <li class="<%= cycle('odd', 'even') %> #{index == params[:image_id].to_i) ? 'selected' : 'other'}">
23
+ <%= link_to_portfolio_image(@master_entry, @portfolio_entry, image, index) %>
24
+ </li>
25
+ <% end %>
26
+ </ul>
27
+ <% end %>
28
+
29
+ <div class='portfolio'>
30
+ <%= render :partial => "/shared/content_page" %>
29
31
  </div>
32
+
30
33
  <% content_for :head do %>
34
+ <%= stylesheet_link_tag('portfolio') %>
31
35
  <%# remove the jquery_include_tags call if jquery is included in your layout.
32
36
  %>
33
37
  <%= jquery_include_tags(:include_ui => false) %>
@@ -1,6 +1,10 @@
1
1
  en:
2
+ plugins:
3
+ portfolio:
4
+ title: Portfolio
5
+ description: Manage a portfolio within RefineryCMS
2
6
  admin:
3
- portfolio_entries:
7
+ portfolio:
4
8
  index:
5
9
  actions: Actions
6
10
  create_new_portfolio_entry: "Create New Portfolio Entry"
@@ -0,0 +1,25 @@
1
+ pt-BR:
2
+ plugins:
3
+ portfolio:
4
+ title: Pasta
5
+ admin:
6
+ portfolio:
7
+ index:
8
+ actions: Ações
9
+ create_new_portfolio_entry: "Criar novo Portfólio"
10
+ reorder_portfolio: "Reordenar Portfólio"
11
+ reorder_portfolio_done: "Finalizar reordenação do Portfólio"
12
+ portfolio: Portfólio
13
+ no_portfolio_entries_yet: 'Não há portfólios cadastrados. Clique em "Criar novo Portfólio" para cadastrar seu primeiro portfólio.'
14
+ list:
15
+ view_live: "Ver este portfólio no site<br/><em>(abrirá em uma nova janela)</em>"
16
+ edit_this_entry: "Alterar este portfólio"
17
+ move_this_entry_up: "Mover este portfólio um nível acima"
18
+ confirm_delete_entry_title: "Remover este portfólio para sempre"
19
+ form:
20
+ title: Título
21
+ images: Imagens
22
+ add: Adicionar
23
+ add_another_image: "Adicionar outra Imagem"
24
+ content: Conteúdo
25
+ parent: Pai
@@ -3,7 +3,7 @@ sl:
3
3
  portfolio:
4
4
  title: Portfelja
5
5
  admin:
6
- portfolio_entries:
6
+ portfolio:
7
7
  index:
8
8
  actions: Dejavnosti
9
9
  create_new_portfolio_entry: "Ustvari Novo Portfelje"
data/config/routes.rb CHANGED
@@ -1,24 +1,38 @@
1
1
  require File.expand_path("../../lib/portfolio.rb", __FILE__)
2
2
 
3
- ActionController::Routing::Routes.draw do |map|
3
+ Refinery::Application.routes.draw do
4
+ match '/portfolio', :as => 'portfolio', :to => 'portfolio#index'
4
5
 
5
6
  # Make sure you restart your web server after changing the multi level setting.
6
7
  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"
9
- else
10
- map.portfolio_project "/portfolio/:id", :controller => "portfolio", :action => "show"
11
- map.portfolio_image "/portfolio/:id/:image_id", :controller => "portfolio", :action => "show"
12
- end
8
+ match "/portfolio/:id/projects/:portfolio_id/:image_id",
9
+ :as => :portfolio_image,
10
+ :to => "portfolio#show"
13
11
 
14
- map.portfolio "/portfolio/:id/", :controller => 'portfolio', :action => 'show'
12
+ match "/portfolio/:id/projects/:portfolio_id",
13
+ :as => :portfolio_project,
14
+ :to => "portfolio#show"
15
+ else
16
+ match "/portfolio/:id/:image_id",
17
+ :as => :portfolio_image,
18
+ :to => "portfolio#show"
15
19
 
16
- map.resources :portfolio do |portfolio|
17
- portfolio.resources :portfolio, :as => :portfolio
20
+ match "/portfolio/:id",
21
+ :as => :portfolio_project,
22
+ :to => "portfolio#show"
18
23
  end
19
24
 
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}
25
+ match '/portfolio/:id', :as => 'portfolio', :to => 'portfolio#show'
26
+
27
+ scope(:path => 'refinery', :as => 'admin', :module => 'admin') do
28
+ resources :portfolio, :as => :portfolio_entries do
29
+ member do
30
+ get :emancipate
31
+ end
32
+ collection do
33
+ post :update_positions
34
+ end
35
+ end
22
36
  end
23
37
 
24
38
  end
data/lib/gemspec.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
- require File.expand_path('../portfolio.rb', __FILE__)
2
+ require File.expand_path('../portfolio/version.rb', __FILE__)
3
3
  version = Refinery::Portfolio.version
4
4
  raise "Could not get version so gemspec can not be built" if version.nil?
5
5
  files = %w( readme.md license.md )
@@ -16,9 +16,11 @@ Gem::Specification.new do |s|
16
16
  s.summary = %q{Ruby on Rails portfolio plugin for RefineryCMS.}
17
17
  s.email = %q{info@refinerycms.com}
18
18
  s.homepage = %q{http://refinerycms.com}
19
- s.authors = %w(Resolve\\ Digital)
19
+ s.authors = ['Resolve Digital']
20
20
  s.require_paths = %w(lib)
21
21
 
22
+ s.add_dependency 'refinerycms', '>= 0.9.8'
23
+
22
24
  s.files = [
23
25
  '#{files.join("',\n '")}'
24
26
  ]
@@ -0,0 +1,59 @@
1
+ require 'rails/generators/migration'
2
+
3
+ class PortfolioGenerator < Rails::Generators::NamedBase
4
+
5
+ include Rails::Generators::Migration
6
+
7
+ source_root File.expand_path('../templates', __FILE__)
8
+ argument :name, :type => :string, :default => 'portfolio'
9
+
10
+ def generate
11
+ Dir.glob(File.expand_path('../templates/**/**', __FILE__)).each do |path|
12
+ template path, plugin_path_for(path) unless File.directory?(path)
13
+ end
14
+ end
15
+
16
+ protected
17
+
18
+ def plugin_path_for(path)
19
+ path = path.gsub(File.dirname(__FILE__) + "/templates/", "vendor/engines/#{plural_name}/")
20
+ path = path.gsub("plural_name", plural_name)
21
+ path = path.gsub("singular_name", singular_name)
22
+ path = path.gsub(".migration", '')
23
+
24
+ # hack can be removed after issue is fixed
25
+ next_migration_number = ActiveRecord::Generators::Base.next_migration_number(File.dirname(__FILE__))
26
+ path = path.gsub("migration_number", next_migration_number)
27
+
28
+ # replace our local db path with the app one instead.
29
+ path = path.gsub("/db/", "/../../../db/")
30
+ end
31
+
32
+ end
33
+
34
+ # Below is a hack until this issue:
35
+ # https://rails.lighthouseapp.com/projects/8994/tickets/3820-make-railsgeneratorsmigrationnext_migration_number-method-a-class-method-so-it-possible-to-use-it-in-custom-generators
36
+ # is fixed on the Rails project.
37
+
38
+ require 'rails/generators/named_base'
39
+ require 'rails/generators/migration'
40
+ require 'rails/generators/active_model'
41
+ require 'active_record'
42
+
43
+ module ActiveRecord
44
+ module Generators
45
+ class Base < Rails::Generators::NamedBase #:nodoc:
46
+ include Rails::Generators::Migration
47
+
48
+ # Implement the required interface for Rails::Generators::Migration.
49
+ def self.next_migration_number(dirname) #:nodoc:
50
+ next_migration_number = current_migration_number(dirname) + 1
51
+ if ActiveRecord::Base.timestamped_migrations
52
+ [Time.now.utc.strftime("%Y%m%d%H%M%S"), "%.14d" % next_migration_number].max
53
+ else
54
+ "%.3d" % next_migration_number
55
+ end
56
+ end
57
+ end
58
+ end
59
+ end
@@ -0,0 +1,42 @@
1
+ class CreateStructureForPortfolio < 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 :parent_id
17
+ t.integer :lft
18
+ t.integer :rgt
19
+ t.integer :depth
20
+ t.timestamps
21
+ end
22
+
23
+ add_index :portfolio_entries, :id
24
+ add_index :portfolio_entries, :parent_id
25
+ add_index :portfolio_entries, :lft
26
+ add_index :portfolio_entries, :rgt
27
+
28
+ load(Rails.root.join('db', 'seeds', 'portfolio.rb'))
29
+ end
30
+
31
+ def self.down
32
+ UserPlugin.destroy_all({:name => "portfolio"})
33
+
34
+ Page.find_all_by_link_url("/portfolio").each do |page|
35
+ page.destroy!
36
+ end
37
+
38
+ drop_table :images_portfolio_entries
39
+ drop_table :portfolio_entries
40
+ end
41
+
42
+ end
@@ -0,0 +1,30 @@
1
+ User.find(:all).each do |user|
2
+ user.plugins.create({
3
+ :name => "portfolio",
4
+ :position => (user.plugins.maximum(:position) || -1) +1
5
+ })
6
+ end
7
+
8
+ page = Page.create({
9
+ :title => "Portfolio",
10
+ :link_url => "/portfolio",
11
+ :menu_match => "\/portfolio(|\/.+?)",
12
+ :deletable => false,
13
+ :position => ((Page.maximum(:position, :conditions => {:parent_id => nil}) || -1)+1)
14
+ })
15
+ Page.default_parts.each do |default_page_part|
16
+ page.parts.create(:title => default_page_part, :body => nil)
17
+ end
18
+
19
+ # we need to retrieve the value, merge it in and then save it back because it's a frozen hash.
20
+ image_thumbnails = RefinerySetting.find_or_set(:image_thumbnails, {}).dup
21
+ new_thumbnails = image_thumbnails.merge({
22
+ :portfolio_thumb => '96x96#c',
23
+ :portfolio => '600x512'
24
+ })
25
+ # handles a change in Refinery API
26
+ if RefinerySetting.methods.map(&:to_sym).include?(:set)
27
+ RefinerySetting.set(:image_thumbnails, new_thumbnails)
28
+ else
29
+ RefinerySetting[:image_thumbnails] = new_thumbnails
30
+ end
data/lib/portfolio.rb CHANGED
@@ -1,23 +1,5 @@
1
- module Refinery
2
- module Portfolio
1
+ require 'portfolio/version'
3
2
 
4
- def self.version
5
- ::Refinery::Portfolio::Version.to_s
6
- end
7
-
8
- class Version
9
- def self.to_s
10
- %q{0.9.7}
11
- end
12
- end
13
-
14
- class << self
15
- def multi_level?
16
- RefinerySetting.table_exists? and RefinerySetting.find_or_set(:multi_level_portfolio, true, {
17
- :callback_proc_as_string => %q{::ActionController::Routing::Routes.reload!},
18
- :restricted => true
19
- })
20
- end
21
- end
22
- end
23
- end
3
+ unless defined?(::Refinery::Portfolio::Engine)
4
+ require File.expand_path('../refinerycms-portfolio.rb', __FILE__)
5
+ end
@@ -0,0 +1,7 @@
1
+ module Refinery
2
+ module Portfolio
3
+ def self.version
4
+ %q{0.9.8.rc1}
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,34 @@
1
+ require 'refinery'
2
+
3
+ module Refinery
4
+ module Portfolio
5
+
6
+ class << self
7
+ def multi_level?
8
+ RefinerySetting.table_exists? and RefinerySetting.find_or_set(:multi_level_portfolio, false, {
9
+ :callback_proc_as_string => %q{::ActionController::Routing::Routes.reload!},
10
+ :restricted => true
11
+ })
12
+ end
13
+ end
14
+
15
+ class Engine < Rails::Engine
16
+ initializer "static assets" do |app|
17
+ app.middleware.insert_after ::ActionDispatch::Static, ::ActionDispatch::Static, "#{root}/public"
18
+ end
19
+
20
+ config.after_initialize do
21
+ Refinery::Plugin.register do |plugin|
22
+ plugin.name = "portfolio"
23
+ plugin.version = ::Refinery::Portfolio.version
24
+ plugin.menu_match = /admin\/portfolio(_entries)?/
25
+ plugin.activity = {
26
+ :class => PortfolioEntry
27
+ }
28
+ end unless Refinery::Plugins.registered.names.include?('portfolio')
29
+ end
30
+ end
31
+ end
32
+ end
33
+
34
+ require File.expand_path('../portfolio', __FILE__)
@@ -45,9 +45,10 @@ image_added = function(image) {
45
45
  }
46
46
 
47
47
  $(document).ready(function() {
48
+ $('h1#body_content_page_title').addClass('clearfix');
48
49
  reset_functionality();
49
50
 
50
- $("ul#portfolio_images li a.pale img").fadeTo(0, 0.3);
51
+ $("ul#portfolio_images li.other a img").fadeTo(0, 0.3);
51
52
 
52
53
  $('#portfolio_entry_to_param').change(function() {
53
54
  window.location = portfolio_entry_url + this.value;
@@ -61,12 +62,12 @@ $(document).ready(function() {
61
62
  if (textStatus == "success") {
62
63
  $('#portfolio_main_image').before(data).remove();
63
64
 
64
- $('ul#portfolio_images li a.selected').removeClass('selected').addClass('pale');
65
+ $('ul#portfolio_images li.selected').removeClass('selected').addClass('other');
65
66
 
66
- clicked_on.removeClass('pale').addClass('selected');
67
+ clicked_on.parent().removeClass('other').addClass('selected');
67
68
  clicked_on.find('img').fadeTo(0, 1);
68
69
 
69
- $("ul#portfolio_images li a.pale img").fadeTo(0, 0.3);
70
+ $("ul#portfolio_images li.other a img").fadeTo(0, 0.3);
70
71
  }
71
72
  });
72
73
  }
@@ -1,26 +1,27 @@
1
- #body_content.portfolio #body_content_left {
1
+ .portfolio #body_content #body_content_left {
2
2
  width: 621px;
3
3
  margin-right: 39px;
4
4
  }
5
- #body_content.portfolio #body_content_left h1 {
5
+ .portfolio #body_content h1#body_content_page_title {
6
6
  margin-bottom: 24px;
7
+ width: 621px;
7
8
  }
8
- #body_content.portfolio #body_content_left h1 span {
9
+ .portfolio #body_content h1#body_content_page_title span {
9
10
  float: left;
10
11
  }
11
- #body_content.portfolio #body_content_left h1 select {
12
+ .portfolio #body_content h1#body_content_page_title select {
12
13
  margin-left: 12px;
13
14
  float: right;
14
15
  margin-top: 3px;
15
16
  display: block;
16
17
  }
17
- #body_content.portfolio #body_content_right {
18
+ .portfolio #body_content #body_content_right {
18
19
  width: 280px;
19
20
  text-align: left;
20
- padding-top: 43px;
21
21
  }
22
- #body_content.portfolio #body_content_right h2, #body_content.portfolio #body_content_right {
22
+ .portfolio #body_content #body_content_right h2, .portfolio #body_content #body_content_right {
23
23
  font-size: 15px;
24
+ margin-top: 0px;
24
25
  font-weight: normal;
25
26
  }
26
27
  #portfolio_main_image_container {
data/readme.md CHANGED
@@ -6,26 +6,18 @@ By: [Resolve Digital](http://www.resolvedigital.com)
6
6
 
7
7
  Open your ``Gemfile`` and add this line to the bottom:
8
8
 
9
- gem 'refinerycms-portfolio', '= 0.9.6', :require => 'portfolio'
9
+ gem 'refinerycms-portfolio', '>= 0.9.8.rc1'
10
10
 
11
11
  Now run ``bundle install`` and once bundler has installed the gem run:
12
12
 
13
- rake refinery:portfolio:install
13
+ rails generate portfolio
14
+ rake db:migrate
14
15
 
15
- ..and follow the instructions!
16
-
17
- ## Plugin Installation
18
-
19
- From within your Refinery directory at command line, install this as a plugin using:
20
-
21
- script/plugin install git://github.com/resolve/refinerycms-portfolio.git
22
-
23
- Then run:
24
-
25
- rake refinery:portfolio:install
26
-
27
- ..and follow the instructions!
16
+ Now, restart your web server and enjoy.
28
17
 
29
18
  ## Single or Multiple Level Portfolios
30
19
 
31
- 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.
20
+ The standard setup for portfolios is single-level.
21
+ If you need a multi-level portfolio where you have "categories" of portfolio
22
+ items you can switch to a multi level setup by changing the Refinery Setting for
23
+ ``Multi Level Portfolio`` to true.
metadata CHANGED
@@ -1,13 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: refinerycms-portfolio
3
3
  version: !ruby/object:Gem::Version
4
- hash: 53
5
- prerelease: false
4
+ hash: 977940518
5
+ prerelease: true
6
6
  segments:
7
7
  - 0
8
8
  - 9
9
- - 7
10
- version: 0.9.7
9
+ - 8
10
+ - rc1
11
+ version: 0.9.8.rc1
11
12
  platform: ruby
12
13
  authors:
13
14
  - Resolve Digital
@@ -15,10 +16,25 @@ autorequire:
15
16
  bindir: bin
16
17
  cert_chain: []
17
18
 
18
- date: 2010-07-09 00:00:00 +12:00
19
+ date: 2010-09-20 00:00:00 +12:00
19
20
  default_executable:
20
- dependencies: []
21
-
21
+ dependencies:
22
+ - !ruby/object:Gem::Dependency
23
+ name: refinerycms
24
+ prerelease: false
25
+ requirement: &id001 !ruby/object:Gem::Requirement
26
+ none: false
27
+ requirements:
28
+ - - ">="
29
+ - !ruby/object:Gem::Version
30
+ hash: 43
31
+ segments:
32
+ - 0
33
+ - 9
34
+ - 8
35
+ version: 0.9.8
36
+ type: :runtime
37
+ version_requirements: *id001
22
38
  description: A really straightforward open source Ruby on Rails portfolio plugin designed for integration with RefineryCMS
23
39
  email: info@refinerycms.com
24
40
  executables: []
@@ -30,30 +46,32 @@ extra_rdoc_files: []
30
46
  files:
31
47
  - readme.md
32
48
  - license.md
33
- - app/controllers/admin/portfolio_entries_controller.rb
49
+ - app/controllers/admin/portfolio_controller.rb
34
50
  - app/controllers/portfolio_controller.rb
35
51
  - app/helpers/portfolio_helper.rb
36
52
  - app/models/portfolio_entry.rb
37
- - app/views/admin/portfolio_entries/_form.html.erb
38
- - app/views/admin/portfolio_entries/_list.html.erb
39
- - app/views/admin/portfolio_entries/_sortable_list.html.erb
40
- - app/views/admin/portfolio_entries/edit.html.erb
41
- - app/views/admin/portfolio_entries/index.html.erb
42
- - app/views/admin/portfolio_entries/new.html.erb
53
+ - app/views/admin/portfolio/_form.html.erb
54
+ - app/views/admin/portfolio/_list.html.erb
55
+ - app/views/admin/portfolio/_sortable_list.html.erb
56
+ - app/views/admin/portfolio/edit.html.erb
57
+ - app/views/admin/portfolio/index.html.erb
58
+ - app/views/admin/portfolio/new.html.erb
43
59
  - app/views/portfolio/_main_image.html.erb
44
60
  - app/views/portfolio/empty.html.erb
45
61
  - app/views/portfolio/show.html.erb
46
62
  - config/locales/en.yml
63
+ - config/locales/pt-BR.yml
47
64
  - config/locales/sl.yml
48
65
  - config/routes.rb
49
- - generators/portfolio/portfolio_generator.rb
50
- - generators/portfolio/templates/migration.rb
51
66
  - lib/gemspec.rb
67
+ - lib/generators/portfolio/portfolio_generator.rb
68
+ - lib/generators/portfolio/templates/db/migrate/migration_number_create_structure_for_portfolio.rb
69
+ - lib/generators/portfolio/templates/db/seeds/portfolio.rb
70
+ - lib/portfolio/version.rb
52
71
  - lib/portfolio.rb
53
- - lib/tasks/portfolio.rake
72
+ - lib/refinerycms-portfolio.rb
54
73
  - public/javascripts/portfolio.js
55
74
  - public/stylesheets/portfolio.css
56
- - rails/init.rb
57
75
  has_rdoc: true
58
76
  homepage: http://refinerycms.com
59
77
  licenses: []
@@ -75,12 +93,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
75
93
  required_rubygems_version: !ruby/object:Gem::Requirement
76
94
  none: false
77
95
  requirements:
78
- - - ">="
96
+ - - ">"
79
97
  - !ruby/object:Gem::Version
80
- hash: 3
98
+ hash: 25
81
99
  segments:
82
- - 0
83
- version: "0"
100
+ - 1
101
+ - 3
102
+ - 1
103
+ version: 1.3.1
84
104
  requirements: []
85
105
 
86
106
  rubyforge_project:
@@ -1,32 +0,0 @@
1
- class Admin::PortfolioEntriesController < Admin::BaseController
2
-
3
- crudify :portfolio_entry, :order => 'position ASC', :conditions => "parent_id IS NULL"
4
- before_filter :find_portfolio_entries_for_parents_list, :only => [:new, :create, :edit, :update]
5
-
6
- def emancipate
7
- if (entry = PortfolioEntry.find(params[:id])).present?
8
- entry.update_attribute(:parent_id, (entry.parent.present? ? entry.parent.parent_id : nil))
9
- end
10
-
11
- redirect_to :action => "index"
12
- end
13
-
14
- protected
15
-
16
- # This finds all of the entries that could possibly be assigned as the current entry's parent.
17
- def find_portfolio_entries_for_parents_list
18
- if ::Refinery::Portfolio.multi_level?
19
- @portfolio_entries_for_parents_list = PortfolioEntry.find(:all, :order => "parent_id, position ASC")
20
-
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
26
- end
27
- else
28
- @portfolio_entries_for_parents_list = []
29
- end
30
- end
31
-
32
- end
@@ -1,23 +0,0 @@
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)
@@ -1,52 +0,0 @@
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(:name => "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
@@ -1,37 +0,0 @@
1
- namespace :refinery do
2
- namespace :portfolio do
3
- desc "Install extra files from the portfolio plugin"
4
-
5
- task :install do
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"
35
- end
36
- end
37
- end
data/rails/init.rb DELETED
@@ -1,17 +0,0 @@
1
- Refinery::Plugin.register do |plugin|
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