Inheritance: implements Suin\RSSWriter\ChannelInterface
示例#1
0
function generate_rss($posts)
{
    $feed = new Feed();
    $channel = new Channel();
    $channel->title('LBlog')->description('A very light weight blog.')->url('http://localhost:8000')->appendTo($feed);
    $item = new Item();
    foreach ($posts as $post) {
        $item->title($post->title)->description($post->body)->url($post->url)->appendTo($channel);
    }
    echo $feed;
}
示例#2
0
function generate_rss($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)->description($p->body)->url($p->url)->appendTo($channel);
    }
    echo $feed;
}
示例#3
0
 /**
  * Method to render the view.
  *
  * @return  string  The rendered view.
  *
  * @throws  \RuntimeException
  */
 public function render()
 {
     $this->prepareGlobals($this->getData());
     $this->prepareData($this->getData());
     $feed = new Feed();
     $channel = new Channel();
     $channel->title($this['blog']->title)->description($this['blog']->description)->url($this['uri']->get('base.full'))->appendTo($feed);
     foreach ($this['posts'] as $post) {
         $item = new Item();
         $item->title($post->title)->description($post->introtext)->url($this['uri']->get('base.full') . ltrim($post->link, '/'))->appendTo($channel);
     }
     return $feed;
 }
示例#4
0
 public function get()
 {
     $posts = Model::factory('Article')->where('status', '1')->order_by_desc('point')->limit(10)->find_many();
     $feed = new FeedFactory();
     $channel = new Channel();
     $channel->title(config('site.title'))->description(config('site.default_meta'))->url(Url::site())->appendTo($feed);
     foreach ($posts as $post) {
         $item = new Item();
         /** @var $post \Model\Article */
         $item->title($post->title)->description(Html::fromMarkdown($post->content))->url($post->permalink())->pubDate(strtotime($post->created_at))->appendTo($channel);
     }
     $this->data = substr($feed, 0, -1);
 }
示例#5
0
 public function showAction(Post $postModel)
 {
     $posts = $postModel->getRecentlyPosts(1, 20);
     $feed = new Feed();
     $channel = new Channel();
     $channel->title('Aicode')->description('爱生活,爱代码')->url('http://aicode.cc')->lastBuildDate($posts['data'][0]['publish_date'])->appendTo($feed);
     foreach ($posts['data'] as $art) {
         $item = new Item();
         $item->title($art['title'])->description('<p><img src="' . $art['feature_img'] . '" /></p>' . (new \Parsedown())->parse($art['content']))->url('http://aicode.cc/article/' . $art['id'] . '.html')->pubDate($art['publish_date'])->guid('http://aicode.cc/article/' . $art['id'] . '.html')->appendTo($channel);
     }
     header('Content-Type:text/xml; charset=utf-8');
     return $feed->render();
 }
 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function show($type)
 {
     $feedData = $this->feed->where('slug', $type)->firstOrFail();
     $model = $feedData->model;
     $entities = $model::getFeedItems();
     $feed = new Feed();
     $channel = new Channel();
     $channel->title($feedData->title)->description($feedData->description)->url($feedData->url)->language($feedData->language)->copyright($feedData->copyright)->ttl($feedData->ttl)->appendTo($feed);
     foreach ($entities as $entity) {
         $item = new Item();
         $item->title($entity->itemTitle())->description($entity->itemDescription())->contentEncoded($entity->itemContent())->url($entity->itemUrl())->guid($entity->itemUrl(), true)->pubDate($entity->itemPubDate())->appendTo($channel);
     }
     return $feed;
 }
示例#7
0
 public function index()
 {
     $parsedown = new \ParsedownExtra();
     $config = Configuration::find(1);
     $posts = Post::published()->orderBy('published_at', 'desc')->get();
     $feed = new Feed();
     $channel = new Channel();
     $channel->title($config->blog_title)->description($config->blog_description)->url(url('/'))->appendTo($feed);
     foreach ($posts as $post) {
         $item = new Item();
         $item->title($post->title)->description($parsedown->parse($post->content))->url(url("/articles/{$post->slug}"))->guid(url("/articles/{$post->slug}"), true)->appendTo($channel);
     }
     return response($feed)->header('Content-Type', 'application/rss+xml');
 }
示例#8
0
 private function renderRss($competitions)
 {
     $this->setIsAjaxRequest(true);
     $baseUrl = Yii::app()->request->getBaseUrl(true);
     $feed = new Feed();
     $channel = new Channel();
     $channel->title(Yii::t('common', 'Cubing China'))->description(Yii::t('common', Yii::app()->params->description))->url($baseUrl)->language(Yii::app()->language)->copyright('Copyright ' . date('Y') . ', Cubing China')->pubDate(isset($competitions[0]) ? $competitions[0]->date : time())->lastBuildDate(time())->ttl(300)->appendTo($feed);
     foreach ($competitions as $competition) {
         $item = new Item();
         $item->title($competition->getAttributeValue('name'))->description($competition->getAttributeValue('information'))->url($baseUrl . CHtml::normalizeUrl($competition->getUrl('detail')))->pubDate($competition->date)->guid(CHtml::normalizeUrl($competition->getUrl('detail')), true)->appendTo($channel);
     }
     header('Content-Type:application/xml');
     echo $feed;
 }
示例#9
0
function CreateRSSFeed($projectid)
{
    // Checks
    if (!isset($projectid) || !is_numeric($projectid)) {
        echo 'Not a valid projectid!';
        return;
    }
    // Find the project name
    $project = pdo_query("SELECT public,name FROM project WHERE id='{$projectid}'");
    $project_array = pdo_fetch_array($project);
    $projectname = $project_array['name'];
    // Don't create RSS feed for private projects
    if ($project_array['public'] != 1) {
        return;
    }
    global $CDASH_ROOT_DIR;
    $filename = $CDASH_ROOT_DIR . '/public/rss/SubmissionRSS' . $projectname . '.xml';
    $currentURI = get_server_URI();
    $currenttime = time();
    $feed = new Feed();
    $channel = new Channel();
    $channel->title("CDash for {$projectname}")->url("{$currentURI}/index.php?project={$projectname}")->description("Recent CDash submissions for {$projectname}")->language('en-US')->lastBuildDate($currenttime)->appendTo($feed);
    // Get the last 24hrs submissions
    $beginning_timestamp = $currenttime - 24 * 3600;
    $end_timestamp = $currenttime;
    $builds = pdo_query("SELECT * FROM build\n                         WHERE UNIX_TIMESTAMP(starttime)<{$end_timestamp} AND UNIX_TIMESTAMP(starttime)>{$beginning_timestamp}\n                         AND projectid='{$projectid}'\n                         ");
    while ($build_array = pdo_fetch_array($builds)) {
        $siteid = $build_array['siteid'];
        $buildid = $build_array['id'];
        $site_array = pdo_fetch_array(pdo_query("SELECT name FROM site WHERE id='{$siteid}'"));
        // Find the number of errors and warnings
        $nerrors = $build_array['builderrors'];
        $nwarnings = $build_array['buildwarnings'];
        $nnotrun = $build_array['testnotrun'];
        $nfail = $build_array['testfailed'];
        $title = 'CDash(' . $projectname . ') - ' . $site_array['name'] . ' - ' . $build_array['name'] . ' - ' . $build_array['type'];
        $title .= ' - ' . $build_array['submittime'] . ' - ' . $nerrors . ' errors, ' . $nwarnings . ' warnings, ' . $nnotrun . ' not run, ' . $nfail . ' failed.';
        // Should link to the errors...
        $link = $currentURI . '/buildSummary.php?buildid=' . $buildid;
        $description = 'A new ' . $build_array['type'] . ' submission from ' . $site_array['name'] . ' - ' . $build_array['name'] . ' is available: ';
        $description .= $nerrors . ' errors, ' . $nwarnings . ' warnings, ' . $nnotrun . ' not run, ' . $nfail . ' failed.';
        $item = new Item();
        $item->guid($currentURI . '/buildSummary.php?buildid=' . $buildid)->title($title)->url($link)->description($description)->pubDate($currenttime)->appendTo($channel);
    }
    if (file_put_contents($filename, $feed) === false) {
        add_log('Cannot write file ' . $filename, 'CreateRSSFeed', LOG_ERR, $projectid);
    }
}
示例#10
0
 /**
  * Return a string with the feed data
  * 
  * @return string
  */
 protected function buildRssData()
 {
     $now = Carbon::now();
     $feed = new Feed();
     $channel = new Channel();
     $channel->title(config('blog.title'))->description(config('blog.description'))->url(url())->language('en')->copyright('Copyright ' . config('blog.author'))->lastBuildDate($now->timestamp)->appendTo($feed);
     $posts = Post::where('published_at', '<=', $now)->where('is_draft', 0)->orderBy('published_at', 'desc')->take(config('blog.rss_size'))->get();
     foreach ($posts as $post) {
         $item = new Item();
         $item->title($post->title)->description($post->subtitle)->url($post->url())->pubDate($post->published_at->timestamp)->guid($post->url(), true)->appendTo($channel);
     }
     $feed = (string) $feed;
     $feed = str_replace('<rss version="2.0">', '<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">', $feed);
     $feed = str_replace('<channel>', '<channel' . "\n" . '    <atom:link href="' . url('/rss') . '" rel="self" type="application/rss+xml" />', $feed);
     return $feed;
 }
示例#11
0
文件: Rss.php 项目: lembarek/core
 /**
  * Return a string with the feed data
  *
  * @return string
  */
 public function buildRssFeed()
 {
     $now = Carbon::now();
     $feed = new Feed();
     $channel = new Channel();
     $channel->title($this->title())->description($this->description())->url(url('/'))->language($this->getLang())->copyright('Copyright (c) ' . $this->author())->lastBuildDate($now->timestamp)->appendTo($feed);
     $its = $this->repo->getRssItems();
     foreach ($its as $it) {
         $item = new Item();
         $item = $this->format($item, $it);
         $item->guid($this->getuid($it), true)->appendTo($channel);
     }
     // Replace a couple items to make the feed more compliant
     $feed = str_replace('<rss version="2.0">', '<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">', $feed);
     $feed = str_replace('<channel>', '<channel>' . "\n" . '    <atom:link href="' . url('/rss') . '" rel="self" type="application/rss+xml" />', $feed);
     return $feed;
 }
示例#12
0
 /**
  * Return a string with the feed data
  *
  * @return string
  */
 protected function buildRssData()
 {
     $now = Carbon::now();
     $feed = new Feed();
     $channel = new Channel();
     $channel->title(config('blog.title'))->description(config('blog.description'))->url(url())->language('en')->copyright('Copyright (c) ' . config('blog.author'))->lastBuildDate($now->timestamp)->appendTo($feed);
     $articles = Article::where('published_date', '<=', $now)->orderBy('published_date', 'desc')->take(config('blog.rss_size'))->get();
     foreach ($articles as $article) {
         $item = new Item();
         $item->title($article->title)->tumnail_url($article->thumnail_url)->url($article->url())->pubDate($article->published_date->timestamp)->guid($article->url(), true)->appendTo($channel);
     }
     $feed = (string) $feed;
     // Replace a couple items to make the feed more compliant
     $feed = str_replace('<rss version="2.0">', '<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">', $feed);
     $feed = str_replace('<channel>', '<channel>' . "\n" . '    <atom:link href="' . url('/rss') . '" rel="self" type="application/rss+xml" />', $feed);
     return $feed;
 }
示例#13
0
    /**
     * Return a string with the feed data
     *
     * @return string
     */
    protected function buildRssData($objs, $type, $hash)
    {
        $now = \Carbon\Carbon::now();
        $feed = new Feed();
        $channel = new Channel();
        $channel->title(Config::get('site.name'))->description(Config::get('site.description'))->url($_ENV['SITE_URL'])->language('ht')->copyright('&copy; 2012 - ' . date('Y') . ' ' . Config::get('site.name') . ', Tout Dwa Rezève.')->lastBuildDate($now->timestamp)->appendTo($feed);
        foreach ($objs as $obj) {
            $item = new Item();
            $title = "#Nouvo{$hash} {$obj->name} #{$obj->category->slug} via @TKPMizik | @TiKwenPam";
            $item->title($title)->description($obj->description)->url(url("/{$type}/{$obj->id}"))->pubDate($obj->created_at->timestamp)->guid(url("/{$type}/{$obj->id}"), true)->appendTo($channel);
        }
        $feed = (string) $feed;
        // Replace a couple items to make the feed more compliant
        $feed = str_replace('<rss version="2.0">', '<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">', $feed);
        $feed = str_replace('<channel>', '<channel>
			<atom:link href="' . url($_ENV['SITE_URL'] . "/{$type}/feed") . '" rel="self" type="application/rss+xml" />', $feed);
        return $feed;
    }
示例#14
0
 protected function createRSSFeed()
 {
     $feed = new Feed();
     $channel = new Channel();
     $channel->title($this->kg['option']->getOption("channel.title"))->description($this->kg['option']->getOption("channel.description"))->url("https://youtube.com/user/" . $this->kg['config']['youtube_channel_username'])->appendTo($feed);
     $i = 0;
     foreach ($this->kg['video']->getDownloadedVideos() as $video) {
         if ($i >= 20) {
             break;
         }
         /** @var Video $video */
         $item = new Item();
         $item->title($video->getTitle())->description($video->getDescription())->url("https://www.youtube.com/watch?v=" . $video->getId())->enclosure($this->kg['config']['web_url'] . "/media/" . $video->getId() . ".mp3", filesize($this->kg['web_dir'] . "/media/" . $video->getId() . ".mp3"), 'audio/mpeg')->appendTo($channel);
         $i++;
     }
     $rssPath = $this->kg['web_dir'] . "/podcast.rss";
     file_put_contents($rssPath, $feed, LOCK_EX);
     $this->kg['monolog']->addDebug(sprintf("Rendered %s", $rssPath));
 }
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $dir = $input->getOption('dir');
     $limit = '- ' . $input->getOption('limit') . ' day';
     if (!is_dir($dir)) {
         throw new RuntimeException('Dir does not exist');
     }
     $url = rtrim($input->getOption('url'), '/') . '/';
     $filename = $input->getOption('filename');
     $feedFile = $dir . '/' . $filename;
     $server = new Server($input->getOption('hostname'), $input->getOption('port'), $input->getOption('type'));
     $server->setAuthentication($input->getOption('username'), $input->getOption('password'));
     $feed = new Feed();
     $channel = new Channel();
     $channel->title($input->getOption('title'))->description($input->getOption('description'))->url($url . $filename)->appendTo($feed);
     $generator = new EmailFeedGenerator($server, $feed, $channel);
     $generator->createFeed($dir, $filename, $url, $limit);
     $output->writeln('Succesfully generated ' . $feedFile);
 }
示例#16
0
 private function assembleFeed()
 {
     $feed = new Feed();
     $channel = new Channel();
     $posts = (new Post())->whereNotNull('published_at')->orderBy('published_at', 'DESC')->take(25)->get();
     $lastBuildDate = null;
     if (!$posts->isEmpty()) {
         $lastBuildDate = $posts->first()->published_at->timestamp;
     }
     $channel->title(config('genealabs-laravel-weblog.title'))->description(config('genealabs-laravel-weblog.title'))->url(url(config('genealabs-laravel-weblog.rss-route-name')))->language('en')->copyright(config('genealabs-laravel-weblog.copyright-notice'))->lastBuildDate($lastBuildDate)->appendTo($feed);
     foreach ($posts as $post) {
         $item = new Item();
         $item->title($post->title)->description($post->excerpt)->contentEncoded($post->content)->url($post->slug)->author($post->author->name)->pubDate($post->published_at->timestamp)->guid($post->slug, true)->appendTo($channel);
     }
     $feed = $feed->render();
     $feed = str_replace('<rss version="2.0">', '<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">', $feed);
     $feed = str_replace('<channel>', '<channel>' . "\n" . '    <atom:link href="' . url(config('genealabs-laravel-weblog.rss-route-name')) . '" rel="self" type="application/rss+xml" />', $feed);
     return $feed;
 }
示例#17
0
 public function buildRssFeed()
 {
     $now = Carbon::now();
     $feed = new Feed();
     $channel = new Channel();
     $channel->title(config('settings.app_name_' . config('app.locale')))->description("Le club Université Nantes Aviron est LE club d'aviron des étudiants nantais,\n            mais demeure ouvert à tous les publics et tous les types de pratiques.")->url(route('home'))->language('fr')->copyright('Copyright (c) ' . config('settings.app_name_' . config('app.locale')))->lastBuildDate($now->timestamp)->appendTo($feed);
     $news_list = $this->model->where('released_at', '<=', $now)->where('active', true)->orderBy('released_at', 'desc')->take(20)->get();
     foreach ($news_list as $news) {
         $item = new Item();
         // we parse the markdown content
         $parsedown = new Parsedown();
         $news->content = isset($news->content) ? $parsedown->text($news->content) : null;
         $item->title($news->title)->description(str_limit(strip_tags($news->content), 250))->url(route('news.show', ['id' => $news->id, 'key' => $news->key]))->pubDate(Carbon::createFromFormat('Y-m-d H:i:s', $news->released_at)->timestamp)->guid(route('news.show', ['id' => $news->id, 'key' => $news->key]), true)->appendTo($channel);
     }
     $feed = (string) $feed;
     // replace a couple items to make the feed more compliant
     $feed = str_replace('<rss version="2.0">', '<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">', $feed);
     $feed = str_replace('<channel>', '<channel>' . "\n" . '    <atom:link href="' . url('/rss') . '" rel="self" type="application/rss+xml" />', $feed);
     return $feed;
 }
示例#18
0
 /**
  * Return a string with the feed data
  *
  * @param $posts
  *
  * @return string
  */
 public function buildRssData($posts)
 {
     $now = \Carbon::now();
     $feed = new Feed();
     $channel = new Channel();
     $channel->title('Shuvayatra')->description("Shuvayatra")->url(url())->language('en')->copyright("Copyright (c) 2016 Shuvayatra")->lastBuildDate($now->timestamp)->appendTo($feed);
     foreach ($posts['data'] as $post) {
         $item = new PostRssItem();
         $post = (object) $post;
         $item->title($post->title)->description($this->stripInvalidXml($post->description))->url($post->share_url)->pubDate($post->created_at)->extend(['sy:source' => $post->source])->extend(['sy:postType' => $post->type])->extend(['sy:language' => $post->language])->extend(['sy:featured_image' => $post->featured_image])->extend(['sy:like_count' => $post->like_count])->extend(['sy:share_count' => $post->share_count])->extend(['sy:tags' => implode(',', $post->tags)])->extend(['sy:categories' => implode(',', $post->categories)])->guid($post->share_url, true)->preferCdata(true)->appendTo($channel);
         if ($post->type == 'text') {
             //$item->extend(['sy:content' => isset($post->data->content) ? $post->data->content : '']);
         } else {
             $item->extend(['sy:media_url' => isset($post->data->media_url) ? $post->data->media_url : ''])->extend(['sy:duration' => isset($post->data->duration) ? $post->data->duration : ''])->extend(['sy:thumbnail' => isset($post->data->thumbnail) ? $post->data->thumbnail : '']);
         }
     }
     $feed = (string) $feed;
     $feed = str_replace('version="2.0"', 'xmlns:sy="http://shuvayatra.org/doc/rss/" version="2.0"', $feed);
     $feed = str_replace('<channel>', '<channel>' . "\n" . '   <atom:link href="' . url('/rss') . '" rel="self" type="application/rss+xml"/>', $feed);
     return $feed;
 }
示例#19
0
function generate_rss($posts)
{
    $feed = new Feed();
    $channel = new Channel();
    $rssLength = config('rss.char');
    $channel->title(blog_title())->description(blog_description())->url(site_url())->appendTo($feed);
    foreach ($posts as $p) {
        if (!empty($rssLength)) {
            if (strlen(strip_tags($p->body)) < config('rss.char')) {
                $string = preg_replace('/\\s\\s+/', ' ', strip_tags($p->body));
                $body = $string . '...';
            } else {
                $string = preg_replace('/\\s\\s+/', ' ', strip_tags($p->body));
                $string = substr($string, 0, config('rss.char'));
                $string = substr($string, 0, strrpos($string, ' '));
                $body = $string . '...';
            }
        } else {
            $body = $p->body;
        }
        $item = new Item();
        $cats = explode(',', str_replace(' ', '', strip_tags(remove_accent($p->category))));
        foreach ($cats as $cat) {
            $item->category($cat, site_url() . 'category/' . strtolower($cat));
        }
        $item->title($p->title)->pubDate($p->date)->description($body)->url($p->url)->appendTo($channel);
    }
    echo $feed;
}
示例#20
0
<?php

// Load test target classes
spl_autoload_register(function ($c) {
    @(include_once strtr($c, '\\_', '//') . '.php');
});
set_include_path(get_include_path() . PATH_SEPARATOR . __DIR__ . '/Source');
use Suin\RSSWriter\Feed;
use Suin\RSSWriter\Channel;
use Suin\RSSWriter\Item;
$feed = new Feed();
$channel = new Channel();
$channel->title("Channel Title")->description("Channel Description")->url('http://blog.example.com')->language('en-US')->copyright('Copyright 2012, Foo Bar')->pubDate(strtotime('Tue, 21 Aug 2012 19:50:37 +0900'))->lastBuildDate(strtotime('Tue, 21 Aug 2012 19:50:37 +0900'))->ttl(60)->appendTo($feed);
$item = new Item();
$item->title("Blog Entry Title")->description("<div>Blog body</div>")->url('http://blog.example.com/2012/08/21/blog-entry/')->pubDate(strtotime('Tue, 21 Aug 2012 19:50:37 +0900'))->guid('http://blog.example.com/2012/08/21/blog-entry/', true)->appendTo($channel);
echo $feed;
// or echo $feed->render();
    render($app, 'archive', array('posts' => $posts, 'date' => $date, 'skin' => $skin));
});
// Previews
$app->get('/preview', function () use($app, $prismic) {
    $token = $app->request()->params('token');
    $url = $prismic->get_api()->previewSession($token, $prismic->linkResolver, '/');
    $app->setCookie(Prismic\PREVIEW_COOKIE, $token, time() + 1800, '/', null, false, false);
    $app->response->redirect($url ? $url : '/', 301);
});
// RSS Feed,
// using the Suin RSS Writer library
$app->get('/feed', function () use($app, $prismic) {
    $blogUrl = $app->request()->getUrl();
    $posts = $prismic->get_posts(current_page($app))->getResults();
    $feed = new Feed();
    $channel = new Channel();
    $channel->title($prismic->config('site.title'))->description($prismic->config('site.description'))->url($blogUrl)->appendTo($feed);
    foreach ($posts as $post) {
        $item = new Item();
        $item->title($post->getText('post.title'))->description($post->getHtml('post.body', $prismic->linkResolver))->url($blogUrl . $prismic->linkResolver->resolveDocument($post))->pubDate($post->getDate('post.date')->asEpoch())->appendTo($channel);
    }
    echo $feed;
});
// --- DISQUS
$app->post('/disqus/threads/create', function () use($app, $prismic) {
    $title = $app->request->post('title');
    $identifier = $app->request->post('identifier');
    $apiKey = $prismic->config('disqus.apikey');
    $apiSecret = $prismic->config('disqus.apisecret');
    $accessToken = $prismic->config('disqus.accesstoken');
    $forum = $prismic->config('disqus.forum');
示例#22
0
 /**
  * prepare feed
  */
 private function prepareRss($articleList)
 {
     $feed = new Feed();
     $channel = new Channel();
     $time = strtotime(date('Y-m-d'));
     $copyrightYear = date('Y');
     $channel->title("Blog Rss")->description("Blog Rss")->url(config('sys.sys_blog_domain'))->language('zh-CN')->copyright('Copyright ' . $copyrightYear . ', Jiang')->pubDate($time)->lastBuildDate($time)->ttl(3600 * 24)->appendTo($feed);
     foreach ($articleList as $key => $value) {
         $item = new Item();
         $item->title($value['title'])->description($value['content'])->url(route('blog.index.detail', ['id' => $value['id']]))->pubDate($value['write_time'])->guid(route('blog.index.detail', ['id' => $value['id']]), true)->appendTo($channel);
     }
     return $feed->render();
 }
示例#23
0
<?php

use Suin\RSSWriter\Channel;
use Suin\RSSWriter\Feed;
use Suin\RSSWriter\Item;
// Load test target classes
spl_autoload_register(function ($c) {
    @(include_once strtr($c, '\\_', '//') . '.php');
});
set_include_path(get_include_path() . PATH_SEPARATOR . dirname(__DIR__) . '/src');
$feed = new Feed();
$channel = new Channel();
$channel->title('Channel Title')->description('Channel Description')->url('http://blog.example.com')->language('en-US')->copyright('Copyright 2012, Foo Bar')->pubDate(strtotime('Tue, 21 Aug 2012 19:50:37 +0900'))->lastBuildDate(strtotime('Tue, 21 Aug 2012 19:50:37 +0900'))->ttl(60)->pubsubhubbub('http://example.com/feed.xml', 'http://pubsubhubbub.appspot.com')->appendTo($feed);
// Blog item
$item = new Item();
$item->title('Blog Entry Title')->description('<div>Blog body</div>')->contentEncoded('<div>Blog body</div>')->url('http://blog.example.com/2012/08/21/blog-entry/')->author('John Smith')->pubDate(strtotime('Tue, 21 Aug 2012 19:50:37 +0900'))->guid('http://blog.example.com/2012/08/21/blog-entry/', true)->preferCdata(true)->appendTo($channel);
// Podcast item
$item = new Item();
$item->title('Some Podcast Entry')->description('<div>Podcast body</div>')->url('http://podcast.example.com/2012/08/21/podcast-entry/')->enclosure('http://podcast.example.com/2012/08/21/podcast.mp3', 4889, 'audio/mpeg')->appendTo($channel);
echo $feed;
// or echo $feed->render();
示例#24
0
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
require_once "../lib/base.php";
use Symfony\Component\HttpFoundation\Response as HTTPResponse;
use Suin\RSSWriter\Feed as RSSFeed;
use Suin\RSSWriter\Channel as RSSChannel;
use Suin\RSSWriter\Item as RSSItem;
$gl3Path = \Mesamatrix::path(\Mesamatrix::$config->getValue("info", "xml_file"));
$xml = simplexml_load_file($gl3Path);
if (!$xml) {
    \Mesamatrix::$logger->critical("Can't read " . $gl3Path);
    exit;
}
$baseUrl = \Mesamatrix::$request->getSchemeAndHttpHost() . \Mesamatrix::$request->getBasePath();
// prepare RSS
$rss = new RSSFeed();
$channel = new RSSChannel();
$channel->title(\Mesamatrix::$config->getValue("info", "title"))->description(\Mesamatrix::$config->getValue("info", "description"))->url($baseUrl)->appendTo($rss);
$commitWeb = \Mesamatrix::$config->getValue("git", "mesa_web") . "/commit/" . \Mesamatrix::$config->getValue("git", "gl3") . "?id=";
foreach ($xml->commits->commit as $commit) {
    $item = new RSSItem();
    $item->title((string) $commit["subject"])->url($baseUrl . '?commit=' . $commit["hash"])->pubDate((int) $commit["timestamp"])->appendTo($channel);
}
// send response
$response = new HTTPResponse($rss, HTTPResponse::HTTP_OK, ['Content-Type' => 'text/xml']);
$response->prepare(\Mesamatrix::$request);
$response->send();
示例#25
0
use Wurst\Transformer\RecordToCategoryTransformer;
use Wurst\Transformer\RecordToDescriptionTransformer;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Wurst\Transformer\RecordToTitleTransformer;
$app = new Silex\Application();
$app['debug'] = true;
$app->register(new Silex\Provider\TwigServiceProvider(), array('twig.path' => "{$FOLDER_ROOT}/templates"));
$app->register(new Wurst\Provider\WurstServiceProvider(array('path.xml' => $FOLDER_XML, 'path.cache' => $FILE_HISTORY_CACHE)));
/**
 * Main method to calculate rss string from
 * status xml files or from cache
 */
$app->get('/', function (Request $request) use($app, $SERVER_ROOT, $SERVER_ROOT_SCRIPT) {
    $feed = new Feed();
    $channel = new Channel();
    $channel->title('Wurst update status');
    $channel->description("Uni-Hamburg server");
    $channel->url('http://zbh.uni-hamburg.de');
    $channel->appendTo($feed);
    $transformerCategory = new RecordToCategoryTransformer();
    $transformerTitle = new RecordToTitleTransformer($transformerCategory);
    $transformerDescription = new RecordToDescriptionTransformer($app['twig']);
    foreach ($app['wurst.history']->collection() as $id => $element) {
        $item = new Item();
        $item->author("wurst update");
        $item->url("http://{$SERVER_ROOT_SCRIPT}/details/{$id}");
        $item->pubDate($element->getDate());
        $item->title($transformerTitle->transform($element));
        $item->category($transformerCategory->transform($element));
        $item->description($transformerDescription->transform($element));
示例#26
0
 /**
  * Display rss feeds from content category
  * @return string
  * @throws ForbiddenException
  */
 public function actionRss()
 {
     $path = $this->request->getPathWithoutControllerAction();
     $configs = $this->getConfigs();
     // build model data
     $model = new EntityCategoryList($path, $configs, 0);
     // remove global layout
     $this->layout = null;
     // check if rss display allowed for this category
     if ((int) $model->category['configs']['showRss'] !== 1) {
         throw new ForbiddenException(__('Rss feed is disabled for this category'));
     }
     // initialize rss feed objects
     $feed = new Feed();
     $channel = new Channel();
     // set channel data
     $channel->title($model->category['title'])->description($model->category['description'])->url(App::$Alias->baseUrl . '/content/list/' . $model->category['path'])->appendTo($feed);
     // add content data
     if ($model->getContentCount() > 0) {
         foreach ($model->items as $row) {
             $item = new Item();
             // add title, short text, url
             $item->title($row['title'])->description($row['text'])->url(App::$Alias->baseUrl . $row['uri']);
             // add poster
             if ($row['thumb'] !== null) {
                 $item->enclosure(App::$Alias->scriptUrl . $row['thumb'], $row['thumbSize'], 'image/jpeg');
             }
             // append response to channel
             $item->appendTo($channel);
         }
     }
     // define rss read event
     App::$Event->run(static::EVENT_RSS_READ, ['model' => $model, 'feed' => $feed, 'channel' => $channel]);
     // render response from feed object
     return $feed->render();
 }
示例#27
0
文件: feed.php 项目: jgrnt/oe1ToRss
<?php

spl_autoload_register(function ($c) {
    @(include_once strtr($c, '\\_', '//') . '.php');
});
use Suin\RSSWriter\Feed;
use Suin\RSSWriter\Channel;
use Suin\RSSWriter\Item;
date_default_timezone_set('Europe/Vienna');
$feed = new Feed();
$channel = new Channel();
$channel->title("Ö1 " . $_GET["title"])->description("Converted RSS from 7 Tage Ö1")->url('http://oe1.orf.at/konsole')->language('de')->copyright('Copyright 2014')->pubDate(time())->lastBuildDate(time())->ttl(60)->appendTo($feed);
for ($offset = 0; $offset < 7; $offset++) {
    $streamDate = date_sub(new DateTime(NULL), new DateInterval("P" . $offset . "D"));
    $daysProgramm = json_decode(file_get_contents("http://oe1.orf.at/programm/konsole/tag/" . $streamDate->format("Ymd")));
    foreach ($daysProgramm->list as $show) {
        if (preg_match("/^" . $_GET["title"] . "\$/", $show->title)) {
            $item = new Item();
            $itemDate = DateTime::createFromFormat("d.m.YH:i", $show->day_label . $show->time);
            $item->title($show->title)->description($show->info)->enclosure($show->url_stream)->pubDate($itemDate->getTimestamp())->guid($show->id, true)->appendTo($channel);
        }
    }
}
echo $feed;
示例#28
0
function generate_rss($posts)
{
    $feed = new Feed();
    $channel = new Channel();
    $rssLength = config('rss.char');
    $channel->title(blog_title())->description(blog_description())->url(site_url())->appendTo($feed);
    foreach ($posts as $p) {
        if (!empty($rssLength)) {
            if (strlen(strip_tags($p->body)) < config('rss.char')) {
                $string = preg_replace('/\\s\\s+/', ' ', strip_tags($p->body));
                $body = $string . '...' . ' <a class="readmore" href="' . $p->url . '#more">more</a>';
            } else {
                $string = preg_replace('/\\s\\s+/', ' ', strip_tags($p->body));
                $string = substr($string, 0, config('rss.char'));
                $string = substr($string, 0, strrpos($string, ' '));
                $body = $string . '...' . ' <a class="readmore" href="' . $p->url . '#more">more</a>';
            }
        } else {
            $body = $p->body;
        }
        $item = new Item();
        $tags = explode(',', str_replace(' ', '', strip_tags($p->tag)));
        foreach ($tags as $tag) {
            $item->category($tag, site_url() . 'tag/' . $tag);
        }
        $item->title($p->title)->pubDate($p->date)->description($body)->url($p->url)->appendTo($channel);
    }
    echo $feed;
}
示例#29
0
    if (count($messageArray) > 1) {
        $title = $messageArray[0];
        $content = $messageArray[1];
    } else {
        $title = splitMessage(wordwrap($message, $titleLength), "title");
        $content = str_replace($title, "...", $message);
        $title .= "...";
    }
    if ($returnItem == "title") {
        return $title;
    } else {
        return $content;
    }
}
$feed = new Feed();
$channel = new Channel();
$channel->title($channelTitle)->description($channelDesc)->url($channelUrl)->language($channelLanguage)->copyright($channelCopyRight)->pubDate(date("U"))->lastBuildDate(date("U"))->appendTo($feed);
// Make a new request and execute it.
try {
    $posts = (new FacebookRequest($session, 'GET', '/' . $page_id . '/posts'))->execute()->getGraphObject(GraphObject::className())->getPropertyAsArray('data');
    //print_r($posts);
    foreach ($posts as $dings) {
        $type = $dings->getProperty('type');
        $message = $dings->getProperty('message');
        if (empty($message)) {
            continue;
        }
        $id = $dings->getProperty('id');
        $title = splitMessage($message, "title");
        $content = splitMessage($message, "content");
        $createdAt = date("U", strtotime($dings->getProperty('created_time')));
         *
         * $fInfo = new finfo(FILEINFO_MIME_TYPE);
         * $photoType = $fInfo->file($photoInternalPath);
         * unset($fInfo);
         **/
        $photoType = 'image/jpeg';
        $blogPostItem->enclosure("https://blog.jacobemerick.com{$photoPath}", $photoSize, $photoType);
    }
    $blogPostItem->appendTo($blogPostChannel);
}
$buildFeed($blogPostFeed, 'blog');
/*********************************************
 * Then the blog comments
 *********************************************/
$blogCommentFeed = new Feed();
$blogCommentChannel = new Channel();
$blogCommentChannel->title('Jacob Emerick | Blog Comment Feed');
$blogCommentChannel->description('Most recent comments on blog posts of Jacob Emerick');
$blogCommentChannel->url('https://blog.jacobemerick.com');
// todo depends on env
$blogCommentChannel->appendTo($blogCommentFeed);
$query = "\n    SELECT `comment_meta`.`id`, `comment_meta`.`date`, `comment`.`body`, `commenter`.`name`,\n           `post`.`title`, `post`.`category`, `post`.`path`\n    FROM `jpemeric_comment`.`comment_meta`\n    INNER JOIN `jpemeric_comment`.`comment` ON `comment`.`id` = `comment_meta`.`comment`\n    INNER JOIN `jpemeric_comment`.`commenter` ON `commenter`.`id` = `comment_meta`.`commenter` AND\n                                                 `commenter`.`trusted` = :trusted_commenter\n    INNER JOIN `jpemeric_comment`.`comment_page` ON `comment_page`.`id` = `comment_meta`.`comment_page` AND\n                                                    `comment_page`.`site` = :comment_site\n    INNER JOIN `jpemeric_blog`.`post` ON `post`.`path` = `comment_page`.`path` AND\n                                         `post`.`display` = :display_post\n    WHERE `comment_meta`.`display` = :active_comment\n    ORDER BY `comment_meta`.`date` DESC";
$bindings = ['trusted_commenter' => 1, 'comment_site' => 2, 'display_post' => 1, 'active_comment' => 1];
$activeBlogComments = $db->getRead()->fetchAll($query, $bindings);
foreach ($activeBlogComments as $blogComment) {
    $blogCommentItem = new Item();
    $blogCommentItem->title("Comment on '{$blogComment['title']}' from {$blogComment['name']}");
    $url = "https://blog.jacobemerick.com/{$blogComment['category']}/{$blogComment['path']}/";
    $url .= "#comment-{$blogComment['id']}";
    $blogCommentItem->url($url);
    $blogCommentItem->guid($url, true);