From f9bc0457955d99e321c4554e761d385f41b28437 Mon Sep 17 00:00:00 2001 From: Dan Conley Date: Thu, 3 Sep 2020 11:16:30 -0400 Subject: [PATCH] sync method; more manifest entries --- README.md | 6 ++---- module.json | 7 +++++-- scripts/journallink.js | 18 +++++++++++++++++- 3 files changed, 24 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 954a806..262b034 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,5 @@ Add the manifest to your Foundry modules: https://raw.githubusercontent.com/Siga ## Settings * **Rebuild on save**: if disabled, won't automatically generate links between entities (default: enabled) -* **Heading tag**: By default it uses `

` tags for the section. If you'd like to change it to `

`, etc, you can (note: this doesn't support custom classes yet) - -## Bugs? -This is very alpha, and doesn't work with at least one other journal plugin. I'll do my best to address any issues that are filed. +* **Heading tag**: by default it uses `

` tags for the section. If you'd like to change it to `

`, etc, you can (note: this doesn't support custom classes, attributes, etc) +* **Debug**: will print more detailed information about the linking process in the developer console (default: disabled) diff --git a/module.json b/module.json index 759c1b0..dd80806 100644 --- a/module.json +++ b/module.json @@ -1,8 +1,8 @@ { "name": "journal-links", "title": "Journal Links", - "description": "See relationships between journal entries", - "version": "0.1.3", + "description": "Include links to entities that reference the viewed journal, actor, item, etc.", + "version": "0.2.0", "author": "dconley", "esmodules": ["./scripts/index.js"], "scripts": [], @@ -10,6 +10,9 @@ "packs": [], "minimumCoreVersion": "0.6.6", "compatibleCoreVersion": "0.6.6", + "url": "https://github.com/Sigafoos/journal-links", + "license": "https://raw.githubusercontent.com/Sigafoos/journal-links/master/LICENSE", + "bugs": "https://github.com/Sigafoos/journal-links/issues", "manifest": "https://raw.githubusercontent.com/Sigafoos/journal-links/master/module.json", "download": "https://github.com/Sigafoos/journal-links/archive/master.zip" } diff --git a/scripts/journallink.js b/scripts/journallink.js index 7d10751..9b65241 100644 --- a/scripts/journallink.js +++ b/scripts/journallink.js @@ -50,7 +50,7 @@ export class JournalLink { let existingOfType = existing[reference.type] || []; if (existingOfType.includes(reference.id)) { - this.debug(reference.type + ' ' + reference.id + ' already exists, skipping'); + this.debug(reference.type + ' ' + reference.id + ' is already referenced, skipping'); continue; } @@ -164,6 +164,22 @@ export class JournalLink { element.append(linksDiv); } + // clears and recreates references + sync() { + this.log('syncing links...'); + let keys = Object.values(this.entityMap); + + for (let key of keys) { + this.log('wiping referencedBy for ' + key); + Array.from(game[key]).forEach(async e => await e.unsetFlag('journal-links', 'referencedBy')) + } + + for (let key of keys) { + this.log('wiping references for ' + key); + Array.from(game[key]).forEach(async e => await e.unsetFlag('journal-links', 'references')) + } + } + references(text) { return Array.from(text.matchAll(this.re)).map( m => {