Skip to content
Snippets Groups Projects
Select Git revision
  • d55c0657f3cd50aad1d12d6ea955ff1d51bb7834
  • main default
  • 35-cgu
  • 34-peertube-support
  • 27-add-autoplay-to-iframe
  • 33-bug-on-youtube-embed-urls
  • RC-Rekall-v1.1-fix_lpo
  • tuleap-140-go-back-to-my-capsules-page-when-i-m-on-capsule-preview-page
  • RC-Rekall-v1.2-fix10
  • RC-Rekall-v1.2-fix9
  • RC-Rekall-v1.2-fix8
  • RC-Rekall-v1.2-fix7
  • RC-Rekall-v1.2-fix6
  • RC-Rekall-v1.2-fix5
  • RC-Rekall-v1.2-fix4
  • RC-Rekall-v1.2-fix3
  • RC-Rekall-v1.2-fix2
  • RC-Rekall-v1.2-fix1
  • RC-Rekall-v1.1-fix-3
  • RC-Rekall-v1.1-fix-2
  • RC-Rekall-v1.1-fix-1
  • RC-Rekall-v1.1-delivered
  • preprod20220209-1535
23 results

push_image_to_registry.sh

Blame
  • index.js 3.06 KiB
    
    /**
    * Return the manifest that belongs to a certain window.
    * @param {object} state
    * @param {String} windowId
    * @return {object}
    */
    export function getWindowManifest(state, windowId) {
      return state.windows[windowId]
        && state.windows[windowId].manifestId
        && state.manifests[state.windows[windowId].manifestId];
    }
    
    /**
    * Return the logo of a manifest or null
    * @param {object} manifest
    * @return {String|null}
    */
    export function getManifestLogo(manifest) {
      return manifest.manifestation
        && manifest.manifestation.getLogo();
    }
    
    /**
    * Return the logo of a manifest or null
    * @param {object} manifest
    * @return {String|null}
    */
    export function getManifestCanvases(manifest) {
      if (!manifest.manifestation) {
        return [];
      }
    
      return manifest.manifestation.getSequences()[0].getCanvases();
    }
    
    /**
    * Return the current canvas selected in a window
    * @param {object} state
    * @param {String} windowId
    * @return {Object}
    */
    export function getSelectedCanvas(state, windowId) {
      const manifest = getWindowManifest(state, windowId);
      const { canvasIndex } = state.windows[windowId];
    
      if (!manifest.manifestation) {
        return {};
      }
    
      return manifest.manifestation.getSequences()[0].getCanvasByIndex(canvasIndex);
    }
    
    
    /** Return position of thumbnail navigation in a certain window.
    * @param {object} state
    * @param {String} windowId
    * @param {String}
    */
    export function getThumbnailNavigationPosition(state, windowId) {
      return state.windows[windowId]
        && state.windows[windowId].thumbnailNavigationPosition;
    }
    
    /**
    * Return manifest title
    * @param {object} manifest
    * @return {String}
    */
    export function getManifestTitle(manifest) {
      return manifest
        && manifest.manifestation
        && manifest.manifestation.getLabel().map(label => label.value)[0];
    }
    
    /** Return type of view in a certain window.
    * @param {object} state
    * @param {String} windowId
    * @param {String}
    */
    export function getWindowViewType(state, windowId) {
      return state.windows[windowId] && state.windows[windowId].view;
    }
    
    /**
    * Return manifest description
    * @param {object} manifest
    * @return {String}
    */
    export function getManifestDescription(manifest) {
      return manifest
        && manifest.manifestation
        && manifest.manifestation.getDescription().map(label => label.value)[0];
    }
    
    /**
    * Return canvas label, or alternatively return the given index + 1 to be displayed
    * @param {object} canvas
    * @return {String|Integer}
    */
    export function getCanvasLabel(canvas, canvasIndex) {
      return (canvas
        && canvas.getLabel()
        && canvas.getLabel().map(label => label.value)[0])
        || (canvasIndex || 0) + 1;
    }
    
    /**
    * Return canvas metadata in a label / value structure
    * This is a potential seam for pulling the i18n locale from
    * state and plucking out the appropriate language.
    * For now we're just getting the first.
    * @param {object} IIIF Resource
    * @return {Array[Object]}
    */
    export function getDestructuredMetadata(iiifResoruce) {
      return (iiifResoruce
        && iiifResoruce.getMetadata()
        && iiifResoruce.getMetadata().map(resource => ({
          label: resource.label[0].value,
          value: resource.value[0].value,
        }))
      );
    }