@internetarchive/ia-item-navigator 0.0.0 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (70) hide show
  1. package/README.md +29 -19
  2. package/demo/app-root.ts +113 -22
  3. package/demo/index.html +12 -4
  4. package/dist/demo/app-root.d.ts +27 -7
  5. package/dist/demo/app-root.js +98 -23
  6. package/dist/demo/app-root.js.map +1 -1
  7. package/dist/src/interfaces/custom-theater-interface.d.ts +20 -0
  8. package/dist/src/interfaces/custom-theater-interface.js +2 -0
  9. package/dist/src/interfaces/custom-theater-interface.js.map +1 -0
  10. package/dist/src/interfaces/event-interfaces.d.ts +13 -23
  11. package/dist/src/interfaces/event-interfaces.js.map +1 -1
  12. package/dist/src/interfaces/menu-interfaces.d.ts +7 -7
  13. package/dist/src/interfaces/menu-interfaces.js.map +1 -1
  14. package/dist/src/interfaces/nav-controller-interface.d.ts +11 -6
  15. package/dist/src/interfaces/nav-controller-interface.js.map +1 -1
  16. package/dist/src/item-inspector/files-by-type/files-by-type-provider.js +5 -3
  17. package/dist/src/item-inspector/files-by-type/files-by-type-provider.js.map +1 -1
  18. package/dist/src/item-inspector/files-by-type/ia-files-by-type.d.ts +1 -0
  19. package/dist/src/item-inspector/files-by-type/ia-files-by-type.js +14 -0
  20. package/dist/src/item-inspector/files-by-type/ia-files-by-type.js.map +1 -1
  21. package/dist/src/item-inspector/item-inspector.d.ts +0 -31
  22. package/dist/src/item-inspector/item-inspector.js +253 -181
  23. package/dist/src/item-inspector/item-inspector.js.map +1 -1
  24. package/dist/src/item-inspector/visual-mod-provider.d.ts +19 -0
  25. package/dist/src/item-inspector/visual-mod-provider.js +46 -0
  26. package/dist/src/item-inspector/visual-mod-provider.js.map +1 -0
  27. package/dist/src/item-navigator.d.ts +50 -28
  28. package/dist/src/item-navigator.js +216 -132
  29. package/dist/src/item-navigator.js.map +1 -1
  30. package/dist/src/loader.d.ts +5 -0
  31. package/dist/src/loader.js +8 -2
  32. package/dist/src/loader.js.map +1 -1
  33. package/dist/src/no-theater-available.d.ts +9 -0
  34. package/dist/src/no-theater-available.js +79 -0
  35. package/dist/src/no-theater-available.js.map +1 -0
  36. package/dist/test/book-nav-stub.d.ts +22 -0
  37. package/dist/test/book-nav-stub.js +49 -0
  38. package/dist/test/book-nav-stub.js.map +1 -0
  39. package/dist/test/ia-item-navigator.test.d.ts +2 -0
  40. package/dist/test/ia-item-navigator.test.js +317 -0
  41. package/dist/test/ia-item-navigator.test.js.map +1 -0
  42. package/dist/test/ia-stub-goody.d.ts +210 -0
  43. package/dist/test/ia-stub-goody.js +276 -0
  44. package/dist/test/ia-stub-goody.js.map +1 -0
  45. package/dist/test/ia-stub.d.ts +22 -0
  46. package/dist/test/ia-stub.js +35 -0
  47. package/dist/test/ia-stub.js.map +1 -0
  48. package/dist/test/no-theater-available.test.d.ts +1 -0
  49. package/dist/test/no-theater-available.test.js +27 -0
  50. package/dist/test/no-theater-available.test.js.map +1 -0
  51. package/package.json +14 -5
  52. package/src/interfaces/custom-theater-interface.ts +28 -0
  53. package/src/interfaces/event-interfaces.ts +17 -24
  54. package/src/interfaces/menu-interfaces.ts +10 -9
  55. package/src/item-navigator.ts +257 -155
  56. package/src/loader.ts +9 -2
  57. package/src/no-theater-available.ts +85 -0
  58. package/test/book-nav-stub.ts +47 -0
  59. package/test/ia-item-navigator.test.ts +438 -0
  60. package/test/ia-stub.ts +79 -0
  61. package/test/no-theater-available.test.ts +32 -0
  62. package/demo/demo-book-manifest.json +0 -1163
  63. package/demo/demo-item-md.json +0 -247
  64. package/src/interfaces/nav-controller-interface.ts +0 -18
  65. package/src/item-inspector/files-by-type/files-by-type-provider.ts +0 -41
  66. package/src/item-inspector/files-by-type/ia-files-by-type.ts +0 -84
  67. package/src/item-inspector/item-inspector.ts +0 -202
  68. package/src/item-inspector/share-provider.ts +0 -51
  69. package/src/item-navigator-js.js +0 -372
  70. package/test/your-webcomponent.test.ts +0 -40
@@ -1,247 +0,0 @@
1
- {
2
- "created": 1623165950,
3
- "d1": "ia601302.us.archive.org",
4
- "d2": "ia801302.us.archive.org",
5
- "dir": "/34/items/EWReidquotsNurs00EWReH",
6
- "files": [
7
- {
8
- "name": "EWReidquotsNurs00EWReH.djvu",
9
- "source": "derivative",
10
- "format": "DjVu",
11
- "original": "EWReidquotsNurs00EWReH_djvu.xml",
12
- "mtime": "1441867975",
13
- "size": "4755873",
14
- "md5": "acea0c4fa2c3649c197b9d4b96b9c90f",
15
- "crc32": "16d30fc2",
16
- "sha1": "1a5ea03e0ac400f060e271fdaabcd690ccb7d6d9"
17
- },
18
- {
19
- "name": "EWReidquotsNurs00EWReH.gif",
20
- "source": "derivative",
21
- "format": "Animated GIF",
22
- "original": "EWReidquotsNurs00EWReH_jp2.zip",
23
- "mtime": "1441867193",
24
- "size": "285494",
25
- "md5": "f567064d9df272a6be24ffa342818f48",
26
- "crc32": "d32159c0",
27
- "sha1": "a403228363e9331b230957c3a3fec9167e06608e"
28
- },
29
- {
30
- "name": "EWReidquotsNurs00EWReH.pdf",
31
- "source": "derivative",
32
- "format": "Text PDF",
33
- "original": "EWReidquotsNurs00EWReH_djvu.xml",
34
- "mtime": "1441868228",
35
- "size": "7292656",
36
- "md5": "037a6cf7afc2c9b3e6c1a7e92339f199",
37
- "crc32": "c0f9025e",
38
- "sha1": "edf129d57ac2ba1272fe485b4a696d48d6d5ee44"
39
- },
40
- {
41
- "name": "EWReidquotsNurs00EWReH_abbyy.gz",
42
- "source": "derivative",
43
- "format": "Abbyy GZ",
44
- "original": "EWReidquotsNurs00EWReH_jp2.zip",
45
- "mtime": "1441867680",
46
- "size": "4356879",
47
- "md5": "7705528ebae28de1d6c6296e9d0a8563",
48
- "crc32": "7a1b5de1",
49
- "sha1": "b1875aec62a8663a3d4ee18a52e38ff3e482f192"
50
- },
51
- {
52
- "name": "EWReidquotsNurs00EWReH_archive.torrent",
53
- "source": "metadata",
54
- "btih": "faae87b4be4a39ff9ca0f6d1690a34e314982801",
55
- "mtime": "1608789321",
56
- "size": "6237",
57
- "md5": "a3afa0ce01bcdc54f208e56731a70669",
58
- "crc32": "b790d98e",
59
- "sha1": "ce08fce64f870e19e88d02ef1e476b12435eca0c",
60
- "format": "Archive BitTorrent"
61
- },
62
- {
63
- "name": "EWReidquotsNurs00EWReH_bhlmets.xml",
64
- "source": "original",
65
- "mtime": "1471594158",
66
- "size": "43346",
67
- "format": "Biodiversity Heritage Library METS",
68
- "md5": "ee4d6874ce88e762c383ce3e3143559d",
69
- "crc32": "82911e3c",
70
- "sha1": "5e0253aea752287ac4eb5eddefd7e06273b2fd2c"
71
- },
72
- {
73
- "name": "EWReidquotsNurs00EWReH_bw.pdf",
74
- "source": "derivative",
75
- "format": "Grayscale PDF",
76
- "original": "EWReidquotsNurs00EWReH_djvu.xml",
77
- "mtime": "1441868612",
78
- "size": "8556119",
79
- "md5": "a94252edb7d0d83573811e9037d40b35",
80
- "crc32": "f82d4fb9",
81
- "sha1": "9863750f7109da08a056e1166b80c1265c4781d7"
82
- },
83
- {
84
- "name": "EWReidquotsNurs00EWReH_dc.xml",
85
- "source": "original",
86
- "format": "Dublin Core",
87
- "mtime": "1441867179",
88
- "size": "1016",
89
- "md5": "3cd7cd1cd217a8345258b75bafb9c209",
90
- "crc32": "64cc8e64",
91
- "sha1": "fa37f7d86bc3b49b605035d45f9caf1c5725641c"
92
- },
93
- {
94
- "name": "EWReidquotsNurs00EWReH_djvu.txt",
95
- "source": "derivative",
96
- "format": "DjVuTXT",
97
- "original": "EWReidquotsNurs00EWReH.djvu",
98
- "mtime": "1441868624",
99
- "size": "290313",
100
- "md5": "6cf51da4b3e17981c56539830c80300b",
101
- "crc32": "f08f35ee",
102
- "sha1": "6044c0eff144a116b7fc12e23a29d774fbf8a7eb"
103
- },
104
- {
105
- "name": "EWReidquotsNurs00EWReH_djvu.xml",
106
- "source": "derivative",
107
- "format": "Djvu XML",
108
- "original": "EWReidquotsNurs00EWReH_abbyy.gz",
109
- "mtime": "1441867758",
110
- "size": "2776587",
111
- "md5": "084f27735670ad1fb831d7b8e123c70d",
112
- "crc32": "cdc8a083",
113
- "sha1": "fec186c4d9137f2da0defd0d394f840d2c8b6282"
114
- },
115
- {
116
- "name": "EWReidquotsNurs00EWReH_files.xml",
117
- "source": "original",
118
- "format": "Metadata",
119
- "md5": "2b38819a7fd448e4a75ab607547fcebd"
120
- },
121
- {
122
- "name": "EWReidquotsNurs00EWReH_jp2.zip",
123
- "source": "original",
124
- "mtime": "1441867164",
125
- "size": "27478796",
126
- "md5": "552112543a4d8df1707bcc8fb163f93c",
127
- "crc32": "104860e5",
128
- "sha1": "19a0a226c36f95b85b6f8bfe32853e72ce4e92a2",
129
- "format": "Single Page Processed JP2 ZIP"
130
- },
131
- {
132
- "name": "EWReidquotsNurs00EWReH_marc.xml",
133
- "source": "original",
134
- "mtime": "1441867158",
135
- "size": "3952",
136
- "md5": "8e7d73ab2f836c4fc6e7640d48648a77",
137
- "crc32": "27703ddb",
138
- "sha1": "3a2bf3f2648dbd58505fa51ea003b6f1749ba32e",
139
- "format": "MARC"
140
- },
141
- {
142
- "name": "EWReidquotsNurs00EWReH_meta.sqlite",
143
- "source": "original",
144
- "mtime": "1471594169",
145
- "size": "11264",
146
- "format": "Metadata",
147
- "md5": "839bf51334ae43c9d21e4ee882f3ff59",
148
- "crc32": "14d1db51",
149
- "sha1": "b176fbaf48c809b87edab208f4e1d3949efaef3e"
150
- },
151
- {
152
- "name": "EWReidquotsNurs00EWReH_meta.xml",
153
- "source": "original",
154
- "mtime": "1608789319",
155
- "size": "2272",
156
- "format": "Metadata",
157
- "md5": "11c0f2e6a01935290009ee193472255f",
158
- "crc32": "b9d893d7",
159
- "sha1": "695a8ff18605b59e71ace14b08f5223716d7c335"
160
- },
161
- {
162
- "name": "EWReidquotsNurs00EWReH_names.xml",
163
- "source": "original",
164
- "mtime": "1442302590",
165
- "size": "57169",
166
- "md5": "51b563e7793a5d52e3c3805ba939fc61",
167
- "crc32": "6a65b15a",
168
- "sha1": "f5ac21dccc3c196f2354d0892d943f5394a6f6f9",
169
- "format": "Name Metadata"
170
- },
171
- {
172
- "name": "EWReidquotsNurs00EWReH_scandata.xml",
173
- "source": "original",
174
- "mtime": "1441867148",
175
- "size": "45352",
176
- "md5": "9b938596c832f6316fa08592c674dec1",
177
- "crc32": "1e2e2496",
178
- "sha1": "d23268b6847d9d2b14af1ff9f08b5026fa8b319c",
179
- "format": "Scandata"
180
- },
181
- {
182
- "name": "__ia_thumb.jpg",
183
- "source": "original",
184
- "mtime": "1608789320",
185
- "size": "25320",
186
- "md5": "d9c7a1b6f92445cb27d1f1a72ce68fbd",
187
- "crc32": "2b0dffc3",
188
- "sha1": "f7d1e9f60857bf9daaeabf18d9b94095ba044dc8",
189
- "format": "Item Tile",
190
- "rotation": "0"
191
- }
192
- ],
193
- "files_count": 18,
194
- "item_last_updated": 1608789321,
195
- "item_size": 55988645,
196
- "metadata": {
197
- "identifier": "EWReidquotsNurs00EWReH",
198
- "abstract": "A collection of nursery and seed catalogs published by E.W. Reid"s Nurseries (Bridgeport; Upland, Ohio; also known as E.W. Reid (Firm)) from 1890-1901; part of the Ethel Z. Bailey Horticultural Catalogue Collection.",
199
- "call_number": "CUbiodiversity31924108762588",
200
- "call-number": "CUbiodiversity31924108762588",
201
- "contributor": "Cornell University Library",
202
- "creator": [
203
- "E.W. Reid's Nurseries",
204
- "Liberty Hyde Bailey Hortorium. Ethel Z. Bailey Horticultural Catalogue Collection"
205
- ],
206
- "curation": "[curator]biodiversitylibrary.org[/curator][date]20150910023608[/date][state]approved[/state]",
207
- "date": "1890",
208
- "genre": "catalog",
209
- "identifier-bib": "CUbiodiversity31924108762588",
210
- "language": "eng",
211
- "mediatype": "texts",
212
- "possible-copyright-status": "Public domain. The BHL considers that this work is no longer under copyright protection.",
213
- "sponsor": "L.H. Bailey Hortorium; Mann Library; IMLS",
214
- "title": "[E.W. Reid's Nurseries materials]",
215
- "volume": "1897 Spring",
216
- "year": "1890",
217
- "collection": [
218
- "cornell",
219
- "biodiversity",
220
- "seedcatalogs"
221
- ],
222
- "subject": [
223
- "Seeds",
224
- "Nurseries (Horticulture)",
225
- "E.W. Reid's Nurseries"
226
- ],
227
- "publicdate": "2015-09-10 06:39:09",
228
- "uploader": "mikecook@cornell.edu",
229
- "addeddate": "2015-09-10 06:39:09",
230
- "description": "A collection of nursery and seed catalogs published by E.W. Reid's Nurseries (Bridgeport; Upland, Ohio; also known as E.W. Reid (Firm)) from 1890-1901; part of the Ethel Z. Bailey Horticultural Catalogue Collection",
231
- "ppi": "300",
232
- "imagecount": "74",
233
- "foldoutcount": "0",
234
- "identifier-access": "http://archive.org/details/EWReidquotsNurs00EWReH",
235
- "identifier-ark": "ark:/13960/t9z06rw3f",
236
- "ocr": "ABBYY FineReader 11.0",
237
- "repub_state": "4",
238
- "backup_location": "ia905501_8",
239
- "filesxml": "Thu Dec 24 5:55:19 UTC 2020"
240
- },
241
- "server": "ia801302.us.archive.org",
242
- "uniq": 2094171797,
243
- "workable_servers": [
244
- "ia801302.us.archive.org",
245
- "ia601302.us.archive.org"
246
- ]
247
- }
@@ -1,18 +0,0 @@
1
- import { LitElement } from 'lit-element';
2
- import { MetadataResponse } from '@internetarchive/search-service';
3
- import { IntMenuShortcut } from './menu-interfaces';
4
-
5
- export interface IntNavController extends LitElement {
6
- baseHost: string;
7
- itemMD: MetadataResponse;
8
- menuProviders: object;
9
- menuShortcuts: IntMenuShortcut[];
10
- sideMenuOpen: boolean;
11
-
12
- emitLoadingStatusUpdate: (loaded: boolean) => void;
13
-
14
- addMenuShortcut: (menuId: string) => void;
15
- removeMenuShortcut: (menuId: string) => void;
16
- sortMenuShortcuts: () => void;
17
- emitMenuShortcutsUpdated: () => void;
18
- }
@@ -1,41 +0,0 @@
1
- import { html, TemplateResult } from 'lit-element';
2
-
3
- import './ia-files-by-type';
4
- import '@internetarchive/icon-share/icon-share';
5
- import {
6
- IntMenuProvider,
7
- IntProviderArgs,
8
- } from '../../interfaces/menu-interfaces';
9
-
10
- export class FilesByTypeProvider implements IntMenuProvider {
11
- item: any = null;
12
-
13
- baseHost: string = 'https://archive.org';
14
-
15
- icon: TemplateResult = html`<ia-icon-share
16
- style="width: var(--iconWidth); height: var(--iconHeight);"
17
- ></ia-icon-share>`;
18
-
19
- id: string = 'filesByType';
20
-
21
- label: string = 'Files by type';
22
-
23
- component: TemplateResult | null = null;
24
-
25
- subPrefix: string = '';
26
-
27
- constructor(shareArgs: IntProviderArgs) {
28
- const { item, baseHost, subPrefix = '' } = shareArgs;
29
- const { title = '' } = item.metadata;
30
-
31
- this.item = item;
32
- this.baseHost = baseHost;
33
- this.subPrefix = subPrefix;
34
-
35
- this.component = html`<ia-files-by-type
36
- .item=${this.item}
37
- .description="${title}"
38
- .baseHost="${this.baseHost}"
39
- ></ia-files-by-type>`;
40
- }
41
- }
@@ -1,84 +0,0 @@
1
- import { MetadataResponse, File } from '@internetarchive/search-service';
2
- import { html, customElement, LitElement, property } from 'lit-element';
3
-
4
- interface CollapsedFileInt extends File {
5
- [menuId: string]: any;
6
- derivatives: [];
7
- }
8
-
9
- @customElement('ia-files-by-type')
10
- export default class IaFilesByType extends LitElement {
11
- @property({ type: Object }) item: MetadataResponse = {} as MetadataResponse;
12
-
13
- @property({ type: Array }) archivalArtifacts: File[] = [];
14
-
15
- @property({ type: Array }) collapsedFiles: CollapsedFileInt[] = [];
16
-
17
- firstUpdated() {
18
- this.collapseFiles();
19
- }
20
-
21
- render() {
22
- return html`
23
- <div>
24
- <p>there are ${this.collapsedFiles.length} original files</p>
25
-
26
- <p>there are ${this.archivalArtifacts.length} archival artifacts</p>
27
-
28
- <p></p>
29
- </div>
30
- `;
31
- }
32
-
33
- collapseFiles() {
34
- const { files = [] } = this?.item as MetadataResponse;
35
-
36
- const archivalArtifacts: File[] = [];
37
- const origDir: any = {};
38
-
39
- files.forEach(fi => {
40
- const { format, source, name, original = '' } = fi as File;
41
- if (
42
- format.toLowerCase() === 'metadata' ||
43
- format.toLowerCase() === 'item tile'
44
- ) {
45
- archivalArtifacts.push(fi);
46
- return;
47
- }
48
-
49
- let origEntry: any = {};
50
- if (source === 'original') {
51
- origEntry = origDir[name];
52
- if (!origEntry) {
53
- // add new
54
- origDir[name] = { ...fi, derivatives: [] } as CollapsedFileInt;
55
- origEntry = origDir[name];
56
- } else {
57
- // update
58
- const merged = { ...origEntry, ...fi };
59
- origDir[name] = merged;
60
- }
61
- return;
62
- }
63
-
64
- if (source === 'derivative') {
65
- const keyToFile = original || '';
66
- origEntry = origDir[keyToFile];
67
- if (!origEntry && original) {
68
- // add new
69
- const fileFrame = { derivatives: [] } as CollapsedFileInt;
70
- origEntry = fileFrame;
71
- origEntry?.derivatives.push(fi);
72
- origDir[keyToFile] = origEntry;
73
- origEntry = origDir[keyToFile];
74
- }
75
- origEntry?.derivatives.push(fi);
76
- }
77
- });
78
-
79
- this.archivalArtifacts = archivalArtifacts;
80
- this.collapsedFiles = Object.keys(origDir).map(
81
- (fileName: string) => origDir[fileName]
82
- );
83
- }
84
- }
@@ -1,202 +0,0 @@
1
- /* eslint-disable no-console */
2
- import {
3
- css,
4
- html,
5
- LitElement,
6
- customElement,
7
- property,
8
- state,
9
- } from 'lit-element';
10
- // import { nothing, TemplateResult } from 'lit-html';
11
- import { MetadataResponse } from '@internetarchive/search-service';
12
- import { IntNavController } from '../interfaces/nav-controller-interface';
13
- import {
14
- IntMenuShortcut,
15
- IntMenuProvider,
16
- } from '../interfaces/menu-interfaces';
17
-
18
- import { ShareProvider } from './share-provider';
19
- import { FilesByTypeProvider } from './files-by-type/files-by-type-provider';
20
-
21
- // eslint-disable-next-line no-shadow
22
- enum ItemInspectorEvents {
23
- menuUpdated = 'menuUpdated',
24
- updateSideMenu = 'updateSideMenu',
25
- PostInit = 'PostInit',
26
- ViewportInFullScreen = 'ViewportInFullScreen',
27
- }
28
-
29
- interface menuProvidersInt {
30
- [menuId: string]: IntMenuProvider;
31
- }
32
-
33
- @customElement('ia-item-inspector')
34
- export class IaItemInspector extends LitElement implements IntNavController {
35
- @property({ type: Object }) itemMD: MetadataResponse = {} as MetadataResponse;
36
-
37
- @property({ type: String }) baseHost = 'https://archive.org';
38
-
39
- @property({ type: Object }) menuProviders: menuProvidersInt = {};
40
-
41
- @property({ type: Array }) menuShortcuts: IntMenuShortcut[] = [];
42
-
43
- @property({ type: Array }) shortcutOrder: string[] = ['filesByType'];
44
-
45
- @property({ type: Boolean }) sideMenuOpen = false;
46
-
47
- @state() fileCount: number = 0;
48
-
49
- @state() loaded: boolean = false;
50
-
51
- firstUpdated() {
52
- this.loaded = true;
53
- }
54
-
55
- updated(changed: any) {
56
- if (changed.has('loaded')) {
57
- this.emitLoadingStatusUpdate(this.loaded);
58
- }
59
-
60
- if (changed.has('itemMD') && this.itemMD) {
61
- this.parseItemInfo();
62
- this.setMenu();
63
- }
64
-
65
- if (changed.has('menuProviders') || changed.has('menuShortcuts')) {
66
- this.updateMenuContents();
67
- }
68
- }
69
-
70
- render() {
71
- const { identifier = '' } = this.itemMD?.metadata || {};
72
- return html`
73
- <section>
74
- <div>
75
- <h2>${identifier}</h2>
76
- </div>
77
- <img src=${this.imageUrl} alt=${`${identifier} thumbnail`} />
78
- </section>
79
- `;
80
- }
81
-
82
- setMenu() {
83
- const menuProviders = {
84
- share: new ShareProvider({
85
- item: this.itemMD,
86
- baseHost: this.baseHost,
87
- subPrefix: '',
88
- }),
89
- filesByType: new FilesByTypeProvider({
90
- item: this.itemMD,
91
- baseHost: this.baseHost,
92
- subPrefix: '',
93
- }),
94
- };
95
-
96
- this.menuProviders = menuProviders;
97
-
98
- this.addMenuShortcut('filesByType');
99
- }
100
-
101
- addMenuShortcut(menuId: keyof menuProvidersInt) {
102
- if (this.menuShortcuts.find(m => m.id === menuId)) {
103
- return;
104
- }
105
-
106
- const shortcut = this.menuProviders[menuId];
107
- this.menuShortcuts.push(shortcut);
108
- this.sortMenuShortcuts();
109
- this.emitMenuShortcutsUpdated();
110
- }
111
-
112
- sortMenuShortcuts() {
113
- const sorted = this.shortcutOrder.reduce(
114
- (shortcuts: IntMenuShortcut[], id): IntMenuShortcut[] => {
115
- const menu = this.menuShortcuts.find(
116
- m => m.id === id
117
- ) as IntMenuShortcut;
118
-
119
- let allShortcuts: IntMenuShortcut[] = [...shortcuts];
120
- if (menu) {
121
- const newShortcut = [menu];
122
- allShortcuts = [...shortcuts, ...newShortcut];
123
- }
124
- return allShortcuts;
125
- },
126
- []
127
- );
128
-
129
- this.menuShortcuts = sorted;
130
- }
131
-
132
- emitMenuShortcutsUpdated() {
133
- const event = new CustomEvent('menuShortcutsUpdated', {
134
- detail: this.menuShortcuts,
135
- });
136
- this.dispatchEvent(event);
137
- }
138
-
139
- removeMenuShortcut(menuId: string) {
140
- this.menuShortcuts = this.menuShortcuts.filter(m => m.id !== menuId);
141
- this.emitMenuShortcutsUpdated();
142
- }
143
-
144
- updateMenuContents() {
145
- const { share, filesByType } = this.menuProviders;
146
- const availableMenus = [filesByType, share].filter(menu => !!menu);
147
-
148
- const event = new CustomEvent(ItemInspectorEvents.menuUpdated, {
149
- detail: availableMenus,
150
- });
151
-
152
- this.dispatchEvent(event);
153
- }
154
-
155
- emitLoadingStatusUpdate(loaded: boolean) {
156
- const event = new CustomEvent('loadingStateUpdated', {
157
- detail: { loaded },
158
- });
159
- this.dispatchEvent(event);
160
- }
161
-
162
- parseItemInfo() {
163
- this.fileCount = this.itemMD?.files?.length || 0;
164
- }
165
-
166
- get imageUrl() {
167
- const { metadata = {} } = this.itemMD;
168
- const url = `${this.baseHost}/download/${metadata?.identifier}/__ia_thumb.jpg`;
169
- return url;
170
- }
171
-
172
- static get styles() {
173
- const main = css`
174
- :host {
175
- display: block;
176
- width: 100%;
177
- margin: 0 auto;
178
- position: relative;
179
- overflow: hidden;
180
- display: block;
181
- }
182
-
183
- :host,
184
- section {
185
- min-height: inherit;
186
- height: inherit;
187
- }
188
-
189
- section {
190
- margin: auto;
191
- width: 100%;
192
- border: 1px solid;
193
- text-align: center;
194
- }
195
-
196
- img {
197
- border: 1px solid var(--primaryTextColor, #fff);
198
- }
199
- `;
200
- return [main];
201
- }
202
- }
@@ -1,51 +0,0 @@
1
- import { html, TemplateResult } from 'lit-element';
2
-
3
- import '@internetarchive/ia-sharing-options';
4
- import '@internetarchive/icon-share/icon-share';
5
- import {
6
- IntMenuProvider,
7
- IntProviderArgs,
8
- } from '../interfaces/menu-interfaces';
9
-
10
- export class ShareProvider implements IntMenuProvider {
11
- item: any = null;
12
-
13
- baseHost: string = 'https://archive.org';
14
-
15
- icon: TemplateResult = html`<ia-icon-share
16
- style="width: var(--iconWidth); height: var(--iconHeight);"
17
- ></ia-icon-share>`;
18
-
19
- id: string = 'share';
20
-
21
- label: string = 'Share this item';
22
-
23
- component: TemplateResult | null = null;
24
-
25
- subPrefix: string = '';
26
-
27
- encodedSubPrefix: string = '';
28
-
29
- constructor(shareArgs: IntProviderArgs) {
30
- const { item, baseHost, subPrefix = '' } = shareArgs;
31
- const { identifier = '', creator = '', title = '' } = item.metadata || {};
32
- const encodedSubPrefix = encodeURIComponent(subPrefix);
33
- const urlIdentifier =
34
- subPrefix && subPrefix !== identifier
35
- ? `${identifier}/${encodedSubPrefix}`
36
- : identifier;
37
-
38
- this.item = item;
39
- this.baseHost = baseHost;
40
- this.subPrefix = subPrefix;
41
- this.encodedSubPrefix = encodedSubPrefix;
42
-
43
- this.component = html`<ia-sharing-options
44
- identifier=${urlIdentifier}
45
- type="item"
46
- creator="${creator}"
47
- description="${title}"
48
- baseHost="${this.baseHost}"
49
- ></ia-sharing-options>`;
50
- }
51
- }