Commit Graph

514 Commits

Author SHA1 Message Date
Toby Zerner
53326e509c Number is a filter, not page param 2015-07-23 14:34:19 +09:30
Toby Zerner
5b54a122c9 Notification one-per-user limit should work between instances 2015-07-23 14:33:58 +09:30
Toby Zerner
6d57f902b3 Ensure we don't preload index data on non-index pages 2015-07-23 14:33:31 +09:30
Toby Zerner
b699bbadbc Make formatter extensible 2015-07-23 14:29:33 +09:30
Toby Zerner
34b7a2fbf6 Move locale files 2015-07-22 16:05:24 +09:30
Toby Zerner
8442f65cdf Fix post visibility scoping 2015-07-22 16:05:11 +09:30
Toby Zerner
017c258e46 Live preview of post editing/replying thanks to TextFormatter 👏 2015-07-22 16:05:00 +09:30
Toby Zerner
a0fe68272c Implement TextFormatter for posts
Get rid of formatting on user bios, we'll do that with JavaScript
2015-07-22 16:03:48 +09:30
Toby Zerner
6c50f1614b Group assets by client in extension stub 2015-07-22 10:12:11 +09:30
Toby Zerner
4fb292a777 Always use default includes when preloading discussion list
Making them explicit causes problems when extensions want to include
something by default (e.g. tags)
2015-07-22 10:11:23 +09:30
Toby Zerner
57f55c2dd6 Improve forum route registration API 2015-07-22 10:04:22 +09:30
Toby Zerner
c697c734d5 Don't run gambits if there's no search query 2015-07-22 09:57:52 +09:30
Toby Zerner
e1a51f095f Random cleanup 2015-07-22 09:57:25 +09:30
Toby Zerner
d410746c51 Fix new notifications on old subjects not appearing 2015-07-20 18:20:34 +09:30
Toby Zerner
c287d40072 Fix incorrect variable name 2015-07-20 18:10:11 +09:30
Toby Zerner
3820b8c65f Fix incorrect member visibility on event 2015-07-20 18:10:04 +09:30
Toby Zerner
605c56ce3c Update extension generator 2015-07-20 18:08:50 +09:30
Toby Zerner
6b7cf1b6bf Rework extension bootstrapping
System JS modules don't execute when they're registered, so we need to
import them explicitly. While we're at it, we may as well make the
locale bootstrapper a module too.
2015-07-20 18:08:28 +09:30
Toby Zerner
19fe138770 Change order of bootstrapping
See commit on flarum/flarum for explanation
2015-07-20 18:01:08 +09:30
Toby Zerner
57650fa648 Rework public API based on events 2015-07-18 22:59:47 +09:30
Toby Zerner
6ae270db95 Remove duplicates; replace missing commas 2015-07-17 17:47:53 +09:30
Toby Zerner
f93ff7cb3f Make front-end localizable 2015-07-17 17:43:28 +09:30
Toby Zerner
ea29bd42d8 Merge remote-tracking branch 'origin/master' 2015-07-17 15:05:03 +09:30
Toby Zerner
bc750c8694 Fix login action 2015-07-17 14:48:24 +09:30
Toby Zerner
e3bfa8e404 Fix notifications 2015-07-17 14:48:20 +09:30
Toby Zerner
6fa4d25a5b Fix forgot password action 2015-07-17 14:48:06 +09:30
Franz Liedke
fab9bdb0ef Remove unused import 2015-07-16 00:44:02 +02:00
Franz Liedke
48c5574c66 Try to fix some namespace imports 2015-07-16 00:43:49 +02:00
Franz Liedke
9af1519864 Rename import command 2015-07-16 00:38:27 +02:00
Franz Liedke
6b3a86dd87 Move extension loading to boot method
This will likely have to be reverted, to make things like $this->app->extend() work
reasonably well in extensions' service providers.

For now, since we fetch the enabled extensions from the config, there is no other way
for us to guarantee that the config is already available.
2015-07-16 00:36:14 +02:00
Franz Liedke
c2bf0b6b3a Inject SettingsRepository where possible 2015-07-16 00:32:50 +02:00
Franz Liedke
31e9f44dfb Rename caching setting repository implementation
I'm foreseeing another implementation that uses real caching (across requests).
2015-07-16 00:10:52 +02:00
Franz Liedke
6a7889934c Register database and cache implementations as binding for the settings repository 2015-07-15 23:54:56 +02:00
Franz Liedke
ba3fa73f16 Build a caching repository decorator for settings 2015-07-15 23:22:25 +02:00
Franz Liedke
8e9cf4fd2e Move settings repositories to own namespace
Also add a third method to the contract. This will help with building a caching decorator.
2015-07-15 23:16:57 +02:00
Toby Zerner
88b754ee8d Don't include deleted notifications in the unread count 2015-07-15 14:01:11 +09:30
Toby Zerner
0bb00e4eb2 Fix broken user activity syncer 2015-07-15 14:01:11 +09:30
Toby Zerner
ab6c03c0cc Massive JavaScript cleanup
- Use JSX for templates
- Docblock/comment everything
- Mostly passes ESLint (still some work to do)
- Lots of renaming, refactoring, etc.

CSS hasn't been updated yet.
2015-07-15 14:01:11 +09:30
Toby Zerner
42f1fa1272 Improve fulltext search API and interface 2015-07-07 20:35:18 +09:30
Toby Zerner
38c2ff0306 Finish client action refactoring. closes flarum/core#126 2015-07-07 19:23:13 +09:30
Toby Zerner
8a54b362c7 Add todos to document magic properties on models 2015-07-07 19:20:18 +09:30
Toby Zerner
54daad6e7d CSRF protection on logout action 2015-07-07 15:30:13 +09:30
Toby Zerner
99876e9e36 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
5fe88e448e 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
01ec661c3f PSR-2 fixes 2015-07-05 21:46:57 +09:30
Toby Zerner
873088750f Remove Interface suffix from some classes 2015-07-05 12:30:23 +09:30
Toby Zerner
2cc619a998 Remove todo 2015-07-05 12:25:51 +09:30
Toby Zerner
53e269fd89 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
04501545e3 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
81170980e0 Don't error if trying to serialise a non-existent relationship 2015-07-04 18:39:43 +09:30
Toby Zerner
86811c6508 Get rid of Repository interfaces 2015-07-04 18:38:59 +09:30
Toby Zerner
f7b6d8a568 Merge 2015-07-04 12:28:50 +09:30
Toby Zerner
336c05e77a Clean up
Goddammit GitHub for Mac
2015-07-04 12:25:21 +09:30
Toby Zerner
a74b40fe47 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
126039850a Some things should not be run when Flarum is not installed yet 2015-07-02 23:14:25 +02:00
Franz Liedke
12dd550a14 Add settings repository interface and database implementation.
Almost done with flarum/core#121 now.
2015-07-01 23:08:26 +02:00
Franz Liedke
03fd4a5aba Read debug mode from config 2015-07-01 22:49:38 +02:00
Franz Liedke
1e04a20220 Fix login
We cannot write to an empty response.
2015-07-01 22:45:14 +02:00
Franz Liedke
ccbebce93b 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
c1e7c00e2d Clean up some relation stuff 2015-07-01 22:35:56 +09:30
Toby Zerner
56932604db 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
Toby Zerner
d414ee33ed Make traits more generic
Type hinting User should take place in the callbacks. Theoretically
these traits could be used for another project now, where something
else has permissions (like a Sheep class, or a number)
2015-07-01 16:49:40 +09:30
Toby Zerner
810f79ee77 Cleanup, fix static date property error 2015-07-01 16:47:07 +09:30
Toby Zerner
d44b101373 Clean up merging stuff 2015-07-01 16:31:06 +09:30
Toby Zerner
3f32236379 API: allow date attributes to be added 2015-07-01 15:11:57 +09:30
Toby Zerner
c1595af84f Add todo about model validation 2015-07-01 13:35:27 +09:30
Toby Zerner
eafdd415ef Clean up model custom relation functionality 2015-07-01 13:22:09 +09:30
Toby Zerner
094825792a Clean up activity model 2015-07-01 13:19:24 +09:30
Franz Liedke
6e7cb1ff0e Some fixes to get along with the new bootstrapping 2015-06-30 23:29:52 +02:00
Franz Liedke
31effe943e Implement Android theme color support
As requested in the forums.
http://updates.html5rocks.com/2014/11/Support-for-theme-color-in-Chrome-39-for-Android
2015-06-26 23:11:13 +02:00
Franz Liedke
074f8087fa Update FastRoute
This enables optional route parameters.

Required some code changes in the RouteCollection class; once we
actually use optional route parameters, we will have to see whether
route generation for those works as expected.

Closes flarum/core#108
2015-06-26 23:09:58 +02:00
Franz Liedke
391c510f90 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
558d12c870 Search API tweaks
Rename some methods, include a mechanism for gambit negation.
Also always include the relevant posts in results. closes
flarum/core#111
2015-06-26 12:20:43 +09:30
Toby Zerner
bdd7e43e5a Notification API tweaks 2015-06-26 12:18:53 +09:30
Toby Zerner
e829788b63 Update start_post_id when starting a discussion 2015-06-25 09:48:28 +09:30
Toby Zerner
7c0accf14f Be more specific as to when we require edit permission
Since we update per-user data (e.g. isLiked) through this command’s
event
2015-06-25 08:38:18 +09:30
Toby Zerner
4c8a60ed7a Make sure discussion post IDs are ordered correctly 2015-06-24 18:57:07 +09:30
Toby Zerner
e466dcc626 Significantly improve mobile UX
Most of #137 done.

- Use FastClick to make everything feel more responsive
- Use transforms for animations to make them silky smooth
- Style the drawer the same as the header to keep things simple
- Revert to fixed composer, but allow it to be minimised
- Add a separate notifications page for mobile so it’s easy to go back
- Add indicator to the menu button when there are unread notifications
- Close the drawer when navigating away
- Make dropdowns/modals scrollable
- Many other mobile tweaks and bug fixes

Didn’t take much care to keep CSS clean, due to #103
2015-06-24 11:44:53 +09:30
Toby Zerner
b4dcc02520 Give author permission to delete discussion if there are no replies
Forgot to commit this part in 64e5d50533
:3
2015-06-24 09:13:54 +09:30
Toby Zerner
1c6ac80d01 Yo dawg I heard you like APIs so I put an API in your API so you can API while you API 2015-06-23 10:38:17 +09:30
Toby Zerner
64e5d50533 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
3a7efe202e Gracefully handle discussions with no posts
Although this should never happen
2015-06-23 10:30:06 +09:30
Franz Liedke
bc2142db51 Implement middleware for presenting pretty error pages 2015-06-20 22:39:33 +02:00
Franz Liedke
74536d7162 Add method for checking debug mode 2015-06-20 20:38:44 +02:00
Franz Liedke
efccf8bb7d Rename console commands 2015-06-20 20:09:47 +02:00
Franz Liedke
626daa9f38 Implement middleware for handling errors according to JSON API spec 2015-06-20 19:45:32 +02:00
Franz Liedke
e8bd58ec07 Clean up 2015-06-20 18:21:26 +02:00
Toby Zerner
479a09a41f Fix incorrect login after confirming token 2015-06-19 19:25:47 +09:30
Toby Zerner
5d5bbb9832 Cleanup 2015-06-19 17:19:13 +09:30
Toby Zerner
80a11ccc86 Fix newly-created event posts being undeletable 2015-06-19 17:19:09 +09:30
Toby Zerner
190c7a6741 Update avatar uploading code for psr-7
Not sure if a tmp file is the best way, but it works
2015-06-19 16:26:16 +09:30
Toby Zerner
473963087b Default to 404 code for RouteNotFoundException
Just want to get Stratigility’s FinalHandler showing something more apt
than “Internal server error”
2015-06-19 15:29:27 +09:30
Toby Zerner
d4ee1d87a5 Generate a new revision string when files change 2015-06-19 14:44:42 +09:30
Toby Zerner
22f91bb7e4 Add model validation messages 2015-06-19 11:43:49 +09:30
Toby Zerner
d90a8142a1 Get signup working again 2015-06-19 11:43:36 +09:30
Toby Zerner
d14716fa4d Get login/forgot password working again 2015-06-19 11:19:49 +09:30
Toby Zerner
96a2c0eb78 Run discussion events after first post is created 2015-06-19 09:07:39 +09:30
Toby Zerner
137f55317b Add API to add routes 2015-06-18 17:43:41 +09:30
Toby Zerner
555bb18acd Clean up some old code 2015-06-18 17:43:16 +09:30
Toby Zerner
822a216cc9 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
6db3bd9178 Refactor some APIs 2015-06-18 12:45:14 +09:30
Toby Zerner
f2888ee65f Cache permissions per user ID 2015-06-18 12:44:13 +09:30
Toby Zerner
a7e02ca890 Fix permission check in UserSearcher 2015-06-18 12:43:20 +09:30
Toby Zerner
b7617fa5d3 Get rid of total count from UserSearcher
Same reasoning as 64e6b7d26c
2015-06-18 12:42:56 +09:30
Toby Zerner
11b740c768 Make sure user activity is synced when whole discussions are deleted
We need to fire the PostWasDeleted event for every post when a
discussion is deleted. This means deleting big discussions will be an
intensive process, but that’s OK because it’s very rare.
2015-06-18 12:41:00 +09:30
Toby Zerner
9cb257e11d Update core permissions stuff 2015-06-18 12:38:24 +09:30
Toby Zerner
1dd46526a8 Merge query params into request input as well 2015-06-18 12:24:51 +09:30
Toby Zerner
7bf1fad9d6 Fix fatal error on delete actions 2015-06-18 12:24:31 +09:30
Toby Zerner
4792a47265 Define static properties on SerializeAction subclasses
Explained in d1e7453ffd.

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
64b87f55c5 Revert "Prefix API routes for now"
This reverts commit f669b95fd1.
2015-06-17 18:14:41 +09:30
Toby Zerner
25d375cad4 Back to rewritten URLs 2015-06-17 17:58:43 +09:30
Toby Zerner
f669b95fd1 Prefix API routes for now 2015-06-17 17:48:50 +09:30
Toby Zerner
7596dec7b9 Comply to new interface 2015-06-17 12:48:10 +09:30
Toby Zerner
61bea371ab Use UrlGenerator to get avatar URL 2015-06-17 12:48:01 +09:30
Toby Zerner
b91ca93e09 Fix LoginWithCookie middleware being ineffective
Flarum\Support\Actor needs to be a singleton. There is a comment in
LoginWithHeader - is there a better approach to the whole Actor thing?
2015-06-17 12:47:49 +09:30
Toby Zerner
00cb2f2e55 Change event so that data can be modified before it is serialized 2015-06-17 12:46:50 +09:30
Franz Liedke
708782637e Change config values to match new base URLs 2015-06-17 02:37:06 +02:00
Franz Liedke
e8aff5bc95 Make sure generated usernames cannot break validation 2015-06-17 02:36:51 +02:00
Franz Liedke
ce34d922d7 Fix merge conflict 2015-06-17 01:27:44 +02:00
Franz Liedke
29c7bf1b42 Remove debug statement 2015-06-17 00:53:03 +02:00
Franz Liedke
1cbc60ca41 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
ffb28838b5 Add TODO message 2015-06-17 00:18:16 +02:00
Franz Liedke
33d663bc8e 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
d1e7453ffd 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
4b4ff1e7fd Add API to add a link to an action 2015-06-16 17:39:47 +09:30
Toby Zerner
f0df751465 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
be2d0ac682 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
c20a5bb793 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
963078b375 Cache user permissions between calls 2015-06-16 17:18:02 +09:30
Toby Zerner
9ac1f53244 Add todo about query optimization 2015-06-16 16:59:48 +09:30
Toby Zerner
64e6b7d26c 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
c1e3820480 Add a serializer and API action to get information about the forum 2015-06-15 12:18:20 +09:30
Toby Zerner
823027b839 Prefer passing an array to ServiceProvider::extend 2015-06-15 08:59:33 +09:30
Toby Zerner
9997c5d7a3 Update permissions 2015-06-12 16:41:46 +09:30
Toby Zerner
8cebb4d8e6 API: Reorder Extend\Relationship arguments 2015-06-11 18:42:49 +09:30
Toby Zerner
48e33591c9 Add newline in-between JS files, in case last line is a comment 2015-06-11 18:42:26 +09:30
Toby Zerner
8b162344cd Lay the groundwork for translation & refactor asset compilation
Ditched the idea of having language packs as extensions. Reasoning:

1. Because we use machine keys for translations (rather than English
keys), extensions need to be able to define default translations. If
English translations are to be included in extensions and not in a
language pack extension, then it doesn’t make sense to have other
languages as language pack extensions. Inconsistency → complexity.

2. Translations should maintain version parity with their respective
extensions. There’s no way to do this if extension translations are
external to the extension.

Instead, localisation will be a core effort, as well as a per-extension
effort. Translators will be encouraged to send PRs to core + extensions.

In core, each locale has a directory containing three files:
- translations.yml
- config.js: contains pluralisation logic for the JS app, as well as
moment.js localisation if necessary
- config.php: contains pluralisation logic for the PHP app

Extensions can use the Flarum\Extend\Locale extender to add/override
translations/config to a locale.

Asset compilation has been completely refactored with a better
architecture. Translations + config.js are compiled and cached for the
currently active locale.
2015-06-10 14:23:56 +09:30
Franz Liedke
b65d18ee7f Use singleton method 2015-06-09 02:51:20 +02:00
Franz Liedke
d1cd4b174b Remove last remaining usage of DB facade 2015-06-09 02:40:02 +02:00
Franz Liedke
2a713ccb67 Remove HTTP method from generated URLs 2015-06-09 00:06:33 +02:00
Franz Liedke
fed3c2ebd1 Remove facade usage 2015-06-09 00:06:08 +02:00
Franz Liedke
238893a601 Get rid of more facade usage 2015-06-08 11:21:42 +02:00
Franz Liedke
38dfe787f2 Avoid usage of facade in user model 2015-06-08 11:20:46 +02:00
Franz Liedke
4db5cc347b Fix cookie retrieval in admin panel 2015-06-08 10:00:29 +02:00
Franz Liedke
f3c854ca57 Always initialize variable 2015-06-08 09:49:07 +02:00
Toby Zerner
0450aba462 Remove old code. 2015-06-08 14:57:05 +09:30
Toby Zerner
36257b1534 Load extensions from the root directory, with precedence. 2015-06-08 14:56:49 +09:30
Toby Zerner
b864ada389 Add extension generator command. 2015-06-08 14:56:19 +09:30
Toby Zerner
4d2f58b693 Clear bio HTML cache when saving bio 2015-06-08 09:50:07 +09:30
Toby Zerner
7a76bf175d Make HTMLPurifier config extensible; allow images 2015-06-08 09:37:30 +09:30