diff --git a/app/controllers/Api/Web/DashboardController.php b/app/controllers/Api/Web/DashboardController.php
index b0384a9b..343b2ef6 100644
--- a/app/controllers/Api/Web/DashboardController.php
+++ b/app/controllers/Api/Web/DashboardController.php
@@ -34,4 +34,10 @@
'popular_tracks' => Track::popular(30, Auth::check() && Auth::user()->can_see_explicit_content),
'news' => News::getNews(0, 10)], 200);
}
+
+ public function postReadNews() {
+ News::markPostAsRead(Input::get('url'));
+ return Response::json([
+ ]);
+ }
}
\ No newline at end of file
diff --git a/app/models/Entities/News.php b/app/models/Entities/News.php
index 4d8b3a5a..bb0435aa 100644
--- a/app/models/Entities/News.php
+++ b/app/models/Entities/News.php
@@ -20,7 +20,7 @@
$postHashes[] = self::calculateHash($post->get_permalink());
}
- $seenRecords = self::where('user_id', '=', Auth::user()->id)->whereIn('post_hash', $postHashes)->get();
+ $seenRecords = Auth::check() ? self::where('user_id', '=', Auth::user()->id)->whereIn('post_hash', $postHashes)->get() : [];
$seenHashes = [];
foreach ($seenRecords as $record) {
@@ -36,11 +36,9 @@
foreach ($posts as $post) {
$autoRead = $post->get_date('U') < $readCutoffDate;
$postsReturn[] = [
- 'post' => [
- 'title' => $post->get_title(),
- 'date' => $post->get_date('j F Y g:i a'),
- 'url' => $post->get_permalink()
- ],
+ '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())])];
}
@@ -49,7 +47,9 @@
public static function markPostAsRead($postUrl) {
$postHash = self::calculateHash($postUrl);
- $news = News::create(['user_id' => Auth::user()->id, 'post_hash' => $postHash]);
+ $news = new News();
+ $news->user_id = Auth::user()->id;
+ $news->post_hash = $postHash;
$news->save();
}
diff --git a/app/routes.php b/app/routes.php
index 9bcfead5..70292be1 100644
--- a/app/routes.php
+++ b/app/routes.php
@@ -92,6 +92,8 @@
Route::post('/favourites/toggle', 'Api\Web\FavouritesController@postToggle');
Route::post('/follow/toggle', 'Api\Web\FollowController@postToggle');
+
+ Route::post('/dashboard/read-news', 'Api\Web\DashboardController@postReadNews');
});
Route::group(['before' => 'auth'], function() {
diff --git a/bootstrap/compiled.php b/bootstrap/compiled.php
index 20026219..bdd50c2f 100644
--- a/bootstrap/compiled.php
+++ b/bootstrap/compiled.php
@@ -2976,8 +2976,7 @@ class ExceptionHandler
%d/%d %s: %s
-
-', $ind, $total, $class, $message);
+ ', $ind, $total, $class, $message);
foreach ($e['trace'] as $trace) {
$content .= ' - ';
if ($trace['function']) {
@@ -3006,7 +3005,7 @@ class ExceptionHandler
}
}
}
- return "
\r\n
{$title}
\r\n {$content}\r\n ";
+ return " \n
{$title}
\n {$content}\n ";
}
public function getStylesheet(FlattenException $exception)
{
@@ -3063,7 +3062,7 @@ class ExceptionHandler
}
private function decorate($content, $css)
{
- return "\r\n\r\n \r\n \r\n \r\n \r\n \r\n \r\n {$content}\r\n \r\n";
+ return "\n\n \n \n \n \n \n \n {$content}\n \n";
}
private function abbrClass($class)
{
diff --git a/public/asset.php b/public/asset.php
index b314662e..ce56ef1c 100644
--- a/public/asset.php
+++ b/public/asset.php
@@ -33,7 +33,7 @@
$bundle->setTargetPath($filePath);
}
-// $bundle = new AssetCache($bundle, new FilesystemCache("$cacheDirectory/scripts"));
+ $bundle = new AssetCache($bundle, new FilesystemCache("$cacheDirectory/scripts"));
} else if ($_GET['type'] == 'less') {
header('Content-Type: text/css');
diff --git a/public/scripts/app/controllers/dashboard.coffee b/public/scripts/app/controllers/dashboard.coffee
index 2b0ab6a8..1e7014bf 100644
--- a/public/scripts/app/controllers/dashboard.coffee
+++ b/public/scripts/app/controllers/dashboard.coffee
@@ -4,8 +4,8 @@ window.pfm.preloaders['dashboard'] = [
]
angular.module('ponyfm').controller "dashboard", [
- '$scope', 'dashboard'
- ($scope, dashboard) ->
+ '$scope', 'dashboard', 'auth', '$http'
+ ($scope, dashboard, auth, $http) ->
$scope.recentTracks = null
$scope.popularTracks = null
$scope.news = null
@@ -14,4 +14,9 @@ angular.module('ponyfm').controller "dashboard", [
$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/public/scripts/app/controllers/home.coffee b/public/scripts/app/controllers/home.coffee
index aedb8829..d9ca38ea 100644
--- a/public/scripts/app/controllers/home.coffee
+++ b/public/scripts/app/controllers/home.coffee
@@ -8,8 +8,10 @@ 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
diff --git a/public/styles/dashboard.less b/public/styles/dashboard.less
index f960a570..9fa4b3a6 100644
--- a/public/styles/dashboard.less
+++ b/public/styles/dashboard.less
@@ -33,7 +33,16 @@
}
}
-.recent-tracks {
+@media (max-width: 720px) {
+ html .dashboard {
+ section {
+ float: none !important;
+ width: auto !important;
+ }
+ }
+}
+
+.dashboard {
h1 {
a {
color: #fff;
@@ -46,9 +55,7 @@
padding: 5px;
}
}
-}
-.dashboard {
section {
.box-sizing(border-box);
@@ -66,5 +73,44 @@
.news {
width: 25%;
+
+ ul {
+ list-style: none;
+ padding: 0px;
+ margin: 0px;
+
+ li {
+ margin: 0px;
+ padding: 0px;
+
+ &.read {
+ a {
+ background: #eee;
+ border-left-color: #ddd;
+ }
+ }
+
+ a {
+ .ellipsis();
+
+ color: #000;
+ display: block;
+ padding: 5px;
+ font-size: 10pt;
+ background: lighten(@pfm-purple, 30%);
+ border-left: 5px solid @pfm-purple;
+ margin: 5px 0px;
+ overflow: hidden;
+
+ em {
+ display: block;
+ color: #444;
+ float: right;
+ font-size: 8pt;
+ font-style: normal;
+ }
+ }
+ }
+ }
}
}
diff --git a/public/styles/layout.less b/public/styles/layout.less
index f951a84b..9e640ec4 100644
--- a/public/styles/layout.less
+++ b/public/styles/layout.less
@@ -9,6 +9,7 @@ html body {
height: 100%;
background: #444;
font-family: "Helvetica Neue", Helvetica, Arial, "Lucida Grande", sans-serif;
+ padding: 0px !important;
}
header {
diff --git a/public/templates/dashboard/index.html b/public/templates/dashboard/index.html
index 49fbef89..752af030 100644
--- a/public/templates/dashboard/index.html
+++ b/public/templates/dashboard/index.html
@@ -15,12 +15,15 @@
- Pony.fm News
+
+ read all
+ Pony.fm News
+
diff --git a/public/templates/home/index.html b/public/templates/home/index.html
index 0f842bfd..9bc3a8cd 100644
--- a/public/templates/home/index.html
+++ b/public/templates/home/index.html
@@ -1,33 +1,31 @@
-
-
-
Welcome to Pony.fm
-
The pony fan music site. By a brony, for bronies.
-
- We provide a comprehensive set of free tools to host, distribute, and catalogue your music, integrated with a rich community experience for artists and listeners alike.
-
-
- Features include unlimited downloads, unlimited uploads, lossless uploads and much more! Click here to get all of our features!
-
-
+
+
-
-
+
+
+ What's Popular Today
+
+
+
-
-
-
- What's Popular Today
-
-
-
-
-
+
\ No newline at end of file
diff --git a/spa.pony.fm.iml b/spa.pony.fm.iml
index 156eebe7..dafc11e8 100644
--- a/spa.pony.fm.iml
+++ b/spa.pony.fm.iml
@@ -67,7 +67,6 @@
-
@@ -106,7 +105,6 @@
-