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 / public_formats.rb
Created May 29, 2016 01:02
fix for public formats export to pdf
# add this to plugins/aspace-public-formats/backend/controllers/public_formats.rb and restart
module ExportHelpers
def generate_pdf_from_ead( ead )
xml = ""
ead.each { |e| xml << e }
ASFop.new(xml).to_pdf
end
end
@cfitz
cfitz / _branding.html.erb
Last active December 8, 2015 15:35
location deletion hacky fix
<div class="container navbar-branding">
<%= image_tag "archivesspace/archivesspace.small.png", :class=>"img-responsive" %>
</div>
<script>
$(function() {
@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 / 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 / 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 / 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 / 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 / form_fix_controller.rb
Last active August 29, 2015 14:18
form_fix_controller.rb
#
# Add this file to plugins/local/frontend/controllers/form_fix_controller.rb
# Obviously not a controller, but the naming convention is used to make sure that
# it loads.
#
module AspaceFormHelper
class FormContext
def label_and_date(name, opts = {})
@cfitz
cfitz / aspace_form_helper.rb
Created April 10, 2015 08:34
aspace_form_helper.rb
#
# Add this file to plugins/local/frontend/controllers/aspace_forms_helper.rb
module AspaceFormHelper
COMBOBOX_MIN_LIMIT = 50 # if a <select> has equal or more options than this value, output a combobox
class FormContext
def initialize(name, values_from, parent)
@cfitz
cfitz / reports.rb
Created December 8, 2014 22:31
reports.rb
# plugins/local/backend/controllers/reports.rb
class ArchivesSpaceService < Sinatra::Base
ReportManager.registered_reports.each do |uri_suffix, opts|
Endpoint.get("/repositories/:repo_id/reports/#{uri_suffix}")
.description(opts[:description])
.params(*(opts[:params] << ReportHelper.report_formats << ["repo_id", :repo_id]))
.permissions([])