Skip to content

Commit

Permalink
repeatTitle & linkOnHeader conf removed
Browse files Browse the repository at this point in the history
  • Loading branch information
adrien-schiehle committed Sep 23, 2021
1 parent 3f02dd0 commit 34b7649
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 42 deletions.
6 changes: 0 additions & 6 deletions lang/en.json
Expand Up @@ -4,12 +4,6 @@
"WA.ConfigureLabel": "World Anvil Integration",
"WA.ConfigureHint": "Configure your World Anvil integration.",

"WA.RepeatTitleLabel": "Title inside journal entries",
"WA.RepeatTitleHint": "By unchecking this, title won't be repeated on top of each journal entry. Only the link to world anvil article will remain.",

"WA.LinkOnHeaderLabel": "WA link on header",
"WA.LinkOnHeaderHint": "By checking this, the link to the WA webpage will be displayed on header and removed from the article content.",

"WA.PublicArticleLinksLabel": "WA link for everyone",
"WA.PublicArticleLinksHint": "Allow to choose if the WA link on header should be displayed to everyone or only to GMs.",

Expand Down
18 changes: 0 additions & 18 deletions module/config.js
Expand Up @@ -97,24 +97,6 @@ export default class WorldAnvilConfig extends FormApplication {
}
});

game.settings.register("world-anvil", "repeatTitle", {
name: "WA.RepeatTitleLabel",
hint: "WA.RepeatTitleHint",
scope: "world",
type: Boolean,
default: true,
config: true
});

game.settings.register("world-anvil", "linkOnHeader", {
name: "WA.LinkOnHeaderLabel",
hint: "WA.LinkOnHeaderHint",
scope: "world",
type: Boolean,
default: false,
config: true
});

game.settings.register("world-anvil", "publicArticleLinks", {
name: "WA.PublicArticleLinksLabel",
hint: "WA.PublicArticleLinksHint",
Expand Down
24 changes: 8 additions & 16 deletions module/framework.js
Expand Up @@ -78,13 +78,9 @@ function _localizedTitle( sectionId, section ) {
* @private
*/
function _getArticleContent(article) {
let body = "";
let aside = "";

const repeatTitle = game.settings.get("world-anvil", "repeatTitle");
const linkOnHeader = game.settings.get("world-anvil", "linkOnHeader");

// Article sections
let sections = "";
if ( article.sections ) {

const sectionsEntries = Object.entries(article.sections) ;
Expand All @@ -103,22 +99,20 @@ function _getArticleContent(article) {
const title = _localizedTitle(id, section);

// Determine whether the section is body vs. aside (if short)
let contentToAdd = '';
const isLongContent = (section.content.length > 100);
if( isLongContent ) { // Another prior condition will come here later. That's why a rewrote it
contentToAdd += `<h2>${title}</h2>`;
contentToAdd += `\n<p>${section.content_parsed}</p><hr/>`;
sections += `<h2>${title}</h2>`;
sections += `\n<p>${section.content_parsed}</p><hr/>`;

} else {
contentToAdd += `<dt>${title}</dt>`;
contentToAdd += `<dd>${section.content_parsed}</dd>`;
sections += `<dt>${title}</dt>`;
sections += `<dd>${section.content_parsed}</dd>`;
}

body += contentToAdd;
});
}

// Article relations
let aside = "";
if ( article.relations ) {
for ( let [id, section] of Object.entries(article.relations) ) {

Expand All @@ -132,11 +126,9 @@ function _getArticleContent(article) {
}

// Combine content sections
let content = repeatTitle ? `<h1>${article.title}</h1>\n` : '';
content += linkOnHeader ? '' : `<p><a href="${article.url}" title="${article.title} ${game.i18n.localize("WA.OnWA")}" target="_blank">${article.url}</a></p>\n`;
content += `<p>${article.content_parsed}</p><hr/>`;
let content = `<p>${article.content_parsed}</p><hr/>`;
if ( aside ) content += `<aside><dl>${aside}</dl></aside>`;
if ( body ) content += body;
if ( sections ) content += sections;

// Disable image source attributes so that they do not begin loading immediately
content = content.replace(/src=/g, "data-src=");
Expand Down
3 changes: 1 addition & 2 deletions wa.js
Expand Up @@ -95,10 +95,9 @@ Hooks.on("renderJournalSheet", (app, html, data) => {
}

// Add WA shortcut on header
const linkOnHeader = game.settings.get("world-anvil", "linkOnHeader");
const publicArticleLink = game.settings.get("world-anvil", "publicArticleLinks");
const articleURL = entry.getFlag("world-anvil", "articleURL");
if(articleURL && linkOnHeader) {
if(articleURL) {
if( game.user.isGM || publicArticleLink ) {
const link = $(`<a id="wa-external-link" href="${articleURL}"><i class="fas fa-external-link-alt"></i>${game.i18n.localize("WA.OnWA")}</a>`);
title.after(link);
Expand Down

0 comments on commit 34b7649

Please sign in to comment.