Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View afred's full-sized avatar

Andrew Myers afred

  • WGBH Educational Foundation
  • Boston, MA
View GitHub Profile
@afred
afred / jekyll_tutorials_for_samvera_connect_2018.md
Last active April 24, 2023 20:01
Jekyll Tutorials for Samvera Connect 2018

Samvera Connect 2018 - Documentation with Jekyll workshop

This page contains some exercises and discussion topics for using Jekyll to help build and maintain samvera.github.io, a documentation website for the Samvera community.

Expectation Management: We are not experts in Jekyll, but we're here to tell you what we know after playing around with it for the past year or so.

Get the latest code (3 min)

  1. Go to https://github.com/samvera/samvera.github.io
@afred
afred / unobtrusive_monkey_patch_example.rb
Created November 6, 2015 20:31
A more passive way to monkey patch in ruby
# Suppose DogBehavior and Dog are defined in a gem.
module DogBehavior
def go_pee
puts "i am now peeing"
end
end
class Dog
include DogBehavior
end
@afred
afred / making_better_use_of_code_generators_in_hydra_gems.md
Created October 2, 2015 19:55
Making better use of code generators in Hydra gems.

Making better use of code generators in Hydra gems.

The problem:

  • Code that is generated by a gem (configuration, templates, etc) is only guaranteed to work with the version of the gem that generated it.

  • Upgrading the gem may cause the previously generated code to become obsolete.

Handling pbcoreCreator, creator, and creatorRole

Example: creator name is a literal.

NOTE: All PBCore input is using PBCore 2.0 XML unless otherwise specified.
NOTE: All RDF output is in Turtle format unless otherwise specified.

PBCore input:

<pbcoreDescriptionDocument>

Handling pbcoreContributor, contributor, and contributorRole

Example: Contributor name as a literal.

NOTE: All PBCore input is using PBCore 2.0 XML unless otherwise specified.
NOTE: All RDF output is in Turtle format unless otherwise specified.

PBCore input:

<pbcoreDescriptionDocument>
@afred
afred / sample.md
Last active August 29, 2015 14:22

app/models/generic_file.rb

class GenericFile < ActiveFedora::Base
  has_metadata 'descMetadata', type: MediaAnnotationDatastream
  has_attributes :title_attributes, datastream: 'descMetadata', multiple: true
  attr_accessible   :title_attributes     # <== needs to be changed to use strong params, yes?
end

app/models/datastream/media_annotation_datastream.rb

class MyModel < ActiveFedora::Base
end

class MyDatastream < ActiveFedora::RDFDatastream
  property :foo, predicate: ActiveTriples:Resource.new('http://example.com#foo'), 
end
@afred
afred / class_type_enforcement_on_active_triples_properties.rb
Last active August 29, 2015 14:19
Are class types enforced on ActiveTriples properties?
class MyDatastream < ActiveFedora::RDFDatastream
property :foo, predicate: ActiveTriples::Resource.new('http://example.com#foo'), class_name: 'Foo'
end
my_ds = MyDatastream.new
# I would expect this to whine.. but it doesn.
my_ds.foo = "this is definitely not a Foo"
@afred
afred / class_type_enforcement_on_active_triples_properties.rb
Created April 24, 2015 18:54
Are class types enforced on ActiveTriples properties?
class MyDatastream < ActiveFedora::NTriplesRDFDatastream
end
@afred
afred / class_type_enforcement_on_active_triples_properties.rb
Created April 24, 2015 18:54
Are class types enforced on ActiveTriples properties?
class MyDatastream < ActiveFedora::NTriplesRDFDatastream
end