Skip to content

Instantly share code, notes, and snippets.

View jkeck's full-sized avatar
:shipit:

Jessie Keck jkeck

:shipit:
View GitHub Profile
configure_blacklight do |config|
config.default_solr_params = {
:qt => 'search',
:qf => 'id content url title anchor author',
:rows => 10,
:"hl.fl" => "content",
:"hl.simple.pre" => '<span class="label label-info">',
:"hl.simple.post" => "</span>",
:hl => true
}
@jkeck
jkeck / _fimlstrip.html.erb
Last active January 3, 2016 10:09
SearchWorks Filmstrip Example
<div class="filmstrip-container">
<div class="filmstrip-total"><%= link_to("View #{pluralize(document.total_collection_members, "item")} in this collection online", catalog_index_path(:f=>{:collection=>[document[:id]]}, :view=>"gallery")) %></div>
<div class="scroll-control disabled" data-direction="left"></div>
<div class="scroll-control" data-direction="right"></div>
<div class="filmstrip" data-preview-container='true'>
<ul>
<%- document.children.each do |doc| -%>
<%- unless doc.image_urls.blank? -%>
<li>
<div>
@jkeck
jkeck / access_log-20131201
Created December 5, 2013 00:59
All 403 errors from the apache access log on 2013-12-01
/users/jvine-drupal HTTP/1.1" 403 7482
/users/jvine-drupal HTTP/1.1" 403 7482 "http://libweb-test.stanford.edu/user" "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/31.0.1650.57 Safari/537.36"
/sites/default/files/styles/large/public/tech%20desk%20banner.jpg HTTP/1.1" 403 7536
/sites/default/files/styles/large/public/tech%20desk%20banner.jpg HTTP/1.1" 403 7536 "http://libweb-test.stanford.edu/" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/31.0.1650.57 Safari/537.36"
/sites/default/files/styles/large/public/disc.png HTTP/1.1" 403 7525
/sites/default/files/styles/large/public/disc.png HTTP/1.1" 403 7525 "http://libweb-test.stanford.edu/" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/31.0.1650.57 Safari/537.36"
/sites/default/files/styles/large/public/computer_0.png HTTP/1.1" 403 6941
/sites/default/files/styles/large/public/computer_0.png HTTP/1.1" 403 6941 "http://libweb-test.stanford.ed
@jkeck
jkeck / form_ext.rb
Created January 8, 2013 21:31
This would live in the lib directory of a gem. That gem would also provide some JS and some sort of controller logic about how to handle the data / form fields.
module FormExt
module FormHelper
def self.included(arg)
ActionView::Helpers::FormBuilder.send(:include, FormExt::FormBuilder)
end
def multi_valued_text_field_tag(object_name, method, options = {})
output = ''
if options and options[:value] and options[:value].is_a?(Array)
options.merge!(:"data-multivalued" => true)
options[:value].each_with_index do |value, index|
def get_addl_item_info(bcode,building,document)
# we need to have ON-ORDER records dealt with even though they don't have a barcode
if doc_on_order?(document)
return {:request_status => true, :status => "unavailable"}
else
if document.respond_to?(:holdings_from_solr)
unless document["item_display"].nil? or bcode.strip.blank?
return mod_item(bcode,building,document,document.holdings_from_solr[bcode.strip.to_sym]) if document.holdings_from_solr.has_key?(bcode.strip.to_sym)
end
end
@jkeck
jkeck / gist:3515705
Created August 29, 2012 17:07 — forked from MrDys/gist:3512455
Link directly to an open modal window in Bootstrap
/* If you've ever had the need to link directly to an open modal window with Bootstrap, here's a quick and easy way to do it:
Make sure your modal has an id and is classed with modal and permalink:
<div class="modal permalink" id="myModal" ... >
Then stick this bit of Javascript at at the end of your document:
*/
$(document).ready(function() {
@jkeck
jkeck / README
Created May 4, 2012 21:59
Nearby on shelf
These are the flat files for Nearby on Shelf as implemented in SearchWorks.
I would like to turn this into an installable gem, however as a stop-gap measure for those interested in implementing nearby for themselves (or wants to run w/ this code an refactoring into a gem).
Some major areas of consideration are:
1) The current code gets sort keys and call numbers out of a delimited item_display field. These should be single configurable fields for each key.
2) jQuery for scrolling the nearby UI. We should really find a reliable 3rd party library for this kind of carrousel behavior.
3) There is some code revolving around checking barcodes. This should be refactored out in some way but I can't think of how.
4) The part of the NearbyOnShelf class initializer that takes action based on an "ajax" parameter seems wrong to me, but I can't think of a proper solution off the top of my head.
5) Several pieces of this will need to have a way of injecting HTML into the Blacklight UI. Changes to both Blacklight and
Loading development environment (Rails 3.1.1)
ruby-1.8.7-p334 :001 > CatalogController.new
NameError: undefined local variable or method `blacklight_config' for nil:NilClass
from /Users/jkeck/.rvm/gems/ruby-1.8.7-p334@searchworks_rails3/gems/activesupport-3.1.1/lib/active_support/whiny_nil.rb:48:in `method_missing'
from /Users/jkeck/.rvm/gems/ruby-1.8.7-p334@searchworks_rails3/gems/blacklight-3.2.1/app/helpers/blacklight/blacklight_helper_behavior.rb:97:in `index_fields'
from /Users/jkeck/.rvm/gems/ruby-1.8.7-p334@searchworks_rails3/gems/blacklight-3.2.1/app/helpers/blacklight/blacklight_helper_behavior.rb:97:in `index_fields'
from /Users/jkeck/.rvm/gems/ruby-1.8.7-p334@searchworks_rails3/gems/blacklight-3.2.1/lib/blacklight/utils.rb:11:in `send'
from /Users/jkeck/.rvm/gems/ruby-1.8.7-p334@searchworks_rails3/gems/blacklight-3.2.1/lib/blacklight/utils.rb:11:in `[]'
from /Users/jkeck/.rvm/gems/ruby-1.8.7-p334@searchworks_rails3/gems/blacklight-3.2.1/lib/blacklight/configuration.rb:44:in `initialize_defaul
require 'blacklight/catalog'
class CatalogController < ApplicationController
include Blacklight::Catalog
configure_blacklight do |config|
config.default_solr_params = {
:qt => "search",
:per_page => 20
}
function migrate_views_panes(){
$views_panes = db_query("SELECT * FROM {panels_pane} WHERE type = 'views2'");
while($view_pane = db_fetch_object($views_panes)){
$config = unserialize($view_pane->configuration);
$view = views_get_view($view_pane->subtype);
$keys = array_keys($view->display["default"]->display_options["arguments"]);
$new_args = array();
foreach($keys as $i=>$key){
if($key != "group_nid"){
$new_args[$key] = $config["arguments"][$i];