-
Notifications
You must be signed in to change notification settings - Fork 19
OAI-PMH 2.0 Implementation to export Materials #1146
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
eilmiv
wants to merge
43
commits into
ElixirTeSS:master
Choose a base branch
from
pan-training:oai_pmh
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
43 commits
Select commit
Hold shift + click to select a range
6285edc
Add PaN Services to home page
eilmiv dda7c10
Move PaN Services counter next to other counters
eilmiv 81ffe53
Service counter counts lower and upper case now
eilmiv d199aa3
Initial OAI-PMH implementation
eilmiv 8531f82
Add XSLT formating of OAI-PMH XML Results
eilmiv 73214e7
initial oai-pmh rdf setup
eilmiv 72849b7
Add json-ld to xml conversion
eilmiv 9d10575
bind sdo and dc prefixes for oai-pmh rdf export
eilmiv 19a52f9
Add rendering support for OAI-PMH rdf including prefixes
eilmiv 786b2df
Add rdf to quicklinks to oai-pmh records html
eilmiv e4debaf
Map material properties to Dublin Core for oai_dc support
eilmiv 7d98b44
Temporarily undo production config changes
eilmiv 44ce834
Add newline to production config
eilmiv 27b4dc6
Merge pull request #1 from eilmiv/oai_pmh
eilmiv 38e1622
Set repository_url of OAI-PMH based on base_url
eilmiv f28c795
Set repository_url of OAI-PMH based on base_url and not only host
eilmiv 59f941a
Merge pull request #2 from eilmiv/oai_pmh
eilmiv 5b38612
Merge branch 'master' into oai_pmh
eilmiv ebd852e
Show longer URLs in OAI-PMH html
eilmiv bc1c163
Merge pull request #3 from eilmiv/oai_pmh
eilmiv 0ebb24b
Only show visible materials
eilmiv 8ed1115
Test oai-pmh endpoint
eilmiv 8c45669
Add and update comments
eilmiv 744504f
Merge pull request #4 from ElixirTeSS/master
eilmiv b319ce9
Merge branch 'ElixirTeSS:master' into oai_pmh
eilmiv d397580
Modification note in oai2xhtml.xsl
eilmiv cc0ff63
Improved code style of material to dublin core mapping
eilmiv 57b3286
Revert "Add PaN Services to home page"
eilmiv b29873f
Change OAI-PMH ID example to be more realistic
eilmiv 481d799
Update schema of rdf OAI-PMH
eilmiv ee8c087
Don't fail when database does not exist yet.
eilmiv 7c2a9e7
Remove PublicMaterial helper class
eilmiv 12a2501
Support PAI-PMH POST requests
eilmiv c757a91
Remove library dependencies that are already part of linkeddata
eilmiv 323abaf
Improve oai-pmh tests by parsing XML
eilmiv a71a345
Move oai-pmh config to config/initializers
eilmiv 8b54db2
Refactor material to Dublin Core conversion into one method
eilmiv a163f56
Catch more errors when database does not exist yet
eilmiv aa894d8
Catch more errors in oai-pmh config when database does not exist yet
eilmiv 0d5a9ae
Hint that OAI-PMH POST without csrf is save.
eilmiv b12dc40
Simplify OAI-PMH initialization
eilmiv 8653301
More general error catching during OAI-PMH config
eilmiv 5a94a0d
Remove ignored CSRF error suppression
eilmiv File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# The controller for actions related to OAI-PMH | ||
class OaiController < ApplicationController | ||
# CSRF token authentication causes problems with OAI-PMH POST requests and OAI-PMH POST is safe because it returns static public content | ||
skip_before_action :verify_authenticity_token, only: [:index] | ||
|
||
# GET /oai-pmh | ||
def index | ||
provider = TrainingProvider.new | ||
response = provider.process_request(oai_params.to_h) | ||
|
||
# add XSLT prefix | ||
response.sub!(/<\?xml[^>]+\?>/, "\\0\n<?xml-stylesheet type=\"text/xsl\" href=\"/oai2xhtml.xsl\"?>") | ||
|
||
render body: response, content_type: 'text/xml' | ||
end | ||
|
||
private | ||
|
||
def oai_params | ||
params.permit(:verb, :identifier, :metadataPrefix, :set, :from, :until, :resumptionToken) | ||
end | ||
end |
This file contains hidden or 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
module OaiHelper | ||
end |
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
# Load the Rails application. | ||
require_relative "application" | ||
require_relative 'application' | ||
|
||
# Initialize the Rails application. | ||
Rails.application.initialize! |
This file contains hidden or 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# Configure OAI-PMH library | ||
# see comments in: https://github.com/code4lib/ruby-oai/blob/54ea6f7f5b1e2c1be5d0a7cc61cb696b5e653d8a/lib/oai/provider.rb#L98 | ||
require 'oai' | ||
require 'uri' | ||
|
||
class OAIRDF < OAI::Provider::Metadata::Format | ||
def initialize | ||
@prefix = 'rdf' | ||
@schema = 'http://www.openarchives.org/OAI/2.0/rdf.xsd' | ||
@namespace = 'http://www.w3.org/1999/02/22-rdf-syntax-ns#' | ||
@element_namespace = 'rdf' | ||
end | ||
end | ||
|
||
class TrainingProvider < OAI::Provider::Base | ||
repository_name TeSS::Config.site['title'] | ||
repository_url "#{TeSS::Config.base_url}/oai-pmh" | ||
record_prefix "oai:#{URI(TeSS::Config.base_url).host}" | ||
admin_email TeSS::Config.contact_email | ||
sample_id '142' # so that example id is oai:domain:142 | ||
|
||
register_format(OAIRDF.instance) | ||
end | ||
|
||
Rails.application.config.after_initialize do | ||
TrainingProvider.source_model OAI::Provider::ActiveRecordWrapper.new(Material.where(visible: true)) | ||
rescue ActiveRecord::ActiveRecordError | ||
Rails.logger.debug 'There is no database yet or some other error, so the OAI-PMH endpoint is not configured.' | ||
end |
This file contains hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Check failure
Code scanning / CodeQL
CSRF protection weakened or disabled High