Skip to content

Commit

Permalink
auto push via Ubuntu
Browse files Browse the repository at this point in the history
  • Loading branch information
eallion committed Dec 24, 2019
1 parent 695c896 commit fb2537b
Show file tree
Hide file tree
Showing 8 changed files with 964 additions and 0 deletions.
2 changes: 2 additions & 0 deletions JustFeed/.gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Auto detect text files and perform LF normalization
* text=auto
674 changes: 674 additions & 0 deletions JustFeed/LICENSE

Large diffs are not rendered by default.

85 changes: 85 additions & 0 deletions JustFeed/Plugin.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
<?php
/**
* Just Feed
*
* @package JustFeed
* @author jKey
* @version 0.1.2
* @link http://typecho.jkey.lu/
* @fix the 'date' bug by https://eallion.com, update to 0.1.2 -20190412
* @license GPL3
*/

class JustFeed_Plugin implements Typecho_Plugin_Interface
{
/**
* 激活插件方法,如果激活失败,直接抛出异常
*
* @access public
* @return void
* @throws Typecho_Plugin_Exception
*/
public static function activate()
{
Helper::removeRoute('feed');
Helper::addRoute('feed', '/feed[feed:string:0]', 'JustFeed_Widget', 'feed');
}

/**
* 禁用插件方法,如果禁用失败,直接抛出异常
*
* @static
* @access public
* @return void
* @throws Typecho_Plugin_Exception
*/
public static function deactivate()
{
Helper::removeRoute('feed');
Helper::addRoute('feed', '/feed[feed:string:0]', 'Widget_Archive', 'feed');
}

/**
* 获取插件配置面板
*
* @access public
* @param Typecho_Widget_Helper_Form $form 配置面板
* @return void
*/
public static function config(Typecho_Widget_Helper_Form $form)
{
$cfg_copyright = new Typecho_Widget_Helper_Form_Element_Textarea(
'cfg_copyright',
NULL,
'<hr /><small>Copyright &copy; <a href="{authorurl}" target="_blank">{author}</a> for <a href="{siteurl}" target="_blank">{sitetitle}</a> 2010 | <a href="{permalink}" target="_blank">Permalink</a> | {commentsnumber} 条评论</small>',
'在 feed 尾部添加',
'可用标记:{sitetitle}{siteurl}{author}{authorurl}{permalink}{date}{time}{commentsnumber}<br /><br />Example: &lt;a href="{permalink}#comments" title="to the comments"&gt;To the comments&lt;/a&gt;, Author: &lt;a href="{authorlink}" &gt;{author}&lt;/a&gt;'
);
$form->addInput($cfg_copyright);

/* $cfg_related_post = new Typecho_Widget_Helper_Form_Element_Checkbox(
'cfg_related_post',
array('show' => '是否在 feed 尾部显示相关内容?'),
NULL,
'相关日志'
);
$form->addInput($cfg_related_post);
$cfg_related_post_num = new Typecho_Widget_Helper_Form_Element_Text(
'cfg_related_post_num',
NULL,
'5',
'日志数量'
);
$form->addInput($cfg_related_post_num); */
}

/**
* 个人用户的配置面板
*
* @access public
* @param Typecho_Widget_Helper_Form $form
* @return void
*/
public static function personalConfig(Typecho_Widget_Helper_Form $form){}
}
17 changes: 17 additions & 0 deletions JustFeed/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# JustFeed
Ver 0.1.1 有一个bug,输出RSS的时候,如果用上的{date}参数,结果只能显示 “年” 和 “月” ,不能显示 “日”。
如图:
![](https://github.com/eallion/JustFeed/blob/master/bug.png)

今天发现了,随手把里面的 93 行和 141 行修改了一下
```
$d['year'].'/'.$d['mon'].'/'.$date['mday'],
```
改为:
```
$d['year'].'/'.$d['mon'].'/'.$d['mday'],
```

这个插件是jKey开发的,原作者的网站已经打不开了。
感谢原作者的付出。
[http://typecho.jkey.lu/](http://typecho.jkey.lu)
184 changes: 184 additions & 0 deletions JustFeed/Widget.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,184 @@
<?php
class JustFeed_Widget extends Widget_Archive
{
/**
* 请到 Widget_Archive 中看以下私有变量的作用
* 由于父类中是私有变量不能在子类中直接使用,只能间接获取
*/
private $_feed;
private $_description;
private $_archiveTitle;
private $_feedType;

private $_currentFeedUrl;
private $_feedContentType;

/**
* 构造函数,初始化组件
*
* @access public
* @param mixed $request request对象
* @param mixed $response response对象
* @param mixed $params 参数列表
* @return void
*/
public function __construct($request, $response, $params = NULL)
{
parent::__construct($request, $response, $params);

$this->_feed = $this->getFeed();
$this->_feedType = $this->getFeedType();

/** 判断聚合类型 */
switch (true) {
case 0 === strpos($this->request->feed, '/rss/') || '/rss' == $this->request->feed:
/** 如果是RSS1标准 */
$this->_currentFeedUrl = $this->options->feedRssUrl;
$this->_feedContentType = 'application/rdf+xml';
break;
case 0 === strpos($this->request->feed, '/atom/') || '/atom' == $this->request->feed:
/** 如果是ATOM标准 */
$this->_currentFeedUrl = $this->options->feedAtomUrl;
$this->_feedContentType = 'application/atom+xml';
break;
default:
$this->_currentFeedUrl = $this->options->feedUrl;
$this->_feedContentType = 'application/rss+xml';
break;
}
}

/**
* 输出 feed
*/
public function feed()
{
$this->_description = $this->getDescription();
$this->_archiveTitle = $this->getArchiveTitle();

// 获取系统设置
$options = Helper::options();
// 获取 JustFeed 设置
$settings = Helper::options()->plugin('JustFeed');
//$related_post_num = is_numeric($settings->cfg_related_post_num) ? intval($settings->cfg_related_post_num) : 5;

$search = array('{sitetitle}','{siteurl}','{author}','{authorurl}','{permalink}','{date}','{time}','{commentsnumber}');

$this->_feed->setSubTitle($this->_description);
$this->_feed->setFeedUrl($this->_currentFeedUrl);

$this->_feed->setBaseUrl(('/' == $this->request->feed || 0 == strlen($this->request->feed)
|| '/comments' == $this->request->feed || '/comments/' == $this->request->feed) ?
$this->options->siteUrl : Typecho_Common::url($this->request->feed, $this->options->index));
$this->_feed->setFeedUrl($this->request->makeUriByRequest());

if ($this->is('single') || 'comments' == $this->parameter->type) {
$this->_feed->setTitle(_t('%s 的评论',
$this->options->title . ($this->_archiveTitle ? ' - ' . implode(' - ', $this->_archiveTitle) : NULL)));

if ('comments' == $this->parameter->type) {
$comments = $this->widget('Widget_Comments_Recent', 'pageSize=10');
} else {
$comments = $this->widget('Widget_Comments_Recent', 'pageSize=10&parentId=' . $this->cid);
}

while ($comments->next()) {
$d = getdate($comments->created);
$replace = array(
$options->title,
$options->siteUrl,
$this->author->screenName,
$this->author->url,
$comments->permalink,
$d['year'].'/'.$d['mon'].'/'.$d['mday'],
$d['hours'].':'.$d['minutes'].':'.$d['seconds'],
$this->commentsNum
);

$copyright = str_replace($search, $replace, $settings->cfg_copyright);

$suffix = $this->pluginHandle()->trigger($plugged)->commentFeedItem($this->_feedType, $comments);
if (!$plugged) {
$suffix = NULL;
}

$this->_feed->addItem(array(
'title' => $comments->author,
'content' => $comments->content . $copyright,
'date' => $comments->created,
'link' => $comments->permalink,
'author' => (object) array(
'screenName' => $comments->author,
'url' => $comments->url,
'mail' => $comments->mail
),
'excerpt' => strip_tags($comments->content),
'suffix' => $suffix
));
}
} else {
$this->_feed->setTitle($this->options->title . ($this->_archiveTitle ? ' - ' . implode(' - ', $this->_archiveTitle) : NULL));

$feedUrl = '';
if (Typecho_Feed::RSS2 == $this->_feedType) {
$feedUrl = $this->feedUrl;
} else if (Typecho_Feed::RSS1 == $this->_feedType) {
$feedUrl = $this->feedRssUrl;
} else if (Typecho_Feed::ATOM1 == $this->_feedType) {
$feedUrl = $this->feedAtomUrl;
}

while ($this->next()) {
//set_time_limit(60);
// 获取文字内容的时间
$d = getdate($this->created);
$replace = array(
$options->title,
$options->siteUrl,
$this->author->screenName,
$this->author->url,
$this->permalink,
$d['year'].'/'.$d['mon'].'/'.$d['mday'],
$d['hours'].':'.$d['minutes'].':'.$d['seconds'],
$this->commentsNum
);

$copyright = str_replace($search, $replace, $settings->cfg_copyright);

// 相关日志
/* $related_post_html = '';
if ($settings->cfg_related_post) {
$relatedPosts = $this->related($related_post_num);
if ($relatedPosts->have()) {
$related_post_html = '<h4>相关日志</h4><ul>';
while ($relatedPosts->next()) {
$related_post_html .= '<li><a href="' . $relatedPosts->permalink . '" title="' . $relatedPosts->title . '">' . $relatedPosts->title . '</a></li>';
}
$related_post_html .= '</ul>';
}
} */

$suffix = $this->pluginHandle()->trigger($plugged)->feedItem($this->_feedType, $this);
if (!$plugged) {
$suffix = NULL;
}

$this->_feed->addItem(array(
'title' => $this->title,
'content' => $this->options->feedFullText ? $this->content.$related_post_html.$copyright : (false !== strpos($this->text, '<!--more-->') ?
$this->excerpt . "<p class=\"more\"><a href=\"{$this->permalink}\" title=\"{$this->title}\">[...]</a></p>" . $related_post_html.$copyright : $this->content.$related_post_html.$copyright),
'date' => $this->created,
'link' => $this->permalink,
'author' => $this->author,
'excerpt' => $this->description,
'comments' => $this->commentsNum,
'commentsFeedUrl' => $feedUrl,
'suffix' => $suffix
));
}
}

$this->response->setContentType($this->_feedContentType);
echo $this->_feed->__toString();
}
}
Binary file added JustFeed/bug.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@
[Html2Text](Html2Text) | Html代码转Markdown格式插件 | 0.1.0 | [冰剑](https://github.com/binjoo) | [Download](https://github.com/typecho-fans/plugins/releases/download/plugins-H_to_L/Html2Text.zip)
[IQapTcha](IQapTcha) | 评论滑动解锁验证+规则过滤插件 | 1.1.2 | [Byends](https://github.com/visamz) | [Download](https://github.com/typecho-fans/plugins/releases/download/plugins-H_to_L/IQapTcha.zip)
[JSON](JSON) | Json格式输出博客数据API插件 | 0.1 | [公子](https://github.com/lizheming) | [Download](https://github.com/typecho-fans/plugins/releases/download/plugins-H_to_L/JSON.zip)
[JustFeed](https://github.com/eallion/JustFeed) | 在 Feed 尾部添加订阅信息的插件 | 0.1.2 | [jKey](http://typecho.jkey.lu/),[eallion](https://eallion.com) | [Download](https://github.com/typecho-fans/plugins/releases/download/plugins-H_to_L/JustFeed.zip)
[JWPlayer](JWPlayer) | Html5流媒体播放器Jwplayer插件 | 1.0.9 | [羽中](https://github.com/jzwalk) | [Download](https://github.com/typecho-fans/plugins/releases/download/plugins-H_to_L/JWPlayer.zip)
[Keywords](Keywords) | 文章指定关键词自动添加链接插件 | 1.0.8 | [羽中](https://github.com/jzwalk) | [Download](https://github.com/typecho-fans/plugins/releases/download/plugins-H_to_L/Keywords.zip)
[LREditor](LREditor) | Markdown编辑器左右预览插件 | 0.0.4 | [公子](http://github.com/lizheming) | [Download](https://github.com/typecho-fans/plugins/releases/download/plugins-H_to_L/LREditor.zip)
Expand Down
1 change: 1 addition & 0 deletions TESTORE.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@
[HyperMD](https://github.com/journey-ad/HyperMD-Typecho-Plugin) | Markdown所见即所得编辑器插件 | 0.1 | [journey.ad](https://github.com/journey-ad) | [下载](https://github.com/journey-ad/HyperMD-Typecho-Plugin/archive/master.zip)
[ImageBox](https://github.com/journey-ad/Image-Box-Typecho-Plugin) | 简易jQuery图片灯箱弹窗特效插件 | 0.1 | [journey.ad](https://github.com/journey-ad) | [下载](https://github.com/journey-ad/Image-Box-Typecho-Plugin/archive/master.zip)
[IShareEcho](https://github.com/pluveto/IShareEcho) | 为 Typecho 文章增加分享按钮和二维码的插件。 | 1.0.0 | [pluvet](https://github.com/pluveto) | [下载](https://github.com/pluveto/IShareEcho/archive/master.zip)
[JustFeed](https://github.com/eallion/JustFeed) | 在 Feed 尾部添加订阅信息的插件 | 0.1.2 | [jKey](http://typecho.jkey.lu/) & [eallion](https://eallion.com) | [下载](https://github.com/eallion/JustFeed/archive/master.zip)
[KaTeX4Typecho](https://github.com/vc12345679/KaTeX4Typecho) | 基于CDN的KaTeX公式渲染插件 | 0.0.1 | [vc12345679](https://github.com/vc12345679) | [下载](https://github.com/vc12345679/KaTeX4Typecho/archive/master.zip)
[Kefu](https://github.com/1628972070/typecho) | Typecho网站右侧浮动客服插件 | 1.0.0 | [双少](https://github.com/1628972070) | [下载](https://github.com/1628972070/typecho/archive/master.zip)
[KindEditor](https://github.com/hizhengfu/KindEditor) | 所见即所得富文本编辑器插件 | 4.0.1 | [hizhengfu](https://github.com/hizhengfu) | [下载](https://github.com/hizhengfu/KindEditor/archive/master.zip)
Expand Down

0 comments on commit fb2537b

Please sign in to comment.