Support OpenSearch protocol

This commit is contained in:
itepechi 2023-10-23 04:23:48 +09:00
parent e1dcfaa415
commit c85bdb5e54
1 changed files with 11 additions and 0 deletions

View File

@ -283,6 +283,7 @@ const getNodeInfo = async ({ store }) => {
store.dispatch('setInstanceOption', { name: 'translationEnabled', value: features.includes('akkoma:machine_translation') })
store.dispatch('setInstanceOption', { name: 'searchTypeMediaEnabled', value: features.includes('bnakkoma:search_type_media') })
store.dispatch('setInstanceOption', { name: 'searchOptionFollowingEnabled', value: features.includes('bnakkoma:search_option_following') })
store.dispatch('setInstanceOption', { name: 'opensearchProtocolSupported', value: features.includes('bnakkoma:opensearch_protocol') })
const uploadLimits = metadata.uploadLimits
store.dispatch('setInstanceOption', { name: 'uploadlimit', value: parseInt(uploadLimits.general) })
@ -406,6 +407,16 @@ const afterStoreSetup = async ({ store, i18n }) => {
getTOS({ store })
getStickers({ store })
// Create a link tag for OpenSearch and forget about it
if (store.state.instance.opensearchProtocolSupported) {
const node = document.createElement('link')
node.setAttribute('rel', 'search')
node.setAttribute('type', 'application/opensearchdescription+xml')
node.setAttribute('href', '/opensearch.xml')
node.setAttribute('title', store.state.instance.name)
document.head.appendChild(node)
}
const router = createRouter({
history: createWebHistory(),
routes: routes(store),