@fiduswriter/bibliography-manager 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +661 -0
- package/README.md +20 -0
- package/dist/database/index.js +172 -0
- package/dist/database/index.js.map +1 -0
- package/dist/database/server_connector.js +47 -0
- package/dist/database/server_connector.js.map +1 -0
- package/dist/export/index.js +23 -0
- package/dist/export/index.js.map +1 -0
- package/dist/form/cats.js +22 -0
- package/dist/form/cats.js.map +1 -0
- package/dist/form/fields/date.js +28 -0
- package/dist/form/fields/date.js.map +1 -0
- package/dist/form/fields/key.js +100 -0
- package/dist/form/fields/key.js.map +1 -0
- package/dist/form/fields/key_list.js +37 -0
- package/dist/form/fields/key_list.js.map +1 -0
- package/dist/form/fields/literal.js +43 -0
- package/dist/form/fields/literal.js.map +1 -0
- package/dist/form/fields/literal_list.js +36 -0
- package/dist/form/fields/literal_list.js.map +1 -0
- package/dist/form/fields/literal_long.js +42 -0
- package/dist/form/fields/literal_long.js.map +1 -0
- package/dist/form/fields/name.js +121 -0
- package/dist/form/fields/name.js.map +1 -0
- package/dist/form/fields/name_list.js +36 -0
- package/dist/form/fields/name_list.js.map +1 -0
- package/dist/form/fields/range.js +89 -0
- package/dist/form/fields/range.js.map +1 -0
- package/dist/form/fields/range_list.js +36 -0
- package/dist/form/fields/range_list.js.map +1 -0
- package/dist/form/fields/tag_list.js +30 -0
- package/dist/form/fields/tag_list.js.map +1 -0
- package/dist/form/fields/title.js +46 -0
- package/dist/form/fields/title.js.map +1 -0
- package/dist/form/fields/uri.js +40 -0
- package/dist/form/fields/uri.js.map +1 -0
- package/dist/form/fields/verbatim.js +19 -0
- package/dist/form/fields/verbatim.js.map +1 -0
- package/dist/form/index.js +344 -0
- package/dist/form/index.js.map +1 -0
- package/dist/form/strings.js +89 -0
- package/dist/form/strings.js.map +1 -0
- package/dist/form/templates.js +59 -0
- package/dist/form/templates.js.map +1 -0
- package/dist/import/bibliography_import.js +83 -0
- package/dist/import/bibliography_import.js.map +1 -0
- package/dist/import/dialog.js +71 -0
- package/dist/import/dialog.js.map +1 -0
- package/dist/import/index.js +3 -0
- package/dist/import/index.js.map +1 -0
- package/dist/import/templates.js +12 -0
- package/dist/import/templates.js.map +1 -0
- package/dist/index.js +6 -0
- package/dist/index.js.map +1 -0
- package/dist/overview/index.js +453 -0
- package/dist/overview/index.js.map +1 -0
- package/dist/overview/menu.js +91 -0
- package/dist/overview/menu.js.map +1 -0
- package/dist/overview/templates.js +24 -0
- package/dist/overview/templates.js.map +1 -0
- package/dist/plugins/bibliography_overview/index.js +2 -0
- package/dist/plugins/bibliography_overview/index.js.map +1 -0
- package/dist/schema/literal.js +24 -0
- package/dist/schema/literal.js.map +1 -0
- package/dist/schema/literal_long.js +40 -0
- package/dist/schema/literal_long.js.map +1 -0
- package/dist/schema/title.js +31 -0
- package/dist/schema/title.js.map +1 -0
- package/dist/tools.js +53 -0
- package/dist/tools.js.map +1 -0
- package/package.json +55 -0
- package/src/database/index.js +234 -0
- package/src/database/server_connector.js +57 -0
- package/src/export/index.js +27 -0
- package/src/form/cats.js +24 -0
- package/src/form/fields/date.js +31 -0
- package/src/form/fields/key.js +113 -0
- package/src/form/fields/key_list.js +45 -0
- package/src/form/fields/literal.js +48 -0
- package/src/form/fields/literal_list.js +42 -0
- package/src/form/fields/literal_long.js +47 -0
- package/src/form/fields/name.js +152 -0
- package/src/form/fields/name_list.js +42 -0
- package/src/form/fields/range.js +104 -0
- package/src/form/fields/range_list.js +42 -0
- package/src/form/fields/tag_list.js +33 -0
- package/src/form/fields/title.js +51 -0
- package/src/form/fields/uri.js +43 -0
- package/src/form/fields/verbatim.js +21 -0
- package/src/form/index.js +424 -0
- package/src/form/strings.js +122 -0
- package/src/form/templates.js +70 -0
- package/src/import/bibliography_import.js +104 -0
- package/src/import/dialog.js +95 -0
- package/src/import/index.js +2 -0
- package/src/import/templates.js +12 -0
- package/src/index.js +5 -0
- package/src/overview/index.js +548 -0
- package/src/overview/menu.js +106 -0
- package/src/overview/templates.js +30 -0
- package/src/plugins/bibliography_overview/index.js +1 -0
- package/src/schema/literal.js +34 -0
- package/src/schema/literal_long.js +50 -0
- package/src/schema/title.js +42 -0
- package/src/tools.js +58 -0
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { BibLatexFileExporter } from "../export";
|
|
2
|
+
import { BibliographyFileImportDialog } from "../import";
|
|
3
|
+
export const bulkMenuModel = () => ({
|
|
4
|
+
content: [
|
|
5
|
+
{
|
|
6
|
+
title: gettext("Delete selected"),
|
|
7
|
+
tooltip: gettext("Delete selected bibliography entries."),
|
|
8
|
+
action: overview => {
|
|
9
|
+
const ids = overview
|
|
10
|
+
.getSelected()
|
|
11
|
+
.map(id => Number.parseInt(id));
|
|
12
|
+
if (ids.length) {
|
|
13
|
+
overview.deleteBibEntryDialog(ids);
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
disabled: overview => !overview.getSelected().length || overview.app.isOffline()
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
title: gettext("Export selected"),
|
|
20
|
+
tooltip: gettext("Export selected bibliography entries."),
|
|
21
|
+
action: overview => {
|
|
22
|
+
const ids = overview.getSelected();
|
|
23
|
+
if (ids.length) {
|
|
24
|
+
const exporter = new BibLatexFileExporter(overview.app.bibDB, ids);
|
|
25
|
+
exporter.init();
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
disabled: overview => !overview.getSelected().length || overview.app.isOffline()
|
|
29
|
+
}
|
|
30
|
+
]
|
|
31
|
+
});
|
|
32
|
+
export const menuModel = () => ({
|
|
33
|
+
content: [
|
|
34
|
+
{
|
|
35
|
+
type: "dropdown",
|
|
36
|
+
id: "cat_selector",
|
|
37
|
+
keys: "Alt-c",
|
|
38
|
+
content: [
|
|
39
|
+
{
|
|
40
|
+
title: gettext("All categories"),
|
|
41
|
+
action: _overview => {
|
|
42
|
+
const trs = document.querySelectorAll("#bibliography > tbody > tr");
|
|
43
|
+
trs.forEach(tr => (tr.style.display = ""));
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
],
|
|
47
|
+
order: 1
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
type: "text",
|
|
51
|
+
title: gettext("Edit categories"),
|
|
52
|
+
keys: "Alt-e",
|
|
53
|
+
action: overview => overview.editCategoriesDialog(),
|
|
54
|
+
order: 2
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
type: "text",
|
|
58
|
+
title: gettext("Register new source"),
|
|
59
|
+
keys: "Alt-n",
|
|
60
|
+
action: overview => {
|
|
61
|
+
import("../form").then(({ BibEntryForm }) => {
|
|
62
|
+
const form = new BibEntryForm(overview.app.bibDB, overview.app);
|
|
63
|
+
form.init().then(idTranslations => {
|
|
64
|
+
const ids = idTranslations.map(idTrans => idTrans[1]);
|
|
65
|
+
return overview.updateTable(ids);
|
|
66
|
+
});
|
|
67
|
+
});
|
|
68
|
+
},
|
|
69
|
+
order: 3
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
type: "text",
|
|
73
|
+
title: gettext("Import bibliography"),
|
|
74
|
+
keys: "Alt-u",
|
|
75
|
+
action: overview => {
|
|
76
|
+
const fileImporter = new BibliographyFileImportDialog(overview.app.bibDB, ids => overview.updateTable(ids), overview.app);
|
|
77
|
+
fileImporter.init();
|
|
78
|
+
},
|
|
79
|
+
order: 4
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
type: "search",
|
|
83
|
+
icon: "search",
|
|
84
|
+
title: gettext("Search bibliography"),
|
|
85
|
+
keys: "Alt-s",
|
|
86
|
+
input: (overview, text) => overview.table.search(text),
|
|
87
|
+
order: 5
|
|
88
|
+
}
|
|
89
|
+
]
|
|
90
|
+
});
|
|
91
|
+
//# sourceMappingURL=menu.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"menu.js","sourceRoot":"","sources":["../../src/overview/menu.js"],"names":[],"mappings":"AAAA,OAAO,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AO,QAAQ,CAAC,WAAW,CAAC,GAAG,CAAC,CAAA;oBACpC,CAAC,CAAC,CAAA;gBACN,CAAC,CAAC,CAAA;YACN,CAAC;YACD,KAAK,EAAE,CAAC;SACX;QACD;YACI,IAAI,EAAE,MAAM;YACZ,KAAK,EAAE,OAAO,CAAC,qBAAqB,CAAC;YACrC,IAAI,EAAE,OAAO;YACb,MAAM,EAAE,QAAQ,CAAC,EAAE;gBACf,MAAM,YAAY,GAAG,IAAI,4BAA4B,CACjD,QAAQ,CAAC,GAAG,CAAC,KAAK,EAClB,GAAG,CAAC,EAAE,CAAC,QAAQ,CAAC,WAAW,CAAC,GAAG,CAAC,EAChC,QAAQ,CAAC,GAAG,CACf,CAAA;gBACD,YAAY,CAAC,IAAI,EAAE,CAAA;YACvB,CAAC;YACD,KAAK,EAAE,CAAC;SACX;QACD;YACI,IAAI,EAAE,QAAQ;YACd,IAAI,EAAE,QAAQ;YACd,KAAK,EAAE,OAAO,CAAC,qBAAqB,CAAC;YACrC,IAAI,EAAE,OAAO;YACb,KAAK,EAAE,CAAC,QAAQ,EAAE,IAAI,EAAE,EAAE,CAAC,QAAQ,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC;YACtD,KAAK,EAAE,CAAC;SACX;KACJ;CACJ,CAAC,CAAA"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { escapeText } from "fwtoolkit";
|
|
2
|
+
/** A template for each category in the category list edit of the bibliography categories list. */
|
|
3
|
+
const categoryFormsTemplate = ({ categories }) => `${categories
|
|
4
|
+
.map(cat => `<tr id="categoryTr_${cat.id}" class="fw-list-input">
|
|
5
|
+
<td>
|
|
6
|
+
<input type="text" class="category-form" id="categoryTitle_${cat.id}"
|
|
7
|
+
value="${escapeText(cat.category_title)}" data-id="${cat.id}" />
|
|
8
|
+
<span class="fw-add-input icon-addremove" tabindex="0"></span>
|
|
9
|
+
</td>
|
|
10
|
+
</tr>`)
|
|
11
|
+
.join("")}
|
|
12
|
+
<tr class="fw-list-input">
|
|
13
|
+
<td>
|
|
14
|
+
<input type="text" class="category-form" />
|
|
15
|
+
<span class="fw-add-input icon-addremove" tabindex="0"></span>
|
|
16
|
+
</td>
|
|
17
|
+
</tr>`;
|
|
18
|
+
/** A template for the editing of bibliography categories list. */
|
|
19
|
+
export const editCategoriesTemplate = ({ categories }) => `<table id="editCategoryList" class="fw-dialog-table">
|
|
20
|
+
<tbody>
|
|
21
|
+
${categoryFormsTemplate({ categories })}
|
|
22
|
+
</tbody>
|
|
23
|
+
</table>`;
|
|
24
|
+
//# sourceMappingURL=templates.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"templates.js","sourceRoot":"","sources":["../../src/overview/templates.js"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAC,MAAM,WAAW,CAAA;AAEpC,kGAAkG;AAClG,MAAM,qBAAqB,GAAG,CAAC,EAAC,UAAU,EAAC,EAAE,EAAE,CAC3C,GAAG,UAAU;KACR,GAAG,CACA,GAAG,CAAC,EAAE,CACF,sBAAsB,GAAG,CAAC,EAAE;;iFAEqC,GAAG,CAAC,EAAE;qCAClD,UAAU,CAAC,GAAG,CAAC,cAAc,CAAC,cAAc,GAAG,CAAC,EAAE;;;kBAGrE,CACT;KACA,IAAI,CAAC,EAAE,CAAC;;;;;;UAMP,CAAA;AAEV,kEAAkE;AAClE,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAAC,EAAC,UAAU,EAAC,EAAE,EAAE,CACnD;;cAEU,qBAAqB,CAAC,EAAC,UAAU,EAAC,CAAC;;aAEpC,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/plugins/bibliography_overview/index.js"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,OAAO,GAAG,EAAE,CAAA"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { url, enquote, literal, smallcaps, sub, sup, text, variable } from "@fiduswriter/document/bibliography/common";
|
|
2
|
+
import { Schema } from "prosemirror-model";
|
|
3
|
+
import { marks } from "prosemirror-schema-basic";
|
|
4
|
+
const doc = {
|
|
5
|
+
content: "literal"
|
|
6
|
+
};
|
|
7
|
+
export const litSchema = new Schema({
|
|
8
|
+
nodes: {
|
|
9
|
+
doc,
|
|
10
|
+
literal,
|
|
11
|
+
text,
|
|
12
|
+
variable
|
|
13
|
+
},
|
|
14
|
+
marks: {
|
|
15
|
+
em: marks.em,
|
|
16
|
+
enquote,
|
|
17
|
+
smallcaps,
|
|
18
|
+
strong: marks.strong,
|
|
19
|
+
sup,
|
|
20
|
+
sub,
|
|
21
|
+
url
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
//# sourceMappingURL=literal.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"literal.js","sourceRoot":"","sources":["../../src/schema/literal.js"],"names":[],"mappings":"AAAA,OAAO,EACH,GAAG,EACH,OAAO,EACP,OAAO,EACP,SAAS,EACT,GAAG,EACH,GAAG,EACH,IAAI,EACJ,QAAQ,EACX,MAAM,2CAA2C,CAAA;AAClD,OAAO,EAAC,MAAM,EAAC,MAAM,mBAAmB,CAAA;AACxC,OAAO,EAAC,KAAK,EAAC,MAAM,0BAA0B,CAAA;AAE9C,MAAM,GAAG,GAAG;IACR,OAAO,EAAE,SAAS;CACrB,CAAA;AAED,MAAM,CAAC,MAAM,SAAS,GAAG,IAAI,MAAM,CAAC;IAChC,KAAK,EAAE;QACH,GAAG;QACH,OAAO;QACP,IAAI;QACJ,QAAQ;KACX;IACD,KAAK,EAAE;QACH,EAAE,EAAE,KAAK,CAAC,EAAE;QACZ,OAAO;QACP,SAAS;QACT,MAAM,EAAE,KAAK,CAAC,MAAM;QACpB,GAAG;QACH,GAAG;QACH,GAAG;KACN;CACJ,CAAC,CAAA"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { url, enquote, smallcaps, sub, sup, text, variable } from "@fiduswriter/document/bibliography/common";
|
|
2
|
+
import { Schema } from "prosemirror-model";
|
|
3
|
+
import { marks } from "prosemirror-schema-basic";
|
|
4
|
+
const longliteral = {
|
|
5
|
+
content: "inline*",
|
|
6
|
+
marks: "_",
|
|
7
|
+
code: true,
|
|
8
|
+
defining: true,
|
|
9
|
+
parseDOM: [{ tag: "pre.long-literal" }],
|
|
10
|
+
toDOM(_node) {
|
|
11
|
+
return [
|
|
12
|
+
"pre",
|
|
13
|
+
{
|
|
14
|
+
class: "long-literal"
|
|
15
|
+
},
|
|
16
|
+
0
|
|
17
|
+
];
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
const doc = {
|
|
21
|
+
content: "longliteral"
|
|
22
|
+
};
|
|
23
|
+
export const longLitSchema = new Schema({
|
|
24
|
+
nodes: {
|
|
25
|
+
doc,
|
|
26
|
+
longliteral,
|
|
27
|
+
text,
|
|
28
|
+
variable
|
|
29
|
+
},
|
|
30
|
+
marks: {
|
|
31
|
+
em: marks.em,
|
|
32
|
+
enquote,
|
|
33
|
+
smallcaps,
|
|
34
|
+
strong: marks.strong,
|
|
35
|
+
sup,
|
|
36
|
+
sub,
|
|
37
|
+
url
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
//# sourceMappingURL=literal_long.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"literal_long.js","sourceRoot":"","sources":["../../src/schema/literal_long.js"],"names":[],"mappings":"AAAA,OAAO,EACH,GAAG,EACH,OAAO,EACP,SAAS,EACT,GAAG,EACH,GAAG,EACH,IAAI,EACJ,QAAQ,EACX,MAAM,2CAA2C,CAAA;AAClD,OAAO,EAAC,MAAM,EAAC,MAAM,mBAAmB,CAAA;AACxC,OAAO,EAAC,KAAK,EAAC,MAAM,0BAA0B,CAAA;AAE9C,MAAM,WAAW,GAAG;IAChB,OAAO,EAAE,SAAS;IAClB,KAAK,EAAE,GAAG;IACV,IAAI,EAAE,IAAI;IACV,QAAQ,EAAE,IAAI;IACd,QAAQ,EAAE,CAAC,EAAC,GAAG,EAAE,kBAAkB,EAAC,CAAC;IACrC,KAAK,CAAC,KAAK;QACP,OAAO;YACH,KAAK;YACL;gBACI,KAAK,EAAE,cAAc;aACxB;YACD,CAAC;SACJ,CAAA;IACL,CAAC;CACJ,CAAA;AAED,MAAM,GAAG,GAAG;IACR,OAAO,EAAE,aAAa;CACzB,CAAA;AAED,MAAM,CAAC,MAAM,aAAa,GAAG,IAAI,MAAM,CAAC;IACpC,KAAK,EAAE;QACH,GAAG;QACH,WAAW;QACX,IAAI;QACJ,QAAQ;KACX;IACD,KAAK,EAAE;QACH,EAAE,EAAE,KAAK,CAAC,EAAE;QACZ,OAAO;QACP,SAAS;QACT,MAAM,EAAE,KAAK,CAAC,MAAM;QACpB,GAAG;QACH,GAAG;QACH,GAAG;KACN;CACJ,CAAC,CAAA"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { url, enquote, literal, smallcaps, sub, sup, text, variable } from "@fiduswriter/document/bibliography/common";
|
|
2
|
+
import { Schema } from "prosemirror-model";
|
|
3
|
+
import { marks } from "prosemirror-schema-basic";
|
|
4
|
+
const nocase = {
|
|
5
|
+
parseDOM: [{ tag: "span.nocase" }],
|
|
6
|
+
toDOM() {
|
|
7
|
+
return ["span", { class: "nocase" }];
|
|
8
|
+
}
|
|
9
|
+
};
|
|
10
|
+
const doc = {
|
|
11
|
+
content: "literal"
|
|
12
|
+
};
|
|
13
|
+
export const titleSchema = new Schema({
|
|
14
|
+
nodes: {
|
|
15
|
+
doc,
|
|
16
|
+
literal,
|
|
17
|
+
text,
|
|
18
|
+
variable
|
|
19
|
+
},
|
|
20
|
+
marks: {
|
|
21
|
+
em: marks.em,
|
|
22
|
+
enquote,
|
|
23
|
+
nocase,
|
|
24
|
+
smallcaps,
|
|
25
|
+
strong: marks.strong,
|
|
26
|
+
sup,
|
|
27
|
+
sub,
|
|
28
|
+
url
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
//# sourceMappingURL=title.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"title.js","sourceRoot":"","sources":["../../src/schema/title.js"],"names":[],"mappings":"AAAA,OAAO,EACH,GAAG,EACH,OAAO,EACP,OAAO,EACP,SAAS,EACT,GAAG,EACH,GAAG,EACH,IAAI,EACJ,QAAQ,EACX,MAAM,2CAA2C,CAAA;AAClD,OAAO,EAAC,MAAM,EAAC,MAAM,mBAAmB,CAAA;AACxC,OAAO,EAAC,KAAK,EAAC,MAAM,0BAA0B,CAAA;AAE9C,MAAM,MAAM,GAAG;IACX,QAAQ,EAAE,CAAC,EAAC,GAAG,EAAE,aAAa,EAAC,CAAC;IAChC,KAAK;QACD,OAAO,CAAC,MAAM,EAAE,EAAC,KAAK,EAAE,QAAQ,EAAC,CAAC,CAAA;IACtC,CAAC;CACJ,CAAA;AAED,MAAM,GAAG,GAAG;IACR,OAAO,EAAE,SAAS;CACrB,CAAA;AAED,MAAM,CAAC,MAAM,WAAW,GAAG,IAAI,MAAM,CAAC;IAClC,KAAK,EAAE;QACH,GAAG;QACH,OAAO;QACP,IAAI;QACJ,QAAQ;KACX;IACD,KAAK,EAAE;QACH,EAAE,EAAE,KAAK,CAAC,EAAE;QACZ,OAAO;QACP,MAAM;QACN,SAAS;QACT,MAAM,EAAE,KAAK,CAAC,MAAM;QACpB,GAAG;QACH,GAAG;QACH,GAAG;KACN;CACJ,CAAC,CAAA"}
|
package/dist/tools.js
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
// Extract a display year from an EDTF date string.
|
|
2
|
+
// Handles simple years, ranges (2023/2024), uncertainty (?, *, u), and open-ended dates.
|
|
3
|
+
export function dateToYear(dateStr) {
|
|
4
|
+
if (!dateStr) {
|
|
5
|
+
return "";
|
|
6
|
+
}
|
|
7
|
+
// Take the first date component (before "/" for ranges or open-ended dates)
|
|
8
|
+
const firstPart = dateStr.split("/")[0];
|
|
9
|
+
// Strip uncertainty/wildcard characters to get a clean year
|
|
10
|
+
return firstPart.replace(/[?*u~]/g, "");
|
|
11
|
+
}
|
|
12
|
+
// Takes any richtext text field as used in bibliography and returns the text contents
|
|
13
|
+
export function litToText(litStringArray) {
|
|
14
|
+
let outText = "";
|
|
15
|
+
litStringArray.forEach(litString => {
|
|
16
|
+
if (litString.type === "text") {
|
|
17
|
+
outText += litString.text;
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
return outText;
|
|
21
|
+
}
|
|
22
|
+
function nameListItemToString(nameListItem) {
|
|
23
|
+
let nameString = "";
|
|
24
|
+
if (nameListItem["family"]) {
|
|
25
|
+
nameString += litToText(nameListItem["family"]);
|
|
26
|
+
if (nameListItem["given"]) {
|
|
27
|
+
nameString += `, ${litToText(nameListItem["given"])}`;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
else if (nameListItem["literal"]) {
|
|
31
|
+
nameString += litToText(nameListItem["literal"]);
|
|
32
|
+
}
|
|
33
|
+
return nameString;
|
|
34
|
+
}
|
|
35
|
+
export function nameToText(nameList) {
|
|
36
|
+
let nameString;
|
|
37
|
+
switch (nameList.length) {
|
|
38
|
+
case 0:
|
|
39
|
+
nameString = "";
|
|
40
|
+
break;
|
|
41
|
+
case 1:
|
|
42
|
+
nameString = nameListItemToString(nameList[0]);
|
|
43
|
+
break;
|
|
44
|
+
case 2:
|
|
45
|
+
nameString = `${nameListItemToString(nameList[0])} ${gettext("and")} ${nameListItemToString(nameList[1])}`;
|
|
46
|
+
break;
|
|
47
|
+
default:
|
|
48
|
+
nameString = `${nameListItemToString(nameList[0])} ${gettext("and others")}`;
|
|
49
|
+
break;
|
|
50
|
+
}
|
|
51
|
+
return nameString;
|
|
52
|
+
}
|
|
53
|
+
//# sourceMappingURL=tools.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tools.js","sourceRoot":"","sources":["../src/tools.js"],"names":[],"mappings":"AAAA,mDAAmD;AACnD,yFAAyF;AACzF,MAAM,UA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AAA;YACf,MAAK;QACT,KAAK,CAAC;YACF,UAAU,GAAG,oBAAoB,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAA;YAC9C,MAAK;QACT,KAAK,CAAC;YACF,UAAU,GAAG,GAAG,oBAAoB,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,IAAI,OAAO,CACxD,KAAK,CACR,IAAI,oBAAoB,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,EAAE,CAAA;YACxC,MAAK;QACT;YACI,UAAU,GAAG,GAAG,oBAAoB,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,IAAI,OAAO,CACxD,YAAY,CACf,EAAE,CAAA;YACH,MAAK;IACb,CAAC;IACD,OAAO,UAAU,CAAA;AACrB,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@fiduswriter/bibliography-manager",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Fidus Writer bibliography manager",
|
|
5
|
+
"repository": {
|
|
6
|
+
"type": "git",
|
|
7
|
+
"url": "ssh://git@codeberg.org/fiduswriter/fiduswriter-bibliography-manager-js.git"
|
|
8
|
+
},
|
|
9
|
+
"license": "AGPL-3.0",
|
|
10
|
+
"author": "Johannes Wilm",
|
|
11
|
+
"type": "module",
|
|
12
|
+
"main": "./dist/index.js",
|
|
13
|
+
"exports": {
|
|
14
|
+
".": "./dist/index.js",
|
|
15
|
+
"./overview": "./dist/overview/index.js",
|
|
16
|
+
"./form": "./dist/form/index.js",
|
|
17
|
+
"./database": "./dist/database/index.js",
|
|
18
|
+
"./import": "./dist/import/index.js",
|
|
19
|
+
"./export": "./dist/export/index.js",
|
|
20
|
+
"./schema/*": "./dist/schema/*.js",
|
|
21
|
+
"./*": "./dist/*.js"
|
|
22
|
+
},
|
|
23
|
+
"files": [
|
|
24
|
+
"dist/",
|
|
25
|
+
"src/",
|
|
26
|
+
"README.md",
|
|
27
|
+
"LICENSE"
|
|
28
|
+
],
|
|
29
|
+
"scripts": {
|
|
30
|
+
"build": "tsc",
|
|
31
|
+
"prepare": "npm run build",
|
|
32
|
+
"prepublishOnly": "npm run build",
|
|
33
|
+
"typecheck": "tsc --noEmit",
|
|
34
|
+
"lint": "eslint src",
|
|
35
|
+
"lint:fix": "eslint src --fix",
|
|
36
|
+
"format": "prettier --write .",
|
|
37
|
+
"format:check": "prettier --check ."
|
|
38
|
+
},
|
|
39
|
+
"dependencies": {
|
|
40
|
+
"@fiduswriter/common": "^0.1.0",
|
|
41
|
+
"@fiduswriter/document": "file:../fiduswriter-document-js",
|
|
42
|
+
"bibliojson": "^4.0.0",
|
|
43
|
+
"fix-utf8": "2.0.1",
|
|
44
|
+
"fwtoolkit": "^0.1.4",
|
|
45
|
+
"tokenfield": "^1.2.2"
|
|
46
|
+
},
|
|
47
|
+
"devDependencies": {
|
|
48
|
+
"@eslint/js": "^10.0.1",
|
|
49
|
+
"eslint": "^10.6.0",
|
|
50
|
+
"globals": "^15.15.0",
|
|
51
|
+
"prettier": "^3.5.3",
|
|
52
|
+
"typescript": "^6.0.3",
|
|
53
|
+
"typescript-eslint": "^8.62.0"
|
|
54
|
+
}
|
|
55
|
+
}
|
|
@@ -0,0 +1,234 @@
|
|
|
1
|
+
import {activateWait, addAlert, deactivateWait} from "fwtoolkit"
|
|
2
|
+
import {BibliographyDBServerConnector} from "./server_connector"
|
|
3
|
+
|
|
4
|
+
const FW_LOCALSTORAGE_VERSION = "1.2"
|
|
5
|
+
|
|
6
|
+
export class BibliographyDB {
|
|
7
|
+
constructor(app) {
|
|
8
|
+
this.app = app
|
|
9
|
+
this.db = {}
|
|
10
|
+
this.cats = []
|
|
11
|
+
this.sc = new BibliographyDBServerConnector()
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/** Get the bibliography from the server and create as this.db.
|
|
15
|
+
* @function getDB
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
getDB() {
|
|
19
|
+
const localStorageVersion = window.localStorage.getItem("version")
|
|
20
|
+
let lastModified = Number.parseInt(
|
|
21
|
+
window.localStorage.getItem("last_modified_biblist")
|
|
22
|
+
),
|
|
23
|
+
numberOfEntries = Number.parseInt(
|
|
24
|
+
window.localStorage.getItem("number_of_entries")
|
|
25
|
+
),
|
|
26
|
+
localStorageOwnerId = Number.parseInt(
|
|
27
|
+
window.localStorage.getItem("owner_id")
|
|
28
|
+
)
|
|
29
|
+
|
|
30
|
+
// A dictionary to look up bib fields by their fw type name.
|
|
31
|
+
// Needed for translation to CSL and Biblatex.
|
|
32
|
+
//Fill BibDB
|
|
33
|
+
|
|
34
|
+
if (Number.isNaN(lastModified)) {
|
|
35
|
+
lastModified = -1
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
if (Number.isNaN(numberOfEntries)) {
|
|
39
|
+
numberOfEntries = -1
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
if (Number.isNaN(localStorageOwnerId)) {
|
|
43
|
+
localStorageOwnerId = -1
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
if (localStorageVersion != FW_LOCALSTORAGE_VERSION) {
|
|
47
|
+
lastModified = -1
|
|
48
|
+
numberOfEntries = -1
|
|
49
|
+
localStorageOwnerId = -1
|
|
50
|
+
}
|
|
51
|
+
activateWait()
|
|
52
|
+
return this.sc
|
|
53
|
+
.getDB(lastModified, numberOfEntries, localStorageOwnerId)
|
|
54
|
+
.then(
|
|
55
|
+
({bibCats, bibList, lastModified, numberOfEntries, userId}) => {
|
|
56
|
+
bibCats.forEach(bibCat => this.cats.push(bibCat))
|
|
57
|
+
if (bibList) {
|
|
58
|
+
try {
|
|
59
|
+
window.localStorage.setItem(
|
|
60
|
+
"biblist",
|
|
61
|
+
JSON.stringify(bibList)
|
|
62
|
+
)
|
|
63
|
+
window.localStorage.setItem(
|
|
64
|
+
"last_modified_biblist",
|
|
65
|
+
lastModified
|
|
66
|
+
)
|
|
67
|
+
window.localStorage.setItem(
|
|
68
|
+
"number_of_entries",
|
|
69
|
+
numberOfEntries
|
|
70
|
+
)
|
|
71
|
+
window.localStorage.setItem("owner_id", userId)
|
|
72
|
+
window.localStorage.setItem(
|
|
73
|
+
"version",
|
|
74
|
+
FW_LOCALSTORAGE_VERSION
|
|
75
|
+
)
|
|
76
|
+
} catch (error) {
|
|
77
|
+
// The local storage was likely too small
|
|
78
|
+
throw error
|
|
79
|
+
}
|
|
80
|
+
} else {
|
|
81
|
+
bibList = JSON.parse(
|
|
82
|
+
window.localStorage.getItem("biblist")
|
|
83
|
+
)
|
|
84
|
+
}
|
|
85
|
+
bibList.forEach(({id, bibDBEntry}) => {
|
|
86
|
+
this.db[id] = bibDBEntry
|
|
87
|
+
})
|
|
88
|
+
deactivateWait()
|
|
89
|
+
return
|
|
90
|
+
}
|
|
91
|
+
)
|
|
92
|
+
.catch(error => {
|
|
93
|
+
addAlert("error", gettext("Could not obtain bibliography data"))
|
|
94
|
+
deactivateWait()
|
|
95
|
+
throw error
|
|
96
|
+
})
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/** Saves a bibliography entry to the database on the server.
|
|
100
|
+
* @function saveBibEntries
|
|
101
|
+
* @param tmpDB The bibliography DB with temporary IDs to be send to the server.
|
|
102
|
+
*/
|
|
103
|
+
saveBibEntries(tmpDB, isNew) {
|
|
104
|
+
return this.sc
|
|
105
|
+
.saveBibEntries(tmpDB, isNew)
|
|
106
|
+
.then(idTranslations =>
|
|
107
|
+
this.updateLocalBibEntries(tmpDB, idTranslations)
|
|
108
|
+
)
|
|
109
|
+
.catch(error => {
|
|
110
|
+
addAlert(
|
|
111
|
+
"error",
|
|
112
|
+
gettext("The bibliography could not be updated")
|
|
113
|
+
)
|
|
114
|
+
if (this.app.isOffline()) {
|
|
115
|
+
addAlert(
|
|
116
|
+
"info",
|
|
117
|
+
gettext(
|
|
118
|
+
"You are currently offline. Please try again when you are back online."
|
|
119
|
+
)
|
|
120
|
+
)
|
|
121
|
+
} else {
|
|
122
|
+
throw error
|
|
123
|
+
}
|
|
124
|
+
})
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
updateLocalBibEntries(tmpDB, idTranslations) {
|
|
128
|
+
idTranslations.forEach(bibTrans => {
|
|
129
|
+
this.db[bibTrans[1]] = tmpDB[bibTrans[0]]
|
|
130
|
+
})
|
|
131
|
+
addAlert("success", gettext("The bibliography has been updated."))
|
|
132
|
+
return idTranslations
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
/** Update or create new category
|
|
136
|
+
* @function saveCategories
|
|
137
|
+
* @param cats The category objects to add.
|
|
138
|
+
*/
|
|
139
|
+
saveCategories(cats) {
|
|
140
|
+
activateWait()
|
|
141
|
+
|
|
142
|
+
return this.sc
|
|
143
|
+
.saveCategories(cats)
|
|
144
|
+
.then(bibCats => {
|
|
145
|
+
// Replace the old with the new categories, but don't lose the link to the array (so delete each, then add each).
|
|
146
|
+
while (this.cats.length > 0) {
|
|
147
|
+
this.cats.pop()
|
|
148
|
+
}
|
|
149
|
+
while (bibCats.length > 0) {
|
|
150
|
+
this.cats.push(bibCats.pop())
|
|
151
|
+
}
|
|
152
|
+
addAlert("success", gettext("The categories have been updated"))
|
|
153
|
+
deactivateWait()
|
|
154
|
+
return this.cats
|
|
155
|
+
})
|
|
156
|
+
.catch(error => {
|
|
157
|
+
addAlert(
|
|
158
|
+
"error",
|
|
159
|
+
gettext("The categories could not be updated")
|
|
160
|
+
)
|
|
161
|
+
deactivateWait()
|
|
162
|
+
if (this.app.isOffline()) {
|
|
163
|
+
addAlert(
|
|
164
|
+
"info",
|
|
165
|
+
gettext(
|
|
166
|
+
"You are currently offline. Please try again when you are back online."
|
|
167
|
+
)
|
|
168
|
+
)
|
|
169
|
+
} else {
|
|
170
|
+
throw error
|
|
171
|
+
}
|
|
172
|
+
})
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
/** Delete a categories
|
|
176
|
+
* @function deleteCategory
|
|
177
|
+
* @param ids A list of ids to delete.
|
|
178
|
+
*/
|
|
179
|
+
deleteCategory(ids) {
|
|
180
|
+
return this.sc.deleteCategory(ids).then(() => {
|
|
181
|
+
const deletedPks = ids.slice()
|
|
182
|
+
const deletedBibCats = []
|
|
183
|
+
this.cats.forEach(bibCat => {
|
|
184
|
+
if (ids.indexOf(bibCat.id) !== -1) {
|
|
185
|
+
deletedBibCats.push(bibCat)
|
|
186
|
+
}
|
|
187
|
+
})
|
|
188
|
+
deletedBibCats.forEach(bibCat => {
|
|
189
|
+
const index = this.cats.indexOf(bibCat)
|
|
190
|
+
this.cats.splice(index, 1)
|
|
191
|
+
})
|
|
192
|
+
return deletedPks
|
|
193
|
+
})
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
/** Delete a list of bibliography items both locally and on the server.
|
|
197
|
+
* @function deleteBibEntries
|
|
198
|
+
* @param ids A list of bibliography item ids that are to be deleted.
|
|
199
|
+
*/
|
|
200
|
+
deleteBibEntries(ids) {
|
|
201
|
+
activateWait()
|
|
202
|
+
ids = ids.map(id => Number.parseInt(id))
|
|
203
|
+
return this.sc
|
|
204
|
+
.deleteBibEntries(ids)
|
|
205
|
+
.then(() => {
|
|
206
|
+
ids.forEach(id => {
|
|
207
|
+
delete this.db[id]
|
|
208
|
+
})
|
|
209
|
+
addAlert(
|
|
210
|
+
"success",
|
|
211
|
+
gettext("The bibliography item(s) have been deleted")
|
|
212
|
+
)
|
|
213
|
+
deactivateWait()
|
|
214
|
+
return ids
|
|
215
|
+
})
|
|
216
|
+
.catch(error => {
|
|
217
|
+
addAlert(
|
|
218
|
+
"error",
|
|
219
|
+
"The bibliography item(s) could not be deleted"
|
|
220
|
+
)
|
|
221
|
+
deactivateWait()
|
|
222
|
+
if (this.app.isOffline()) {
|
|
223
|
+
addAlert(
|
|
224
|
+
"info",
|
|
225
|
+
gettext(
|
|
226
|
+
"You are currently offline. Please try again when you are back online."
|
|
227
|
+
)
|
|
228
|
+
)
|
|
229
|
+
} else {
|
|
230
|
+
throw error
|
|
231
|
+
}
|
|
232
|
+
})
|
|
233
|
+
}
|
|
234
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import {post, postJson} from "fwtoolkit/network"
|
|
2
|
+
|
|
3
|
+
// class for server calls of BibliographyDB.
|
|
4
|
+
export class BibliographyDBServerConnector {
|
|
5
|
+
constructor() {}
|
|
6
|
+
|
|
7
|
+
getDB(lastModified, numberOfEntries, localStorageOwnerId) {
|
|
8
|
+
return postJson("/api/bibliography/biblist/", {
|
|
9
|
+
last_modified: lastModified,
|
|
10
|
+
number_of_entries: numberOfEntries,
|
|
11
|
+
user_id: localStorageOwnerId
|
|
12
|
+
}).then(({json}) => {
|
|
13
|
+
return {
|
|
14
|
+
bibCats: json["bib_categories"],
|
|
15
|
+
bibList: json.hasOwnProperty("bib_list")
|
|
16
|
+
? json["bib_list"].map(item =>
|
|
17
|
+
this.serverBibItemToBibDB(item)
|
|
18
|
+
)
|
|
19
|
+
: false,
|
|
20
|
+
lastModified: json["last_modified"],
|
|
21
|
+
numberOfEntries: json["number_of_entries"],
|
|
22
|
+
userId: json["user_id"]
|
|
23
|
+
}
|
|
24
|
+
})
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/** Converts a bibliography item as it arrives from the server to a BibDB object.
|
|
28
|
+
* @function serverBibItemToBibDB
|
|
29
|
+
* @param item The bibliography item from the server.
|
|
30
|
+
*/
|
|
31
|
+
serverBibItemToBibDB(bibDBEntry) {
|
|
32
|
+
return {id: bibDBEntry["id"], bibDBEntry}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
saveBibEntries(tmpDB, isNew) {
|
|
36
|
+
return postJson("/api/bibliography/save/", {
|
|
37
|
+
is_new: isNew,
|
|
38
|
+
bibs: tmpDB
|
|
39
|
+
}).then(({json}) => json["id_translations"])
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
saveCategories(cats) {
|
|
43
|
+
return postJson("/api/bibliography/save_category/", cats).then(
|
|
44
|
+
({json}) => {
|
|
45
|
+
return json.entries
|
|
46
|
+
}
|
|
47
|
+
)
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
deleteCategory(ids) {
|
|
51
|
+
return post("/api/bibliography/delete_category/", {ids})
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
deleteBibEntries(ids) {
|
|
55
|
+
return post("/api/bibliography/delete/", {ids})
|
|
56
|
+
}
|
|
57
|
+
}
|