Skip to content
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

Upload and SDC #31

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -143,3 +143,38 @@ The main API endpoints:
* query
* format
* Response depending on format

* /download
* Parameters:
* finnaId
* Response:
* download finished

* /upload
* Parameters:
* access_token
* csrf_token
* finnaId
* text (wikitext includes image info)
* Response:
* upload response from wikicommons

* /delete
* Parameters:
* finnaId
* Response:
* file deleted

* /csrfToken
* Parameters:
* access_token
* Response:
* csrf_token from wikicommons

* /depict
* Parameters:
* access_token
* title
* depictId
* Response:
* depict response from wikicommons
45 changes: 43 additions & 2 deletions finna.js
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ module.exports = {
inventoryNumber: record.identifierString,
license: '',
license_link: '',
licenseTemplate: '',
materials: materials,
measurements: record.measurements,
places: record.subjectPlaces,
Expand All @@ -165,7 +166,8 @@ module.exports = {
subjects: subjects,
thumbURL: thumbURL,
title: [],
year: ''
year: '',
downloadScale: '',
}

if (record.title) {
Expand All @@ -177,13 +179,52 @@ module.exports = {
}

if (record.imagesExtended) {
let displayImage = record.imagesExtended[record.imagesExtended.length - 1].urls.large ? record.imagesExtended[record.imagesExtended.length - 1].urls.large : record.imagesExtended[record.imagesExtended.length - 1].urls.medium;
let imagesExtendedContent = record.imagesExtended[record.imagesExtended.length - 1];
let displayImage = imagesExtendedContent.urls.large ? imagesExtendedContent.urls.large : imagesExtendedContent.urls.medium;
image.imageURL = BASE_URL + displayImage;
if (imagesExtendedContent.highResolution){
let highResolution = imagesExtendedContent.highResolution;
if (highResolution.original) {
image.downloadURL = highResolution.original[highResolution.original.length - 1].url;
image.downloadScale = 'highResolution.original';
}
else if (highResolution.master) {
image.downloadURL = highResolution.master[highResolution.master.length - 1].url;
image.downloadScale = 'highResolution.master';
}
else {
image.downloadURL = image.imageURL;
image.downloadScale = 'displayUrl';
}

}
else if (imagesExtendedContent.urls.master) {
image.downloadURL = imagesExtendedContent.urls.master;
image.downloadScale = 'master';
}
else {
image.downloadURL = image.imageURL;
image.downloadScale = 'displayUrl';
}
}

if (record.imageRights != undefined) {
image.license_link = record.imageRights.link;
image.license = record.imageRights.copyright;
switch (image.license) {
case 'CC BY 4.0':
image.licenseTemplate = '{{Cc-by-4.0}}';
break;
case 'CC BY-SA 4.0':
image.licenseTemplate = '{{Cc-by-sa-4.0}}';
break;
case 'CC0':
image.licenseTemplate = '{{Cc-zero}}';
break;
case 'PDM':
image.licenseTemplate = '{{PD-old}}';
break;
}
}

if (record.institutions) {
Expand Down
Loading