diff --git a/README.md b/README.md index 51f8cec8..c5d03f4e 100644 --- a/README.md +++ b/README.md @@ -116,6 +116,7 @@ [SCS](SCS) | 系统附件使用新浪云存储SCS插件 | 1.1.1 | [vfhky](https://github.com/vfhky) | [Download](https://github.com/typecho-fans/plugins/releases/download/plugins-S_to_Z/SCS.zip) [ShortLinks](ShortLinks) | 基于[GoLinks](GoLinks)更强大的短链接插件 | 1.1.0 b1 | [Ryan](https://github.com/benzBrake) | [Download](https://github.com/typecho-fans/plugins/releases/download/plugins-S_to_Z/ShortLinks.zip) [Sinauth](Sinauth) | 新浪用户授权注册帐号与登录插件 | 1.0.0 Beta | [jimmy chaw](https://github.com/web3d) | [Download](https://github.com/typecho-fans/plugins/releases/download/plugins-S_to_Z/Sinauth.zip) +[Sitemap](Sitemap) | 动态生成Xml标准网站地图页插件 | 1.0.4 | [迷你日志](https://minirizhi.com),[八云酱](https://github.com/bayunjiang),[Hanny](http://www.imhan.com) | [Download](https://github.com/typecho-fans/plugins/releases/download/plugins-S_to_Z/Sinauth.zip) [SlantedExtend](SlantedExtend) | [Slanted主题](https://github.com/typecho-fans/themes/blob/master/Slanted)自定义字段专用插件 | 1.0.0 | [DT27](https://github.com/DT27) | [Special](https://github.com/typecho-fans/plugins/releases/download/plugins-S_to_Z/SlantedExtend.zip) [SlimBox2](SlimBox2) | 轻量级jQuery图片灯箱弹窗插件 | 1.0.7 | [Ryan](https://github.com/ryanfwy), [冰剑](https://github.com/binjoo) | [Download](https://github.com/typecho-fans/plugins/releases/download/plugins-S_to_Z/SlimBox2.zip) [Smilies](Smilies) | Typecho自定义图片表情替换插件 | 1.1.3 | [羽中](https://github.com/jzwalk), Willin Kan | [Download](https://github.com/typecho-fans/plugins/releases/download/plugins-S_to_Z/Smilies.zip) diff --git a/Sitemap/Action.php b/Sitemap/Action.php new file mode 100644 index 00000000..4c3b3025 --- /dev/null +++ b/Sitemap/Action.php @@ -0,0 +1,115 @@ +fetchAll($db->select()->from('table.contents') + ->where('table.contents.status = ?', 'publish') + ->where('table.contents.created < ?', $options->gmtTime) + ->where('table.contents.type = ?', 'page') + ->order('table.contents.created', Typecho_Db::SORT_DESC)); + + $articles = $db->fetchAll($db->select()->from('table.contents') + ->where('table.contents.status = ?', 'publish') + ->where('table.contents.created < ?', $options->gmtTime) + ->where('table.contents.type = ?', 'post') + ->order('table.contents.created', Typecho_Db::SORT_DESC)); + + $cates = $db->fetchAll($db->select()->from('table.metas') + ->where('table.metas.type = ?', 'category') + ->order('table.metas.order', Typecho_Db::SORT_DESC)); + + $tags = $db->fetchAll($db->select()->from('table.metas') + ->where('table.metas.type = ?', 'tag') + ->order('table.metas.mid', Typecho_Db::SORT_DESC)); + + header("Content-Type: application/xml"); + echo "\n"; + echo "pluginUrl . "/Sitemap/sitemap.xsl'?>\n"; + echo ""; + echo "\t\n"; + echo "\t\t".$options->siteUrl."\n"; + echo "\t\tdaily\n"; + echo "\t\t1.0\n"; + echo "\t\n"; + foreach($pages AS $page) { + $type = $page['type']; + $routeExists = (NULL != Typecho_Router::get($type)); + $page['pathinfo'] = $routeExists ? Typecho_Router::url($type, $page) : '#'; + $page['permalink'] = Typecho_Common::url($page['pathinfo'], $options->index); + + echo "\t\n"; + echo "\t\t".$page['permalink']."\n"; + echo "\t\t".date('Y-m-d',$page['modified'])."\n"; + echo "\t\talways\n"; + echo "\t\t0.6\n"; + echo "\t\n"; + } + foreach($articles AS $article) { + $type = $article['type']; + $article['categories'] = $db->fetchAll($db->select()->from('table.metas') + ->join('table.relationships', 'table.relationships.mid = table.metas.mid') + ->where('table.relationships.cid = ?', $article['cid']) + ->where('table.metas.type = ?', 'category') + ->order('table.metas.order', Typecho_Db::SORT_ASC)); + $article['category'] = urlencode(current(Typecho_Common::arrayFlatten($article['categories'], 'slug'))); + $article['slug'] = urlencode($article['slug']); + $article['date'] = new Typecho_Date($article['created']); + $article['year'] = $article['date']->year; + $article['month'] = $article['date']->month; + $article['day'] = $article['date']->day; + $routeExists = (NULL != Typecho_Router::get($type)); + $article['pathinfo'] = $routeExists ? Typecho_Router::url($type, $article) : '#'; + $article['permalink'] = Typecho_Common::url($article['pathinfo'], $options->index); + + echo "\t\n"; + echo "\t\t".$article['permalink']."\n"; + echo "\t\t".date('Y-m-d',$article['modified'])."\n"; + echo "\t\talways\n"; + echo "\t\t0.8\n"; + echo "\t\n"; + } + foreach($cates AS $cate) { + $type = $cate['type']; + $art_rs = $db->fetchRow($db->select()->from('table.contents') + ->join('table.relationships', 'table.contents.cid = table.relationships.cid') + ->where('table.contents.status = ?', 'publish') + ->where('table.relationships.mid = ?', $cate['mid']) + ->order('table.relationships.cid', Typecho_Db::SORT_DESC) + ->limit(1)); + $routeExists = (NULL != Typecho_Router::get($type)); + $cate['pathinfo'] = $routeExists ? Typecho_Router::url($type, $cate) : '#'; + $cate['permalink'] = Typecho_Common::url($cate['pathinfo'], $options->index); + + echo "\t\n"; + echo "\t\t".$cate['permalink']."\n"; + echo "\t\t".date('Y-m-d',$art_rs['modified'])."\n"; + echo "\t\tdaily\n"; + echo "\t\t0.5\n"; + echo "\t\n"; + } + foreach($tags AS $tag) { + $type = $tag['type']; + $art_rt = $db->fetchRow($db->select()->from('table.contents') + ->join('table.relationships', 'table.contents.cid = table.relationships.cid') + ->where('table.contents.status = ?', 'publish') + ->where('table.relationships.mid = ?', $tag['mid']) + ->order('table.relationships.cid', Typecho_Db::SORT_DESC) + ->limit(1)); + $routeExists = (NULL != Typecho_Router::get($type)); + $tag['pathinfo'] = $routeExists ? Typecho_Router::url($type, $tag) : '#'; + $tag['permalink'] = Typecho_Common::url($tag['pathinfo'], $options->index); + + echo "\t\n"; + echo "\t\t".$tag['permalink']."\n"; + echo "\t\t".date('Y-m-d',$art_rt['modified'])."\n"; + echo "\t\tdaily\n"; + echo "\t\t0.5\n"; + echo "\t\n"; + } + echo ""; + } +} diff --git a/Sitemap/Plugin.php b/Sitemap/Plugin.php new file mode 100644 index 00000000..1547b109 --- /dev/null +++ b/Sitemap/Plugin.php @@ -0,0 +1,72 @@ +TF社区维护版】 + * + * @package Sitemap + * @author 迷你日志,八云酱,Hanny + * @version 1.0.4 + * @dependence 9.9.2-* + * @link https://github.com/typecho-fans/plugins/blob/master/Sitemap + * + * version 1.0.4 at 2020-07-02 by Typecho Fans (合并多人修改) + * 页面改xml后缀,加入美化样式,简化时间戳 by Suming/八云酱 + * 调整优先级比例,增加分类页面及首页链接 by 迷你日志/羽中 + * + * version 1.0.3 at 2017-03-28 by 禾令奇 + * 修改增加标签链接,修改页面权重分级 + * + * 历史版本 + * version 1.0.1 at 2010-01-02 + * 修改自定义静态链接时错误的Bug + * + * version 1.0.0 at 2010-01-02 + * Sitemap for Google + * 生成文章和页面的Sitemap + * + */ +class Sitemap_Plugin implements Typecho_Plugin_Interface +{ + /** + * 激活插件方法,如果激活失败,直接抛出异常 + * + * @access public + * @return void + * @throws Typecho_Plugin_Exception + */ + public static function activate() + { + Helper::addRoute('sitemap', '/sitemap.xml', 'Sitemap_Action', 'action'); + } + + /** + * 禁用插件方法,如果禁用失败,直接抛出异常 + * + * @static + * @access public + * @return void + * @throws Typecho_Plugin_Exception + */ + public static function deactivate() + { + Helper::removeRoute('sitemap'); + } + + /** + * 获取插件配置面板 + * + * @access public + * @param Typecho_Widget_Helper_Form $form 配置面板 + * @return void + */ + public static function config(Typecho_Widget_Helper_Form $form){} + + /** + * 个人用户的配置面板 + * + * @access public + * @param Typecho_Widget_Helper_Form $form + * @return void + */ + public static function personalConfig(Typecho_Widget_Helper_Form $form){} + +} diff --git a/Sitemap/README.md b/Sitemap/README.md new file mode 100644 index 00000000..5c4b1944 --- /dev/null +++ b/Sitemap/README.md @@ -0,0 +1,79 @@ + + TF Logo + + +Sitemap v1.0.4 - 社区维护版 +====================== +

—— 动态生成符合搜索引擎收录标准的Xml格式站点地图插件,支持输出分类/标签页地址。

+ +

+ 使用说明 • + 版本历史 • + 贡献作者 • + 附注/链接 • + 授权协议 +

+ +--- + +## 使用说明 + + + + + +
+ +###### Sitemap 可方便站长通知搜索引擎网站上有哪些可供抓取的网页。最简单通行的就是Google制定的XML格式标准,其中可列出网址及其元数据(上次更新时间、更改频率和优先级权重等),便于搜索引擎更高效智能地抓取网站内容。 + +**使用方法**: +##### 1. 下载本插件,放在 `usr/plugins/` 目录中,确保文件夹名为 Sitemap; +##### 2. 激活插件; +##### 3. 访问http://[example].com/sitemap.xml即可看到页面效果。 + +
+ +## 版本历史 + + * v1.0.4 (20-7-02 [@jzwalk](https://github.com/jzwalk)) + * 增加首页地址输出,合并4个衍生版改动: + * 含魔改版Sitemap功能支持分类/标签地址输出([@kavico](https://minirizhi.com)); + * 对调页面文章优先级使Google正常收录([@raymond9zhou](https://github.com/raymond9zhou)); + * 简化样式说明,优化时间戳仅保留日期([@bayunjiang](https://github.com/bayunjiang)); + * 页面路径带xml文件后缀,套用xsl美化样式([@Suming](https://inwao.com))。 + * v1.0.3 (17-03-28 [@Vicshs](https://github.com/Vicshs)) + * 增加标签页地址遍历; + * 提升页面地址优先级。 + * v1.0.2 ([@Vicshs](https://github.com/Vicshs)) + * (不详) + * v1.0.1 (10-01-02 [@Hanny](http://www.imhan.com)) + * 修改自定义静态链接时错误的Bug。 + * v1.0.0 (10-01-02 [@Hanny](http://www.imhan.com)) + * 实现生成含文章页面地址的Google标准sitemap页面。 + +## 贡献作者 + +[![jzwalk](https://avatars1.githubusercontent.com/u/252331?v=3&s=100)](https://github.com/jzwalk) | [![kavico](https://secure.gravatar.com/avatar/03b9df1a08dd482503a70e9339b4888b?s=100)](https://minirizhi.com) | [![raymond9zhou](https://avatars1.githubusercontent.com/u/28761293?v=3&s=100)](https://github.com/raymond9zhou) | [![bayunjiang](https://avatars1.githubusercontent.com/u/19381311?v=3&s=100)](https://github.com/bayunjiang) | [![Suming](https://secure.gravatar.com/avatar/433daae294c13cd6ca7246e84a721038?s=100)](https://inwao.com) | [![Hanny](https://secure.gravatar.com/avatar/?d=mp&s=100)](http://www.imhan.com) +:---:|:---:|:---:|:---:|:---:|:---: +[jzwalk](https://github.com/jzwalk) (2020) | [kavico](https://minirizhi.com) (2020) | [raymond9zhou](https://github.com/raymond9zhou) (2019) | [bayunjiang](https://github.com/bayunjiang) (2017) | [Suming](https://inwao.com) (2016) | [Hanny](http://www.imhan.com) (2010) + +*为避免作者栏显示过长,插件信息仅选取登记3个署名,如有异议可协商修改。 + +## 附注/链接 + +本社区维护版已包含以下各版本功能并做优化调整: + +* [合并版(kavico)](http://forum.typecho.org/viewtopic.php?f=6&t=12315&p=45414) - 含输出分类功能。 +* [微调版(raymond9zhou)](https://github.com/raymond9zhou/typecho-auto-sitemap-plugin) - 调整优先级。 +* [增强版(Vicshs)](https://github.com/Vicshs/Sitemap) - 输出tag,提升优先级。 +* [简化版(bayunjiang)](https://github.com/bayunjiang/typecho-sitemap) - 简化样式及时间戳。 +* [美化版(Suming)](https://inwao.com/Sitemap.html) - 改xml后缀,套用样式。 +* [原版](http://www.imhan.com/typecho) - 实现基本功能。 + +欢迎社区成员继续贡献代码参与更新。 + +## 授权协议 + +TF目录下的社区维护版作品如果没有明确声明,默认采用与Typecho相同的[GPLv2](https://github.com/typecho/typecho/blob/master/LICENSE.txt)开源协议。(要求提及出处,保持开源并注明修改。) + +> Sitemap原作未附协议声明,原作者保留所有权利。 © [Hanny](http://www.imhan.com) diff --git a/Sitemap/sitemap.xsl b/Sitemap/sitemap.xsl new file mode 100644 index 00000000..a94e0e97 --- /dev/null +++ b/Sitemap/sitemap.xsl @@ -0,0 +1,116 @@ + + + + + + + XML Sitemap + + + + +

XML Sitemap

+
+

+ This is a XML Sitemap which is supposed to be processed by search engines like Baidu, Google, 360, Bing and Sogou.
+ You can find more information about XML sitemaps on sitemaps.org and Google's list of sitemap programs. +

+
+
+ + + + + + + + + + + + + ood + + + even + + + + + + + +
URLPriorityChange FrequencyLastChange
+ + + + + + + + + + + + +
+
+ + + +
+
\ No newline at end of file diff --git a/ZIP_CDN/Sitemap.zip b/ZIP_CDN/Sitemap.zip new file mode 100644 index 00000000..0b38390f Binary files /dev/null and b/ZIP_CDN/Sitemap.zip differ