forked from joshjhall/zotero-to-tana-exporter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Tana Metadata Exporter.js
1114 lines (1011 loc) · 35.5 KB
/
Tana Metadata Exporter.js
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
{
"translatorID": "dda092d2-a257-46af-b9a3-2f04a55cb04f",
"translatorType": 2,
"label": "Tana Metadata Export",
"creator": "Joshua Hall based upon Stian Håklev, Joel Chan, and Lukas Kawerau's work",
"target": "md",
"minVersion": "2.0",
"maxVersion": "",
"priority": 200,
"inRepository": false,
"lastUpdated": "2023-05-28 - 15:00"
}
// NOTE: This is explicitly designed around the Tanarian Brain by Lukas Kawerau.
// Zotero schema: https://api.zotero.org/schema
function doExport() {
// Functions to convert date to Tana format
// List of months
const months = [
"January",
"February",
"March",
"April",
"May",
"June",
"July",
"August",
"September",
"October",
"November",
"December",
];
// Application of the ordinal number suffix
const nth = (d) => {
if (d > 3 && d < 21) {
return "th";
}
switch (d % 10) {
case 1:
return "st";
case 2:
return "nd";
case 3:
return "rd";
default:
return "th";
}
};
// Return the Tana formatted date
const formatDate = (dateJSON) => {
// Generate a Tana friendly formatted date
// Falls back to Jan 1, 2100 for any missing components of the date
const year = dateJSON["year"] || "2100";
const month = months[dateJSON["month"]] || months[0];
const day = dateJSON["day"] || 1;
const nthStr = nth(day);
return link(`${month} ${day}${nthStr}, ${year}`);
};
// ---
// Additional helper functions for consistent formatting
// Return a "[[link]]" value
const link = (name) => {
return `[[${name}]]`;
};
// Return a " #[[tag]]" value
const tag = (name) => {
return ` #[[${name}]]`;
};
// Return a "field:: " value
const field = (name) => {
return `${name}:: `;
};
// Return an "[external](https://link.com)" value
const extLink = (name, url) => {
return `[${name}](${url})`;
};
// Return the "https://doi.org/doi/link" value
const doiLink = (id) => {
return `https://doi.org/${id}`
};
// Return the "Title Cased" value
// This is a very simply version of the algorithm, and can be improved
const titleCase = (string) => {
var sentence = string.toLowerCase().split(" ");
for (var i = 0; i < sentence.length; i++) {
sentence[i] = sentence[i][0].toUpperCase() + sentence[i].slice(1);
}
return sentence.join(" ");
};
// Return list of valid creators
const validatedContributors = (creators, includedTypes) => {
const list = [];
for (creator in creators) {
if ((includedTypes !== undefined && includedTypes.indexOf(creators[creator].creatorType.toLowerCase()) !== -1) ||
includedTypes === undefined) {
if (creators[creator].firstName !== undefined && creators[creator].lastName !== undefined) {
// Use the full name of the creator. Should be the most common situation
list.push(`${creators[creator].firstName} ${creators[creator].lastName}`);
} else if (creators[creator].lastName !== undefined) {
// Only use the last name
list.push(`${creators[creator].lastName}`);
}
}
}
return list;
};
// ---
// Various constants used throughout
// Constants for prepending indents consistently
const tab = [
"- ",
" - ",
" - ",
" - ",
" - ",
" - ",
" - ",
" - ",
" - ",
" - "
];
// In Tana, you can explicitly reference a node in your graph by appending a carrot and the ID from the node.
// 1. Get the node link in your Tana graph. https://app.tana.inc?nodeid=p_7iFOOsX3
// 2. Append the ID with a carrot to the node name (e.g., "source") inside the quotes
// So, "source" would become "source^p_7iFOOsX3" in this example
//
// This ensures you're referencing the correct node in Tana, and avoids quite a bit of duplication.
// This is particularly important when working across multiple graphs. I suggest you take a few moments
// and update all of the tags, statuses, and fields below. I suspect it'll save you headaches later.
// Constants describing source type tags
const sourceTag = tag("source");
const journalArticleTag = tag("journal article");
const authorTag = tag("author");
const journalPublicationTag = tag("journal (publication)");
const topicTag = tag("topic");
const bookTag = tag("book");
const organizationTag = tag("organization");
const chapterTag = tag("chapter");
const videoTag = tag("video");
const hostTag = tag("host");
const publicationTag = tag("publication");
const podcastEpisodeTag = tag("podcast episode");
const podcastTag = tag("podcast");
const directorTag = tag("director");
const filmTag = tag("film");
const personTag = tag("person");
const presentationTag = tag("presentation");
const newspaperArticleTag = tag("newspaper article");
const blogPostTag = tag("blog post");
const artworkTag = tag("artwork");
const artistTag = tag("artist");
const reportTag = tag("report");
const billTag = tag("bill");
const caseTag = tag("case");
const letterTag = tag("letter");
const instantMessageTag = tag("instant message");
const mapTag = tag("map");
const emailTag = tag("email");
const patentTag = tag("patent");
const encyclopeidaArticleTag = tag("encyclopedia article");
const interviewTag = tag("interview");
const preprintTag = tag("preprint");
const radioBroadcastTag = tag("radio broadcast");
const tvBroadcastTag = tag("tv broadcast");
const statuteTag = tag("statute");
const conferencePaperTag = tag("conference paper");
const conferenceTag = tag("conference");
const countryTag = tag("country");
const softwareTag = tag("software");
// Constants describing source status options
const toReadStatus = link("📚 To Read");
const toWatchStatus = link("🎞️ To Watch");
const toListenStatus = link("💿 To Listen");
const readingStatus = link("📖 Reading");
const watchingStatus = link("📽️ Watching");
const listeningStatus = link("🎧 Listening");
const readStatus = link("📗 Read");
const watchedStatus = link("📼 Watched");
const listenedStatus = link("🔇 Listened");
// Constants for the fields used
const titleField = field("Title");
const sourceStatusField = field("Source Status");
const citationKeyField = field("Citation Key");
const authorField = field("Author(s)");
const publicationDateField = field("Publication Date");
const zoteroLinkField = field("Zotero Link");
const journalField = field("Journal");
const volumeField = field("Volume");
const issueField = field("Issue");
const urlField = field("URL");
const doiField = field("DOI");
const topicField = field("Topic(s)");
const publisherField = field("Publisher");
const bookField = field("Book");
const hostField = field("Host(s)");
const publicationField = field("Publication");
const episodeNumberField = field("Episode Number");
const podcastField = field("Podcast");
const directorField = field("Director");
const genreField = field("Genre");
const languageField = field("Language");
const dateField = field("Date");
const presenterField = field("Presenter");
const artistField = field("Artist");
const artworkMediumField = field("Artwork Medium");
const artworkSizeField = field("Artwork Size");
const instiutionField = field("Institution");
const billSponsorField = field("Bill Sponsor");
const billNumberField = field("Bill Number");
const legislativeBodyField = field("Legislative Body");
const legislativeSessionField = field("Legislative Session");
const courtField = field("Court");
const dateDecidedField = field("Date Decided");
const cartographerField = field("Cartographer");
const mapTypeField = field("Map Type");
const mapScaleField = field("Map Scale");
const locationField = field("Location");
const conferenceField = field("Conference");
const programTitleField = field("Program Title");
const tvNetworkField = field("TV Network");
const radioNetworkField = field("Radio Network");
const intervieweeField = field("Interview with");
const mediumField = field("Medium");
const encyclopediaTitleField = field("Encyclopedia Title");
const countryField = field("Country");
const patentNumberField = field("Patent Number");
const inventorField = field("Inventor");
// Zotero tags to ignore when importing topics
const ignoredTopics = [
"_tablet",
"_tablet_modified"
];
// ---
// Functions to write content for each field included in a specific section of content
const writeBase = (title = "Unknown title", type = sourceTag, status = toReadStatus) => {
// - Foo bar #[[source]]
// - Title:: Foo bar
// - Source Status:: [[📚 To Read]]
Zotero.write(tab[0] + title + type + "\n");
writeTitle(title);
writeSourceStatus(status);
};
// Write the title
const writeTitle = (title = "Unknown title", t = 1) => {
// - Title:: Foo bar
Zotero.write(tab[t] + titleField + title + "\n");
};
// Write the source status
const writeSourceStatus = (status = toReadStatus, t = 1) => {
// - Source Status:: [[📚 To Read]]
Zotero.write(tab[t] + sourceStatusField + status + "\n");
};
// Write the citekey
const writeCitationKey = (citekey, t = 1) => {
// - Citation Key:: @foo2018bar
if (citekey !== undefined && citekey !== "") {
Zotero.write(tab[t] + citationKeyField + "@" + citekey + "\n");
}
};
// Write Zotero link
const writeZoteroLink = (key, library = 0, t = 1) => {
// - Zotero Link: zotero://select/items/foo_bar
if (key !== undefined && key !== "") {
// const library_id = library ? library : 0;
const itemLink = `zotero://select/items/${library}_${key}`;
Zotero.write(tab[t] + zoteroLinkField + itemLink + "\n");
}
};
// Write the journal title
const writeJournalTitle = (journalTitle, t = 1) => {
// - Journal:: Foo Bar #[[journal (publication)]]
if (journalTitle !== undefined && journalTitle !== "") {
Zotero.write(tab[t] + journalField + journalTitle + journalPublicationTag + "\n");
}
};
// Write the volume information
const writeVolume = (volume, t = 1) => {
// - Volume:: 88
if (volume !== undefined && volume !== "") {
Zotero.write(tab[t] + volumeField + volume + "\n");
}
};
// Write the issue information
const writeIssue = (issue, t = 1) => {
// - Issue:: 88
if (issue !== undefined && issue !== "") {
Zotero.write(tab[t] + issueField + item.issue + "\n");
}
};
// Write the publication date
const writePublicationDate = (date, t = 1) => {
// - Publication Date:: [[March 15th, 2020]]
if (date !== undefined && date !== "") {
Zotero.write(tab[t] + publicationDateField + formatDate(Zotero.Utilities.strToDate(date)) + "\n");
}
};
// Write the date
const writeDate = (date, t = 1) => {
// - Date:: [[March 15th, 2020]]
if (date !== undefined && date !== "") {
Zotero.write(tab[t] + dateField + formatDate(Zotero.Utilities.strToDate(date)) + "\n");
}
};
// Write the list of authors
const writeAuthors = (creators, t = 1) => {
// - Author(s)::
// - Dr. Foo #[[author]]
// - Dr. Foo Bar #[[author]]
// Filter for included types only
const includedTypes = [
"author",
"contributor",
"editor",
"translator",
"seriesEditor",
"bookAuthor",
"reviewedAuthor"
];
if (creators !== undefined) {
// Find list of all of the creators associated with this item
names = validatedContributors(creators, includedTypes);
if (names.length > 0) {
// Start by creating the type field parent
Zotero.write(tab[t] + authorField + "\n");
for (name in names) {
Zotero.write(tab[t + 1] + names[name] + authorTag + "\n");
}
}
}
};
// Write the list of hosts
const writeHosts = (creators, t = 1) => {
// - Host(s)::
// - Dr. Foo #[[host]]
// - Dr. Foo Bar #[[host]]
// Filter for included types only
const includedTypes = [
"director",
"contributor",
"castMember",
"podcaster",
"guest",
"interviewer"
];
if (creators !== undefined) {
// Find list of all of the creators associated with this item
names = validatedContributors(creators, includedTypes);
if (names.length > 0) {
// Start by creating the type field parent
Zotero.write(tab[t] + hostField + "\n");
for (name in names) {
Zotero.write(tab[t + 1] + names[name] + hostTag + "\n");
}
}
}
};
// Write the list of interviewees
const writeInterviewees = (creators, t = 1) => {
// - Interview with::
// - Dr. Foo #[[person]]
// - Dr. Foo Bar #[[person]]
// Filter for included types only
const includedTypes = [
"interviewee"
];
if (creators !== undefined) {
// Find list of all of the creators associated with this item
names = validatedContributors(creators, includedTypes);
if (names.length > 0) {
// Start by creating the type field parent
Zotero.write(tab[t] + intervieweeField + "\n");
for (name in names) {
Zotero.write(tab[t + 1] + names[name] + personTag + "\n");
}
}
}
};
// Write the list of directors
const writeDirectors = (creators, t = 1) => {
// - Director::
// - Dr. Foo #[[director]]
// - Dr. Foo Bar #[[director]]
// Filter for included types only
const includedTypes = [
"director"
];
if (creators !== undefined) {
// Find list of all of the creators associated with this item
names = validatedContributors(creators, includedTypes);
if (names.length > 0) {
// Start by creating the type field parent
Zotero.write(tab[t] + directorField + "\n");
for (name in names) {
Zotero.write(tab[t + 1] + names[name] + directorTag + "\n");
}
}
}
};
// Write the list of presenters
const writePresenters = (creators, t = 1) => {
// - Presenter::
// - Dr. Foo #[[person]]
// - Dr. Foo Bar #[[person]]
// Filter for included types only
const includedTypes = [
"presenter",
"contributor"
];
if (creators !== undefined) {
// Find list of all of the creators associated with this item
names = validatedContributors(creators, includedTypes);
if (names.length > 0) {
// Start by creating the type field parent
Zotero.write(tab[t] + presenterField + "\n");
for (name in names) {
Zotero.write(tab[t + 1] + names[name] + personTag + "\n");
}
}
}
};
// Write the list of artists
const writeArtists = (creators, t = 1) => {
// - Artist::
// - Foo #[[artist]]
// - Bar #[[artist]]
// Filter for included types only
const includedTypes = [
"artist",
"contributor"
];
if (creators !== undefined) {
// Find list of all of the creators associated with this item
names = validatedContributors(creators, includedTypes);
if (names.length > 0) {
// Start by creating the type field parent
Zotero.write(tab[t] + artistField + "\n");
for (name in names) {
Zotero.write(tab[t + 1] + names[name] + artistTag + "\n");
}
}
}
};
// Write the list of bill sponsors
const writeBillSponsors = (creators, t = 1) => {
// - Bill Sponsor::
// - Foo #[[person]]
// - Bar #[[person]]
// Filter for included types only
const includedTypes = [
"sponsor",
"cosponsor",
"contributor"
];
if (creators !== undefined) {
// Find list of all of the creators associated with this item
names = validatedContributors(creators, includedTypes);
if (names.length > 0) {
// Start by creating the type field parent
Zotero.write(tab[t] + billSponsorField + "\n");
for (name in names) {
Zotero.write(tab[t + 1] + names[name] + personTag + "\n");
}
}
}
};
// Write the list of cartographers
const writeCartographers = (creators, t = 1) => {
// - Cartographer::
// - Foo #[[person]]
// - Bar #[[person]]
// Filter for included types only
const includedTypes = [
"cartographer",
"seriesEditor",
"contributor"
];
if (creators !== undefined) {
// Find list of all of the creators associated with this item
names = validatedContributors(creators, includedTypes);
if (names.length > 0) {
// Start by creating the type field parent
Zotero.write(tab[t] + cartographerField + "\n");
for (name in names) {
Zotero.write(tab[t + 1] + names[name] + personTag + "\n");
}
}
}
};
// Write the list of inventors
const writeInventors = (creators, t = 1) => {
// - Inventor::
// - Foo #[[person]]
// - Bar #[[person]]
// Filter for included types only
const includedTypes = [
"inventor",
"contributor"
];
if (creators !== undefined) {
// Find list of all of the creators associated with this item
names = validatedContributors(creators, includedTypes);
if (names.length > 0) {
// Start by creating the type field parent
Zotero.write(tab[t] + inventorField + "\n");
for (name in names) {
Zotero.write(tab[t + 1] + names[name] + personTag + "\n");
}
}
}
};
// Write the item URL
const writeURL = (url, t = 1) => {
// - URL:: https://foo.bar
if (url !== undefined && url !== "") {
Zotero.write(tab[t] + urlField + url + "\n");
}
};
// Write the DOI link
const writeDOI = (doi, t = 1) => {
// - DOI:: https://doi.org/foo/bar
if (doi !== undefined && doi !== "") {
Zotero.write(tab[t] + doiField + doiLink(doi) + "\n");
}
};
// Write tags as topics in Tana
const writeTags = (tags, t = 1) => {
// - Topic(s)::
// - Foo Bar #[[topic]]
// - Woo #[[topic]]
if (tags !== undefined) {
// Start by creating the topic field parent
Zotero.write(tab[t] + topicField + "\n");
// Walk through the available tags
for (topic in tags) {
// Drop any tags on the ignore list
if (ignoredTopics.indexOf(tags[topic].tag.toLowerCase()) === -1) {
Zotero.write(tab[t + 1] + titleCase(tags[topic].tag) + topicTag + "\n");
}
}
}
};
// Write the publisher
const writePublisher = (publisher, t = 1) => {
// - Publisher:: Foo Bar #[[organization]]
if (publisher !== undefined && publisher !== "") {
Zotero.write(tab[t] + publisherField + publisher + organizationTag + "\n");
}
};
// Write the book field. This is used to reference a parent book object
const writeBook = (title, authors, tags, t = 1) => {
if (title !== undefined && title !== "") {
// Start by creating the book field parent
Zotero.write(tab[t] + bookField + "\n");
// Add some critical information about the book
Zotero.write(tab[t + 1] + title + bookTag + "\n");
Zotero.write(tab[t + 2] + titleField + title + "\n");
Zotero.write(tab[t + 2] + sourceStatusField + toReadStatus + "\n");
writeAuthors(authors, t + 2);
writeTags(tags, t + 2);
}
};
// Write the publication title
const writePublication = (pubTitle, t = 1) => {
// - Journal:: Foo Bar #[[journal (publication)]]
if (pubTitle !== undefined && pubTitle !== "") {
Zotero.write(tab[t] + publicationField + pubTitle + publicationTag + "\n");
}
};
// Write the episode number
const writeEpisodeNumber = (episode, t = 1) => {
// - Episode Number:: 88
if (episode !== undefined && episode !== "") {
Zotero.write(tab[t] + episodeNumberField + episode + "\n");
}
};
// Write the podcast information
const writePodcast = (podcast, t = 1) => {
// - Podcast:: Foo Bar #[[podcast]]
if (podcast !== undefined && podcast !== "") {
Zotero.write(tab[t] + podcastField + podcast + podcastTag + "\n");
}
};
// Write the genre
const writeGenre = (genre, t = 1) => {
// - Genre:: Foo Bar
if (genre !== undefined && genre !== "") {
Zotero.write(tab[t] + genreField + genre + "\n");
}
};
// Write the language
const writeLanguage = (language, t = 1) => {
// - Language:: Foo Bar
if (language !== undefined && language !== "") {
Zotero.write(tab[t] + languageField + language + "\n");
}
};
// Write the artwork medium
const writeArtworkMedium = (medium, t = 1) => {
// - Artwork Medium:: Foo Bar
if (medium !== undefined && medium !== "") {
Zotero.write(tab[t] + artworkMediumField + medium + "\n");
}
};
// Write the artwork size
const writeArtworkSize = (size, t = 1) => {
// - Artwork Size:: Foo x Bar
if (size !== undefined && size !== "") {
Zotero.write(tab[t] + artworkSizeField + size + "\n");
}
};
// Write the institution
const writeInstitution = (institution, t = 1) => {
// - Institution:: Foo Bar #[[organization]]
if (institution !== undefined && institution !== "") {
Zotero.write(tab[t] + instiutionField + institution + organizationTag + "\n");
}
};
// Write the bill number
const writeBillNumber = (billNumber, t = 1) => {
// - Bill Number:: Foo Bar
if (billNumber !== undefined && billNumber !== "") {
Zotero.write(tab[t] + billNumberField + billNumber + "\n");
}
};
// Write the legislative body
const writeLegislativeBody = (legislativeBody, t = 1) => {
// - Legislative Body:: Foo Bar #[[organization]]
if (legislativeBody !== undefined && legislativeBody !== "") {
Zotero.write(tab[t] + legislativeBodyField + legislativeBody + organizationTag + "\n");
}
};
// Write the legislative session
const writeLegislativeSession = (session, t = 1) => {
// - Legislative Session:: Foo Bar
if (session !== undefined && session !== "") {
Zotero.write(tab[t] + legislativeSessionField + session + "\n");
}
};
// Write the court
const writeCourt = (court, t = 1) => {
// - Court:: Foo Bar
if (court !== undefined && court !== "") {
Zotero.write(tab[t] + courtField + court + "\n");
}
};
// Write the date decided
const writeDateDecided = (date, t = 1) => {
// - Date Decided:: [[March 15th, 2020]]
if (date !== undefined && date !== "") {
Zotero.write(tab[t] + dateDecidedField + formatDate(Zotero.Utilities.strToDate(date)) + "\n");
}
};
// Write the map type
const writeMapType = (type, t = 1) => {
// - Map Type:: Foo Bar
if (type !== undefined && type !== "") {
Zotero.write(tab[t] + mapTypeField + type + "\n");
}
};
// Write the map scale
const writeMapScale = (scale, t = 1) => {
// - Map Scale:: Foo Bar
if (scale !== undefined && scale !== "") {
Zotero.write(tab[t] + mapScaleField + scale + "\n");
}
};
// Write the location
const writeLocation = (location, t = 1) => {
// - Location:: Foo Bar
if (location !== undefined && location !== "") {
Zotero.write(tab[t] + locationField + location + "\n");
}
};
// Write the conference name
const writeConference = (conference, t = 1) => {
// - Conference:: Foo Bar
if (conference !== undefined && conference !== "") {
Zotero.write(tab[t] + conferenceField + conference + conferenceTag + "\n");
}
};
// Write the program title
const writeProgramTitle = (title, t = 1) => {
// - Program Title:: Foo Bar
if (title !== undefined && title !== "") {
Zotero.write(tab[t] + programTitleField + title + "\n");
}
};
// Write the TV network
const writeTvNetwork = (network, t = 1) => {
// - TV Network:: Foo Bar
if (network !== undefined && network !== "") {
Zotero.write(tab[t] + tvNetworkField + network + "\n");
}
};
// Write the radio network
const writeRadioNetwork = (network, t = 1) => {
// - Radio Network:: Foo Bar
if (network !== undefined && network !== "") {
Zotero.write(tab[t] + radioNetworkField + network + "\n");
}
};
// Write the medium
const writeMedium = (medium, t = 1) => {
// - Medium:: Foo Bar
if (medium !== undefined && medium !== "") {
Zotero.write(tab[t] + mediumField + medium + "\n");
}
};
// Write the encyclopedia title
const writeEncyclopediaTitle = (title, t = 1) => {
// - Encyclopedia Title:: Foo Bar
if (title !== undefined && title !== "") {
Zotero.write(tab[t] + encyclopediaTitleField + title + "\n");
}
};
// Write the country
const writeCountry = (country, t = 1) => {
// - Country:: Foo Bar
if (country !== undefined && country !== "") {
Zotero.write(tab[t] + countryField + country + countryTag + "\n");
}
};
// Write the patent number
const writePatentNumber = (patent, t = 1) => {
// - Patent Number:: Foo Bar
if (patent !== undefined && patent !== "") {
Zotero.write(tab[t] + patentNumberField + patent + "\n");
}
};
// ---
// Finally, write everything out based upon the type
// Create the Tana paste indicator line at the top
Zotero.write("%%tana%%\n");
// Main item variable we'll step through
var item;
// Step through all of the items we are exporting
while (item = Zotero.nextItem()) {
// Write content dependent upon the specific item type
// Always start with writeBase()
if (item.itemType !== undefined) {
switch(item.itemType) {
case "journalArticle":
writeBase(item.title, journalArticleTag, toReadStatus);
writeCitationKey(item.citationKey);
writeZoteroLink(item.key, item.libraryID);
writeAuthors(item.creators);
writeJournalTitle(item.publicationTitle);
writePublicationDate(item.date);
writeVolume(item.volume);
writeIssue(item.issue);
writeURL(item.url);
writeDOI(item.DOI);
writeTags(item.tags);
break;
case "thesis":
case "book":
writeBase(item.title, bookTag, toReadStatus);
writeCitationKey(item.citationKey);
writeZoteroLink(item.key, item.libraryID);
writeAuthors(item.creators);
writeURL(item.url);
writeTags(item.tags);
writePublisher(item.publisher);
break;
case "bookSection":
writeBase(item.title, chapterTag, toReadStatus);
writeCitationKey(item.citationKey);
writeZoteroLink(item.key, item.libraryID);
writeTags(item.tags);
writeBook(item.bookTitle, item.creators, item.tags);
break;
case "videoRecording":
writeBase(item.title, videoTag, toWatchStatus);
writeCitationKey(item.citationKey);
writeZoteroLink(item.key, item.libraryID);
writeHosts(item.creators);
writePublication(item.libraryCatalog);
writeURL(item.url);
writeTags(item.tags);
break;
case "podcast":
case "audioRecording":
writeBase(item.title, podcastEpisodeTag, toListenStatus);
writeCitationKey(item.citationKey);
writeZoteroLink(item.key, item.libraryID);
writeHosts(item.creators);
writeEpisodeNumber(item.episodeNumber);
writePodcast(item.seriesTitle);
writeTags(item.tags);
writeURL(item.url);
break;
case "film":
writeBase(item.title, filmTag, toWatchStatus);
writeCitationKey(item.citationKey);
writeZoteroLink(item.key, item.libraryID);
writeDirectors(item.creators);
writeTags(item.tags);
writeGenre(item.genre);
writeLanguage(item.language);
break;
case "presentation":
writeBase(item.title, presentationTag, toWatchStatus);
writeCitationKey(item.citationKey);
writeZoteroLink(item.key, item.libraryID);
writeTags(item.tags);
writeDate(item.date);
writePresenters(item.creators);
break;
case "newspaperArticle":
case "magazineArticle":
writeBase(item.title, newspaperArticleTag, toReadStatus);
writeCitationKey(item.citationKey);
writeZoteroLink(item.key, item.libraryID);
writeTags(item.tags);
writeAuthors(item.creators);
writePublicationDate(item.date);
break
case "blogPost":
case "webpage":
case "forumPost":
writeBase(item.title, blogPostTag, toReadStatus);
writeCitationKey(item.citationKey);
writeZoteroLink(item.key, item.libraryID);
writeTags(item.tags);
writeAuthors(item.creators);
writePublicationDate(item.date);
writeURL(item.url);
break;
case "artwork":
writeBase(item.title, newspaperArticleTag, toReadStatus);
writeCitationKey(item.citationKey);
writeZoteroLink(item.key, item.libraryID);
writeTags(item.tags);
writeArtists(item.creators);
writeArtworkMedium(item.artworkMedium);
writeArtworkSize(item.artworkSize);
writeDate(item.date);
break;
case "report":
writeBase(item.title, reportTag, toReadStatus);
writeCitationKey(item.citationKey);
writeZoteroLink(item.key, item.libraryID);
writeTags(item.tags);
writePublicationDate(item.date);
writeInstitution(item.institution);
break;
case "bill":
writeBase(item.title, billTag, toReadStatus);
writeCitationKey(item.citationKey);
writeZoteroLink(item.key, item.libraryID);
writeTags(item.tags);
writeBillSponsors(item.creators);
writeBillNumber(item.billNumber);
writeLegislativeBody(item.legislativeBody);
writeLegislativeSession(item.session);
writeDate(item.date);
break;
case "case":
case "hearing":
writeBase(item.caseName, caseTag, toReadStatus);
writeCitationKey(item.citationKey);
writeZoteroLink(item.key, item.libraryID);
writeTags(item.tags);
writeCourt(item.court);
writeDateDecided(item.dateDecided);
writeURL(item.url);
break;
case "letter":
writeBase(item.title, letterTag, toReadStatus);
writeCitationKey(item.citationKey);
writeZoteroLink(item.key, item.libraryID);
writeTags(item.tags);
writeAuthors(item.creators);
writeDate(item.date);
break;
case "document":
case "manuscript":
case "attachment":
case "annotation":
writeBase(item.title, letterTag, toReadStatus);
writeCitationKey(item.citationKey);
writeZoteroLink(item.key, item.libraryID);
writeTags(item.tags);
writePublisher(item.publisher);
writeURL(item.url);
break;
case "computerProgram":
writeBase(item.title, softwareTag, toReadStatus);
writeCitationKey(item.citationKey);
writeZoteroLink(item.key, item.libraryID);
writeTags(item.tags);
writePublisher(item.publisher);
writeURL(item.url);
case "instantMessage":
writeBase(item.title, instantMessageTag, toReadStatus);
writeCitationKey(item.citationKey);
writeZoteroLink(item.key, item.libraryID);
writeTags(item.tags);
writeAuthors(item.creators);