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