Skip to content

Instantly share code, notes, and snippets.

View cfitz's full-sized avatar

Chris Fitzpatrick cfitz

  • Machine Games
  • Sweden
View GitHub Profile
<%# This would go into views/welcome/index.html.erb %>
<%= setup_context :title => "Home", :suppress_breadcrumb => true %>
<div class="row">
<div class="col-md-12">
<%= render_aspace_partial :partial => "shared/flash_messages" %>
</div>
<div class="col-md-12" style="padding: 30px;">
<h1><%= I18n.t "welcome.heading" %></h1>
@cfitz
cfitz / american-communists.xml
Created January 12, 2017 00:03
Add a note with 856$u and 856$z ( <a href="$u">$z</a> )
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<collection xsi:schemaLocation="http://www.loc.gov/MARC21/slim http://www.loc.gov/standards/marcxml/schema/MARC21slim.xsd" xmlns="http://www.loc.gov/MARC21/slim" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<record>
<leader>00000npc a2200000 u 4500</leader>
<controlfield tag="008">081112i19002007xx eng d</controlfield>
<datafield tag="040" ind2=" " ind1=" ">
<subfield code="a">NyNyUA</subfield>
<subfield code="b">eng</subfield>
<subfield code="c">NyNyUA</subfield>
<subfield code="e">dacs</subfield>
# plugins/local/public/plugin_init.rb
Rails.application.config.after_initialize do
SearchController.class_eval do
private
def set_search_criteria
@criteria = params.select{|k,v|
require 'uri'
require 'fileutils'
require 'iiif/presentation'
require 'json'
collection = nil
@base = "http://loris-dev.dlts.org/loris/"
@cfitz
cfitz / manifest.json
Created September 14, 2016 08:28
iip manifests
{
"@context": "http://iiif.io/api/presentation/2/context.json",
"@id": "http://loris-dev.dlts.org/loris//manifest.json",
"@type": "sc:Manifest",
"label": "NYU Example",
"thumbnail": "http://loris-dev.dlts.org/loris/AD-MC-002_ref1000_n000001_m.tif/full/!200,200/0/default.jpg",
"viewingHint": "paged",
"metadata": [
{
"Foo": "Bar"
@cfitz
cfitz / indexer.rb
Created August 10, 2016 11:30
fixes fullrecord indexing in 1.5.1
class CommonIndexer
add_indexer_initialize_hook do |indexer|
indexer.add_document_prepare_hook do |doc, record|
doc['fullrecord'] = CommonIndexer.extract_string_values(record)
%w(finding_aid_subtitle finding_aid_author).each do |field|
if record['record'].has_key?(field)
doc['fullrecord'] << "#{record['record'][field]} "
end
# This edits the archivesspace mysql database to pull out indicator_1 vales in the
# container table that have "XX.YY" values.
# the indicator_1 and indicator_2 values are updated to be indicator_1 = XX and
# indicator_2 = YY, with a type_1 = box and type_2 = folder.
# all other container values are copied over as is.
# Containers with indicator_1 that do not have "." in them are left as-is.
# AS ALWAYS!!! MAKE A BACKUP OF YOUR DB BEFORE YOU DO THIS AND THEN CHECK IF THIS
# DID WHAT YOU WANTED!!!
@cfitz
cfitz / marc4j-demo
Created June 23, 2016 20:21
marc4 example
mport org.marc4j.MarcReader;
import org.marc4j.MarcStreamReader;
import org.marc4j.marc.Record;
import org.marc4j.marc.DataField;
import org.marc4j.MarcWriter;
import org.marc4j.MarcStreamWriter;
import org.marc4j.marc.MarcFactory;
!function(e){function t(n){if(r[n])return r[n].exports;var a=r[n]={exports:{},id:n,loaded:!1};return e[n].call(a.exports,a,a.exports,t),a.loaded=!0,a.exports}var r={};return t.m=e,t.c=r,t.p="/static/",t(0)}([function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{"default":e}}var a=r(1);n(a)},function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{"default":e}}Object.defineProperty(t,"__esModule",{value:!0});var a=r(2),i=n(a);t["default"]=i["default"]},function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{"default":e}}function a(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function o(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,
@cfitz
cfitz / _archival_object.html.erb
Created June 7, 2016 12:32
adding root record id to an archival object summary
<fieldset class="form-horizontal">
<section id="summary">
<h3><%= I18n.t("archival_object._public.section.summary") %></h3>
<dl class="dl-horizontal">
<%= label_and_value I18n.t("archival_object.component_id"), archival_object['component_id'] %>
<%= label_and_value I18n.t("archival_object.level"), i18n_enum(:archival_object, 'level', archival_object['level']) %>
<%= label_and_value I18n.t("archival_object.language"), i18n_enum(:archival_object, 'language', archival_object['language']) %>
<%= label_and_value "Root Record ID", @tree_view["path_to_root"].first["id"] %>
</dl>
</section>