2009年9月14日 星期一

MediaWiki

為什麼要寫這一篇?因為改的地方真的太多太雜了,而且從一開始一路改到現在已經很久了,我需要記錄一下,這樣下次要架站的時候才知道要改些什麼。

超有用資訊 super useful information (Mediawiki FAQ)
http://meta.wikimedia.org/wiki/MediaWiki_FAQ
http://www.mediawiki.org/wiki/Manual:FAQ
http://www.mediawiki.org/wiki/Project:Support_desk

普通有用
http://www.mwusers.com/wiki/index.php?title=Common_installation/configuration_problems

Mediawiki SEO articles
http://www.taommo.com/archives/2007/05/23/mediawiki-sites-and-seo-optimization/

=====================================================================
Remove toolbox function
http://blog.rootninja.com/archive/control-the-links-that-appear-in-mediawikis-toolbox-and-make-it-vanish-for-anonymous-users/

Replace 'nav_urls' with 'remove_toolbox_function' in Modern.php
if($this->data['remove_toolbox_function']) { ?>

1. data['nav_urls']['whatlinkshere']['href']) if( $this->data['remove_toolbox_function']['recentchangeslinked'] ) { ?>

2. data['nav_urls']['recentchangeslinked']['href']) if(!empty($this->data['remove_toolbox_function']['permalink']['href'])) { ?>

3. data['nav_urls']['permalink']['href'])


Upload
允許上傳的檔案類型$wgFileExtensions = array( 'gif', 'jpg', 'jpeg', 'rar' ,'zip','doc','ppt','pdf','xls');

是否要嚴格限制不允許的檔案類型上傳,若為false,則仍可上傳,但會提醒$wgStrictFileExtensions = true;

上傳大小,以byte為單位,預設為150K,建議改為10 M$wgUploadSizeWarning = 10 * 1024 * 1024;
##開啟外部圖片功能,讓link指到的圖片可以直接顯示$wgAllowExternalImages = true;


Change the icon in the browser's address line (favicon)
Simply upload your favicon.ico to the root of your domain/subdomain, make sure file name is in lower case and its name is favicon.ico
The favicon image should be either 16 x 16 pixels or 32 x 32 pixels.
Rewrite RuleIf you are using a rewrite rule in .htaccess to remove "index.php" from the URL, you will also need to add an exception for .ico files. Simply add the following rule to your .htaccess:
RewriteRule .*\.ico$ - [L] This rule must appear before the index.php rule.


Only login user can edit
$wgGroupPermissions['*' ]['read'] = true; //可以瀏覽內容


Only email confirmed user can edit
$wgEmailConfirmToEdit = true;//沒有email confirm的不能編輯


Enable Enternal Link
Find this function in 'YourWikifolder\includes\Skin.php' and change to:
function bottomScripts() {global $wgJsMimeType;return "\n\t\t



\n"."



\n"."



\n";}

Then create a folder and a file in 'YourWikifolder/javascript_form/getXterlinks.js', and copy and paste this into the file then save it (don't forget to set the right value for "YourdomainWithoutHttp"):


File Cache
File cache is enabled by setting three variables in LocalSettings.php:
$wgUseFileCache = true; /* default: false */ $wgFileCacheDirectory = "$IP/cache"; $wgShowIPinHeader = false;
Caching is only done for users who: are not logged in. do not have their user_newtalk flag active.
http://www.mediawiki.org/wiki/Manual:File_cache

Email config
in LocalSetting.php //Email Configuration $wgEmergencyContact="noreply@example.com"; $wgPasswordSender= "noreply@example.com"; $wgNoReplyAddress= "noreply@example.com";
$wgSMTP = array(
'host' => "mail.example.com",'IDhost' => "example.com",'port' => 25,'auth' => true,'username' => "noreply@example.com",'password' => ""
);

Change "Main page" to another page
change the content in MediaWiki:Mainpage

Changing the site title
If you want to change the site title in your browser, you need to edit
MediaWiki:Sitetitle. Go there and edit it just like you would any other page in your Wiki.
However, if you want to change the name of your site, you need to edit LocalSettings.php and change the $wgSitename variable to the name of your site. Then the MediaWiki:Sitetitle page can remain ((sitename)).
[edit] Custom page names
If you want to change how the page name is displayed, edit MediaWiki:Pagetitle
using
$1
to insert the name of the page viewed.
For example, by default it is displayed,


Modify

Go to the skin php file you use and modify it. Then you can changethe title in your website. It helps for SEO purpose. Every word in this sentence could be searched in search engine.

=====================================================================
Extension I Use
FCKEditor + FileLinkCorrection
http://www.mediawiki.org/wiki/Extension:FileLinkCorrection
http://mediawiki.fckeditor.net/
Poll
InputBox
CreateArticle
NewArticleTemplate
GoogleSiteSearch
SpamBlacklist
Google Analytics: Insert code into skins/monobook.php just above
Google AdSense : change both LocalSetting.php and extension file (adsense size and account info)
TopTenPages
APF (advance page function)
=====================================================================

My LocalSettings.php
## 允許上傳的檔案類型
$wgFileExtensions = array( 'gif', 'jpg', 'jpeg', 'rar' ,'zip','doc','ppt','pdf','xls','rm', 'rmvb', 'mpeg', 'avi');

## 是否要嚴格限制不允許的檔案類型上傳,若為false,則仍可上傳,但會提醒
$wgStrictFileExtensions = true;

## 上傳大小,以byte為單位,預設為150K,建議改為10 M
$wgUploadSizeWarning = 20 * 1024 * 1024;

## 檔案上傳黑名單
$wgMimeTypeBlacklist= array(
# HTML may contain cookie-stealing JavaScript and web bugs
'text/html', 'text/javascript', 'text/x-javascript', 'application/x-shellscript',
# PHP scripts may execute arbitrary code on the server
'application/x-php', 'text/x-php',
# Other types that may be interpreted by some servers
'text/x-python', 'text/x-perl', 'text/x-bash', 'text/x-sh', 'text/x-csh',
# Windows metafile, client-side vulnerability on some systems
'application/x-msmetafile',
# A ZIP file may be a valid Java archive containing an applet which exploits the
# same-origin policy to steal cookies
'application/zip');

$wgFileBlacklist = array(
# HTML may contain cookie-stealing JavaScript and web bugs
'html', 'htm', 'js', 'jsb', 'mhtml', 'mht',
# PHP scripts may execute arbitrary code on the server
'php', 'phtml', 'php3', 'php4', 'php5', 'phps',
# Other types that may be interpreted by some servers
'shtml', 'jhtml', 'pl', 'py', 'cgi',
# May contain harmful executables for Windows victims
'exe', 'scr', 'dll', 'msi', 'vbs', 'bat', 'com', 'pif', 'cmd', 'vxd', 'cpl' );

##開啟外部圖片功能,讓link指到的圖片可以直接顯示
$wgAllowExternalImages = true;


//網站暱名拜訪者權限
$wgGroupPermissions['*' ]['createaccount'] = true; //開放內部人員註冊
//在註冊完後將此選項設為false,但仍可由管理員進入到Create Account頁面來產生帳號
$wgGroupPermissions['*' ]['read'] = true; //能瀏覽內容
$wgGroupPermissions['*' ]['edit'] = true; //能編輯頁面
$wgGroupPermissions['*' ]['createpage'] = true; //能產生頁面
$wgGroupPermissions['*' ]['createtalk'] = false; //不能產對話頁面
$wgEmailConfirmToEdit = false;//沒有email confirm的能編輯

//Email Configuration
$wgEmergencyContact="no_reply@example.com";
$wgPasswordSender= "no_reply@example.com";
$wgNoReplyAddress= "no_reply@example.com";

$wgSMTP = array(
'host' => "mail.example.com",
'IDhost' => "example.com",
'port' => 25,
'auth' => true,
'username' => "no_reply@example.com",
'password' => "password for the above email account"

# FCKeditor
$wgFCKEditorToolbarSet = "Wiki";
require_once( "extensions/FCKeditor/FCKeditor.php" );
include("extensions/file link correction/FileLinkCorrection.php");



# Poll
include("extensions/Poll/Poll.php");

#InputBox
require_once( "extensions/InputBox/InputBox.php");

#CreateArticle
require_once( "extensions/CreateArticle/CreateArticle.php" );

#Setting Cache
$wgUseFileCache = true; /* default: false */
$wgFileCacheDirectory = "example.com/cache";
$wgShowIPinHeader = false;

#Extension:New Article Template
require_once ("extensions/NewArticleTemplate/NewArticleTemplate.php");
$wgNewArticleTemplatesEnable = true;

# enable on subpages:
$wgNewArticleTemplatesOnSubpages = true;

# Templates are used in these namespaces:
$wgNewArticleTemplatesNamespaces = array(
NS_MAIN => 1,
100 => 1,
102 => 1,
104 => 1,
106 => 1
);

# new pages in the main namespace use MediaWiki:NewArticleTemplate:
$wgNewArticleTemplates_PerNamespace = array(
NS_MAIN => "MediaWiki:NewArticleTemplate",
);

# new pages in any other namespace defined by $wgNewArticleTemplatesNamespaces use MediaWiki:NewArticleTemplateDefault:
$wgNewArticleTemplatesDefault = "MediaWiki:NewArticleTemplateDefault";

#GoogleSiteSearch (use google to replace the default search engine)
require_once("extensions/GoogleSiteSearch/GoogleSiteSearch.php");

#Extension:SpamBlacklist
require_once( "extensions/SpamBlacklist/SpamBlacklist.php" );

#for fck editor tag correction
require_once("extensions/TagCorrection/TagCorrection.php");

#TopTenPages
include("extensions/TopTenPages/TopTenPages.php");

#ManualSitemap
require_once("extensions/ManualSitemap/ManualSitemap.php");

#APF - Advanced Page Functions
require_once('extensions/APF/APF_setup.php');


沒有留言:

張貼留言