refinerycms-portfolio 0.9.2
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.
- data/app/controllers/admin/portfolio_entries_controller.rb +13 -0
- data/app/controllers/portfolio_controller.rb +45 -0
- data/app/models/portfolio_entry.rb +28 -0
- data/app/views/admin/portfolio_entries/_form.html.erb +38 -0
- data/app/views/admin/portfolio_entries/_list.html.erb +30 -0
- data/app/views/admin/portfolio_entries/_sortable_list.html.erb +2 -0
- data/app/views/admin/portfolio_entries/edit.html.erb +1 -0
- data/app/views/admin/portfolio_entries/index.html.erb +30 -0
- data/app/views/admin/portfolio_entries/new.html.erb +1 -0
- data/app/views/portfolio/_main_image.html.erb +1 -0
- data/app/views/portfolio/empty.html.erb +10 -0
- data/app/views/portfolio/show.html.erb +59 -0
- data/bin/refinerycms-portfolio-install +39 -0
- data/config/locale/en.yml +0 -0
- data/config/routes.rb +15 -0
- data/contributors.md +4 -0
- data/db/migrate/20090917224823_create_portfolio_structure.rb +46 -0
- data/db/migrate/20091121033434_add_position_to_images_portfolio_entries.rb +9 -0
- data/lib/portfolio.rb +1 -0
- data/lib/tasks/portfolio.rake +9 -0
- data/license.md +21 -0
- data/public/javascripts/portfolio.js +47 -0
- data/public/stylesheets/portfolio.css +77 -0
- data/rails/init.rb +15 -0
- data/readme.md +40 -0
- metadata +80 -0
@@ -0,0 +1,13 @@
|
|
1
|
+
class Admin::PortfolioEntriesController < Admin::BaseController
|
2
|
+
|
3
|
+
crudify :portfolio_entry, :order => 'position ASC', :conditions => "parent_id IS NULL"
|
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
|
@@ -0,0 +1,45 @@
|
|
1
|
+
class PortfolioController < ApplicationController
|
2
|
+
|
3
|
+
before_filter :load_page, :only => [:index, :show, :empty]
|
4
|
+
|
5
|
+
def index
|
6
|
+
redirect_to portfolio_url(PortfolioEntry.find_by_parent_id(nil, :order => "position ASC")) rescue error_404
|
7
|
+
end
|
8
|
+
|
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 params[:portfolio_id]
|
18
|
+
@portfolio_entry = @master_entry.children.find(params[:portfolio_id])
|
19
|
+
else
|
20
|
+
@portfolio_entry = @master_entry.children.first
|
21
|
+
end
|
22
|
+
|
23
|
+
begin
|
24
|
+
if params[:image_id]
|
25
|
+
@image = @portfolio_entry.images[params[:image_id].to_i]
|
26
|
+
else
|
27
|
+
@image = @portfolio_entry.images.first
|
28
|
+
end
|
29
|
+
rescue
|
30
|
+
render :action => "empty"
|
31
|
+
end
|
32
|
+
rescue
|
33
|
+
error_404
|
34
|
+
end
|
35
|
+
|
36
|
+
render :partial => "main_image", :layout => false if request.xhr?
|
37
|
+
end
|
38
|
+
|
39
|
+
protected
|
40
|
+
|
41
|
+
def load_page
|
42
|
+
@page = Page.find_by_link_url('/portfolio', :include => [:parts])
|
43
|
+
end
|
44
|
+
|
45
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
class PortfolioEntry < ActiveRecord::Base
|
2
|
+
|
3
|
+
validates_presence_of :title
|
4
|
+
|
5
|
+
# call to gems included in refinery.
|
6
|
+
has_friendly_id :title, :use_slug => true, :strip_diacritics => true
|
7
|
+
acts_as_tree :order => "position"
|
8
|
+
|
9
|
+
has_and_belongs_to_many :images
|
10
|
+
|
11
|
+
def content
|
12
|
+
self.body
|
13
|
+
end
|
14
|
+
|
15
|
+
def content=(value)
|
16
|
+
self.body = value
|
17
|
+
end
|
18
|
+
|
19
|
+
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
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
<%= error_messages_for :portfolio_entry %>
|
2
|
+
<% form_for [:admin, @portfolio_entry] do |f| %>
|
3
|
+
<div class='field'>
|
4
|
+
<%= f.label :title %>
|
5
|
+
<%= f.text_field :title, :class => "larger", :style => 'width: 954px' %>
|
6
|
+
</div>
|
7
|
+
<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}?thickbox=true&modal=true&titlebar=true&callback=image_added&KeepThis=true&TB_iframe=true&width=950&height=510", :class => "thickbox", :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'>
|
26
|
+
<%= f.label :body, 'Content' %>
|
27
|
+
<%= f.text_area :body, :class => "wymeditor", :rows => 7 %>
|
28
|
+
</div>
|
29
|
+
<div class='form-actions'>
|
30
|
+
<%= f.submit 'Save', :class => "wymupdate" %>
|
31
|
+
or
|
32
|
+
<%= link_to "Cancel", admin_portfolio_entries_url, :title => "Cancelling will lose all changes you've made to this entry" %>
|
33
|
+
</div>
|
34
|
+
<% end %>
|
35
|
+
<% content_for :head do %>
|
36
|
+
<%= stylesheet_link_tag 'portfolio' %>
|
37
|
+
<%= javascript_include_tag 'portfolio' %>
|
38
|
+
<% end %>
|
@@ -0,0 +1,30 @@
|
|
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
|
7
|
+
-%>
|
8
|
+
<li class='clearfix record<%= " #{branch}" %>' id="<%= dom_id(list) -%>">
|
9
|
+
<div class='clearfix'>
|
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",
|
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),
|
15
|
+
:title => "Edit this entry" %>
|
16
|
+
<%= link_to refinery_icon_tag('arrow_up.png'),
|
17
|
+
{:controller => "/admin/portfolio_entries", :action => "emancipate", :id => list.id},
|
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),
|
20
|
+
:class => "cancel confirm-delete",
|
21
|
+
:title => "Remove this entry forever" %>
|
22
|
+
</span>
|
23
|
+
<%=h list.title %>
|
24
|
+
</div>
|
25
|
+
<% if (children = list.children).any? %>
|
26
|
+
<ul<%= " class='nested'" %>>
|
27
|
+
<%= render :partial => 'list', :collection => children %>
|
28
|
+
</ul>
|
29
|
+
<% end %>
|
30
|
+
</li>
|
@@ -0,0 +1 @@
|
|
1
|
+
<%= render :partial => "form" %>
|
@@ -0,0 +1,30 @@
|
|
1
|
+
<div id='actions'>
|
2
|
+
<h2>Actions</h2>
|
3
|
+
<ul>
|
4
|
+
<li>
|
5
|
+
<%= link_to "Create New Portfolio Entry", new_admin_portfolio_entry_url, :class => "add_icon" %>
|
6
|
+
</li>
|
7
|
+
<% if PortfolioEntry.any? %>
|
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
|
+
<% end %>
|
13
|
+
</ul>
|
14
|
+
</div>
|
15
|
+
<div id='records' class='tree'>
|
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>
|
28
|
+
<% end %>
|
29
|
+
</div>
|
30
|
+
<%= render :partial => "/shared/admin/make_sortable", :locals => {:tree => true } if PortfolioEntry.any? %>
|
@@ -0,0 +1 @@
|
|
1
|
+
<%= render :partial => "form" %>
|
@@ -0,0 +1 @@
|
|
1
|
+
<%= image_fu @image, :portfolio, :id => "portfolio_main_image" unless @image.nil? %>
|
@@ -0,0 +1,10 @@
|
|
1
|
+
<% content_for :title, "#{@master_entry.title} - " %>
|
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>
|
@@ -0,0 +1,59 @@
|
|
1
|
+
<% content_for :title, "#{@portfolio_entry.title} - " %>
|
2
|
+
<% content_for :head, stylesheet_link_tag('portfolio') %>
|
3
|
+
<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] } %>
|
8
|
+
</h1>
|
9
|
+
|
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
|
+
<% (images = @portfolio_entry.images).each do |image| %>
|
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 %>
|
20
|
+
</li>
|
21
|
+
<% end %>
|
22
|
+
</ul>
|
23
|
+
</div>
|
24
|
+
</div>
|
25
|
+
<% content_for :head do %>
|
26
|
+
<%# remove these javascript_include_tag calls if they are included in your layout.
|
27
|
+
%>
|
28
|
+
<%= javascript_include_tag 'jquery' %>
|
29
|
+
<script type='text/javascript'>
|
30
|
+
$(document).ready(function(){
|
31
|
+
$("ul#portfolio_images li a.pale img").fadeTo(0, 0.3);
|
32
|
+
|
33
|
+
$('#portfolio_entry_to_param').change(function() {
|
34
|
+
window.location = "<%= portfolio_project_url(@master_entry, nil) %>" + this.value;
|
35
|
+
});
|
36
|
+
|
37
|
+
var clicked_on = null;
|
38
|
+
$("ul#portfolio_images li a").click(function(event) {
|
39
|
+
if (!$(this).hasClass('selected')) {
|
40
|
+
clicked_on = $(this);
|
41
|
+
$.get($(this).attr('href'), function(data, textStatus) {
|
42
|
+
if (textStatus == "success") {
|
43
|
+
$('#portfolio_main_image').before(data).remove();
|
44
|
+
|
45
|
+
$('ul#portfolio_images li a.selected').removeClass('selected').addClass('pale');
|
46
|
+
|
47
|
+
clicked_on.removeClass('pale').addClass('selected');
|
48
|
+
clicked_on.find('img').fadeTo(0, 1);
|
49
|
+
|
50
|
+
$("ul#portfolio_images li a.pale img").fadeTo(0, 0.3);
|
51
|
+
}
|
52
|
+
});
|
53
|
+
}
|
54
|
+
|
55
|
+
return false;
|
56
|
+
});
|
57
|
+
});
|
58
|
+
</script>
|
59
|
+
<% end %>
|
@@ -0,0 +1,39 @@
|
|
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
|
File without changes
|
data/config/routes.rb
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
ActionController::Routing::Routes.draw do |map|
|
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"
|
5
|
+
map.portfolio "/portfolio/:id/", :controller => 'portfolio', :action => 'show'
|
6
|
+
|
7
|
+
map.resources :portfolio do |portfolio|
|
8
|
+
portfolio.resources :portfolio, :as => :portfolio
|
9
|
+
end
|
10
|
+
|
11
|
+
map.namespace(:admin) do |admin|
|
12
|
+
admin.resources :portfolio_entries, :as => :portfolio, :collection => {:emancipate => :get}
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
data/contributors.md
ADDED
@@ -0,0 +1,46 @@
|
|
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
|
+
RefinerySetting[:image_thumbnails] = RefinerySetting.find_or_set(:image_thumbnails, {}).merge!({:portfolio_thumb => 'c96x96', :portfolio => '600x512'})
|
30
|
+
end
|
31
|
+
|
32
|
+
def self.down
|
33
|
+
UserPlugin.destroy_all({:title => "Portfolio"})
|
34
|
+
|
35
|
+
Page.find_all_by_link_url("/portfolio").each do |page|
|
36
|
+
page.link_url, page.menu_match, page.deletable = nil
|
37
|
+
page.destroy
|
38
|
+
end
|
39
|
+
Page.destroy_all({:link_url => "/portfolio"})
|
40
|
+
|
41
|
+
RefinerySetting.find_or_set(:image_thumbnails, {}).delete_if {|key, value| key == :portfolio_thumb or key == :portfolio }
|
42
|
+
|
43
|
+
drop_table :images_portfolio_entries
|
44
|
+
drop_table :portfolio_entries
|
45
|
+
end
|
46
|
+
end
|
data/lib/portfolio.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
# empty as yet
|
@@ -0,0 +1,9 @@
|
|
1
|
+
namespace :refinery do
|
2
|
+
namespace :portfolio do
|
3
|
+
desc "Install extra files from the portfolio plugin"
|
4
|
+
|
5
|
+
task :install do
|
6
|
+
puts `ruby #{File.expand_path(File.dirname(__FILE__) << '/../..')}/bin/refinerycms-portfolio-install #{Rails.root.to_s}`
|
7
|
+
end
|
8
|
+
end
|
9
|
+
end
|
data/license.md
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
# MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2005-2010 [Resolve Digital Ltd.](http://www.resolvedigital.co.nz)
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
@@ -0,0 +1,47 @@
|
|
1
|
+
reset_functionality = function() {
|
2
|
+
$("#portfolio_images").sortable({
|
3
|
+
'tolerance': 'pointer'
|
4
|
+
, 'placeholder': 'placeholder'
|
5
|
+
, 'cursor': 'drag'
|
6
|
+
, 'items': 'li'
|
7
|
+
});
|
8
|
+
|
9
|
+
$('#portfolio_images li:not(.empty)').each(function(index, li) {
|
10
|
+
$(li).mouseover(function(e){
|
11
|
+
if ((image_actions = $(this).find('.image_actions')).length == 0) {
|
12
|
+
image_actions = $("<div class='image_actions'></div>");
|
13
|
+
img_delete = $("<img src='/images/refinery/icons/delete.png' width='16' height='16' />");
|
14
|
+
img_delete.appendTo(image_actions);
|
15
|
+
img_delete.click(function() {
|
16
|
+
$(this).parent().remove();
|
17
|
+
});
|
18
|
+
|
19
|
+
image_actions.appendTo($(li));
|
20
|
+
}
|
21
|
+
|
22
|
+
image_actions.show();
|
23
|
+
});
|
24
|
+
|
25
|
+
$(li).mouseout(function(e) {
|
26
|
+
$(this).find('.image_actions').hide();
|
27
|
+
});
|
28
|
+
});
|
29
|
+
}
|
30
|
+
|
31
|
+
image_added = function(image) {
|
32
|
+
last_portfolio_entry_image_id = "";
|
33
|
+
image_id = $(image).attr('id').replace('image_', '');
|
34
|
+
hidden_identifier = $('li.empty').find('input:hidden');
|
35
|
+
hidden_identifier.attr('id', '').val(image_id);
|
36
|
+
$('li.empty').find('img').css('display', '').attr({'id': '', 'src': $(image).attr('src').replace('_dialog_thumb', '_grid'), 'title': $(image).attr('title'), 'alt': $(image).attr('alt')});
|
37
|
+
$('li.empty').attr('id', 'image_' + image_id).removeClass('empty');
|
38
|
+
|
39
|
+
new_list_item = $("<li class='empty'></li>");
|
40
|
+
$("<img id='current_portfolio_entry_image' src='' alt='' style='display:none;' />").appendTo(new_list_item);
|
41
|
+
$("<input type='hidden' id='portfolio_entry_image_id' name='portfolio_entry[image_ids][]' />").appendTo(new_list_item);
|
42
|
+
|
43
|
+
new_list_item.appendTo($('#portfolio_images'));
|
44
|
+
reset_functionality();
|
45
|
+
}
|
46
|
+
|
47
|
+
$(document).ready(reset_functionality);
|
@@ -0,0 +1,77 @@
|
|
1
|
+
#body_content.portfolio #body_content_left {
|
2
|
+
width: 621px;
|
3
|
+
margin-right: 39px;
|
4
|
+
}
|
5
|
+
#body_content.portfolio #body_content_left h1 {
|
6
|
+
margin-bottom: 24px;
|
7
|
+
}
|
8
|
+
#body_content.portfolio #body_content_left h1 span {
|
9
|
+
float: left;
|
10
|
+
}
|
11
|
+
#body_content.portfolio #body_content_left h1 select {
|
12
|
+
margin-left: 12px;
|
13
|
+
min-width: 200px;
|
14
|
+
float: right;
|
15
|
+
margin-top: 3px;
|
16
|
+
display: block;
|
17
|
+
}
|
18
|
+
#body_content.portfolio #body_content_right {
|
19
|
+
width: 280px;
|
20
|
+
text-align: left;
|
21
|
+
padding-top: 43px;
|
22
|
+
}
|
23
|
+
#body_content.portfolio #body_content_right h2, #body_content.portfolio #body_content_right {
|
24
|
+
font-size: 15px;
|
25
|
+
font-weight: normal;
|
26
|
+
}
|
27
|
+
|
28
|
+
#portfolio_main_image {
|
29
|
+
border: 3px solid #d4cabc;
|
30
|
+
}
|
31
|
+
#portfolio_images {
|
32
|
+
margin: 0px;
|
33
|
+
padding: 0px;
|
34
|
+
width: 280px;
|
35
|
+
}
|
36
|
+
#portfolio_images li {
|
37
|
+
position: relative;
|
38
|
+
list-style: none;
|
39
|
+
float: left;
|
40
|
+
margin-bottom: 20px;
|
41
|
+
}
|
42
|
+
#portfolio_images li.odd {
|
43
|
+
margin-right: 18px;
|
44
|
+
}
|
45
|
+
|
46
|
+
#portfolio_images.portfolio_entry_images {
|
47
|
+
width: 100%;
|
48
|
+
}
|
49
|
+
#portfolio_images.portfolio_entry_images li {
|
50
|
+
margin-right: 20px;
|
51
|
+
position: relative;
|
52
|
+
margin-bottom: 10px;
|
53
|
+
margin-top: 10px;
|
54
|
+
}
|
55
|
+
#portfolio_images.portfolio_entry_images li .image_actions {
|
56
|
+
background: white;
|
57
|
+
position: absolute;
|
58
|
+
padding: 3px;
|
59
|
+
left: 0px;
|
60
|
+
top: 0px;
|
61
|
+
}
|
62
|
+
#portfolio_images.portfolio_entry_images li * {
|
63
|
+
cursor: move;
|
64
|
+
}
|
65
|
+
#portfolio_images.portfolio_entry_images li .image_actions * {
|
66
|
+
cursor: pointer;
|
67
|
+
}
|
68
|
+
|
69
|
+
#content ul.ui-sortable li {
|
70
|
+
border: 0px none;
|
71
|
+
background: none !important;
|
72
|
+
}
|
73
|
+
|
74
|
+
#content #portfolio_images.ui-sortable li.placeholder {
|
75
|
+
width: 135px;
|
76
|
+
height: 135px;
|
77
|
+
}
|
data/rails/init.rb
ADDED
@@ -0,0 +1,15 @@
|
|
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.2'
|
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
|
data/readme.md
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
# Portfolio plugin for [RefineryCMS](http://www.refinerycms.com)
|
2
|
+
[Github](http://github.com/resolve/refinerycms)
|
3
|
+
|
4
|
+
By: [Resolve Digital](http://www.resolvedigital.com)
|
5
|
+
|
6
|
+
## Plugin Installation
|
7
|
+
|
8
|
+
Just 'git clone' Refinery, install this as a plugin using:
|
9
|
+
script/plugin install git://github.com/resolve/refinerycms-portfolio.git
|
10
|
+
|
11
|
+
Then run:
|
12
|
+
rake refinery:portfolio:install
|
13
|
+
|
14
|
+
..and follow the instructions!
|
15
|
+
|
16
|
+
## Gem Installation
|
17
|
+
|
18
|
+
### Method One
|
19
|
+
Just install the gem 'portfolio' with the command:
|
20
|
+
gem install refinerycms-portfolio --source http://gemcutter.org
|
21
|
+
|
22
|
+
Then run:
|
23
|
+
refinerycms-portfolio-install /path/to/your/refinery/application
|
24
|
+
|
25
|
+
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.2", :lib => "portfolio", :source => "http://gemcutter.org"
|
27
|
+
|
28
|
+
..and follow the instructions!
|
29
|
+
|
30
|
+
### Method Two
|
31
|
+
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.2", :lib => "portfolio", :source => "http://gemcutter.org"
|
33
|
+
|
34
|
+
Then run in your application's directory:
|
35
|
+
rake gems:install
|
36
|
+
|
37
|
+
Then run:
|
38
|
+
refinerycms-portfolio-install /path/to/your/refinery/application
|
39
|
+
|
40
|
+
..and follow the instructions!
|
metadata
ADDED
@@ -0,0 +1,80 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: refinerycms-portfolio
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.9.2
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Resolve Digital
|
8
|
+
- Philip Arndt
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
|
13
|
+
date: 2010-02-18 00:00:00 +13:00
|
14
|
+
default_executable: refinerycms-portfolio-install
|
15
|
+
dependencies: []
|
16
|
+
|
17
|
+
description: A really straightforward open source Ruby on Rails portfolio plugin designed for integration with RefineryCMS.
|
18
|
+
email: info@refinerycms.com
|
19
|
+
executables:
|
20
|
+
- refinerycms-portfolio-install
|
21
|
+
extensions: []
|
22
|
+
|
23
|
+
extra_rdoc_files: []
|
24
|
+
|
25
|
+
files:
|
26
|
+
- contributors.md
|
27
|
+
- license.md
|
28
|
+
- readme.md
|
29
|
+
- app/controllers/admin/portfolio_entries_controller.rb
|
30
|
+
- app/controllers/portfolio_controller.rb
|
31
|
+
- app/models/portfolio_entry.rb
|
32
|
+
- app/views/admin/portfolio_entries/_form.html.erb
|
33
|
+
- app/views/admin/portfolio_entries/_list.html.erb
|
34
|
+
- app/views/admin/portfolio_entries/_sortable_list.html.erb
|
35
|
+
- app/views/admin/portfolio_entries/edit.html.erb
|
36
|
+
- app/views/admin/portfolio_entries/index.html.erb
|
37
|
+
- app/views/admin/portfolio_entries/new.html.erb
|
38
|
+
- app/views/portfolio/_main_image.html.erb
|
39
|
+
- app/views/portfolio/empty.html.erb
|
40
|
+
- app/views/portfolio/show.html.erb
|
41
|
+
- bin/refinerycms-portfolio-install
|
42
|
+
- config/locale/en.yml
|
43
|
+
- config/routes.rb
|
44
|
+
- db/migrate/20090917224823_create_portfolio_structure.rb
|
45
|
+
- db/migrate/20091121033434_add_position_to_images_portfolio_entries.rb
|
46
|
+
- lib/portfolio.rb
|
47
|
+
- lib/tasks/portfolio.rake
|
48
|
+
- public/javascripts/portfolio.js
|
49
|
+
- public/stylesheets/portfolio.css
|
50
|
+
- rails/init.rb
|
51
|
+
has_rdoc: true
|
52
|
+
homepage: http://refinerycms.com
|
53
|
+
licenses: []
|
54
|
+
|
55
|
+
post_install_message:
|
56
|
+
rdoc_options: []
|
57
|
+
|
58
|
+
require_paths:
|
59
|
+
- lib
|
60
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
61
|
+
requirements:
|
62
|
+
- - ">="
|
63
|
+
- !ruby/object:Gem::Version
|
64
|
+
version: "0"
|
65
|
+
version:
|
66
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
67
|
+
requirements:
|
68
|
+
- - ">="
|
69
|
+
- !ruby/object:Gem::Version
|
70
|
+
version: "0"
|
71
|
+
version:
|
72
|
+
requirements: []
|
73
|
+
|
74
|
+
rubyforge_project:
|
75
|
+
rubygems_version: 1.3.5
|
76
|
+
signing_key:
|
77
|
+
specification_version: 3
|
78
|
+
summary: Ruby on Rails portfolio plugin for RefineryCMS.
|
79
|
+
test_files: []
|
80
|
+
|