mirror of
https://github.com/BookStackApp/BookStack.git
synced 2025-05-23 23:29:59 +08:00
Added view count tracking with personalised lists
This commit is contained in:
@ -11,6 +11,7 @@ use BookStack\Http\Requests;
|
||||
use BookStack\Repos\BookRepo;
|
||||
use BookStack\Repos\ChapterRepo;
|
||||
use BookStack\Repos\PageRepo;
|
||||
use Views;
|
||||
|
||||
class BookController extends Controller
|
||||
{
|
||||
@ -41,7 +42,8 @@ class BookController extends Controller
|
||||
public function index()
|
||||
{
|
||||
$books = $this->bookRepo->getAllPaginated(10);
|
||||
return view('books/index', ['books' => $books]);
|
||||
$recents = $this->bookRepo->getRecentlyViewed(10, 0);
|
||||
return view('books/index', ['books' => $books, 'recents' => $recents]);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -86,6 +88,7 @@ class BookController extends Controller
|
||||
public function show($slug)
|
||||
{
|
||||
$book = $this->bookRepo->getBySlug($slug);
|
||||
Views::add($book);
|
||||
return view('books/show', ['book' => $book, 'current' => $book]);
|
||||
}
|
||||
|
||||
|
@ -10,6 +10,7 @@ use BookStack\Http\Requests;
|
||||
use BookStack\Http\Controllers\Controller;
|
||||
use BookStack\Repos\BookRepo;
|
||||
use BookStack\Repos\ChapterRepo;
|
||||
use Views;
|
||||
|
||||
class ChapterController extends Controller
|
||||
{
|
||||
@ -79,6 +80,7 @@ class ChapterController extends Controller
|
||||
{
|
||||
$book = $this->bookRepo->getBySlug($bookSlug);
|
||||
$chapter = $this->chapterRepo->getBySlug($chapterSlug, $book->id);
|
||||
Views::add($chapter);
|
||||
return view('chapters/show', ['book' => $book, 'chapter' => $chapter, 'current' => $chapter]);
|
||||
}
|
||||
|
||||
|
@ -2,13 +2,12 @@
|
||||
|
||||
namespace BookStack\Http\Controllers;
|
||||
|
||||
use Activity;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
use BookStack\Http\Requests;
|
||||
use BookStack\Http\Controllers\Controller;
|
||||
use BookStack\Repos\BookRepo;
|
||||
use BookStack\Services\ActivityService;
|
||||
use BookStack\Services\Facades\Activity;
|
||||
use Views;
|
||||
|
||||
class HomeController extends Controller
|
||||
{
|
||||
@ -18,12 +17,10 @@ class HomeController extends Controller
|
||||
|
||||
/**
|
||||
* HomeController constructor.
|
||||
* @param ActivityService $activityService
|
||||
* @param BookRepo $bookRepo
|
||||
*/
|
||||
public function __construct(ActivityService $activityService, BookRepo $bookRepo)
|
||||
public function __construct(BookRepo $bookRepo)
|
||||
{
|
||||
$this->activityService = $activityService;
|
||||
$this->bookRepo = $bookRepo;
|
||||
parent::__construct();
|
||||
}
|
||||
@ -36,9 +33,9 @@ class HomeController extends Controller
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$books = $this->bookRepo->getAll(10);
|
||||
$activity = $this->activityService->latest();
|
||||
return view('home', ['books' => $books, 'activity' => $activity]);
|
||||
$activity = Activity::latest();
|
||||
$recentlyViewed = Views::getUserRecentlyViewed(10, 0);
|
||||
return view('home', ['activity' => $activity, 'recents' => $recentlyViewed]);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -10,6 +10,7 @@ use BookStack\Http\Requests;
|
||||
use BookStack\Repos\BookRepo;
|
||||
use BookStack\Repos\ChapterRepo;
|
||||
use BookStack\Repos\PageRepo;
|
||||
use Views;
|
||||
|
||||
class PageController extends Controller
|
||||
{
|
||||
@ -86,6 +87,7 @@ class PageController extends Controller
|
||||
{
|
||||
$book = $this->bookRepo->getBySlug($bookSlug);
|
||||
$page = $this->pageRepo->getBySlug($pageSlug, $book->id);
|
||||
Views::add($page);
|
||||
return view('pages/show', ['page' => $page, 'book' => $book, 'current' => $page]);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user