ArchCN wiki 服务器配置

来自Arch Linux 中文社区 维护者 Wiki
跳转到导航 跳转到搜索

MediaWiki 配置

GitHub 登录

使用修改版的 OAuth2_Client 扩展。修改如下:

diff --git a/SpecialOAuth2Client.php b/SpecialOAuth2Client.php
index a2c32e8..a483479 100644
--- a/SpecialOAuth2Client.php
+++ b/SpecialOAuth2Client.php
@@ -116,6 +116,23 @@ class SpecialOAuth2Client extends SpecialPage {
                }
 
                $resourceOwner = $this->_provider->getResourceOwner($accessToken);
+
+                $request = $this->_provider->getAuthenticatedRequest(
+                  $this->_provider::METHOD_GET,
+                  'https://api.github.com/user/orgs', $accessToken);
+                $orgs = $this->_provider->getResponse($request);
+                $found = false;
+                foreach($orgs as $org) {
+                  if($org['login'] === 'archlinuxcn') {
+                    $found = true;
+                    break;
+                  }
+                }
+                if(!$found) {
+                  throw new MWException('You are not in our group.');
+                  die();
+                }
+
                $user = $this->_userHandling( $resourceOwner->toArray() );
                $user->setCookies();
 
@@ -128,7 +145,7 @@ class SpecialOAuth2Client extends SpecialPage {
                        $wgRequest->getSession()->save();
                }
 
-               if( !$title instanceof Title || 0 > $title->mArticleID ) {
+               if( !$title instanceof Title || 0 > $title->getArticleID() ) {
                        $title = Title::newMainPage();
                }
                $wgOut->redirect( $title->getFullURL() );

后一处修改来自 GitHub pull#9

注意:移动版上看不到登录按钮。可直接访问 Special:OAuth2Client/redirect 来登录。

移动版支持

使用 MobileFrontend 扩展及 Minerva_Neue 皮肤。

相关配置:

wfLoadExtension('MobileFrontend');
$wgMFAutodetectMobileView = true;

wfLoadSkin('MinervaNeue');
$wgMFDefaultSkinClass = 'SkinMinerva';

可视化编辑器

启用自带的 VisualEditor 扩展。相关配置:

wfLoadExtension('VisualEditor');
$wgDefaultUserOptions['visualeditor-enable'] = 1;
$wgDefaultUserOptions['visualeditor-enable-experimental'] = 1;
$wgVisualEditorNamespaces = array_merge($wgContentNamespaces, array(
  NS_USER, NS_USER_TALK, NS_CATEGORY, NS_PROJECT));

备份

脚本位于 /etc/cron.daily 下,由 dcron 执行。备份文件位于 /root/wiki-backups。脚本源码:https://github.com/archlinuxcn/misc_scripts/blob/master/aux-scripts/backupwiki

lilydjwg 每周会将最新的备份拖回她本地。