Skip to content

Instantly share code, notes, and snippets.

View aschweer's full-sized avatar

Andrea Schweer aschweer

  • Hamilton, New Zealand
View GitHub Profile
@aschweer
aschweer / scopus-citecounts.js
Created October 1, 2013 01:06
Scopus citation counts in DSpace xmlui
document.write('<script type="text/javascript" src="http://api.elsevier.com/javascript/scopussearch.jsp"> </' + 'script>');
callbackCitedbycount = function(){
if (sciverse.areSearchResultsValid()) {
var resultObj = sciverse.getSearchResults();
if (resultObj.returnedResults >0) {
citedbycount = resultObj.results[0].citedbycount;
eid = resultObj.results[0].eid;
if (citedbycount > 0) {
citeHtml = '<span class="bold">Scopus times cited</span>:</span> ';
@aschweer
aschweer / IRRStatsController.java
Last active March 24, 2016 03:55
Extracing CAUL IRR stats from a DSpace repository
package nz.ac.lconz.irr.dspace.app.xmlui.aspect.irrstats;
import org.apache.log4j.Logger;
import org.apache.solr.client.solrj.SolrServerException;
import org.dspace.authorize.AuthorizeManager;
import org.dspace.content.*;
import org.dspace.core.Constants;
import org.dspace.core.Context;
import org.dspace.eperson.Group;
import org.dspace.statistics.ObjectCount;
@aschweer
aschweer / linebreaks.xsl
Created November 1, 2012 22:31
DSpace XMLUI render newlines in abstract metadata
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" xmlns="http://www.w3.org/1999/xhtml" exclude-result-prefixes="xsl xhtml">
<!-- make sure double linefeeds are rendered as paragraph breaks -->
<xsl:template name="break">
<xsl:param name="text" select="."/>
<xsl:choose>
<xsl:when test="contains($text, '&#xa;&#xd;&#xa;')">
<p>
@aschweer
aschweer / index.php
Created August 30, 2012 21:19
PHP script to redirect item/bitstream/newsfeed links from an EPrints instance (eprints.example.net) to a DSpace instance (dspace.example.net; handle prefix 123456789)
<?php
// Example redirect script for EPrints to DSpace
// Written by Andrea Schweer <schweer@waikato.ac.nz>
//
// Configure Apache on eprints.example.net server to redirect all requests to this script:
// RewriteEngine On
//
// RewriteCond ${REQUEST_URI} !="/index.php"
// RewriteRule ^(.*)$ /index.php/$1 [L]
@aschweer
aschweer / item-view.xsl
Created June 20, 2012 21:07
Show mimetype icons on DSpace XMLUI item page (files section)
<xsl:stylesheet
xmlns:i18n="http://apache.org/cocoon/i18n/2.1"
xmlns:dri="http://di.tamu.edu/DRI/1.0/"
xmlns:mets="http://www.loc.gov/METS/"
xmlns:dim="http://www.dspace.org/xmlns/dspace/dim"
xmlns:xlink="http://www.w3.org/TR/xlink/"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"
xmlns:atom="http://www.w3.org/2005/Atom"
xmlns:ore="http://www.openarchives.org/ore/terms/"
@aschweer
aschweer / Mirage.xsl
Created May 10, 2012 21:30
Rendering the front page search above the community list, DSpace home page
<?xml version="1.0" encoding="UTF-8"?>
<!--
The contents of this file are subject to the license and copyright
detailed in the LICENSE and NOTICE files at the root of the source
tree and available online at
http://www.dspace.org/license/
-->
@aschweer
aschweer / sidebar-menu.xml
Created November 24, 2011 20:12
Adding an additional sidebar menu to DSpace XMLUI
<?xml version="1.0" encoding="UTF-8" ?>
<document xmlns="http://di.tamu.edu/DRI/1.0/" xmlns:i18n="http://apache.org/cocoon/i18n/2.1" version="1.1">
<body/>
<options>
<list id="extra.menu.help" n="help">
<head>Help</head>
<item>
<xref target="(some link)">(some text)</xref>
</item>
<list id="extra.menu.help.authorhelp" n="authorhelp">
@aschweer
aschweer / SpiderDetector.java
Created September 23, 2011 03:12
DSpace org.dspace.statistics.util.SpiderDetector snippet to exclude more bots
/**
* Static Service Method for testing spiders against existing spider files.
* <p/>
* In the future this will be extended to support User Agent and
* domain Name detection.
* <p/>
* In future spiders HashSet may be optimized as byte offset array to
* improve performance and memory footprint further.
*
* @param request
@aschweer
aschweer / waikato_get_record_ids.py
Created September 22, 2011 01:56
Example python script to get record IDs from an OAI harvest
#!/usr/bin/env python
# uses http://www.infrae.com/download/OAI/pyoai
from oaipmh.client import Client
from oaipmh.metadata import MetadataRegistry, oai_dc_reader
URL = 'http://researchcommons.waikato.ac.nz/dspace-oai/request'
registry = MetadataRegistry()
registry.registerReader('oai_dc', oai_dc_reader)
client = Client(URL, registry)