mirror of
https://github.com/danpros/htmly.git
synced 2026-04-22 13:36:22 +05:30
Improve RSS feed
Improve RSS feed, adding sitemap and markup.
This commit is contained in:
parent
0f53d0de69
commit
bd66a69ad5
5 changed files with 39 additions and 5 deletions
|
|
@ -30,3 +30,5 @@ Disallow: /composer.lock
|
||||||
Disallow: /composer.phar
|
Disallow: /composer.phar
|
||||||
# Paths
|
# Paths
|
||||||
Disallow: /search/
|
Disallow: /search/
|
||||||
|
|
||||||
|
Sitemap: /feed/sitemap
|
||||||
|
|
@ -270,6 +270,14 @@ get('/feed/rss',function(){
|
||||||
echo generate_rss(get_posts(null, 1, config('rss.count')));
|
echo generate_rss(get_posts(null, 1, config('rss.count')));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Show the RSS feed for sitemap
|
||||||
|
get('/feed/sitemap',function(){
|
||||||
|
|
||||||
|
header('Content-Type: application/rss+xml');
|
||||||
|
|
||||||
|
// Generate RSS feed for all blog posts
|
||||||
|
echo generate_sitemap(get_posts(null, null, null));
|
||||||
|
});
|
||||||
|
|
||||||
// If we get here, it means that
|
// If we get here, it means that
|
||||||
// nothing has been matched above
|
// nothing has been matched above
|
||||||
|
|
|
||||||
|
|
@ -935,12 +935,36 @@ function generate_rss($posts){
|
||||||
->appendTo($feed);
|
->appendTo($feed);
|
||||||
|
|
||||||
foreach($posts as $p){
|
foreach($posts as $p){
|
||||||
|
|
||||||
$item = new Item();
|
$item = new Item();
|
||||||
$item
|
$item
|
||||||
->title($p->title)
|
->title($p->title)
|
||||||
|
->pubDate($p->date)
|
||||||
->description($p->body)
|
->description($p->body)
|
||||||
->url($p->url)
|
->url($p->url)
|
||||||
|
->category($p->tag, $p->tagurl)
|
||||||
|
->appendTo($channel);
|
||||||
|
}
|
||||||
|
|
||||||
|
echo $feed;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Turn an array of posts into an RSS feed for sitemap
|
||||||
|
function generate_sitemap($posts){
|
||||||
|
|
||||||
|
$feed = new Feed();
|
||||||
|
$channel = new Channel();
|
||||||
|
|
||||||
|
$channel
|
||||||
|
->title(config('blog.title'))
|
||||||
|
->description(config('blog.description'))
|
||||||
|
->url(site_url())
|
||||||
|
->appendTo($feed);
|
||||||
|
|
||||||
|
foreach($posts as $p){
|
||||||
|
$item = new Item();
|
||||||
|
$item
|
||||||
|
->title($p->title)
|
||||||
|
->url($p->url)
|
||||||
->appendTo($channel);
|
->appendTo($channel);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -16,8 +16,8 @@
|
||||||
<script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
|
<script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
|
||||||
<![endif]-->
|
<![endif]-->
|
||||||
</head>
|
</head>
|
||||||
<body class="<?php echo $bodyclass; ?>">
|
<body class="<?php echo $bodyclass; ?>" itemscope="itemscope" itemtype="http://schema.org/Blog">
|
||||||
<div itemscope="itemscope" itemtype="http://schema.org/Blog" class="hide">
|
<div class="hide">
|
||||||
<meta content="<?php echo config('blog.title') ?>" itemprop="name"/>
|
<meta content="<?php echo config('blog.title') ?>" itemprop="name"/>
|
||||||
<meta content="<?php echo config('blog.description')?>" itemprop="description"/>
|
<meta content="<?php echo config('blog.description')?>" itemprop="description"/>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -16,8 +16,8 @@
|
||||||
<script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
|
<script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
|
||||||
<![endif]-->
|
<![endif]-->
|
||||||
</head>
|
</head>
|
||||||
<body class="<?php echo $bodyclass; ?>">
|
<body class="<?php echo $bodyclass; ?>" itemscope="itemscope" itemtype="http://schema.org/Blog">
|
||||||
<div itemscope="itemscope" itemtype="http://schema.org/Blog" class="hide">
|
<div class="hide">
|
||||||
<meta content="<?php echo config('blog.title') ?>" itemprop="name"/>
|
<meta content="<?php echo config('blog.title') ?>" itemprop="name"/>
|
||||||
<meta content="<?php echo config('blog.description')?>" itemprop="description"/>
|
<meta content="<?php echo config('blog.description')?>" itemprop="description"/>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue