From b6f5452a4906773892fbd3fb15fa36998d91e138 Mon Sep 17 00:00:00 2001 From: lakejason0 Date: Mon, 20 Sep 2021 10:42:34 +0800 Subject: [PATCH 01/12] Init search vue Rebased from commit f700cb73379856158dea06fac0ac0ac4e3fc07a7 Bug: #21 Change-Id: I918fd0f74044bea2344acd219f92115f4a377ce9 --- resources/skins.lakeus.search/App.vue | 111 ++++++++++++++++++ .../skins.lakeus.search.js | 48 ++++++++ skin.json | 9 +- 3 files changed, 167 insertions(+), 1 deletion(-) create mode 100644 resources/skins.lakeus.search/App.vue create mode 100644 resources/skins.lakeus.search/skins.lakeus.search.js diff --git a/resources/skins.lakeus.search/App.vue b/resources/skins.lakeus.search/App.vue new file mode 100644 index 0000000..dfe8536 --- /dev/null +++ b/resources/skins.lakeus.search/App.vue @@ -0,0 +1,111 @@ + + + \ No newline at end of file diff --git a/resources/skins.lakeus.search/skins.lakeus.search.js b/resources/skins.lakeus.search/skins.lakeus.search.js new file mode 100644 index 0000000..7054a77 --- /dev/null +++ b/resources/skins.lakeus.search/skins.lakeus.search.js @@ -0,0 +1,48 @@ +/** @module search */ +var Vue = require("vue").default || require("vue"), + App = require("./App.vue"), + config = require("./config.json"); +/** + * @param {HTMLElement} searchForm + * @param {HTMLInputElement} search + * @return {void} + */ +function initApp(searchForm, search) { + // eslint-disable-next-line no-new + new Vue({ + el: searchForm, + /** + * + * @param {Function} createElement + * @return {Vue.VNode} + */ + render: function (createElement) { + return createElement(App, { + props: $.extend( + { + autofocusInput: search === document.activeElement, + action: searchForm.getAttribute("action"), + searchAccessKey: search.getAttribute("accessKey"), + searchTitle: search.getAttribute("title"), + searchPlaceholder: search.getAttribute("placeholder"), + searchQuery: search.value, + }, + // Pass additional config from server. + config + ), + }); + }, + }); +} +/** + * @param {Document} document + * @return {void} + */ +function main(document) { + var searchForm = /** @type {HTMLElement} */ (document.querySelector("#searchform")), + search = /** @type {HTMLInputElement|null} */ (document.getElementById("searchInput")); + if (search && searchForm) { + initApp(searchForm, search); + } +} +main(document); \ No newline at end of file diff --git a/skin.json b/skin.json index 28229de..73d2624 100644 --- a/skin.json +++ b/skin.json @@ -240,7 +240,8 @@ ], "scripts": [ "skins.lakeus", - "skins.lakeus.designer" + "skins.lakeus.designer", + "skins.lakeus.search" ], "messages": [ "sitetitle", @@ -265,6 +266,12 @@ "value": true, "description": "Whether to show the link to the repository or not." }, + "LakeusWvuiSearchOptions": { + "value": { + "showThumbnail": true, + "showDescription": true + } + }, "LakeusSiteNoticeHasBorder": { "value": false, "description": "Whether to add a border to site notice. Useful for plain text notices." From 0edff6758d4a29276a7d1578ee04e97e1a1ed91e Mon Sep 17 00:00:00 2001 From: lakejason0 Date: Mon, 20 Sep 2021 10:51:50 +0800 Subject: [PATCH 02/12] Fix searchForm querySelector id Rebased from commit "Update" 2dd78d6aca20a0f9e57dd94a30e817c0c529dfa3 Bug: #21 Change-Id: I1f382480b725ec6f0911ae24b3b78eea94899be7 --- resources/skins.lakeus.search/skins.lakeus.search.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/skins.lakeus.search/skins.lakeus.search.js b/resources/skins.lakeus.search/skins.lakeus.search.js index 7054a77..baf0281 100644 --- a/resources/skins.lakeus.search/skins.lakeus.search.js +++ b/resources/skins.lakeus.search/skins.lakeus.search.js @@ -39,7 +39,7 @@ function initApp(searchForm, search) { * @return {void} */ function main(document) { - var searchForm = /** @type {HTMLElement} */ (document.querySelector("#searchform")), + var searchForm = /** @type {HTMLElement} */ (document.querySelector("#p-search")), search = /** @type {HTMLInputElement|null} */ (document.getElementById("searchInput")); if (search && searchForm) { initApp(searchForm, search); From 78a79b80e0d1fa851f6a31ccf9e0509067a20379 Mon Sep 17 00:00:00 2001 From: lakejason0 Date: Mon, 20 Sep 2021 11:13:32 +0800 Subject: [PATCH 03/12] Add modules to skin.json and hook for search vue Rebased from commit "Update" b82e2a48a699c6612b11c183cfb6376323a3c6bb Bug: #21 Change-Id: Icac717f530a63e11b0e5ab20892b499abc5d1251 --- includes/Hooks.php | 16 ++++++++++++++++ resources/skins.lakeus.search/App.vue | 2 +- skin.json | 20 ++++++++++++++++++++ 3 files changed, 37 insertions(+), 1 deletion(-) diff --git a/includes/Hooks.php b/includes/Hooks.php index 34a8b82..bced8f3 100644 --- a/includes/Hooks.php +++ b/includes/Hooks.php @@ -2,9 +2,25 @@ namespace MediaWiki\Skins\Lakeus; +use Config; +# use MediaWiki\Config\Config; // Namespaced in 1.41.0 use MediaWiki\Preferences\Hook\GetPreferencesHook; +# use MediaWiki\ResourceLoader\Context; // Namespaced in 1.39.0 +use ResourceLoaderContext; class Hooks implements GetPreferencesHook { + /** + * @param ResourceLoaderContext $context + * @param Config $config + * @return $wgLakeusWvuiSearchOptions + */ + public function getSnapwikiskinWvuiSearchResourceLoaderConfig( + ResourceLoaderContext $context, + Config $config + ) { + return $config->get( 'LakeusWvuiSearchOptions' ); + } + /** * @see https://www.mediawiki.org/wiki/Special:MyLanguage/Manual:Hooks/GetPreferences * @param User $user diff --git a/resources/skins.lakeus.search/App.vue b/resources/skins.lakeus.search/App.vue index dfe8536..211416a 100644 --- a/resources/skins.lakeus.search/App.vue +++ b/resources/skins.lakeus.search/App.vue @@ -1,6 +1,6 @@