Skip to content

Instantly share code, notes, and snippets.

View cbeer's full-sized avatar

Chris Beer cbeer

View GitHub Profile
@cbeer
cbeer / data-config.xml
Created March 13, 2010 20:57
Mapping the NPR API schema to a solr index using the Data Import Handler URLDataSource
<dataConfig>
<dataSource name="nprapi" type="URLDataSource" encoding="UTF-8" connectionTimeout="5000" readTimeout="10000"/>
<document>
<entity name="nprapi"
pk="id"
url="http://api.npr.org/query?numResults=20&amp;fields=all&amp;output=nprml&amp;apiKey=[redacted]&amp;startNum=${dataimporter.request.startNum}"
processor="XPathEntityProcessor"
forEach="/nprml/list/story"
transformer="DateFormatTransformer">
Mar 19, 2010 2:51:27 PM org.apache.catalina.core.ApplicationContext log
INFO: HTMLManager: restart: Reloading web application at '/solr'
Mar 19, 2010 2:51:27 PM org.apache.catalina.core.StandardContext reload
INFO: Reloading this Context has started
WARN: The method class org.apache.commons.logging.impl.SLF4JLogFactory#release() was invoked.
WARN: Please see http://www.slf4j.org/codes.html#release for an explanation.
Mar 19, 2010 2:51:27 PM org.apache.solr.core.SolrResourceLoader locateSolrHome
INFO: JNDI not configured for solr (NoInitialContextEx)
Mar 19, 2010 2:51:27 PM org.apache.solr.core.SolrResourceLoader locateSolrHome
INFO: solr home defaulted to 'solr/' (could not find system property or JNDI)
undefined method `export_formats' for #<Mash:0x102f0d388>
RAILS_ROOT: /Users/chris/Projects/ov_app
Application Trace | Framework Trace | Full Trace
/Users/chris/Projects/ov_app/vendor/gems/rsolr-ext-0.12.0/lib/rsolr-ext/model.rb:96:in `send'
/Users/chris/Projects/ov_app/vendor/gems/rsolr-ext-0.12.0/lib/rsolr-ext/model.rb:96:in `method_missing'
vendor/plugins/blacklight/app/controllers/catalog_controller.rb:41:in `show'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/mime_responds.rb:106:in `call'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/mime_responds.rb:106:in `respond_to'
vendor/plugins/blacklight/app/controllers/catalog_controller.rb:33:in `show'
# Ruby/Fedora script to upload a file to a Fedora Commons repository
# Author: Chris Beer
require 'rubygems'
require 'rest_client'
require 'mime/types'
require 'cgi'
rest_uri = 'http://localhost:8080/fedora'
user = 'fedoraUser'
#!/usr/bin/env ruby
#
# ./dscm-to-html.rb repository_url PID
#
require 'rubygems'
require 'nokogiri'
require 'open-uri'
require 'erb'
require 'active_support'
class Surrogate < ActiveRecord::Base
def self.columns()
@columns ||= [];
end
def self.column(name, sql_type = nil, default = nil, null = true)
columns << ActiveRecord::ConnectionAdapters::Column.new(name.to_s, default, sql_type.to_s, null)
end
def save
end
def new_record?
diff --git a/app/controllers/folder_controller.rb b/app/controllers/folder_controller.rb
index 9427a6f..804c7f0 100644
--- a/app/controllers/folder_controller.rb
+++ b/app/controllers/folder_controller.rb
@@ -12,21 +12,30 @@ class FolderController < ApplicationController
session[:folder_document_ids] = session[:folder_document_ids] || []
session[:folder_document_ids] << params[:id]
flash[:notice] = "#{params[:title] || "Item"} successfully added to Folder"
- redirect_to :back
+ respond_to do |format|
require 'rubygems'
require 'curb'
require 'trollop'
require 'activesupport'
skos_property_id = {"alternative-label"=>1, "hidden-label"=>9, "notation"=>30, "note"=>17, "definition"=>5, "example"=>7, "scope-note"=>22, "editorial-note"=>6, "change-note"=>4, "history-note"=>10, "has-broader"=>3, "has-narrower"=>16, "related-to"=>21, "is-in-mapping-relation-with"=>37, "has-broader-match"=>32, "has-narrower-match"=>33, "has-related-match"=>34, "has-close-match"=>36, "has-exact-match"=>35}
opts = Trollop::options do
version "metadataregistry.org ingest 0.0.1 (c) 2011 Chris Beer"
banner <<-EOS
#!/usr/bin/env jython
# This is a Jython Servlet wrapper for FITS <http://code.google.com/p/fits/>
#
# INSTALL:
# Set the FITS_HOME variable to the location of the FITS package
#
# Some JARs may need to be moved into the endorsed folder (./common/endorsed)
# like jaxon, jdom, saxon, saxpath, and xerces.
#
(function($) {
$.fn.sync = function(target, options) {
media = this;
var settings = {
'begin' : 'begin_seconds',
'end' : 'end_seconds',
'on' : function() { $(this).trigger('sync-on'); },
'off' : function() { $(this).trigger('sync-off'); },
'time' : function() { return this.currentTime },
'poll' : false,