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:f031108cc44bd109620b
Created April 14, 2015 13:46
RAC ead converter
class RacEADConverter < EADConverter
def self.import_types(show_hidden = false)
[
{
:name => "rac_ead_xml",
:description => "Import RAC EAD records from an XML file"
}
@cfitz
cfitz / accession_converter.rb
Created April 23, 2015 14:09
Add lots of dates and extents to the ASPACE accession CSV importer
# add this plugin to plugins/local/backend/model/accession_converter.rb
# this plugin allows the CSV importer to have columns like date_3_label, date_3_expression,
# extent_2_type, extent_2_container_summary etc.
class AccessionConverter < Converter
# we alias the old configure method...
self.singleton_class.send(:alias_method,:old_configure, :configure)
@cfitz
cfitz / converter.rb
Created May 28, 2015 15:21
converter.rb
# put this file in
# plugins/local/backend/model/converter.rb
# and restart aspace.
class Converter
# forcibly remove files in the event of an interruption
def remove_files
@batch.each_open_file_path do |path|
@cfitz
cfitz / application_controller.rb
Last active August 29, 2015 14:22
update the css in ASPACE
# plugins/local/frontend/controllers/application_controller.rb
# Obviously, not a application controller, but we just name it this to follow a convention.
class ApplicationController < ActionController::Base
end
module ApplicationHelper
def include_theme_css
css = ""
@cfitz
cfitz / rake_jruby_complete_patch.rake
Last active August 29, 2015 14:25
adding a relative url root
# frontend/lib/tasks/rake_jruby_complete_patch.rake
# Icky to have to do this, but had trouble with the recursive calls to Rake
# running with jruby-complete.jar.
classpath = [File.join(Rails.root, "..", "common")]
classpath << Dir.glob(File.join(Rails.root, "..", "build", "jruby*complete*.jar")).first
$rake_cmd = ["java",
"-XX:MaxPermSize=128m", "-Xmx256m",
@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: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: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: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/") {