mirror of
https://iceshrimp.dev/limepotato/jormungandr-bite.git
synced 2024-11-21 17:37:29 -07:00
Make MFM search engine a config option, switch default engine to DuckDuckGo, replaces #207
This commit is contained in:
parent
1ce0f778e7
commit
b97c4511d9
12 changed files with 27 additions and 7 deletions
|
@ -204,6 +204,9 @@ reservedUsernames: [
|
|||
# notFound: '/twemoji/2049.svg'
|
||||
# error: '/twemoji/1f480.svg'
|
||||
|
||||
# Search engine (MFM)
|
||||
#searchEngine: 'https://duckduckgo.com/?q='
|
||||
|
||||
#allowedPrivateNetworks: [
|
||||
# '127.0.0.1/32'
|
||||
#]
|
||||
|
|
|
@ -203,6 +203,9 @@ reservedUsernames: [
|
|||
# notFound: '/twemoji/2049.svg'
|
||||
# error: '/twemoji/1f480.svg'
|
||||
|
||||
# Search engine (MFM)
|
||||
#searchEngine: 'https://duckduckgo.com/?q='
|
||||
|
||||
#allowedPrivateNetworks: [
|
||||
# '127.0.0.1/32'
|
||||
#]
|
||||
|
|
|
@ -49,6 +49,8 @@ export default function load() {
|
|||
error: '/twemoji/1f480.svg',
|
||||
};
|
||||
|
||||
config.searchEngine = config.searchEngine ?? 'https://duckduckgo.com/?q=';
|
||||
|
||||
mixin.version = meta.version;
|
||||
mixin.host = url.host;
|
||||
mixin.hostname = url.hostname;
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
export const engine = "https://www.google.com/search?q="
|
|
@ -72,6 +72,8 @@ export type Source = {
|
|||
info?: string;
|
||||
};
|
||||
|
||||
searchEngine?: string;
|
||||
|
||||
proxy?: string;
|
||||
proxySmtp?: string;
|
||||
proxyBypassHosts?: string[];
|
||||
|
|
|
@ -3,7 +3,6 @@ import type * as mfm from "mfm-js";
|
|||
import config from "@/config/index.js";
|
||||
import { intersperse } from "@/prelude/array.js";
|
||||
import type { IMentionedRemoteUsers } from "@/models/entities/note.js";
|
||||
import { engine } from "@/config/sane-defaults.js";
|
||||
|
||||
export function toHtml(
|
||||
nodes: mfm.MfmNode[] | null,
|
||||
|
@ -157,7 +156,7 @@ export function toHtml(
|
|||
|
||||
search(node) {
|
||||
const a = doc.createElement("a");
|
||||
a.href = `${engine}{node.props.query}`;
|
||||
a.href = `${config.searchEngine}${node.props.query}`;
|
||||
a.textContent = node.props.content;
|
||||
return a;
|
||||
},
|
||||
|
|
|
@ -190,6 +190,11 @@ export const meta = {
|
|||
optional: false,
|
||||
nullable: false,
|
||||
},
|
||||
searchEngine: {
|
||||
type: "string",
|
||||
optional: false,
|
||||
nullable: false,
|
||||
},
|
||||
emojis: {
|
||||
type: "array",
|
||||
optional: false,
|
||||
|
@ -449,6 +454,7 @@ export default define(meta, paramDef, async (ps, me) => {
|
|||
logoImageUrl: instance.logoImageUrl,
|
||||
maxNoteTextLength: MAX_NOTE_TEXT_LENGTH, // 後方互換性のため
|
||||
maxCaptionTextLength: MAX_CAPTION_TEXT_LENGTH,
|
||||
searchEngine: config.searchEngine,
|
||||
emojis: instance.privateMode && !me ? [] : await Emojis.packMany(emojis),
|
||||
// クライアントの手間を減らすためあらかじめJSONに変換しておく
|
||||
defaultLightTheme: instance.defaultLightTheme
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
<script lang="ts" setup>
|
||||
import { ref } from "vue";
|
||||
import { i18n } from "@/i18n";
|
||||
import {engine} from "../../../../sane-defaults"
|
||||
import { searchEngine } from "@/config"
|
||||
|
||||
const props = defineProps<{
|
||||
q: string;
|
||||
|
@ -21,7 +21,7 @@ const query = ref(props.q);
|
|||
|
||||
const search = () => {
|
||||
window.open(
|
||||
`${engine}${query.value}`,
|
||||
`${searchEngine}${query.value}`,
|
||||
"_blank",
|
||||
);
|
||||
};
|
||||
|
|
|
@ -7,6 +7,10 @@ export function setHost(newHost: string): void {
|
|||
host = newHost;
|
||||
}
|
||||
|
||||
export function setSearchEngine(engine: string): void {
|
||||
searchEngine = engine;
|
||||
}
|
||||
|
||||
export let host = address.host;
|
||||
export const hostname = address.hostname;
|
||||
export const url = address.origin;
|
||||
|
@ -19,5 +23,6 @@ export const langs = _LANGS_;
|
|||
export const locale = JSON.parse(localStorage.getItem("locale"));
|
||||
export const version = _VERSION_;
|
||||
export const instanceName = siteName === "Iceshrimp" ? host : siteName;
|
||||
export let searchEngine = 'https://duckduckgo.com/?q=';
|
||||
export const ui = localStorage.getItem("ui");
|
||||
export const debug = localStorage.getItem("debug") === "true";
|
||||
|
|
|
@ -32,7 +32,7 @@ import { compareVersions } from "compare-versions";
|
|||
import widgets from "@/widgets";
|
||||
import directives from "@/directives";
|
||||
import components from "@/components";
|
||||
import { version, ui, lang, setHost } from "@/config";
|
||||
import { version, ui, lang, setHost, setSearchEngine } from "@/config";
|
||||
import { applyTheme } from "@/scripts/theme";
|
||||
import { isDeviceDarkmode } from "@/scripts/is-device-darkmode";
|
||||
import { i18n } from "@/i18n";
|
||||
|
@ -181,6 +181,7 @@ function checkForSplash() {
|
|||
fetchInstanceMetaPromise.then(() => {
|
||||
localStorage.setItem("v", instance.version);
|
||||
setHost(instance.domain);
|
||||
setSearchEngine(instance.searchEngine);
|
||||
|
||||
// Init service worker
|
||||
initializeSw();
|
||||
|
|
|
@ -300,6 +300,7 @@ export type LiteInstanceMetadata = {
|
|||
enableGithubIntegration: boolean;
|
||||
enableDiscordIntegration: boolean;
|
||||
enableServiceWorker: boolean;
|
||||
searchEngine: string;
|
||||
emojis: CustomEmoji[];
|
||||
images: {
|
||||
error: string;
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
export const engine = "https://www.google.com/search?q="
|
Loading…
Reference in a new issue