Jump to content

Extension:GoogleSiteSearch

From mediawiki.org
This page is a translated version of the page Extension:GoogleSiteSearch and the translation is 53% complete.
MediaWiki 拡張機能マニュアル
GoogleSiteSearch
リリースの状態: 安定
実装 検索
説明 Prepends to, or replaces, Special:Search results with Google CSE results
作者 Ryan Finnie (Fo0barトーク)
メンテナー Sophivorus
最新バージョン 3.1 (2022-09-23)
MediaWiki 1.32+
PHP 7.0+
ライセンス GNU 一般公衆利用許諾書 2.0 以降
ダウンロード
appropedia.org search result
  • $wgGoogleSiteSearchAppend
  • $wgGoogleSiteSearchOnly
  • $wgGoogleSiteSearchCSEID
  • $wgGoogleSiteSearchAttributes
translatewiki.net で翻訳を利用できる場合は、GoogleSiteSearch 拡張機能の翻訳にご協力ください

The GoogleSiteSearch extension allows you to prepend Google Custom Search Engine (CSE) results to "Special:Search" additionally to MediaWiki search results, or optionally, replace them altogether.

インストール

  • Go to the Google CSE management page and add a custom search engine. Note down the "Search engine unique ID". It should be in the format numbers:letters.
  • ダウンロードして、ファイルをextensions/フォルダー内のGoogleSiteSearchという名前のディレクトリ内に配置します。
    開発者とコード寄稿者は、上記の代わりに以下を使用してGitからインストールします:
    cd extensions/
    git clone https://gerrit.wikimedia.org/r/mediawiki/extensions/GoogleSiteSearch
    
  • 以下のコードを LocalSettings.php ファイルの末尾に追加します:
    wfLoadExtension( 'GoogleSiteSearch' );
    $wgGoogleSiteSearchCSEID = 'YOUR_CSE_ID';
    
  • Configure as required.
  • Yes 完了 – ウィキの「Special:Version」に移動して、拡張機能が正しくインストールされたことを確認します。

設定

The following configuration parameters are available:

名前 説明 既定 必須かどうか
$wgGoogleSiteSearchCSEID The ID of the created Google custom search engine. 必須
$wgGoogleSiteSearchOnly Whether to replace the the MediaWiki search results. If true, only the CSE search results are shown. If false, the CSE results are shown above the MediaWiki results. false 省略可能
$wgGoogleSiteSearchAppend Whether to prepend (not append) rather than replace the Google search results. Note that under some circumstances, for example when they're too many or no search results, the relevant hook may not fire and Google search results will not be appended. false 省略可能
$wgGoogleSiteSearchAttributes An array of optional Custom Search element attributes. For example, to make links open in a new window/tab:
$wgGoogleSiteSearchAttributes = [
	'linkTarget' => '_blank'
];
省略可能

In addition, the HTML built by the extension is customizable via the "GoogleSiteSearchHTML" hook. For example:

$wgHooks['GoogleSiteSearchHTML'][] = function ( $specialSearch, $term, &$html ) {
	$html .= '<p>Example append</p>';
};

関連項目

  • Extension:GoogleCustomWikiSearch - Offers similar functionality but appends search after, rather than before MediaWiki search if set to add to, rather than replace, search.