0.3.14 • Published 1 month ago

@cwrc/dtoc v0.3.14

Weekly downloads
-
License
GPL-2.0
Repository
gitlab
Last release
1 month ago

Dynamic Table of Contexts 2.0

This project is based on Voyant Dynamic Table of Contexts and aims to be an independent and more robust iteration.

Current build

Installation

  1. Get the files
    • Either add as a dependency: npm i @cwrc/dtoc
    • Or download: https://registry.npmjs.org/@cwrc/dtoc/-/dtoc-0.x.x.tgz
  2. Copy files to a directory in your workspace
  3. Initialize (and provide a configuration object)
<!DOCTYPE html>
<html>
	<head>
		<script type="text/javascript" src="./lib/ext/ext.js"></script>
		<script type="text/javascript" src="./lib/saxon/saxon.js"></script>
		<script type="module" src="./dtoc.min.js"></script>
		<link rel="stylesheet" type="text/css" href="./lib/ext/ext.css" />
		<link rel="stylesheet" type="text/css" href="./css/dtc.css" />
		<script src="https://kit.fontawesome.com/891f15ee2f.js" crossorigin="anonymous"></script>
		<link rel="preconnect" href="https://fonts.googleapis.com">
		<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
		<link href="https://fonts.googleapis.com/css2?family=Nunito:wght@300;400&family=Roboto+Slab:wght@300;400&display=swap" rel="stylesheet">
	</head>
	<body>
	<script type="text/javascript">
		const dtocApp = new dtoc();
	</script>
	</body>
</html>

Loading Documents

There are two approaches for loading documents into DToC.

Constructor With Input Configuration

Provide a configuration object with an input entry to the constructor.

new dtoc({
	"dtocRootUrl": "https://calincs.gitlab.io/cwrc/dtoc/",
	"input": {
		"documents": "//div[@type='chapter']|//div[@type='preface']|//div[@type='afterword']",
		...
		"inputs": [
			"https://calincs.gitlab.io/cwrc/dtoc/dtoc-2.0/data/xml/sample.xml"
		]
	}
});

Calling Methods After Initialization

Call load with an input configuration.

const dtocApp = new dtoc();
dtocApp.load({
	"documents": "//div[@type='chapter']|//div[@type='preface']|//div[@type='afterword']",
	...
	"inputs": [
		"https://calincs.gitlab.io/cwrc/dtoc/dtoc-2.0/data/xml/sample.xml"
	]
})

Call showInputWindow (with an optional input configuration).

const dtocApp = new dtoc();
dtocApp.showInputWindow();

Configuration Object Details

The configuration object contains app configuration as well as the input configuration.

Italicized properties are optional

Configuration Object

NameTypeDetails
dtocRootUrlStringAn URL specifying the location of the DToC files root. If not provided then window.location will be used.
inputObjectThe input configuration object (see below for details)
showMenuBooleanWhether to show the options menu. Default is true.
showTitleBooleanWhether to show the edition title. Default is true.
debugBooleanWhether to enable debug messages in the console.

Input Configuration Object

NameTypeDetails
inputsArrayAn array of URLs or Files
documentsStringThe XPath for locating the document(s) within each XML file
documentContentStringThe XPath for locating the actual content within the document
documentTitleStringThe XPath for locating the document title
documentAuthorStringThe XPath for locating the document author
documentImagesStringThe XPath for identifying images
documentNotesStringThe XPath for identifying notes
documentLinksStringThe XPath for identifying links
ignoreNamespaceBooleanWhether to remove the root/default namespace prior to evaluating XPaths. Use to avoid having to use local-name() in XPaths.
editionTitleStringThe title of the edition
editionSubtitleStringThe subtitle of the edition
indexDocumentStringThe XPath for locating the index document to use as the corpus index
curationObjectAn optional curation object. Can be used to customize the tags panel and the table of contents panel.
curation.markupArrayAn array of markup
curation.tocArrayThe table of contents

Get the Input Configuration Object

You can get the current input configuration by calling the getInputConfig method.

const inputConfig = dtocApp.getInputConfig();
console.log(inputConfig.documents);
0.3.14

1 month ago

0.3.13

1 month ago

0.3.12

3 months ago

0.3.11

3 months ago

0.3.9

5 months ago

0.3.10

5 months ago

0.3.8

5 months ago

0.3.7

5 months ago

0.3.6

5 months ago

0.3.5

6 months ago

0.3.4

6 months ago

0.3.3

6 months ago

0.3.2

6 months ago

0.3.1

6 months ago

0.3.0

6 months ago

0.2.0

6 months ago

0.1.8

7 months ago

0.1.7

7 months ago

0.1.6

7 months ago

0.1.5

7 months ago