Skip to content

Commit

Permalink
allow passing strings to isprofile
Browse files Browse the repository at this point in the history
  • Loading branch information
edsilv committed Aug 13, 2018
1 parent 662b8d6 commit d3c63a0
Show file tree
Hide file tree
Showing 6 changed files with 68 additions and 12 deletions.
12 changes: 12 additions & 0 deletions dist/client/manifesto.bundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -2438,6 +2438,9 @@ var Manifesto;
return Utils.normaliseUrl(url1) === Utils.normaliseUrl(url2);
};
Utils.isImageProfile = function (profile) {
if (typeof (profile) === 'string') {
profile = new Manifesto.ServiceProfile(profile);
}
if (Utils.normalisedUrlsMatch(profile.toString(), Manifesto.ServiceProfile.STANFORDIIIFIMAGECOMPLIANCE0.toString()) ||
Utils.normalisedUrlsMatch(profile.toString(), Manifesto.ServiceProfile.STANFORDIIIFIMAGECOMPLIANCE1.toString()) ||
Utils.normalisedUrlsMatch(profile.toString(), Manifesto.ServiceProfile.STANFORDIIIFIMAGECOMPLIANCE2.toString()) ||
Expand Down Expand Up @@ -2467,6 +2470,9 @@ var Manifesto;
return false;
};
Utils.isLevel0ImageProfile = function (profile) {
if (typeof (profile) === 'string') {
profile = new Manifesto.ServiceProfile(profile);
}
if (Utils.normalisedUrlsMatch(profile.toString(), Manifesto.ServiceProfile.STANFORDIIIFIMAGECOMPLIANCE0.toString()) ||
Utils.normalisedUrlsMatch(profile.toString(), Manifesto.ServiceProfile.STANFORDIIIF1IMAGECOMPLIANCE0.toString()) ||
Utils.normalisedUrlsMatch(profile.toString(), Manifesto.ServiceProfile.STANFORDIIIFIMAGECONFORMANCE0.toString()) ||
Expand All @@ -2480,6 +2486,9 @@ var Manifesto;
return false;
};
Utils.isLevel1ImageProfile = function (profile) {
if (typeof (profile) === 'string') {
profile = new Manifesto.ServiceProfile(profile);
}
if (Utils.normalisedUrlsMatch(profile.toString(), Manifesto.ServiceProfile.STANFORDIIIFIMAGECOMPLIANCE1.toString()) ||
Utils.normalisedUrlsMatch(profile.toString(), Manifesto.ServiceProfile.STANFORDIIIF1IMAGECOMPLIANCE1.toString()) ||
Utils.normalisedUrlsMatch(profile.toString(), Manifesto.ServiceProfile.STANFORDIIIFIMAGECONFORMANCE1.toString()) ||
Expand All @@ -2493,6 +2502,9 @@ var Manifesto;
return false;
};
Utils.isLevel2ImageProfile = function (profile) {
if (typeof (profile) === 'string') {
profile = new Manifesto.ServiceProfile(profile);
}
if (Utils.normalisedUrlsMatch(profile.toString(), Manifesto.ServiceProfile.STANFORDIIIFIMAGECOMPLIANCE2.toString()) ||
Utils.normalisedUrlsMatch(profile.toString(), Manifesto.ServiceProfile.STANFORDIIIF1IMAGECOMPLIANCE2.toString()) ||
Utils.normalisedUrlsMatch(profile.toString(), Manifesto.ServiceProfile.STANFORDIIIFIMAGECONFORMANCE2.toString()) ||
Expand Down
14 changes: 13 additions & 1 deletion dist/client/manifesto.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// manifesto v2.2.31 https://github.com/iiif-commons/manifesto
// manifesto v2.2.32 https://github.com/iiif-commons/manifesto
(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.manifesto = f()}})(function(){var define,module,exports;return (function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r})()({1:[function(require,module,exports){
(function (global){

Expand Down Expand Up @@ -2366,6 +2366,9 @@ var Manifesto;
return Utils.normaliseUrl(url1) === Utils.normaliseUrl(url2);
};
Utils.isImageProfile = function (profile) {
if (typeof (profile) === 'string') {
profile = new Manifesto.ServiceProfile(profile);
}
if (Utils.normalisedUrlsMatch(profile.toString(), Manifesto.ServiceProfile.STANFORDIIIFIMAGECOMPLIANCE0.toString()) ||
Utils.normalisedUrlsMatch(profile.toString(), Manifesto.ServiceProfile.STANFORDIIIFIMAGECOMPLIANCE1.toString()) ||
Utils.normalisedUrlsMatch(profile.toString(), Manifesto.ServiceProfile.STANFORDIIIFIMAGECOMPLIANCE2.toString()) ||
Expand Down Expand Up @@ -2395,6 +2398,9 @@ var Manifesto;
return false;
};
Utils.isLevel0ImageProfile = function (profile) {
if (typeof (profile) === 'string') {
profile = new Manifesto.ServiceProfile(profile);
}
if (Utils.normalisedUrlsMatch(profile.toString(), Manifesto.ServiceProfile.STANFORDIIIFIMAGECOMPLIANCE0.toString()) ||
Utils.normalisedUrlsMatch(profile.toString(), Manifesto.ServiceProfile.STANFORDIIIF1IMAGECOMPLIANCE0.toString()) ||
Utils.normalisedUrlsMatch(profile.toString(), Manifesto.ServiceProfile.STANFORDIIIFIMAGECONFORMANCE0.toString()) ||
Expand All @@ -2408,6 +2414,9 @@ var Manifesto;
return false;
};
Utils.isLevel1ImageProfile = function (profile) {
if (typeof (profile) === 'string') {
profile = new Manifesto.ServiceProfile(profile);
}
if (Utils.normalisedUrlsMatch(profile.toString(), Manifesto.ServiceProfile.STANFORDIIIFIMAGECOMPLIANCE1.toString()) ||
Utils.normalisedUrlsMatch(profile.toString(), Manifesto.ServiceProfile.STANFORDIIIF1IMAGECOMPLIANCE1.toString()) ||
Utils.normalisedUrlsMatch(profile.toString(), Manifesto.ServiceProfile.STANFORDIIIFIMAGECONFORMANCE1.toString()) ||
Expand All @@ -2421,6 +2430,9 @@ var Manifesto;
return false;
};
Utils.isLevel2ImageProfile = function (profile) {
if (typeof (profile) === 'string') {
profile = new Manifesto.ServiceProfile(profile);
}
if (Utils.normalisedUrlsMatch(profile.toString(), Manifesto.ServiceProfile.STANFORDIIIFIMAGECOMPLIANCE2.toString()) ||
Utils.normalisedUrlsMatch(profile.toString(), Manifesto.ServiceProfile.STANFORDIIIF1IMAGECOMPLIANCE2.toString()) ||
Utils.normalisedUrlsMatch(profile.toString(), Manifesto.ServiceProfile.STANFORDIIIFIMAGECONFORMANCE2.toString()) ||
Expand Down
10 changes: 5 additions & 5 deletions dist/manifesto.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// manifesto v2.2.31 https://github.com/iiif-commons/manifesto
// manifesto v2.2.32 https://github.com/iiif-commons/manifesto

declare namespace Manifesto {
class StringValue {
Expand Down Expand Up @@ -556,10 +556,10 @@ declare namespace Manifesto {
static normaliseType(type: string): string;
static normaliseUrl(url: string): string;
static normalisedUrlsMatch(url1: string, url2: string): boolean;
static isImageProfile(profile: Manifesto.ServiceProfile): boolean;
static isLevel0ImageProfile(profile: Manifesto.ServiceProfile): boolean;
static isLevel1ImageProfile(profile: Manifesto.ServiceProfile): boolean;
static isLevel2ImageProfile(profile: Manifesto.ServiceProfile): boolean;
static isImageProfile(profile: string | Manifesto.ServiceProfile): boolean;
static isLevel0ImageProfile(profile: string | Manifesto.ServiceProfile): boolean;
static isLevel1ImageProfile(profile: string | Manifesto.ServiceProfile): boolean;
static isLevel2ImageProfile(profile: string | Manifesto.ServiceProfile): boolean;
static loadResource(uri: string): Promise<string>;
static loadExternalResourcesAuth1(resources: IExternalResource[], openContentProviderInteraction: (service: Manifesto.IService) => any, openTokenService: (resource: Manifesto.IExternalResource, tokenService: Manifesto.IService) => Promise<any>, getStoredAccessToken: (resource: Manifesto.IExternalResource) => Promise<Manifesto.IAccessToken | null>, userInteractedWithContentProvider: (contentProviderInteraction: any) => Promise<any>, getContentProviderInteraction: (resource: IExternalResource, service: Manifesto.IService) => Promise<any>, handleMovedTemporarily: (resource: IExternalResource) => Promise<any>, showOutOfOptionsMessages: (resource: IExternalResource, service: Manifesto.IService) => void): Promise<IExternalResource[]>;
static loadExternalResourceAuth1(resource: IExternalResource, openContentProviderInteraction: (service: Manifesto.IService) => any, openTokenService: (resource: Manifesto.IExternalResource, tokenService: Manifesto.IService) => Promise<void>, getStoredAccessToken: (resource: Manifesto.IExternalResource) => Promise<Manifesto.IAccessToken | null>, userInteractedWithContentProvider: (contentProviderInteraction: any) => Promise<any>, getContentProviderInteraction: (resource: IExternalResource, service: Manifesto.IService) => Promise<any>, handleMovedTemporarily: (resource: IExternalResource) => Promise<any>, showOutOfOptionsMessages: (resource: IExternalResource, service: Manifesto.IService) => void): Promise<IExternalResource>;
Expand Down
14 changes: 13 additions & 1 deletion dist/server/manifesto.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "manifesto.js",
"version": "2.2.31",
"version": "2.2.32",
"description": "IIIF Presentation API utility library for client and server",
"main": "./dist/server/manifesto.js",
"types": "./dist/manifesto.d.ts",
Expand Down
28 changes: 24 additions & 4 deletions src/Utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,12 @@ namespace Manifesto {
return Utils.normaliseUrl(url1) === Utils.normaliseUrl(url2);
}

static isImageProfile(profile: Manifesto.ServiceProfile): boolean {
static isImageProfile(profile: string | Manifesto.ServiceProfile): boolean {

if (typeof(profile) === 'string') {
profile = new Manifesto.ServiceProfile(profile);
}

if (Utils.normalisedUrlsMatch(profile.toString(), Manifesto.ServiceProfile.STANFORDIIIFIMAGECOMPLIANCE0.toString()) ||
Utils.normalisedUrlsMatch(profile.toString(), Manifesto.ServiceProfile.STANFORDIIIFIMAGECOMPLIANCE1.toString()) ||
Utils.normalisedUrlsMatch(profile.toString(), Manifesto.ServiceProfile.STANFORDIIIFIMAGECOMPLIANCE2.toString()) ||
Expand Down Expand Up @@ -149,7 +154,12 @@ namespace Manifesto {
return false;
}

static isLevel0ImageProfile(profile: Manifesto.ServiceProfile): boolean {
static isLevel0ImageProfile(profile: string | Manifesto.ServiceProfile): boolean {

if (typeof(profile) === 'string') {
profile = new Manifesto.ServiceProfile(profile);
}

if (Utils.normalisedUrlsMatch(profile.toString(), Manifesto.ServiceProfile.STANFORDIIIFIMAGECOMPLIANCE0.toString()) ||
Utils.normalisedUrlsMatch(profile.toString(), Manifesto.ServiceProfile.STANFORDIIIF1IMAGECOMPLIANCE0.toString()) ||
Utils.normalisedUrlsMatch(profile.toString(), Manifesto.ServiceProfile.STANFORDIIIFIMAGECONFORMANCE0.toString()) ||
Expand All @@ -164,7 +174,12 @@ namespace Manifesto {
return false;
}

static isLevel1ImageProfile(profile: Manifesto.ServiceProfile): boolean {
static isLevel1ImageProfile(profile: string | Manifesto.ServiceProfile): boolean {

if (typeof(profile) === 'string') {
profile = new Manifesto.ServiceProfile(profile);
}

if (Utils.normalisedUrlsMatch(profile.toString(), Manifesto.ServiceProfile.STANFORDIIIFIMAGECOMPLIANCE1.toString()) ||
Utils.normalisedUrlsMatch(profile.toString(), Manifesto.ServiceProfile.STANFORDIIIF1IMAGECOMPLIANCE1.toString()) ||
Utils.normalisedUrlsMatch(profile.toString(), Manifesto.ServiceProfile.STANFORDIIIFIMAGECONFORMANCE1.toString()) ||
Expand All @@ -179,7 +194,12 @@ namespace Manifesto {
return false;
}

static isLevel2ImageProfile(profile: Manifesto.ServiceProfile): boolean {
static isLevel2ImageProfile(profile: string | Manifesto.ServiceProfile): boolean {

if (typeof(profile) === 'string') {
profile = new Manifesto.ServiceProfile(profile);
}

if (Utils.normalisedUrlsMatch(profile.toString(), Manifesto.ServiceProfile.STANFORDIIIFIMAGECOMPLIANCE2.toString()) ||
Utils.normalisedUrlsMatch(profile.toString(), Manifesto.ServiceProfile.STANFORDIIIF1IMAGECOMPLIANCE2.toString()) ||
Utils.normalisedUrlsMatch(profile.toString(), Manifesto.ServiceProfile.STANFORDIIIFIMAGECONFORMANCE2.toString()) ||
Expand Down

0 comments on commit d3c63a0

Please sign in to comment.