Skip to content

Instantly share code, notes, and snippets.

View flyingzumwalt's full-sized avatar

Matt Zumwalt flyingzumwalt

View GitHub Profile
@flyingzumwalt
flyingzumwalt / Hydra Plugin Conventions.md
Last active December 16, 2015 14:09
Conventions when writing "plugins" for Hydra Apps

Conventions

  • Implement a Rails Engine with engine_name defined
  • Expect host application to use mount if they want to inherit routes

Implement a Rails Engine with engine_name defined

Example:

module Hydra

Callback: ActiveFedora::Base.solrization_logic

Example of usage

class GenericFile
    after_solrize << :index_collection_pids

    def index_collection_pids(solr_doc={})
 collection_pids = self.collections.map {|c| c.pid}
@flyingzumwalt
flyingzumwalt / Node Types.md
Last active December 17, 2015 09:29
Sample Test for behavior of Mads::List

##Simple Subject

BuiltWorkPlace
CulturalContext
Function
GenreForm
Geographic
Iconography
ScientificName
StylePeriod

@flyingzumwalt
flyingzumwalt / damsSubjectExpectedOutput.rdf.xml
Last active December 17, 2015 12:59
Aspirational representation of how redesigned ActiveFedora::RDFNode would work.
<mads:Topic>
<mads:authoritativeLabel>Cosmology</mads:authoritativeLabel>
<mads:elementList rdf:parseType="Collection">
<mads:TopicElement>
<mads:elementValue>Cosmology</mads:elementValue>
</mads:TopicElement>
</mads:elementList>
</mads:Topic>
<mads:Temporal>
@flyingzumwalt
flyingzumwalt / Gemfile
Last active December 18, 2015 23:29 — forked from ucsdlib/Gemfile
source 'https://rubygems.org'
gem 'rails', '3.2.13'
gem "active-fedora", :git => "git://github.com/projecthydra/active_fedora.git", :branch => "rdf_nested_attributes"
@flyingzumwalt
flyingzumwalt / option_A.rb
Last active December 20, 2015 04:29
case-based syntax for makes_derivatives_of
makes_derivatives_of :content, when: :mime_type, is_one_of: 'application/pdf',
derivatives: { :thumb => "100x100>" }
makes_derivatives_of :content, when: :mime_type, is_one_of: 'audio/wav',
derivatives: { :mp3 => {format: 'mp3'}, :ogg => {format: 'ogg'} }, processors: :audio
# -g 30 enforces keyframe generation every second (30fps)
# -b:v is the video bitrate
# -acodec is the audio codec
size_attributes = "-s 320x240"
@flyingzumwalt
flyingzumwalt / custom jquery-fileupload processAction.js.coffee
Created December 6, 2013 05:36
custom jquery-fileupload processAction: Found a simpler way to do what I wanted, but this could be useful reference for times when you want to pre-process a file when user adds it to the queue.
#
# Custom processActions
#
# Prepend to the default processQueue:
$.blueimp.fileupload.prototype.options.processQueue.unshift(
{
action: 'prepS3Upload',
# Use the action as prefix for the "@" options:
prefix: true,
fileTypes: '@',
describe ... do
...
it "should link back to collections" do
stub_request = stub("request", referer: "http://.../collections")
allow(view).to receive(:request).and_return(stub_request)
render
expect(page).to have_link(...)
end
...
end
@flyingzumwalt
flyingzumwalt / Blacklight Analysis.md
Last active August 29, 2015 14:09
Analysis: What Blacklight does

What Blacklight Does

Receives Queries

  • Translate Request params to a valid request for index (solr) & use index client library (rsolr) to query the index
  • Log search history (per user/session)
  • Keep track of configured query types (ie. search by title), sorting options and how to apply them

Generates Responses

  • Decide which serialization to return
  • Keep track of mappings between (solr documents) and supported serializations, perform those mappings when requested
@flyingzumwalt
flyingzumwalt / api_responses.rb
Last active August 29, 2015 14:21
Spec Matchers for API Responses
# spec/support/matchers/api_responses.rb
#
# RSpec matchers for API default JSON responses.
# Creates a matcher like respond_forbidden or respond_not_found corresponding to each of the Api::V1.default_responses
# Accepts optional overrides to the expected response body.
# @example Override the description expected in the JSON body of a :forbidden response
# expect(response).to respond_forbidden(description:"You can't create for that identity")
::Api::V1.default_responses.each_pair do |response_type,default_response_body|
RSpec::Matchers.define "respond_#{response_type.to_s}".to_sym do |expectation_options|