Last active
August 29, 2015 14:07
-
-
Save cfitz/af3157ef7967368aadfc to your computer and use it in GitHub Desktop.
Some basic ASpace overrides...
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<=# plugins/local/frontend/views/shared/_header_repository.html.erb %> | |
<=# just removes the links to classification %> | |
<div class="container repository-header"> | |
<div class="navbar"> | |
<div class="navbar-inner"> | |
<div class="container"> | |
<button type="button" class="btn btn-navbar" data-toggle="collapse" data-target=".nav-repository-collapse"> | |
<span class="icon-bar"></span> | |
<span class="icon-bar"></span> | |
<span class="icon-bar"></span> | |
</button> | |
<div class="nav-collapse nav-repository-collapse collapse"> | |
<% if session[:user] and session[:repo_id] %> | |
<ul class="nav"> | |
<li <% if controller_name === "welcome" %>class="active"<% end %>> | |
<%= link_to raw('<span class="icon-home"></span>'), :controller => :welcome, :action => :index %> | |
</li> | |
<li class="dropdown browse-container"> | |
<a href="#" class="dropdown-toggle" data-toggle="dropdown"><%= I18n.t("actions.browse") %> <b class="caret"></b></a> | |
<ul class="dropdown-menu"> | |
<li><%= link_to I18n.t("accession._plural"), :controller => :accessions, :action => :index %></li> | |
<li><%= link_to I18n.t("resource._plural"), :controller => :resources, :action => :index %></li> | |
<li><%= link_to I18n.t("digital_object._plural"), :controller => :digital_objects, :action => :index %></li> | |
<li class="divider"></li> | |
<li><%= link_to I18n.t("subject._plural"), :controller => :subjects, :action => :index %></li> | |
<li><%= link_to I18n.t("agent._plural"), :controller => :agents, :action => :index %></li> | |
<li><%= link_to I18n.t("location._plural"), :controller => :locations, :action => :index %></li> | |
<li><%= link_to I18n.t("event._plural"), :controller => :events, :action => :index %></li> | |
<li><%= link_to I18n.t("collection_management._plural"), :controller => :collection_management, :action => :index %></li> | |
</ul> | |
</li> | |
<% if ['update_archival_record', 'update_subject_record', 'update_event_record', | |
'update_agent_record', 'update_location_record'].find {|p| user_can?(p)} %> | |
<li class="dropdown create-container"> | |
<a href="#" class="dropdown-toggle" data-toggle="dropdown"><%= I18n.t("navbar.create") %> <b class="caret"></b></a> | |
<ul class="dropdown-menu"> | |
<% if user_can?('update_archival_record') %> | |
<li><%= link_to I18n.t("accession._singular"), :controller => :accessions, :action => :new %></li> | |
<li><%= link_to I18n.t("resource._singular"), :controller => :resources, :action => :new %></li> | |
<li><%= link_to I18n.t("digital_object._singular"), :controller => :digital_objects, :action => :new %></li> | |
<li class="divider"></li> | |
<% end %> | |
<% if user_can?('update_subject_record') %> | |
<li><%= link_to I18n.t("subject._singular"), :controller => :subjects, :action => :new %></li> | |
<% end %> | |
<% if user_can?('update_agent_record') %> | |
<li class="dropdown-submenu"> | |
<a href="javascript:void(0);"><%= I18n.t("agent._singular") %></a> | |
<ul class="dropdown-menu"> | |
<li><%= link_to I18n.t("agent_person._singular"), :controller => :agents, :action => :new, :agent_type => :agent_person %></li> | |
<li><%= link_to I18n.t("agent_family._singular"), :controller => :agents, :action => :new, :agent_type => :agent_family %></li> | |
<li><%= link_to I18n.t("agent_corporate_entity._singular"), :controller => :agents, :action => :new, :agent_type => :agent_corporate_entity %></li> | |
<li><%= link_to I18n.t("agent_software._singular"), :controller => :agents, :action => :new, :agent_type => :agent_software %></li> | |
</ul> | |
</li> | |
<% end %> | |
<% if user_can?('update_location_record') %> | |
<li class="dropdown-submenu"> | |
<a href="javascript:void(0);"><%= I18n.t("location._singular") %></a> | |
<ul class="dropdown-menu"> | |
<li><%= link_to I18n.t("location._frontend.action.single"), :controller => :locations, :action => :new %></li> | |
<li><%= link_to I18n.t("location._frontend.action.batch"), :controller => :locations, :action => :batch %></li> | |
</ul> | |
</li> | |
<% end %> | |
<% if user_can?('update_event_record') %> | |
<li><%= link_to I18n.t("event._singular"), :controller => :events, :action => :new %></li> | |
<% end %> | |
</ul> | |
</li> | |
<% end %> | |
<li> | |
<%= form_tag(url_for(:controller => :search, :action => :do_search), :method => :get, :class => "navbar-form pull-left") do %> | |
<div class="input-append"> | |
<input id="global-search-box" type="text" class="span2" placeholder="<%= I18n.t("navbar.search_placeholder") %>" name="q" value="<%= params[:q] %>"/> | |
<div class="btn-group"> | |
<button id="global-search-button" class="btn"><span class=" icon-search"></span></button> | |
</div> | |
</div> | |
<% end %> | |
</li> | |
</ul> | |
<ul class="nav pull-right"> | |
<% if user_can?('update_archival_record') %> | |
<li><%= link_to I18n.t("job._plural"), :controller => :jobs, :action => :index %></li> | |
<% end %> | |
<li><%= link_to I18n.t("navbar.list_reports"), :controller => :reports, :action => :index %></li> | |
<% if Plugins.repository_menu_items.any? {|plugin| has_permission_for_controller?(session, plugin)} %> | |
<li class="dropdown plugin-container"> | |
<a href="#" class="dropdown-toggle" data-toggle="dropdown"><%= I18n.t("navbar.plugins") %> <b class="caret"></b></a> | |
<ul class="dropdown-menu"> | |
<% Plugins.repository_menu_items.each do |plugin| %> | |
<% if has_permission_for_controller?(session, plugin) %> | |
<li><%= link_to I18n.t("plugins.#{plugin}.label"), :controller => plugin.intern, :action => :index %></li> | |
<% end %> | |
<% end %> | |
</ul> | |
</li> | |
<% end %> | |
<li class=" dropdown repo-container"> | |
<div <% if user_can?('manage_repository') %>class="input-append"<% end %>> | |
<span class="inset-label"> | |
<span class="repository-label has-popover" data-trigger="hover" data-placement="bottom" data-html='true' data-title="<span class='icon-hdd'></span> <%= CGI::escapeHTML(current_repo['repo_code']) %>" data-content="<%= CGI::escapeHTML(current_repo['name']) %>"> | |
<span class="icon-hdd"></span><span class="current-repository-id"><% if current_repo %><%= current_repo['repo_code'] %><% end %></span> | |
</span> | |
</span> | |
<% if user_can?('manage_repository') || user_can?('transfer_repository') %> | |
<a class="btn dropdown-toggle last" data-toggle="dropdown" href="#"><span class="icon-cog"></span> <span class="caret"></span></a> | |
<ul class="dropdown-menu pull-right"> | |
<% if user_can?('manage_repository') %> | |
<li><%= link_to I18n.t("navbar.manage_groups"), :controller => :groups, :action => :index %></li> | |
<li><%= link_to I18n.t("user._frontend.section.manage_access"), :controller => :users, :action => :manage_access %></li> | |
<li><%= link_to I18n.t("navbar.repo_preferences"), :controller => :preferences, :action => :edit, :id => 0, :repo => true %></li> | |
<% end %> | |
<% if user_can?('transfer_repository') && @repositories.length > 1 %> | |
<li><%= link_to I18n.t("repository._frontend.section.transfer"), :controller => :repositories, :action => :transfer, :id => session[:repo_id] %></li> | |
<% end %> | |
</ul> | |
<% end %> | |
</div> | |
</li> | |
<% if ArchivesSpaceHelp.enabled? %> | |
<li><%= link_to_help :link_opts => {"data-placement" => (session[:user] ? "left" : "bottom")} %></li> | |
<% end %> | |
</ul> | |
<% end %> | |
</div><!-- /.nav-collapse --> | |
</div> | |
</div><!-- /navbar-inner --> | |
</div> | |
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# plugins/local/frontend/controllers/my_resources_controller.rb | |
# just adds a default sort param to the index action of the resources_controller | |
# can do a similar tweak to others, like accessions. | |
require Rails.root.join('app/controllers/resources_controller') | |
class ResourcesController < ApplicationController | |
def index | |
params["sort"] ||= "user_mtime asc" | |
@search_data = Search.for_type(session[:repo_id], params[:include_components]==="true" ? ["resource", "archival_object"] : "resource", params_for_backend_search.merge({"facet[]" => SearchResultData.RESOURCE_FACETS})) | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# plugins/local/frontend/plugin_init.rb | |
require_relative 'models/search_result_data' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# plugins/local/frontend/models/search_result_data.rb | |
# redefines facets, which you can see at: | |
# https://github.com/archivesspace/archivesspace/blob/master/frontend/app/models/search_result_data.rb#L215-L257 | |
require Rails.root.join('app/models/search_result_data') | |
class SearchResultData | |
# this changes what facets are requested for Resource searches. Display order follows the order in the array. | |
def self.RESOURCE_FACETS | |
[ "primary_type", "level", "publish", "subjects"] | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# plugins/local/backend/model/solr.rb | |
# simply adds a solr param to sort by index (alpha) rather than count. | |
class Solr::Query | |
def to_solr_url | |
raise "Missing pagination settings" unless @pagination | |
add_solr_param(:"facet.sort", "index") # add the sort | |
unless @show_excluded_docs | |
add_solr_param(:fq, "-exclude_by_default:true") | |
end | |
if @show_published_only | |
add_solr_param(:fq, "publish:true") | |
end | |
unless @show_suppressed | |
add_solr_param(:fq, "suppressed:false") | |
end | |
add_solr_param(:facet, "true") | |
unless @facet_fields.empty? | |
add_solr_param(:"facet.field", @facet_fields) | |
end | |
if @query_type == :edismax | |
add_solr_param(:defType, "edismax") | |
add_solr_param(:pf, "four_part_id^4") | |
add_solr_param(:qf, "four_part_id^3 title^2 fullrecord") | |
end | |
Solr.search_hooks.each do |hook| | |
hook.call(self) | |
end | |
url = @solr_url | |
# retain path if present i.e. "solr/aspace/select" when using an external | |
# Solr with path required | |
url.path += "/select" | |
url.query = URI.encode_www_form([[:q, @query_string], | |
[:wt, @writer_type], | |
[:start, (@pagination[:page] - 1) * @pagination[:page_size]], | |
[:rows, @pagination[:page_size]]] + | |
@solr_params) | |
url | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment