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

Commit

Permalink
added flickr js page plugin, lets you give it a flickr json feed and …
Browse files Browse the repository at this point in the history
…it'll display them rotating.
  • Loading branch information
Josh Adams committed Dec 23, 2008
1 parent 9017d3d commit f39a7dd
Show file tree
Hide file tree
Showing 9 changed files with 85 additions and 5 deletions.
23 changes: 23 additions & 0 deletions app/controllers/admin/proto_page_plugins_controller.rb
@@ -0,0 +1,23 @@
class Admin::ProtoPagePluginsController < Admin::BaseController
before_filter :load_page_plugin, :only => [:update]

protected
def load_page_plugin
@page_plugin = PagePlugin.find(params[:id])
@module = @page_plugin.module
end

public
def update
@module.settings = params[:settings]
if @module.save
render :update do |page|
page << "notify('Module has been updated');"
end
else
render :update do |page|
page << "notify('An error occurred updating the Module');"
end
end
end
end
4 changes: 2 additions & 2 deletions app/views/admin/pages/edit.html.erb
Expand Up @@ -20,9 +20,9 @@
<% @page.page_plugins.each do |plugin| -%>
<div id='page-plugin-<%= plugin.id -%>'>
<% if plugin.module_class.respond_to?(:admin_partial) -%>
<%= render :partial => plugin.module_class.admin_partial, :locals => { :plugin_module => plugin.module } -%>
<%= render :partial => plugin.module_class.admin_partial, :locals => { :plugin_module => plugin.module, :plugin => plugin } -%>
<% else -%>
<%= render :partial => plugin.module.view_partial, :locals => { :plugin_module => plugin.module } -%>
<%= render :partial => plugin.module.view_partial, :locals => { :plugin_module => plugin.module, :plugin => plugin } -%>
<% end -%>
</div>
<% end -%>
Expand Down
1 change: 1 addition & 0 deletions config/routes.rb
Expand Up @@ -21,6 +21,7 @@
map.namespace :admin do |admin|
admin.resources :pages, :member => [:shift_order], :has_one => [:page_metadata]
admin.resources :page_plugins, :member => [:move_up, :move_down]
admin.resources :proto_page_plugins
admin.resources :plugins
admin.resources :tags
admin.resources :roles
Expand Down
6 changes: 3 additions & 3 deletions public/javascripts/jquery.cycle.all.pack.js

Large diffs are not rendered by default.

12 changes: 12 additions & 0 deletions public/themes/default/stylesheets/base.css
Expand Up @@ -141,3 +141,15 @@ strong{
em{
font-style: oblique;
}

.flickr-js-images{
height: 185px !important;
width: 240px !important;
padding:0;
margin:0;
overflow: hidden;
}

.flickr-js-images img{
border: none;
}
@@ -0,0 +1,15 @@
module Ansuz
module JAdams
class FlickrJs < ProtoPagePlugin
has_settings

def view_partial
'/admin/flickr_js/flickr_js'
end

def self.admin_partial
'/admin/flickr_js/edit'
end
end
end
end
@@ -0,0 +1,9 @@
<% remote_form_for :page_plugin, plugin, :url => admin_proto_page_plugin_path(plugin), :html => { :method => :put } do |f| %>
<div class='fullwidth'>
<table class='form-table'>
<%= form_row "Feed URL", text_field_tag("settings[feed_url]", plugin_module.settings[:feed_url]) -%>
</table>
</div>
<br />
<%= submit_tag "Update Flickr JS Module" %>
<% end %>
@@ -0,0 +1,19 @@
<div id="<%= dom_id(plugin_module) -%>" class='flickr-js-images'></div>
<div class="flickrNav">
<a id="<%= dom_id(plugin_module) -%>-prev" href="#">Prev</a><a id="<%= dom_id(plugin_module) -%>-next" href="#">Next</a>
</div>

<%= javascript_tag <<-EOF
jQuery.getJSON("#{plugin_module.settings[:feed_url]}&jsoncallback=?", function(data){
jQuery.each(data.items, function(i,item){
jQuery("<img/>").attr("src", item.media.m).appendTo("##{dom_id(plugin_module)}")
.wrap("<a href='" + item.link + "'></a>");
});
jQuery('##{dom_id(plugin_module)}').cycle({
fx: 'fade',
speed: 300,
timeout: 3000
});
});
EOF
%>
1 change: 1 addition & 0 deletions vendor/plugins/ansuz_flickr_js/init.rb
@@ -0,0 +1 @@
Ansuz::PluginManagerInstance.register_plugin(Ansuz::JAdams::FlickrJs)

0 comments on commit f39a7dd

Please sign in to comment.