All files / app/mods/media pdf.ts

83.33% Statements 5/6
0% Branches 0/7
0% Functions 0/1
83.33% Lines 5/6

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59117x   117x   117x   117x                                                                                             117x          
import { DateTime } from 'luxon';
import { Plugin } from '../../model/plugin';
import { findCache, findExtension, Ref } from '../../model/ref';
import { Mod } from '../../model/tag';
import { hasTag } from '../../util/tag';
 
export const pdfPlugin: Plugin = {
  tag: 'plugin/pdf',
  name: $localize`📄️ PDF`,
  config: {
    mod: $localize`📄️ PDF`,
    version: 1,
    type: 'plugin',
    default: true,
    proxy: true,
    add: true,
    embeddable: true,
    generated: $localize`Generated by jasper-ui ${DateTime.now().toISO()}`,
    description: $localize`Adds an action button to open the PDF version.`,
    submit: $localize`📄️ pdf`,
    icons: [{ label: $localize`📄️`, order: 2 }],
    filters: [
      { query: 'plugin/pdf', label: $localize`📄️ pdf`, title: $localize`PDFs`, group: $localize`Media 🎬️` },
    ],
    actions: [{ label: $localize`pdf`, event: 'pdf' }],
    extensions: ['.pdf'],
    advancedForm: [{
      key: 'url',
      type: 'pdf',
    }, {
      key: 'showAbstract',
      type: 'boolean',
      props: {
        label: $localize`Show Abstract:`,
      },
    }],
  },
  defaults: {},
  schema: {
    optionalProperties: {
      url: { type: 'string' },
      showAbstract: { type: 'boolean' },
    },
  },
};
 
export function pdfUrl(plugin?: typeof pdfPlugin, ref?: Ref, repost?: Ref) {
  return ref?.plugins?.['plugin/pdf']?.url && { url: ref!.plugins?.['plugin/pdf'].url, origin: ref!.origin }
    || repost?.plugins?.['plugin/pdf']?.url && { url: repost!.plugins?.['plugin/pdf'].url, origin: repost!.origin }
    || findExtension('.pdf', ref, repost)
    || hasTag('plugin/pdf', ref) && findCache(ref, repost);
}
 
export const pdfMod: Mod = {
  plugin: [
    pdfPlugin,
  ]
};