!!! See full, ready-to-run app versions (with db dumps, vendors and .git folder) at https://github.com/absent1706/laravel-minihabr-full-app-releases
##v0.10
- user public activity. Show on user public activity section (on user page) next:
- user comments creation
- article create and update
- user follows
- starring articles
##v0.9 Views, stars
-
- article views:
- automatically views increment when someone reads full article
- user can see view history on user page (user can only see own views; but admins can see views of all users)
-
- adding stars to articles:
- AJAX star/unstar link
- user starred articles are displayed on user page
- confirm deleting category on category management page
User follows feature
- ++ user follows:
- AJAX follow button
- display followers and followed users on user page
-
- fixed articles table creation: added foreign key on user_id
-
- display errors NOT attached to form field as notifications (needed if general errors occured):
- in shared.flash partial
- in AJAX error handler (app.s)
- ~+ login form: always display ONE, STANDARD message if any error occured (less code, more secure)
-
- more detailly log errors in debug area (bottom of _app layout) (use getMessages() instead of all() )
-
- log DB queries in debug area (bottom of _app layout)
- structurized and commented routes.php; removed unused passwordUpdate route
- delete_links_hack partial:
- renamed delete_links_hack -> crud_links_hack
- allow links with data-method=POST to be handled with crud-links-hack
- if data-confirm is NOT set, hack will send form without confirming (previously there was a default confirm text 'Are you sure?')
Added password reset, simplified user edit logic
-
- password reset by email; set up fake email sending by means of https://mailtrap.io
- +~ simplified user edit logic:
- now all fields (including email from this version) can be edited throw SINGLE request (update password request is not a different request now), but current password is always required
- changed password update logic (it's done more clear now)
-
- after logout, redirect to root page (not back)
- moved auth middleware registration to routes.php
- normalized 'home' routes:
- removed '/articles' URL.
- now we have '/' URL with name 'articles.index' (main route) and '/home' URL named 'home' for compatibility with Laravel redirects
- middleware: if not permitted, redirect to /, not throw 403. It's important because when I log out from user/article edit page and logout controller redirects me back (as it was in prev versions), I should NOT see 403.
-
- log request params, errors and all session vars in the bottom of layout
Improved arcticle filtering system
- add ability to sort articles PRESERVING current filters (category)
- made filter system extensible: all filters are in filters array. Now the only filter is category, but in future it will be possible to add another filters
-
- is_admin flag for users;
-
- admin user can manage all articles, comments and user profiles
-
- category CRUD for admin users
- provided default data-confirm value for put/delete links (see delete_links_hack template)
- Renamed categories._list partial to widgets.categories
-
~ improved CommentController: added CommentRequest; adapted controller to handle AJAX requests (store method)
-
+++ AJAX create comment: 2.1. + main AJAX code: see comments._create view. If all's OK, then success notification appears. If there're problems,
2.2. + frontend.allow_ajax_crud_requests option: sets whether to use AJAX for comment creating (further - for comment and post deleting too) note: after changing config vars, don't forget to run php artisan config:cache
2.3. + modified app\Exceptions\Handler.php to return errors in JSON format, if request is AJAX if config('app.debug') is true, then additional info provided (class name, message and stack trace)
2.4. + added default AJAX error handler (see app.js): - response is always logged to console - if it's a form validation error, then all errors are displayed as notification - otherwise common error message appears.
- +++ AJAX delete comment:
-
- Use pnotify.js for displaying ALL flash messages: regular and AJAX ones (see flash.blade.php)
- ~ Removed errors_list partial. Now all forms use help-blocks to display errors (except very specific login form which uses notifications)
-
- loading indicator on AJAX requests
-
- CSS class (list-split-hr) for automatically inserting hr lines after comments and articles
- ~ moved JS includes to the head in _app.blade.php
- ~ moved global JS functions to app object
- ~ beautified code in routes.php
Added possibilities to:
- update/delete articles
- delete comments
- update users (including user passwords)
Middleware is used for checking permissions to manage resource, FormRequests are used to validate input.
- Flash messages of various classes: info,success,warning, error (see shared.flash partial); info and success automatically disappear after 5 seconds (see js/app.js file)
- Use Jeffrey Way's unobtrusive JS hack to make links to DELETE http method (code taken from http://stackoverflow.com/a/28420767) + use bootbox.js (http://bootboxjs.com/) for modal confirming (like 'are you sure want to delete article?') - see layouts.parts.delete_links_hack partial
- Custom 403, 404 error pages
Сделал отдельный scope для категорий, pagination. Параметры для отображения статей (метод сортировки и категория) теперь передаются в GET-параметрах. Работают УРЛы типа http://localhost:8000/articles?cat=2&sort=most-commented (однако на фронтенде генерятся ссылки только для категории и только для сортировки).
Сделал pagination страниц user->articles, user->comments
-
как реализован просмотр постов и комментариев юзера (nested routes + отдельные контроллеры UserArticles, UserComments). Так советуют гуру Ларавела.
-
в ArticlesController и CommentsController стоит middleware на проверку, авторизован ли пользователь.
-
всё реализовано по возможности в философии rest (например, когда ты включаешь форму для создания коммента, то она лежит в файле views/comments/create.blade.php)
- (на будущее. это свистелка-перделка, но реализация интересная) ссылки на этой странице https://www.dropbox.com/s/i9ds9nbv298bcn5/%D0%A1%D0%BA%D1%80%D0%B8%D0%BD%D1%88%D0%BE%D1%82%202015-11-09%2022.22.09.png?dl=0
содержат URL, на который мы хотим редиректнуться после авторизации. Типичный случай - хочу оставить комментарий , иду авторизовываться, а после авторизации меня возвращает не на дом. страницу, а на тот пост, откуда я ушёл. Это и реализовано.
URL , на который мы хотим редиректнуться после авторизации, запоминается в middleware RememberReturnUrl.php
Интересно работает. Всё - благодаря переменной сессии url.intended и методу redirect()->intended()
-
использую gravatar пользователя. Он берётся по имейлу . Если такого нет, возвращается картинка, построенная из хэша имейла смотри мой отзыв, ненастойчивые предложения по новым фичам №2 (http://www.evernote.com/l/ANlcvPHnZO1H9rKg3YlU1-i_x8MTHU4b5DI/)
-
передаю title страницы, когда делаю extend во вьюхе
-
использую несколько layout'ов (в поучительных целях)
- нет pagination на фронтенде (хотя если написать /articles/?page=2 заработает)
- пагинации нет потому, что механизм фильтра по категориям и по другим scope'ам (recent, most-commented) работает по-разному. По категориям надо фильтровать так же, как и по дате или кол-ву комментариев. ПРОСМОТР ПОСТОВ В КАТЕГОРИЯХ РЕАЛИЗОВАН КРИВО. Буду переделывать.
Кроме того, должна быть возможность сортировать посты в категории по разным критериям. Т.е. посты должны отбираться по категории и сортироваться по выбранному критерию.
- сущности (посты, комментарии, юзеры) только создаются и просматриваются. Ничего изменять/удалять нельзя. Изменение/удаление не так просто, т.к. требует механизма защиты.
-
flash messaging
-
отдельный scope для категорий
-
pagination
-
update статей, юзера, комментариев - с помощью котроля доступа https://mattstauffer.co/blog/acl-access-control-list-authorization-in-laravel-5-1
-
DB seeds
-
модели rate, follow, view
-
админ-пользователи
-
аттач картинок к постам
-
удаление постов ajax-ом