Skip to content

Instantly share code, notes, and snippets.

View cfitz's full-sized avatar

Chris Fitzpatrick cfitz

  • Machine Games
  • Sweden
View GitHub Profile
@cfitz
cfitz / gist:705504
Created November 18, 2010 19:57
_edit.html.erb
<% stylesheet_links << "../javascripts/date-picker/css/datepicker" %>
<% javascript_includes << infusion_javascripts(:default_no_jquery, :extras=>[:inline_editor_integrations], :debug=>true, :render_html=>false) %>
<% javascript_includes << "jquery.jeditable.mini" %>
<% javascript_includes << "date-picker/js/datepicker" %>
<% javascript_includes << "jquery.form.js" %>
<% javascript_includes << 'custom' %>
<% javascript_includes << "catalog/edit" %>
<% javascript_includes << "jquery.hydraMetadata.js" %>
<% javascript_includes << "/plugin_assets/fluid-infusion/infusion/components/undo/js/Undo.js" %>
<% javascript_includes << "jquery.notice.js" %>
@cfitz
cfitz / gist:705520
Created November 18, 2010 20:06
_edit_description.html.erb
<form id="document_metadata" action="<%= url_for(:action=>"update", :controller=>"assets", :content_type=>"hydra_tune")%>" method="post" data-resourceType="hydra_tune" accept-charset="utf-8">
<fieldset id="title_fields">
<legend>Title</legend>
<input id="content_type" type="hidden" name="content_type" value="hydra_audio" />
<dl>
<dt>
<%= fedora_field_label("descMetadata", :title, "Title:") %>
</dt>
<dd class="title">
<%= fedora_text_field(@document_fedora,"descMetadata", [:title], :multiple=>false) %>
@cfitz
cfitz / gist:705521
Created November 18, 2010 20:06
_index.html.erb
<tr class="document" class="<%= cycle("even","odd") %>">
<td>
<%= link_to_document(document, :label => Blacklight.config[:show][:heading].to_sym, :counter => (counter + 1 + @response.params[:start].to_i)) %>
</td>
<td>
<% creator = get_person_from_role(document, "Creator") %>
<%= [creator[:last], creator[:first]].join(", ") unless creator.nil? %>
</td>
<td>
<%= DateTime.parse(document.get(:system_create_dt)).to_time %>
@cfitz
cfitz / gist:705523
Created November 18, 2010 20:07
_show.html.erb
<% javascript_includes << "/plugin_assets/fluid-infusion/infusion-1.2-src/lib/jquery/ui/js/jquery.ui.accordion.js" %>
<% javascript_includes << 'custom' %>
<% javascript_includes << "catalog/show" %>
<div class="document_viewer" id="cover_container">
<div id="accordion">
<h2 class="section-title"><a href="#">Description</a></h2>
<%= render :partial => 'hydra_tunes/show_description' %>
@cfitz
cfitz / gist:705526
Created November 18, 2010 20:08
_show_description.html.erb
<dl>
<% unless get_values_from_datastream(@document_fedora,"descMetadata", [:title]).empty? %>
<dt>
<%= fedora_field_label("descMetadata", [:title], "Title:") %>
</dt>
<dd class="title">
<%= get_values_from_datastream(@document_fedora,"descMetadata", [:title]) %>
</dd>
@cfitz
cfitz / gist:705589
Created November 18, 2010 20:49
hydra_tune.rb
# HydraTune
#
# Default content datastreams: content
#
require 'hydra'
class HydraTune < ActiveFedora::Base
include Hydra::ModelMethods # Uses the Hydra Rights Metadata Schema for tracking access permissions & copyright
has_metadata :name => "rightsMetadata", :type => Hydra::RightsMetadata
has_metadata :name => "descMetadata", :type => HydraTuneDS
# A place to put extra metadata values
@cfitz
cfitz / gist:705593
Created November 18, 2010 20:50
hydra_tune_ds.rb
# HydraTuneDS
class HydraTuneDS < ActiveFedora::NokogiriDatastream
set_terminology do |t| t.root(:path=>"dc", :xmlns=>"http://purl.org/dc/elements/1.1/", :schema=>"http://purl.org/dc/elements/1.1/")
t.title(:index_as=>[:searchable, :displayable, :facetable, :sortable], :required=>:true, :type=>:string )
t.creator(:index_as=>[:searchable, :displayable, :facetable, :sortable], :required=>:true, :type=>:string)
end
def self.xml_template
builder = Nokogiri::XML::Builder.new do |xml|
xml.dc(:xmlns=>"http://purl.org/dc/elements/1.1/") {
$ git clone https://github.com/projecthydra/hydrangea.git
$ cd hydrangea
$ git submodule init
$ git submodule update
<?php
function _footer_menu_build_tree() {
$tree = menu_build_tree('main-menu', array('max_depth'=>2));
$tree = array_slice($tree, 0, 9);
$tree = menu_tree_output($tree);
return $tree;
}
function wmu_base_preprocess(&$vars, $hook) {
@cfitz
cfitz / gist:5265810
Last active December 15, 2015 13:18
quick coffeescript example how to pull bookjacket covers from Google Books in Blacklight. In the views, I added a span with .bookcover and an id of the isbn. AJAX grabs all the .bookcover id's, queries google, which returns JSONP that have all the images url. eh. you don't have to use google...you could just make your own controller that returns…
insertBookCoverImage = (data) ->
for id, values of data
imgId = values.bib_key.toLowerCase().replace(":", "_")
$("##{imgId}").attr("src", values.thumbnail_url)
addBookCovers = (ids) ->
url = "http://books.google.com/books?bibkeys=#{ids}&jscmd=viewapi&callback=?"
$.getJSON url, {}, insertBookCoverImage