1
0
mirror of https://github.com/flarum/core.git synced 2025-07-23 09:41:26 +02:00
Commit Graph

112 Commits

Author SHA1 Message Date
Toby Zerner
77d0bfccd7 Rework public API based on events 2015-07-18 22:59:47 +09:30
Toby Zerner
54ab536f96 Fix forgot password action 2015-07-17 14:48:06 +09:30
Toby Zerner
f17c3a2778 Add todos to document magic properties on models 2015-07-07 19:20:18 +09:30
Toby Zerner
23eec806e6 Initial refactor of client actions, data preloading, SEO
An initial stab at flarum/core#126. Still WIP. Preliminary
implementation of flarum/core#128 and flarum/core#13.
2015-07-07 15:29:21 +09:30
Toby Zerner
eee5133d6e Improve post stream
- Return all discussion post IDs from API requests which add/remove
posts, so the post stream updates appropriately. Related to #146
- Always unload posts that are two pages away, no matter how fast
you’re scrolling
- Retrieve posts from cache instead of reloading them
- Fix various bugs. Maybe #152, needs confirmation
2015-07-06 16:26:27 +09:30
Toby Zerner
6fe1c73a49 PSR-2 fixes 2015-07-05 21:46:57 +09:30
Toby Zerner
7cf0fefbbe Remove Interface suffix from some classes 2015-07-05 12:30:23 +09:30
Toby Zerner
c55cc1bd1a Extract model validation into a trait
Also use Laravel’s ValidationException rather than our own custom one
2015-07-05 12:25:08 +09:30
Toby Zerner
f3c4b24ad4 Move Group to its own namespace
We’ll need to add commands etc. for group management in the future
2015-07-04 19:30:58 +09:30
Toby Zerner
ab78546349 Don't error if trying to serialise a non-existent relationship 2015-07-04 18:39:43 +09:30
Toby Zerner
f134345be1 Get rid of Repository interfaces 2015-07-04 18:38:59 +09:30
Toby Zerner
41c5ed0acb Massive refactor
- Use contextual namespaces within Flarum\Core
- Clean up and docblock everything
- Refactor Activity/Notification blueprint stuff
- Refactor Formatter stuff
- Refactor Search stuff
- Upgrade to JSON-API 1.0
- Removed “addedPosts” and “removedPosts” relationships from discussion
API. This was used for adding/removing event posts after renaming a
discussion etc. Instead we should make an additional request to get all
new posts

Todo:
- Fix Extenders and extensions
- Get rid of repository interfaces
- Fix other bugs I’ve inevitably introduced
2015-07-04 12:24:48 +09:30
Franz Liedke
1e640ba632 Get rid of JsonApiResponse class
With the JSON-API library being updated, we can just make use of
Diactoros' JSON response class.
2015-07-01 20:58:14 +02:00
Toby Zerner
09d1c4d8ed Clean up some relation stuff 2015-07-01 22:35:56 +09:30
Toby Zerner
659ca692e3 Refactor CoreServiceProvider
A good start I think, but still some work to do. If we go ahead with
https://github.com/flarum/core/issues/132#issuecomment-117507974 (which
I am in favour of), we can extract the entity-related stuff into some
smaller service providers (e.g. discussion repo, an event listener,
permissions, and gambits stuff could all go in
Flarum\Core\Discussions\DiscussionsServiceProvider).
2015-07-01 22:34:11 +09:30
Franz Liedke
cca97398ae Upgrade Zend Diactoros to 1.1
This gives us a bunch of handy helper classes for empty responses,
redirects, HTML and JSON content types.

Closes flarum/core#153
2015-06-26 22:38:43 +02:00
Toby Zerner
57fc62eaf1 Make sure discussion post IDs are ordered correctly 2015-06-24 18:57:07 +09:30
Toby Zerner
3223f65ce3 Allow author to delete discussion if there are no replies
Also disallow the first post in a discussion to be deleted or hidden
(thus preventing discussions with zero posts)

closes flarum/core#90 closes flarum/core#92
2015-06-23 10:34:33 +09:30
Toby Zerner
dfe1a9bae5 Gracefully handle discussions with no posts
Although this should never happen
2015-06-23 10:30:06 +09:30
Franz Liedke
0c66bd6872 Implement middleware for handling errors according to JSON API spec 2015-06-20 19:45:32 +02:00
Toby Zerner
525af6f168 Cleanup 2015-06-19 17:19:13 +09:30
Toby Zerner
f07e2d9520 Fix newly-created event posts being undeletable 2015-06-19 17:19:09 +09:30
Toby Zerner
1f2e16c4bb Get login/forgot password working again 2015-06-19 11:19:49 +09:30
Toby Zerner
b43f34c120 Roughly implement routes and data preloading
Only preloading data for basic requests w/o query params, at least for
the moment - if we have to preload for something like
/?q=test&sort=newest, we end up having to duplicate a whole lot of
logic between JS/PHP.
2015-06-18 17:41:37 +09:30
Toby Zerner
9b97688898 Merge query params into request input as well 2015-06-18 12:24:51 +09:30
Toby Zerner
02947edf1b Fix fatal error on delete actions 2015-06-18 12:24:31 +09:30
Toby Zerner
6f7a06820d Define static properties on SerializeAction subclasses
Explained in 8a0cf2dcba.

If we ever come up with a better way of doing this it should be easy to
change over, since modification of these properties by extensions is
abstracted by an Extend API.
2015-06-18 12:24:18 +09:30
Toby Zerner
b8fe298b04 Revert "Prefix API routes for now"
This reverts commit 4728b6f414.
2015-06-17 18:14:41 +09:30
Toby Zerner
4728b6f414 Prefix API routes for now 2015-06-17 17:48:50 +09:30
Toby Zerner
2db36916fb Change event so that data can be modified before it is serialized 2015-06-17 12:46:50 +09:30
Franz Liedke
26afeced69 Fix merge conflict 2015-06-17 01:27:44 +02:00
Franz Liedke
0262f45f57 Merge branch 'master' into psr-7
Conflicts:
	src/Api/Actions/Discussions/IndexAction.php
	src/Api/Actions/SerializeAction.php
	src/Core/Formatter/FormatterManager.php
	src/Extend/ForumAssets.php
	src/Forum/Actions/IndexAction.php
	src/Forum/ForumServiceProvider.php
2015-06-17 00:52:50 +02:00
Franz Liedke
b559a32f9e Revamp routing
All routes are now stored in a RouteCollection, which is then used
for dispatching by the (reusable) RouterMiddleware.

This change also entails moving all routes to the service providers.
This may be changed again later, and is done for convenience reasons
right now.
2015-06-17 00:16:35 +02:00
Toby Zerner
8a0cf2dcba Override static property
@franzliedke I didn’t realise that static properties are static to the
class they are defined on, and not each individual subclass. All of the
static members of the SerializeAction class (which are intended for
extensions to alter per-action) are being inherited by all actions.

Any ideas on how to work around this other than defining every static
member on each individual subclass?
2015-06-16 21:55:59 +09:30
Toby Zerner
31369bd806 Overhaul permissions
Get rid of Permissible - too complex and inefficient. Replace with:
- a “Locked” trait which works similarly but only evaluates logic on
hydrated models.
- a “VisibleScope” trait which also works similarly but only scopes
queries

This is all we need, Permissible is overkill. There is only one
instance where we have to duplicate some logic
(Discussion::scopeVisiblePosts and Post::allow(‘view’, …)) but it’s
barely anything.

Haven’t decoupled for now, we can definitely look at doing that later.

Permissions table seeder slightly updated.

Also did a bit of a query audit, there’s still a lot to be done but
it’s much better than it was. Some relatively low-hanging fruit
detailed in EloquentPostRepository.
2015-06-16 17:33:56 +09:30
Toby Zerner
1ff2c2f90a Add WillRespond event
So that custom data can be loaded onto a model before it is serialized.
(Tags extension uses this to load tags onto the forum model.)
2015-06-16 17:22:15 +09:30
Toby Zerner
a890dc2114 Static relationship collections need to be initialised on subclasses
Will probably make this whole “custom relationships” thing a trait
instead of being on the base class
2015-06-16 17:21:04 +09:30
Toby Zerner
320180efc4 Remove total results from discussion searching
It’s too inefficient (requires a whole table scan) to do a query like:
select count(*) from discussions where [conditions determining
visibility]
2015-06-16 16:58:10 +09:30
Toby Zerner
385ebf012d Add a serializer and API action to get information about the forum 2015-06-15 12:18:20 +09:30
Franz Liedke
b94aa11573 Always initialize variable 2015-06-08 09:49:07 +02:00
Franz Liedke
891f9c4032 Merge branch 'master' into psr-7
Conflicts:
	composer.json
	composer.lock
	src/Api/Actions/TokenAction.php
	src/Core/Formatter/FormatterManager.php
	src/Core/Handlers/Events/EmailConfirmationMailer.php
	src/Forum/Actions/ConfirmEmailAction.php
	src/Forum/Actions/IndexAction.php
	src/Forum/Actions/ResetPasswordAction.php
	src/Forum/Actions/SavePasswordAction.php
	src/Forum/routes.php
2015-06-06 13:59:59 +02:00
Toby Zerner
944e5c649c Rejig formatting API. closes flarum/core#85
It works but it’s not the most pretty thing in the world. @franzliedke
Would be great if you could take a look at the whole formatting API and
work your magic on it sometime… my brain is fried!
2015-06-04 10:48:07 +09:30
Toby Zerner
920ad4f04f Implement search on front end 2015-06-03 18:10:56 +09:30
Franz Liedke
0754d64f9b Remove lots of unneeded imports. 2015-06-03 03:20:58 +02:00
Franz Liedke
6c3acd06bf Create an API client class.
This should make it easier to make API calls from the frontends.
2015-06-03 02:39:01 +02:00
Franz Liedke
58b2b474d8 Make JSON parameter middleware a bit more generic 2015-06-03 02:04:00 +02:00
Franz Liedke
00699b69da Fix responses returned by JSON helper. 2015-06-03 02:02:28 +02:00
Toby Zerner
3eed9a99b6 Extract current user attributes into a separate serializer
This prevents the unread notifications count query being run for every
post by the currently authenticated user
2015-06-01 12:25:40 +09:30
Toby Zerner
39e1b8e008 Remove default relationships from serializers 2015-06-01 12:24:06 +09:30
Toby Zerner
731b00571c Eager load notification relationships 2015-05-30 13:57:39 +09:30