Skip to content

Instantly share code, notes, and snippets.

Avatar

Andrew Myers afred

  • WGBH Educational Foundation
  • Boston, MA
View GitHub Profile
@afred
afred / jekyll_tutorials_for_samvera_connect_2018.md
Last active Oct 10, 2018
Jekyll Tutorials for Samvera Connect 2018
View jekyll_tutorials_for_samvera_connect_2018.md

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 Nov 6, 2015
A more passive way to monkey patch in ruby
View unobtrusive_monkey_patch_example.rb
# 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 Oct 2, 2015
Making better use of code generators in Hydra gems.
View making_better_use_of_code_generators_in_hydra_gems.md

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.

View pbcoreCreator.md

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>
View pbcoreContributor.md

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>
View sample.md

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

View datastream_vs_module.md
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
Created Apr 24, 2015
Are class types enforced on ActiveTriples properties?
View class_type_enforcement_on_active_triples_properties.rb
class MyDatastream < ActiveFedora::NTriplesRDFDatastream
end
@afred
afred / class_type_enforcement_on_active_triples_properties.rb
Created Apr 24, 2015
Are class types enforced on ActiveTriples properties?
View class_type_enforcement_on_active_triples_properties.rb
class MyDatastream < ActiveFedora::NTriplesRDFDatastream
end
@afred
afred / class_type_enforcement_on_active_triples_properties.rb
Created Apr 24, 2015
Are class types enforced on ActiveTriples properties?
View class_type_enforcement_on_active_triples_properties.rb
class MyDatastream < ActiveFedora::NTriplesRDFDatastream
end