From 1aa0b5f9d7bee23363b9d1842d9e6e98686e08d8 Mon Sep 17 00:00:00 2001 From: Peter Deltchev Date: Wed, 16 Sep 2015 12:55:15 -0700 Subject: [PATCH] Closes T360: Replace the dev blog feed with the Twitter feed. --- .../Api/Web/DashboardController.php | 15 +--- app/News.php | 70 ------------------ composer.json | 1 - composer.lock | 71 +++---------------- public/templates/dashboard/index.html | 29 ++++---- public/templates/home/index.html | 27 +++---- .../scripts/app/controllers/dashboard.coffee | 9 +-- .../scripts/app/controllers/home.coffee | 4 +- 8 files changed, 44 insertions(+), 182 deletions(-) delete mode 100644 app/News.php diff --git a/app/Http/Controllers/Api/Web/DashboardController.php b/app/Http/Controllers/Api/Web/DashboardController.php index 727cacfd..3567bad2 100644 --- a/app/Http/Controllers/Api/Web/DashboardController.php +++ b/app/Http/Controllers/Api/Web/DashboardController.php @@ -3,9 +3,7 @@ namespace App\Http\Controllers\Api\Web; use App\Http\Controllers\ApiControllerBase; -use App\News; use App\Track; -use Cover; use Illuminate\Support\Facades\Auth; use Illuminate\Support\Facades\Input; use Illuminate\Support\Facades\Response; @@ -32,16 +30,7 @@ class DashboardController extends ApiControllerBase return Response::json([ 'recent_tracks' => $recentTracks, - 'popular_tracks' => Track::popular(30, Auth::check() && Auth::user()->can_see_explicit_content), - 'news' => News::getNews(0, 10) + 'popular_tracks' => Track::popular(30, Auth::check() && Auth::user()->can_see_explicit_content) ], 200); } - - public function postReadNews() - { - News::markPostAsRead(Input::get('url')); - - return Response::json([ - ]); - } -} \ No newline at end of file +} diff --git a/app/News.php b/app/News.php deleted file mode 100644 index 27f721eb..00000000 --- a/app/News.php +++ /dev/null @@ -1,70 +0,0 @@ -cache = false; - $feed->set_feed_url('http://mlpforums.com/blog/rss/404-ponyfm-development-blog/'); - $feed->init(); - $feed->handle_content_type(); - - $posts = $feed->get_items($start, $end); - $postHashes = []; - - foreach ($posts as $post) { - $postHashes[] = self::calculateHash($post->get_permalink()); - } - - if (count($postHashes) == 0) { - return []; - } - - $seenRecords = Auth::check() ? self::where('user_id', '=', Auth::user()->id)->whereIn('post_hash', - $postHashes)->get() : []; - $seenHashes = []; - - foreach ($seenRecords as $record) { - $seenHashes[$record->post_hash] = 1; - } - - $postsReturn = []; - - // This date is around when the last blog post was posted as of now. - // I put in a cutoff so that blog posts made before this update is pushed are always marked as 'read' - $readCutoffDate = mktime(null, null, null, 4, 28, 2013); - - foreach ($posts as $post) { - $autoRead = $post->get_date('U') < $readCutoffDate; - $postsReturn[] = [ - 'title' => $post->get_title(), - 'date' => $post->get_date('j F Y g:i a'), - 'url' => $post->get_permalink(), - 'read' => $autoRead || isset($seenHashes[self::calculateHash($post->get_permalink())]) - ]; - } - - return $postsReturn; - } - - public static function markPostAsRead($postUrl) - { - $postHash = self::calculateHash($postUrl); - $news = new News(); - $news->user_id = Auth::user()->id; - $news->post_hash = $postHash; - $news->save(); - } - - private static function calculateHash($postPermalink) - { - return md5($postPermalink); - } -} \ No newline at end of file diff --git a/composer.json b/composer.json index a5146fc5..8b8ea866 100644 --- a/composer.json +++ b/composer.json @@ -9,7 +9,6 @@ "laravel/framework": "5.1.*", "codescale/ffmpeg-php": "2.7.0", "kriswallsmith/assetic": "1.2.*@dev", - "simplepie/simplepie": "1.3.1", "intouch/laravel-newrelic": "*", "barryvdh/laravel-ide-helper": "^2.1" }, diff --git a/composer.lock b/composer.lock index 12939c00..46e3e19d 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,8 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "hash": "d034b42b177f410db0ab3fc82a278346", + "hash": "9079e8e598ee7e2caa54fdc23e02e0c1", + "content-hash": "de0cc2821022365e5f198a9e5ba3be3f", "packages": [ { "name": "barryvdh/laravel-ide-helper", @@ -555,16 +556,16 @@ }, { "name": "kriswallsmith/assetic", - "version": "1.2.x-dev", + "version": "dev-master", "source": { "type": "git", "url": "https://github.com/kriswallsmith/assetic.git", - "reference": "182bfb92b61df601b6eb5676bcb3c91eb5fad57a" + "reference": "5bea57990f7ddbeb3d57e7ef96eae9ddd56c4297" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/kriswallsmith/assetic/zipball/182bfb92b61df601b6eb5676bcb3c91eb5fad57a", - "reference": "182bfb92b61df601b6eb5676bcb3c91eb5fad57a", + "url": "https://api.github.com/repos/kriswallsmith/assetic/zipball/5bea57990f7ddbeb3d57e7ef96eae9ddd56c4297", + "reference": "5bea57990f7ddbeb3d57e7ef96eae9ddd56c4297", "shasum": "" }, "require": { @@ -579,8 +580,8 @@ "leafo/scssphp": "*", "leafo/scssphp-compass": "*", "mrclay/minify": "*", - "patchwork/jsqueeze": "~1.0", - "phpunit/phpunit": "~4", + "patchwork/jsqueeze": "*", + "phpunit/phpunit": "~3.7", "psr/log": "~1.0", "ptachoire/cssembed": "*", "twig/twig": "~1.6" @@ -625,7 +626,7 @@ "compression", "minification" ], - "time": "2015-08-05 10:14:34" + "time": "2014-07-08 11:30:40" }, { "name": "laravel/framework", @@ -1207,60 +1208,6 @@ ], "time": "2015-07-16 15:26:57" }, - { - "name": "simplepie/simplepie", - "version": "1.3.1", - "source": { - "type": "git", - "url": "https://github.com/simplepie/simplepie.git", - "reference": "ce53709778bc1e2e4deda1651b66e5081398d5cc" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/simplepie/simplepie/zipball/ce53709778bc1e2e4deda1651b66e5081398d5cc", - "reference": "ce53709778bc1e2e4deda1651b66e5081398d5cc", - "shasum": "" - }, - "require": { - "php": ">=5.2.0" - }, - "type": "library", - "autoload": { - "psr-0": { - "SimplePie": "library" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Ryan Parman", - "homepage": "http://ryanparman.com/", - "role": "Creator, alumnus developer" - }, - { - "name": "Geoffrey Sneddon", - "homepage": "http://gsnedders.com/", - "role": "Alumnus developer" - }, - { - "name": "Ryan McCue", - "email": "me@ryanmccue.info", - "homepage": "http://ryanmccue.info/", - "role": "Developer" - } - ], - "description": "A simple Atom/RSS parsing library for PHP", - "homepage": "http://simplepie.org/", - "keywords": [ - "atom", - "feeds", - "rss" - ], - "time": "2012-10-30 17:54:03" - }, { "name": "swiftmailer/swiftmailer", "version": "v5.4.1", diff --git a/public/templates/dashboard/index.html b/public/templates/dashboard/index.html index 752af030..723a0ad7 100644 --- a/public/templates/dashboard/index.html +++ b/public/templates/dashboard/index.html @@ -2,30 +2,33 @@

see more - The Newest Tunes + The newest tunes

- read all - Pony.fm News + follow @ponyfm + Pony.fm news

- + +
- \ No newline at end of file + diff --git a/public/templates/home/index.html b/public/templates/home/index.html index 29291818..c101cc24 100644 --- a/public/templates/home/index.html +++ b/public/templates/home/index.html @@ -2,14 +2,14 @@

see more - The Newest Tunes + The newest tunes

@@ -26,15 +26,18 @@

read all - Pony.fm News + Pony.fm news

- + Tweets by + @ponyfm + - \ No newline at end of file + diff --git a/resources/assets/scripts/app/controllers/dashboard.coffee b/resources/assets/scripts/app/controllers/dashboard.coffee index 1e7014bf..5e4a385c 100644 --- a/resources/assets/scripts/app/controllers/dashboard.coffee +++ b/resources/assets/scripts/app/controllers/dashboard.coffee @@ -8,15 +8,8 @@ angular.module('ponyfm').controller "dashboard", [ ($scope, dashboard, auth, $http) -> $scope.recentTracks = null $scope.popularTracks = null - $scope.news = null dashboard.refresh().done (res) -> $scope.recentTracks = res.recent_tracks $scope.popularTracks = res.popular_tracks - $scope.news = res.news - - $scope.markAsRead = (post) -> - if auth.data.isLogged - $http.post('/api/web/dashboard/read-news', {url: post.url, _token: window.pfm.token}).success -> - post.read = true -] \ No newline at end of file +] diff --git a/resources/assets/scripts/app/controllers/home.coffee b/resources/assets/scripts/app/controllers/home.coffee index d9ca38ea..aa1c47f0 100644 --- a/resources/assets/scripts/app/controllers/home.coffee +++ b/resources/assets/scripts/app/controllers/home.coffee @@ -8,10 +8,8 @@ angular.module('ponyfm').controller "home", [ ($scope, dashboard) -> $scope.recentTracks = null $scope.popularTracks = null - $scope.news = null dashboard.refresh().done (res) -> $scope.recentTracks = res.recent_tracks $scope.popularTracks = res.popular_tracks - $scope.news = res.news -] \ No newline at end of file +]