Exemplo n.º 1
0
 protected function schedule(Schedule $schedule)
 {
     // $schedule->command('inspire')
     //          ->hourly();
     $schedule->call(function () {
         // Process the Feeds
         \p4\Libraries\RSSParser::processFeeds();
     })->hourly();
     $schedule->call(function () {
         // Process the Feeds
         \p4\Libraries\RSSParser::updateTagScores();
     })->daily();
     $schedule->call(function () {
         // Process the Feeds
         \p4\Libraries\RSSParser::removeOldArticles(env('ARTICLE_KEEP_DAYS', 90));
     })->weekly();
     $schedule->call(function () {
         // Process the Feeds
         \p4\Libraries\RSSParser::processTrending();
     })->daily();
 }
Exemplo n.º 2
0
 public static function processTrending()
 {
     $sql = "DELETE FROM trending";
     \DB::update(\DB::raw($sql));
     \p4\Libraries\RSSParser::updateTrending(-90, -30, 30);
     \p4\Libraries\RSSParser::updateTrending(-21, -7, 7);
     \p4\Libraries\RSSParser::updateTrending(-7, -1, 1);
 }
Exemplo n.º 3
0
 public function processTrending()
 {
     #Used for testing the downloading of articles
     \p4\Libraries\RSSParser::processTrending();
 }
Exemplo n.º 4
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     // This will automatically populate the feeds with real articles
     \p4\Libraries\RSSParser::processFeeds();
 }
Exemplo n.º 5
0
 public function postAddFeed(Request $request)
 {
     $user_id = \Auth::user()->id;
     #Validate User Input
     $input = array('feed-url' => $request->input('feed-url'), 'feed-name' => $request->input('feed-name'), 'feed_category' => $request->input('add-feed-category'), 'new-feed-weight' => $request->input('new-feed-weight'));
     $validator = Validator::make($input, ['feed-url' => 'required|url', 'feed-name' => 'required|min:3|max:50', 'feed_category' => 'required|integer|min:0', 'new-feed-weight' => 'required|integer|min:1|max:100']);
     #dd($request->input('add-feed-category'));
     if ($validator->fails()) {
         return redirect('/Manage')->withErrors($validator)->withInput();
     }
     $feed_url = $request->input('feed-url');
     $feed_name = $request->input('feed-name');
     $feed_weight = $request->input('new-feed-weight');
     $categoryID = $request->input('add-feed-category');
     #Add Feed to the Feeds table (if it does not already exist)
     if (!\p4\Feed::where('feed_url', '=', $feed_url)->exists()) {
         $feed = new \p4\Feed();
         $feed->feed_url = $feed_url;
         $feed->next_update = new \DateTime();
         $feed->last_updated = new \DateTime();
         $feed->status = 'A';
         $feed->save();
         # Try to auto-load articles for the first time if it is a new feed.
         # If the URL is not a valid RSS feed, do not allow the user to add it, send back an error message instead.
         try {
             \p4\Libraries\RSSParser::getFeed($feed);
         } catch (\Exception $e) {
             # If the feed is not valid, remove it and tell the user
             $feed->delete();
             \Session::flash('message', '"The URL does not appear to point to a valid RSS feed. Please verify and try again."');
             return \Redirect::to('/Manage');
         }
     } else {
         $feed = \p4\Feed::where('feed_url', '=', $feed_url)->first();
     }
     #Add Feed to the Users_Feeds table
     $user_feed = new \p4\UserFeed();
     $user_feed->user_id = $user_id;
     $user_feed->feed_id = $feed->id;
     $user_feed->feed_name = $feed_name;
     $user_feed->category_id = $categoryID;
     $user_feed->weight = $feed_weight;
     $user_feed->save();
     # Update the Session Feeds so the updated list will appear in the left nav
     \p4\User::setSessionFeeds($user_id);
     return \Redirect::to('/Manage');
 }