Skip to content
This repository has been archived by the owner on Aug 15, 2018. It is now read-only.

Commit

Permalink
added the ability to choose different render modes for the photo albu…
Browse files Browse the repository at this point in the history
…m. Currently only works in the isotope11 theme.
  • Loading branch information
Josh Adams committed Dec 18, 2008
1 parent c918468 commit c94291a
Show file tree
Hide file tree
Showing 17 changed files with 212 additions and 15 deletions.
2 changes: 1 addition & 1 deletion app/models/page_plugin.rb
Expand Up @@ -11,7 +11,7 @@ def module
end

def module_class
module_type.constantize
Object.path2class(module_type)
end

def module_default_name
Expand Down
20 changes: 12 additions & 8 deletions app/views/content/_page.html.erb
@@ -1,12 +1,16 @@
<% if page.page_plugins.any? -%>
<% page.page_plugins.each do |plugin| -%>
<%= render :partial => plugin.module_class.view_partial, :locals => { :plugin_module => plugin.module } -%>
<% if logged_in? && get_setting('show_inline_edit_links') %>
<% if current_user.can_author_content? %>
<%= link_to "[Edit]", edit_admin_page_path(:id => page.id, :anchor => "page-plugin-#{plugin.id}") %>
<% elsif current_user.can_approve_content? %>
<%= link_to "[Manage Content]", edit_admin_page_path(:id => page.id, :anchor => "page-plugin-#{plugin.id}") %>
<% page.page_plugins.each_with_index do |plugin, i| -%>
<%# render :partial => plugin.module_class.view_partial, :locals => { :plugin_module => plugin.module } -%>
<div class='page-plugin page-plugin-<%= i -%>'>
<%= render :partial => plugin.module.view_partial, :locals => { :plugin_module => plugin.module } -%>
<% if logged_in? && get_setting('show_inline_edit_links') %>
<div class='clear'></div>
<% if current_user.can_author_content? %>
<%= link_to "[Edit]", edit_admin_page_path(:id => page.id, :anchor => "page-plugin-#{plugin.id}") %>
<% elsif current_user.can_approve_content? %>
<%= link_to "[Manage Content]", edit_admin_page_path(:id => page.id, :anchor => "page-plugin-#{plugin.id}") %>
<% end %>
<% end %>
<% end %>
</div>
<% end -%>
<% end -%>
5 changes: 5 additions & 0 deletions config/initializers/object_extensions.rb
@@ -0,0 +1,5 @@
class Object # :nodoc:
def self.path2class(klassname)
klassname.split('::').inject(Object) { |k,n| k.const_get n }
end
end
53 changes: 53 additions & 0 deletions public/javascripts/jquery.jsgal.js
@@ -0,0 +1,53 @@
//
// Galeria v1.3
// Autor: Oscar Linares
// http://www.innovacionweb.com/galeria-accesible-jquery.php
// http://code.google.com/p/galeria-jquery-jsgal/
//
// Gracias a:
// Ariel Flesler por su plugin jQuery.Preload, aunque al final no lo uso (muy potente, demasiado
// para lo que necesito aquí).
// http://flesler.blogspot.com/2008/01/jquerypreload.html
// Para la precarga me inspire en (muchas gracias)
// http://www.noth.es/2007/11/25/actualizacion-del-jquery-gallery-v-0-2/
//
(function($) {
//
// plugin
//
$.fn.galimg = function() {
// trabaja con cada elemento
return this.each(function() {
var idCapaGaleria = $(this).attr("id");

$("a", this).click(function() {
// otra posibilidad para mostrar el aviso de cargando.
//$("#" + idCapaGaleria + " .imgprin").append("<div class='jsgalpre'>Cargando...</div>");

var rutaImagen = $(this).attr("href");
var altImagen = $(this).children("img").attr("alt");

$("#" + idCapaGaleria + " .imgprin img").fadeOut("normal").remove();

var objImagen = new Image();

$(objImagen).load(function() {
$(this).hide();

$("#" + idCapaGaleria + " .imgprin").append(this);

$(this).fadeIn("slow");
});

$(objImagen).attr("src", rutaImagen);

//$("#" + idCapaGaleria + " .imgprin .jsgalpre").remove();

return false;
});
});
};
//
// fin del plugin
//
})(jQuery);
59 changes: 59 additions & 0 deletions public/stylesheets/galimg.css
@@ -0,0 +1,59 @@
div.galimg, div.imgprin, .galimg a, .galimg img, .galimg ul, .galimg li {
margin: 0;
padding: 0;
border: 0;
outline: 0;
font-weight: inherit;
font-style: inherit;
font-size: 100%;
font-family: inherit;
vertical-align: baseline;
}

/* fin del reset */

.galimg {
position: relative;
background: #fff url(jsgal/loading.gif) no-repeat 50% 50%;
width: 710px;
}

.imgprin {
/* es necesario para evitar un parpadero al quitar la imagen */
width: 710px;
height: 510px;
}

.imgprin img {
background-color: #fff;
border: solid 1px #ccc;
padding: 5px;
}

.galimg ul {
position: absolute;
top: 420px;
width: 710px;
list-style: none;
text-align: center;
}

.galimg ul li {
display: inline;
padding-left: 3px;
}

.galimg ul li a img {
background-color: #fff;
border: solid 1px #ccc;
padding: 3px;
}

.jsgalpre {
position: absolute;
top: 0;
left: 0;
background-color: #f00;
color: #fff;
padding: 3px;
}
Expand Up @@ -17,6 +17,10 @@ def edit_path
def self.view_partial
"/admin/content_sections/content_section"
end

def view_partial
self.class.view_partial
end
end
end
end
Expand Up @@ -18,6 +18,10 @@ def self.view_partial
"/admin/form_builders/form_builder"
end

def view_partial
self.class.view_partial
end

protected
def ensure_submit_text
if self.submit_text.blank?
Expand Down
@@ -1,7 +1,7 @@
class Admin::PhotoAlbumsController < Admin::BaseController
unloadable # This is required if you subclass a controller provided by the base rails app

before_filter :load_photo_album, :only => [:show, :update]
before_filter :load_photo_album, :only => [:show, :edit, :update]
before_filter :load_photos, :only => [:show]
layout 'admin'

Expand All @@ -17,6 +17,16 @@ def load_photos
def show
end

def edit
end

def update
if @photo_album.update_attributes(params[:photo_album])
flash[:notice] = "The Photo Album was updated successfully."
redirect_to admin_photo_album_path(@photo_album)
else
flash.now[:error] = "There was a problem updating the photo album."
render :action => "edit"
end
end
end
Expand Up @@ -11,12 +11,30 @@ def edit_path
end

def self.view_partial
"/photo_albums/photo_album"
case display_type
when 'Gallery'
"/photo_albums/photo_album_gallery"
else
"/photo_albums/photo_album"
end
end

def self.admin_partial
"/admin/photo_albums/photo_album"
end

def self.display_types
["Lightbox", "Gallery"]
end

def view_partial
case display_type
when 'Gallery'
"/photo_albums/photo_album_gallery"
else
"/photo_albums/photo_album"
end
end
end
end
end
@@ -0,0 +1,13 @@
<%= title "Edit Photo Album" -%>
<% content_for :sidebar do -%>
<%= link_to "Back", admin_photo_album_path(@photo_album), :class => 'button icon back' %>
<% end -%>
<% form_for :photo_album, :url => admin_photo_album_path(@photo_album), :html => { :method => :put } do |f| %>
<div class='fullwidth'>
<table class='form-table'>
<%= form_row "Display Type", f.select(:display_type, Ansuz::JAdams::PhotoAlbum.display_types) -%>
</table>
</div>
<br />
<%= submit_tag "Update Photo Album" %> or <%= link_to "Cancel", admin_photo_album_path(@photo_album) %>
<% end %>
@@ -1,6 +1,7 @@
<%= title "Photo Album" -%>
<% content_for :sidebar do -%>
<%= link_to "Add Photo", new_admin_photo_album_photo_path(@photo_album), :class => 'button icon add' -%>
<%= link_to "Add Photo", new_admin_photo_album_photo_path(@photo_album), :class => 'button icon add' %>
<%= link_to "Edit Settings", edit_admin_photo_album_path(@photo_album), :class => 'button icon edit' %>
<% end -%>
<h3>Photos</h3>
<ul class='photos'>
Expand Down
@@ -0,0 +1,13 @@
<% if plugin_module.photos.any? %>
<div id='<%= dom_id(plugin_module) %>' class='galimg'>
<div class='imgprin'>
<%= image_tag plugin_module.photos.first.photo_album_photo_image.url(:large) %>
</div>
<ul>
<% plugin_module.photos.each do |photo| %>
<li><%= link_to image_tag(photo.photo_album_photo_image.url(:thumb)), photo.photo_album_photo_image.url(:large), :title => photo.caption -%></li>
<% end %>
</ul>
</div>
<% end %>
<%= javascript_tag "jQuery('##{dom_id(plugin_module)}').galimg();" %>
@@ -0,0 +1,9 @@
class AddDisplayTypeToPhotoAlbums < ActiveRecord::Migration
def self.up
add_column :photo_albums, :display_type, :string
end

def self.down
remove_column :photo_albums, :display_type
end
end
Expand Up @@ -13,6 +13,10 @@ def edit_path
def self.view_partial
"/admin/scrollable_contents/scrollable_content"
end

def view_partial
self.class.view_partial
end
end
end
end
2 changes: 1 addition & 1 deletion vendor/plugins/engines/test/lib/engines_test_helper.rb
Expand Up @@ -23,7 +23,7 @@ def get_action_on_controller(*args)
def with_controller(controller, namespace = nil)
classname = controller.to_s.classify + 'Controller'
classname = namespace.to_s.classify + '::' + classname unless namespace.nil?
@controller = classname.constantize.new
@controller = Kernel.const_get(classname).new
end

def assert_response_body(expected)
Expand Down
2 changes: 1 addition & 1 deletion vendor/plugins/fckeditor/lib/fckeditor.rb
Expand Up @@ -15,7 +15,7 @@ def fckeditor_textarea(object, field, options = {})
value = value.nil? ? "" : value
else
value = ""
klass = "#{object}".camelcase.constantize
klass = Kernel.const_get("#{object}".camelcase)
instance_variable_set("@#{object}", eval("#{klass}.new()"))
end
id = fckeditor_element_id(object, field)
Expand Down
2 changes: 1 addition & 1 deletion vendor/plugins/paperclip/shoulda_macros/paperclip.rb
@@ -1,7 +1,7 @@
module Paperclip
module Shoulda
def should_have_attached_file name, options = {}
klass = self.name.gsub(/Test$/, '').constantize
klass = Object.path2class(self.name.gsub(/Test$/, ''))
context "Class #{klass.name} with attachment #{name}" do
should "respond to all the right methods" do
["#{name}_file_name", name, "#{name}?"].each do |meth|
Expand Down

0 comments on commit c94291a

Please sign in to comment.