mirror of
https://github.com/dbgate/dbgate
synced 2024-11-07 20:26:23 +00:00
handle plugin icon
This commit is contained in:
parent
5ea6c56752
commit
9f5013c6da
@ -1,7 +1,7 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import openNewTab from '../utility/openNewTab';
|
import openNewTab from '../utility/openNewTab';
|
||||||
|
|
||||||
import { extractPluginAuthor, extractPluginIcon } from './manifestExtractors';
|
import { extractPluginAuthor, extractPluginDescription, extractPluginIcon } from './manifestExtractors';
|
||||||
|
|
||||||
export let plugins: any[];
|
export let plugins: any[];
|
||||||
|
|
||||||
@ -30,7 +30,7 @@
|
|||||||
{/if}
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
{(packageManifest.description?.indexOf('[![') >= 0 ? null : packageManifest.description) || '(No description)'}
|
{extractPluginDescription(packageManifest)}
|
||||||
</div>
|
</div>
|
||||||
<div class="bold">
|
<div class="bold">
|
||||||
{extractPluginAuthor(packageManifest)}
|
{extractPluginAuthor(packageManifest)}
|
||||||
|
@ -6,17 +6,24 @@ export function extractPluginIcon(packageManifest) {
|
|||||||
const homepage = (links && links.homepage) || packageManifest.homepage;
|
const homepage = (links && links.homepage) || packageManifest.homepage;
|
||||||
const tested = repository || homepage || packageManifest.homepage;
|
const tested = repository || homepage || packageManifest.homepage;
|
||||||
|
|
||||||
|
if (packageManifest.description) {
|
||||||
|
const iconLink = packageManifest.description.match(/\!\[icon\]\(([^)]+)\)/, '');
|
||||||
|
if (iconLink) {
|
||||||
|
return iconLink[1];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (tested == 'https://dbgate.org' || tested == 'https://github.com/dbgate/dbgate') {
|
if (tested == 'https://dbgate.org' || tested == 'https://github.com/dbgate/dbgate') {
|
||||||
// monorepo plugin
|
// monorepo plugin
|
||||||
return `https://github.com/dbgate/dbgate/raw/master/plugins/${packageManifest.name}/icon.svg`;
|
return `https://github.com/dbgate/dbgate/raw/master/plugins/${packageManifest.name}/icon.svg`;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tested) {
|
// if (tested) {
|
||||||
const match = tested.match(/https:\/\/github.com\/([^/]*)\/([^/]*)/);
|
// const match = tested.match(/https:\/\/github.com\/([^/]*)\/([^/]*)/);
|
||||||
if (match) {
|
// if (match) {
|
||||||
return `https://raw.githubusercontent.com/${match[1]}/${match[2]}/master/icon.svg`;
|
// return `https://raw.githubusercontent.com/${match[1]}/${match[2]}/master/icon.svg`;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
return 'unknown.svg';
|
return 'unknown.svg';
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -39,3 +46,11 @@ export function extractPluginAuthor(packageManifest) {
|
|||||||
}
|
}
|
||||||
return '(Unknown author)';
|
return '(Unknown author)';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function extractPluginDescription(packageManifest) {
|
||||||
|
if (!packageManifest.description || packageManifest.description?.indexOf('[![') >= 0) {
|
||||||
|
return '(No description)';
|
||||||
|
}
|
||||||
|
|
||||||
|
return packageManifest.description.replace(/\!\[icon\]\([^)]+\)/, '').trim();
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user