Skip to content

Commit

Permalink
fix: fix assets to link to the correct URL
Browse files Browse the repository at this point in the history
  • Loading branch information
eXaminator committed Jul 25, 2022
1 parent d250b75 commit 3748855
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 23 deletions.
4 changes: 4 additions & 0 deletions src/KankaJournal/KankaJournalApplication.scss
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
user-select: text;
}

img {
cursor: pointer;
}

.write-action {
display: none;
}
Expand Down
21 changes: 13 additions & 8 deletions src/KankaJournal/KankaJournalApplication.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,19 @@ export default function registerSheet(kanka: KankaFoundry): void {
super.activateListeners(html);
if (!this.isKankaEntry) return;

// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
if (game.version?.startsWith('9.')) {
// This is a fallback for Foundry V9. Sicne V10 this seems to be the deault
html.on('click', 'img', (event) => {
const target = event.currentTarget;
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
const ip = new ImagePopout(target.src, { title: target.title, shareable: true });
ip.render(true);
});
}

html.on('click', '[data-action]', async (event) => {
const { action } = event.currentTarget?.dataset ?? {};

Expand All @@ -103,14 +116,6 @@ export default function registerSheet(kanka: KankaFoundry): void {
await kanka.journals.write(campaign, [{ child_id: snapshot.id, type }]);
this.rerender();
}

if (action === 'show-image') {
const target = event.currentTarget;
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
const ip = new ImagePopout(target.src, { title: target.title, shareable: true });
ip.render(true);
}
});
}

Expand Down
2 changes: 1 addition & 1 deletion src/KankaJournal/shared/baseLayout.partial.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
<div class="image-column">
{{~#if kankaEntity.image_full ~}}
{{~#if settings.imageInText~}}
<input type="image" src="{{kankaEntity.image_full}}" alt="{{name}}" data-action="show-image">
<img src="{{kankaEntity.image_full}}" alt="{{name}}" />
{{~/if~}}
{{~/if~}}

Expand Down
2 changes: 1 addition & 1 deletion src/KankaJournal/shared/tabs/attributes.partial.hbs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{{#if image}}
{{#if settings.imageInText}}
<div class="image-column">
<input type="image" src="{{image}}" alt="{{name}}" data-action="show-image">
<img src="{{image}}" alt="{{name}}" />
</div>
{{/if}}
{{/if}}
Expand Down
31 changes: 19 additions & 12 deletions src/KankaJournal/shared/tabs/files.partial.hbs
Original file line number Diff line number Diff line change
@@ -1,19 +1,26 @@
<div class="kanka-gallery">
{{#each (kankaFilterAccessible entity.entity_assets)}}
{{#if (kankaEq this.type_id 1)}}
<!-- File -->
<a href="{{ this.metadata.path }}" target="_blank"{{#if (kankaIsSecret this) }} class="-secret"{{/if}}>
{{#if (kankaEq this.metadata.type 'regex:^image/.*') }}
<img src="{{this.metadata.path}}" alt="{{this.name}}" />
{{else}}
<!-- File -->
{{#if (kankaEq this.metadata.type 'regex:^image/.*') }}
<div class="interactive{{#if (kankaIsSecret this) }} -secret{{/if}}">
<img src="{{this._url}}" alt="{{this.name}}" />
<strong>
{{#if (kankaIsSecret this) }}<i class="fas fa-lock fw"></i>{{/if}}
{{ this.name }}
</strong>
<small>{{ kankaFileSize this.metadata.size }}</small>
</div>
{{else}}
<a href="{{this._url}}" target="_blank"{{#if (kankaIsSecret this) }} class="-secret"{{/if}}>
{{ kankaFileIcon this.metadata.type }}
{{/if}}
<strong>
{{#if (kankaIsSecret this) }}<i class="fas fa-lock fw"></i>{{/if}}
{{ this.name }}
</strong>
<small>{{ kankaFileSize this.metadata.size }}</small>
</a>
<strong>
{{#if (kankaIsSecret this) }}<i class="fas fa-lock fw"></i>{{/if}}
{{ this.name }}
</strong>
<small>{{ kankaFileSize this.metadata.size }}</small>
</a>
{{/if}}
{{else if (kankaEq this.type_id 2)}}
<!-- Link -->
<a href="{{ this.metadata.url }}" target="_blank"{{#if (kankaIsSecret this) }} class="-secret"{{/if}}>
Expand Down
2 changes: 1 addition & 1 deletion src/index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -489,7 +489,7 @@ ul.kanka-cards {
}
}

a:hover {
a:hover, .interactive:hover {
> img,
> i {
box-shadow: 0 0 1rem 0 #00000099;
Expand Down
1 change: 1 addition & 0 deletions src/types/kanka.ts
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,7 @@ export interface KankaApiEntityAssetAlias extends KankaApiEntityBaseAsset {

export interface KankaApiEntityAssetFile extends KankaApiEntityBaseAsset {
type_id: KankaApiAssetType.file;
_url: string;
metadata: {
path: string;
size: number;
Expand Down

0 comments on commit 3748855

Please sign in to comment.