public static function generateSitemap($reGenerate = false) { // create new sitemap object $sitemap = App::make("sitemap"); $sitemap->setCache('laravel.sitemap', 3600); if ($reGenerate) { Cache::forget($sitemap->model->getCacheKey()); } // check if there is cached sitemap and build new only if is not if (!$sitemap->isCached()) { // add item to the sitemap (url, date, priority, freq) $sitemap->add(URL::to('/'), null, '1.0', 'daily'); $categories = Category::get(); foreach ($categories as $category) { $sitemap->add(URL::route('category', [$category->slug]), null, '1.0', 'daily'); } // get all lists from db $lists = ViralList::orderBy('created_at', 'desc')->get(); // add every post to the sitemap foreach ($lists as $list) { $sitemap->add(ListHelpers::viewListUrl($list), $list->updated_at, '1.0', 'monthly'); } } // show your sitemap (options: 'xml' (default), 'html', 'txt', 'ror-rss', 'ror-rdf') return $sitemap->render('xml'); }
public function getNotificationData() { $newListCreator = $this->newListCreator; $originalList = $this->originalList; $originalListCreator = $this->originalListCreator; return ['RecipientName' => $originalListCreator->name, 'NewListLink' => '<a href="' . \ListHelpers::viewListUrl($this->newList) . '">' . $this->newList->title . '</a>', 'OriginalListTitle' => $originalList->title, 'OriginalListLink' => '<a href="' . \ListHelpers::viewListUrl($originalList) . '">' . $originalList->title . '</a>', 'NewListCreatorName' => $newListCreator->name]; /* * * TODO: Add NewListCreatorProfileLink after creating user profile pages. * * */ }
public static function generateRssFeed() { $config = Config::get('siteConfig'); // create new feed $feed = Feed::make(); // cache the feed for 10 minutes (second parameter is optional) $feed->setCache(10, 'list-rss-feed'); // check if there is cached feed and build new only if is not if (!$feed->isCached()) { // creating rss feed with our most recent 20 posts $lists = ViralList::orderBy('created_at', 'desc')->take(20)->get(); // set your feed's title, description, link, pubdate and language $feed->title = $config['main']['siteTitle']; $feed->description = @$config['main']['siteDescription']; $feed->logo = @asset($config['main']['logo']); $feed->link = URL::route('rssFeed'); $feed->setDateFormat('datetime'); // 'datetime', 'timestamp' or 'carbon' $feed->pubdate = $lists->count() ? $lists[0]->created_at : time(); $feed->lang = $config['languages']['activeLanguage']; $feed->setShortening(true); // true or false $feed->setTextLimit(100); // maximum length of description text foreach ($lists as $list) { // set item's title, author, url, pubdate, description and content $listContentHtml = View::make('lists.rssFeedListContent', ['list' => $list]); $feed->add($list->title, $list->creator->name, ListHelpers::viewListUrl($list), $list->created_at->toDateTimeString(), $list->description, $listContentHtml); } } // 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('rss'); // to return your feed as a string set second param to -1 // $xml = $feed->render('atom', -1); }
public function getNotificationData() { $creator = $this->creator; return ['RecipientName' => $creator->name, 'ListTitle' => $this->list->title, 'ListLink' => '<a href="' . \ListHelpers::viewListUrl($this->list) . '">' . $this->list->title . '</a>', 'ListUrl' => \ListHelpers::viewListUrl($this->list)]; }
public static function saveOgImage($list) { $imagePath = public_path($list->image); $ogImagePath = ListHelpers::getListOGPathFromImage($imagePath); try { $image = self::getOgImageObject($list); $image->save($ogImagePath); } catch (Intervention\Image\Exception\NotReadableException $e) { throw new Exception('Error saving thumbnail! Invalid image!'); } catch (Intervention\Image\Exception\NotWritableException $e) { throw new Exception('Error saving thumbnail! Permission issue! Contact site admin'); } }