Meidawiki 配置
为coder建立了一个“编程百科”http://codingwiki.info,codingwiki采用mediawiki,这里记录详细的配置:
- codingwiki编程百科站点是一个为Coder而建的关于编程(Coding)的wiki站点,我们期望“新人在这里可以学习提高,熟手在这里可以跨越瓶颈,迈向高手之路”。
- codingwiki编程百科 的内容来自国外优秀的Coding博客或者 Coding技术站点。它属于非盈利性的,我们在这里创作、改进、收集和整理 编程(Coding)相关的中文文档,当然,我们热烈欢迎您也参与我们的翻译,您可以点击帮助了解相关信息。
- 如果想要与他人交流获得问题解答(多数情况作为最后选项,既然您已经来了这里:P),请参见建议的通讯方法。
1、首先,配置logo
# logo
$wgLogo = "/logo.png";
2、配置时间
## Timezone Settings
$wgLocaltimezone = "Asia/Shanghai";
$oldtz = getenv("TZ");
putenv("TZ=$wgLocaltimezone");
$wgLocalTZoffset = date("Z") / 3600;
putenv("TZ=$oldtz");
3、配置上传
#开启图片上传
$wgEnableUploads= true;
#上传文件类型
$wgFileExtensions = array( 'png', 'gif', 'jpg', 'jpeg','doc','ppt','pdf' );
4、urlrewrite Url重写
#url REWRITE
$wgScriptPath = "";
$wgArticlePath = "/$1";
$wgUsePathInfo = true;
$wgScriptExtension = ".php";
服务器采用nginx,添加下面的配置
location / {
if (!-e $request_filename) {
rewrite ^/([^?]*)(?:\?(.*))? /index.php?title=$1&$2 last;
}
}
5、添加常用扩展
#SyntaxHighlight
require_once("$IP/extensions/SyntaxHighlight_GeSHi/SyntaxHighlight_GeSHi.php");
#ParserFunctions
require_once( "$IP/extensions/ParserFunctions/ParserFunctions.php" );
6、实现自己的扩展——找出wiki最热条目和最新条目,以及热门分类,通过扩展tag实现
直接贴代码,详细效果见
http://codingwiki.info/%E9%A6%96%E9%A1%B5,
http://codingwiki.info/%E5%88%86%E7%B1%BB:.NET
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 | <?php $wgHooks [ 'ParserFirstCallInit' ][] = 'efCodingWikiTagParserInit' ; function efCodingWikiTagParserInit( & $parser ) { $parser ->setHook( 'hotpages' , 'efHotPageRender' ); $parser ->setHook( 'hotcategories' , 'efHotCategoryRender' ); $parser ->setHook( 'newpage' , 'efNewPageRender' ); return true; } function makePageListItem( $row ) { global $wgUser ; $title = Title::makeTitleSafe( $row ->page_namespace, $row ->page_title ); if ( ! is_null ( $title ) ) { $skin = $wgUser ->getSkin(); $link = $row ->page_is_redirect ? '<span class="allpagesredirect">' . $skin ->makeKnownLinkObj( $title ) . '</span>' : $skin ->makeKnownLinkObj( $title ); return ( "<li>{$link}({$row->page_counter}次)</li>\n" ); } else { return ( "<!-- Invalid title " . htmlspecialchars( $row ->page_title ) . " in namespace " . htmlspecialchars( $row ->page_namespace ) . " -->\n" ); } } function efHotPageRender( $input , $args , $parser , $frame ) { global $wgRequest , $wgOut , $wgContLang , $wgLang ; $dbr = wfGetDB( DB_SLAVE ); $limit = isset( $args [ "count" ])? $args [ "count" ]:10; $res = null; if (isset( $args [ "category" ])){ $res = $dbr ->select( array ( 'page' , 'categorylinks' ), '*' , array ( 'cl_to' => "{$args['category']}" ), __METHOD__ , array ( 'ORDER BY' => 'page_counter DESC' , 'LIMIT' => "$limit" , 'OFFSET' => '0' , ), array ( 'categorylinks' => array ( 'JOIN' , 'page_id=cl_from' ) ) ); } else { $res = $dbr ->select( 'page' , array ( 'page_namespace' , 'page_title' , 'page_counter' , 'page_is_redirect' ), array ( 'page_namespace' => '0' ), __METHOD__ , array ( 'ORDER BY' => 'page_counter DESC' , 'LIMIT' => "$limit" , 'OFFSET' => '0' , ) ); } $result = "<ul>" ; foreach ( $res as $row ) { $result .= makePageListItem( $row ); } $result .= "</ul>" ; return $result ; } function efHotCategoryRender( $input , $args , $parser , $frame ) { global $wgRequest , $wgOut , $wgContLang , $wgLang ; $dbr = wfGetDB( DB_SLAVE ); $limit = isset( $args [ "count" ])? $args [ "count" ]:10; $res = $dbr ->select( 'category' , '*' , array (), __METHOD__ , array ( 'ORDER BY' => 'cat_pages DESC' , 'LIMIT' => "$limit" , 'OFFSET' => '0' , ) ); $result = "<ul>" ; foreach ( $res as $row ) { $result .= "<li><a href='/分类:{$row->cat_title}'>{$row->cat_title}</a>(<a href='/分类:{$row->cat_title}'>{$row->cat_pages}</a>)</li>\n" ; } $result .= "</ul>" ; return $result ; } function efNewPageRender( $input , $args , $parser , $frame ) { global $wgRequest , $wgOut , $wgContLang , $wgLang ; $dbr = wfGetDB( DB_SLAVE ); $limit = isset( $args [ "count" ])? $args [ "count" ]:10; $res = null; if (isset( $args [ "category" ])){ $res = $dbr ->select( array ( 'page' , 'categorylinks' ), '*' , array ( 'cl_to' => "{$args['category']}" ), __METHOD__ , array ( 'ORDER BY' => 'page_id DESC' , 'LIMIT' => "$limit" , 'OFFSET' => '0' , ), array ( 'categorylinks' => array ( 'JOIN' , 'page_id=cl_from' ) ) ); } else { $res = $dbr ->select( 'page' , array ( 'page_namespace' , 'page_title' , 'page_counter' , 'page_is_redirect' ), array (), __METHOD__ , array ( 'ORDER BY' => 'page_id DESC' , 'LIMIT' => "$limit" , 'OFFSET' => '0' , ) ); } $result = "<ul>" ; foreach ( $res as $row ) { $result .= makePageListItem( $row ); } $result .= "</ul>" ; return $result ; } |
关注作者
作者: JadePeng
出处:https://www.cnblogs.com/xiaoqi/archive/2011/03/02/1969136.html
版权:本文采用「署名-非商业性使用-相同方式共享 4.0 国际(欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文链接) 」知识共享许可协议进行许可。
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
· 没有源码,如何修改代码逻辑?
· 全程不用写代码,我用AI程序员写了一个飞机大战
· DeepSeek 开源周回顾「GitHub 热点速览」
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 记一次.NET内存居高不下排查解决与启示
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了