Skip to content

Commit

Permalink
Bug fix for WA API change as 1.3.3 release
Browse files Browse the repository at this point in the history
  • Loading branch information
aaclayton committed Jun 11, 2022
1 parent 00d612c commit e9fe7ed
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 15 deletions.
4 changes: 2 additions & 2 deletions module.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"author": "Atropos",
"authors": [],
"url": "https://github.com/foundryvtt/world-anvil",
"version": "1.3.2",
"version": "1.3.3",
"minimumCoreVersion": "0.7.6",
"compatibleCoreVersion": "9",
"scripts": [],
Expand All @@ -26,5 +26,5 @@
"system": [],
"dependencies": [],
"manifest": "https://raw.githubusercontent.com/foundryvtt/world-anvil/master/module.json",
"download": "https://github.com/foundryvtt/world-anvil/archive/refs/tags/release-1.3.2.zip"
"download": "https://github.com/foundryvtt/world-anvil/archive/refs/tags/release-1.3.3.zip"
}
18 changes: 13 additions & 5 deletions module/framework.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,20 @@ export const ARTICLE_CSS_CLASSES = {
* @property {Category} [category] A parent category to which this article belongs
* @property {object[]} sections Sections of the Article
* @property {object[]} relations Relations to the Article
* @property {string} content_parsed Parsed HTML content for the article
* @property {string} contentParsed Parsed HTML content for the article
* @property {string} portrait A portrait image URL
* @property {string} cover A cover image URL
* @property {JournalEntry} [entry] A linked JournalEntry document for this article
*/

/**
* @typedef {Object} ArticleSection
* @property {string} title The section title
* @property {string} position A special positional assignment for the section
* @property {string} content The original WorldAnvil content in bbCode format
* @property {string} contentParsed The HTML parsed content of the section
*/

/**
* @typedef {Object} ParsedArticleResult Used by the hook WAParseArticle. It contains primary data which could be altered by additional modules
* @property {string} html What will become the journal entry content. Is in html format
Expand Down Expand Up @@ -215,7 +223,7 @@ export function getArticleContent(article) {
const includeSidebars = sectionEntries.some(s => {
const [id, section] = s;
if ( id !== DISPLAY_SIDEBAR_SECTION_ID ) return false;
return section.content_parsed === "1"
return section.contentParsed === "1"
});

// Determine whether there are secrets inside this article
Expand Down Expand Up @@ -252,13 +260,13 @@ export function getArticleContent(article) {
const isLongContent = section.content.length > 100;
if( isLongContent ) {
sections += `<h2>${title}</h2>`;
sections += `\n<p>${section.content_parsed}</p><hr/>`;
sections += `\n<p>${section.contentParsed}</p><hr/>`;
}

// Display short-format content as a details list
else {
sections += `<dl><dt>${title}</dt>`;
sections += `<dd>${section.content_parsed}</dd></dl>`;
sections += `<dd>${section.contentParsed}</dd></dl>`;
}

// End main section div
Expand All @@ -281,7 +289,7 @@ export function getArticleContent(article) {

// Combine content sections
let content = `<section class="${ARTICLE_CSS_CLASSES.ALL_PARTS} ${ARTICLE_CSS_CLASSES.MAIN_CONTENT}">`;
content += `<p>${article.content_parsed}</p>`;
content += `<p>${article.contentParsed}</p>`;
content += "</section><hr/>";
content += aside;
content += sections;
Expand Down
16 changes: 8 additions & 8 deletions module/journal.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,8 @@ export default class WorldAnvilBrowser extends Application {

// Check linked entry permissions
article.entry = entries.find(e => e.getFlag("world-anvil", "articleId") === article.id);
article.visibleByPlayers = article.entry?.data.permission.default >= CONST.ENTITY_PERMISSIONS.OBSERVER;
article.visibleByPlayers = article.entry?.data.permission.default >= CONST.DOCUMENT_PERMISSION_LEVELS.OBSERVER;

// Get the category to which the article belongs
const category = categories.get(article.category?.id) || uncategorized;
category.articles.push(article);
Expand Down Expand Up @@ -243,11 +243,11 @@ export default class WorldAnvilBrowser extends Application {
const category = this.categories.get(categoryId);
const articles = category?.articles ?? [];
const updates = articles.filter( a => {
return !a.entry?.data.permission.default < CONST.ENTITY_PERMISSIONS.OBSERVER;
return !a.entry?.data.permission.default < CONST.DOCUMENT_PERMISSION_LEVELS.OBSERVER;
}).map( a => {
return {
_id: a.entry.id,
permission: { default: CONST.ENTITY_PERMISSIONS.OBSERVER }
permission: { default: CONST.DOCUMENT_PERMISSION_LEVELS.OBSERVER }
}
});

Expand All @@ -267,11 +267,11 @@ export default class WorldAnvilBrowser extends Application {
const category = this.categories.get(categoryId);
const articles = category?.articles ?? [];
const updates = articles.filter( a => {
return a.entry?.data.permission.default >= CONST.ENTITY_PERMISSIONS.OBSERVER;
return a.entry?.data.permission.default >= CONST.DOCUMENT_PERMISSION_LEVELS.OBSERVER;
}).map( a => {
return {
_id: a.entry.id,
permission: { default: CONST.ENTITY_PERMISSIONS.NONE }
permission: { default: CONST.DOCUMENT_PERMISSION_LEVELS.NONE }
}
});

Expand All @@ -292,7 +292,7 @@ export default class WorldAnvilBrowser extends Application {
if( !entry ) { throw 'Can\'t find journal entry with id : ' + entryId; }

const perms = {
default: CONST.ENTITY_PERMISSIONS.OBSERVER
default: CONST.DOCUMENT_PERMISSION_LEVELS.OBSERVER
};

await entry.update({permission: perms}, {diff: false, recursive: false, noHook: true});
Expand All @@ -310,7 +310,7 @@ export default class WorldAnvilBrowser extends Application {
if( !entry ) { throw 'Can\'t find journal entry with id : ' + entryId; }

const perms = {
default: CONST.ENTITY_PERMISSIONS.NONE
default: CONST.DOCUMENT_PERMISSION_LEVELS.NONE
};

await entry.update({permission: perms}, {diff: false, recursive: false, noHook: true});
Expand Down

0 comments on commit e9fe7ed

Please sign in to comment.