feat: Custom External Tools

Fix #220
This commit is contained in:
ShareVB committed 2025-12-07 21:04:22 +01:00
1 parent 6e525b92c7
commit 801e3d52d1
8 files changed
+120 -2

No files matched your search

+27
View File
@@ -102,6 +102,33 @@ Category matches on category (English) names ; Tools matches on tools path/url.
See (docker-tools-filter-and-home-content)[https://github.com/sharevb/it-tools]
## Add custom external tools
You can add custom external tools (href or markdownContent) by mounting a `external-tools.json` in `/usr/share/nginx/html` with the following structure:
```json
[
{
"name": "GitHub",
"path": "/github",
"description": "Link to Github",
"keywords": ["github"],
"category": "Links",
"href": "https://github.com"
},
{
"name": "Some text",
"path": "/some-text",
"description": "Some description",
"keywords": ["some"],
"category": "Links",
"markdownContent": "Some useful **text**\n\nin *markdown*"
}
]
```
See (docker-tools-filter-and-home-content)[https://github.com/sharevb/it-tools]
## Setting default tools parameters / default UI language at runtime
You can set default tool parameters by mounting a `tools-setting.json` in `/usr/share/nginx/html`.
@@ -5,6 +5,7 @@ services:
restart: unless-stopped
volumes:
- ./tools-filter.json:/usr/share/nginx/html/tools-filter.json
- ./external-tools.json:/usr/share/nginx/html/external-tools.json
- ./home.custom.md:/usr/share/nginx/html/home.custom.md
ports:
- 8080:8080
@@ -0,0 +1,18 @@
[
{
"name": "GitHub",
"path": "/github",
"description": "Link to Github",
"keywords": ["github"],
"category": "Links",
"href": "https://github.com"
},
{
"name": "Some text",
"path": "/some-text",
"description": "Some description",
"keywords": ["some"],
"category": "Links",
"markdownContent": "Some useful **text**\n\nin *markdown*"
}
]
+1
View File
@@ -7147,3 +7147,4 @@ tools:
input-placeholder-paste-your-raw-json-here: Paste your raw JSON here...
input-label-your-raw-json: 'Your raw JSON:'
output-label-toon-version-of-your-json: 'TOON version of your JSON:'
external-link-goto: 'To open this tool, follow this link: '
+1
View File
@@ -0,0 +1 @@
[]
+29
View File
@@ -5,6 +5,7 @@ import type { HeadObject } from '@vueuse/head';
import VueMarkdown from 'vue-markdown-render';
import { useThemeVars } from 'naive-ui';
import { useTheme } from '../ui/c-link/c-link.theme';
import BaseLayout from './base.layout.vue';
import FavoriteButton from '@/components/FavoriteButton.vue';
import type { Tool } from '@/tools/tools.types';
@@ -71,6 +72,8 @@ const toolFooter = computed<string>(() => {
return ((npmPackages.length > 0 ? t('tools.tool.layout.text.made-with-npmpackages-join-n', [npmPackages.join(', ')]) : '') + footer).trim();
});
const themeVars = useThemeVars();
const linkTheme = useTheme();
</script>
<template>
@@ -166,4 +169,30 @@ const themeVars = useThemeVars();
font-style: italic;
}
}
::v-deep(.external-tool) a {
line-height: inherit;
font-family: inherit;
font-size: inherit;
border: none;
cursor: pointer;
text-decoration: none;
font-weight: 400;
color: v-bind('linkTheme.default.textColor');
border-radius: 4px;
transition: color cubic-bezier(0.4, 0, 0.2, 1) 0.3s;
outline-offset: 1px;
&:hover {
color: v-bind('linkTheme.default.hover.textColor');
}
&:active {
color: v-bind('linkTheme.default.textColor');
}
&:focus {
color: v-bind('linkTheme.default.outline.color');
}
}
</style>
+29 -2
View File
@@ -1,4 +1,7 @@
import type { ToolCategory, ToolWithCategory, ToolsFilter } from './tools.types';
import markdownit from 'markdown-it';
import { IconExternalLink } from '@tabler/icons-vue';
import type { ExternalTool, ToolCategory, ToolWithCategory, ToolsFilter } from './tools.types';
import { translate as t } from '@/plugins/i18n.plugin';
const modules = import.meta.glob<true, string, ToolWithCategory>('./*/index.ts', { eager: true, import: 'tool' });
@@ -12,6 +15,30 @@ try {
}
catch {}
let allModules: ToolWithCategory[] = Object.values(modules);
try {
const remoteConfigResponse = await fetch(`${base}external-tools.json`);
if (remoteConfigResponse.ok) {
allModules = [
...allModules,
...((await remoteConfigResponse.json()) as ExternalTool[])
.map(externalTool => ({
icon: IconExternalLink,
...externalTool,
component: () => new Promise((resolve) => {
const html = markdownit().render(externalTool.markdownContent
|| (externalTool.href
? `${t('tools.external-link-goto')}[${externalTool.href}](${externalTool.href})`
: ''));
resolve({
template: `<div class="external-tool">${html}</div>`,
});
}),
} as ToolWithCategory))];
}
}
catch {}
const makeRegExp = (regex: string | undefined) => regex ? new RegExp(regex, 'i') : null;
const filters = {
excludeCategoryFilterRegex: makeRegExp(filterConfig.excludeCategoryFilterRegex),
@@ -20,7 +47,7 @@ const filters = {
includeToolsFilterRegex: makeRegExp(filterConfig.includeToolsFilterRegex),
};
const filteredModules = Object.values(modules).filter((tool) => {
const filteredModules = allModules.filter((tool) => {
const category = tool.category || 'Development';
if (filters.includeToolsFilterRegex?.test(tool.path)) {
return true;
+14
View File
@@ -15,6 +15,20 @@ export interface Tool {
category: string
}
export interface ExternalTool {
name: string
path: string
description?: string
keywords?: string[]
icon?: Component
redirectFrom?: string[]
isNew: boolean
createdAt?: Date
category: string
markdownContent?: string
href?: string
}
export interface ToolCategory {
name: string
components: Tool[]