} else { if (isset($article)) { $writing_type = 'SINGLE_WRITING_TYPE'; } } // 4. Single Article Settings if ($writing_type == 'SINGLE_WRITING_TYPE') { // 4.1. General $site_title = $article->title . ' — ' . Config::get('settings.title'); $og_description = Thinker::limitMarkdownText($article->text, 159); $og_type = 'article'; if ($article->image) { $og_image = $article->image; } else { if ($article->video) { $og_image = Thinker::getVideoThumb($article->video); } } // 4.2. Cover or not if ($article->image == '') { // 4.2.1. Article w/o cover $header_classes = 'c-header--relative'; $cover_active = false; } else { // 4.2.2. Article w/ cover $cover_subtitle = $article->title; if (strlen($article->title) > 40) { $cover_classes_title_b = 'c-cover__title-b--small'; } $cover_image = $article->image; $cover_classes .= 'is-faded is-fullscreen';
public function getFeed(Request $request) { // create new feed $feed = App::make("feed"); // cache the feed for 60 minutes (second parameter is optional) $feed->setCache(60, 'laravelFeedKey'); // check if there is cached feed and build new only if is not if (!$feed->isCached()) { $default_author = 'Nono Martínez Alonso'; // creating rss feed with our most recent articles $show = Config::get('writing.feed.show'); $articles = Article::published()->public()->rss()->orderBy('published_at', 'DESC')->take($show)->get(); // set your feed's title, description, link, pubdate and language $feed->title = Config::get('writing.feed.title'); $feed->description = Config::get('writing.feed.description'); $feed->logo = Config::get('writing.feed.logo'); $feed->link = \URL::to('/' . Writing::path()); $feed->setDateFormat('datetime'); // 'datetime', 'timestamp' or 'carbon' $feed->pubdate = $articles[0]->published_at; $feed->lang = 'en'; $feed->setShortening(false); // true or false $feed->setTextLimit(159); // maximum length of description text $feed->setView("writing::feed.rss"); foreach ($articles as $article) { // set item's title, author, url, pubdate, description and content $imageURL = ''; $image = ''; if ($article->image) { $image = '<p><img src="' . $article->image . '" alt="' . $article->title . '"></p>'; } if ($article->video) { $image = '<p><a href="' . $request->root() . '/' . Writing::path() . $article->slug . '">' . '<img src="' . \Thinker::getVideoThumb($article->video) . '" alt="' . $article->title . '"></a></p>'; } if ($imageURL != '') { $image = '<p><img src="' . $imageURL . '" alt="' . $article->title . '"></p>'; } $feed->add($article->title, $default_author, \URL::to(Writing::path() . $article->slug), $article->published_at, '', str_replace('<img', '<img width="100%"', $image . \Markdown::string($article->text))); } } // first param is the feed format // optional: second param is cache duration (value of 0 turns off caching) // optional: you can set custom cache key with 3rd param as string //return $feed->render('atom'); return \Response::make($feed->render('rss', -1), 200, array('Content-Type' => 'text/xml', 'Cache-Control' => 'no-cache')); // to return your feed as a string set second param to -1 // $xml = $feed->render('atom', -1); }