Commit Graph

890 Commits

Author SHA1 Message Date
Toby Zerner
58223b8a23 Don't allow empty post content
Parsing the post content makes it non-empty (`<t></t>`), so we don't
parse it if it is empty. Also delete a created discussion if the first
post was invalid.

closes flarum/core#224
2015-08-13 13:03:49 +09:30
Toby Zerner
9a0190e13a Allow post author to see their own deleted post
closes flarum/core#225
2015-08-13 13:02:13 +09:30
Toby Zerner
6dd6942e17 Fix avatar uploading permissions
closes flarum/core#230
2015-08-13 12:59:40 +09:30
Toby Zerner
9c7fab5d8c Support running in subdirectory with base_path config 2015-08-13 12:58:59 +09:30
Toby Zerner
aec83b295a Remove old files 2015-08-13 12:56:26 +09:30
Toby Zerner
6123773001 New listen API
Event subscriptions now take place before *any* boot method is called.
This ensures that all event listeners are registered before things
happen – e.g. locales are registered before the translator is
instantiated in the Tags extension's boot method.
2015-08-13 12:55:48 +09:30
Toby Zerner
acf27cebb1 Fix tobscure/json-api compat 2015-08-13 10:41:39 +09:30
Toby Zerner
8aafce5fd8 Fix Laravel 5.1 compat 2015-08-13 10:41:17 +09:30
Toby Zerner
46a69b6b7e Fix PHP 5.5 compat
Might be better to opt for a getLayout method?
2015-08-13 10:41:08 +09:30
Toby Zerner
47595ff9c4 Decouple from Laravel, implement translator 2015-08-12 18:33:39 +09:30
Toby Zerner
9f0358bb39 Update to Laravel 5.1
Eloquent `lists()` now returns a collection
2015-08-12 13:24:11 +09:30
Franz Liedke
25c5fb075f Redo installer 2015-08-12 01:42:39 +02:00
Franz Liedke
7b07e02e75 Use dependency injection in migrations 2015-08-12 01:29:40 +02:00
Toby Zerner
4e01aa10d8 Flush client assets when custom LESS is updated 2015-08-06 16:17:05 +09:30
Toby Zerner
3aebd458b0 Make sure access/email/password tokens are valid 2015-08-06 15:04:38 +09:30
Toby Zerner
2553f4f0a3 Throw an exception if discussion not found
closes flarum/core#208
2015-08-06 13:59:09 +09:30
Toby Zerner
edddeeb553 Make some changes to facilitate updates to mentions extension 2015-08-06 13:16:53 +09:30
Toby Zerner
fa5c7cb123 Build very rough HTML-only content
And redirect to the "no JS" mode if the JS app crashes on boot.

ClientView/ClientAction is all a bit of a mess and will need to be
radically cleaned up at some point...
2015-08-06 12:21:11 +09:30
Toby Zerner
80e13ae289 Implement default route config setting 2015-08-06 12:18:59 +09:30
Toby Zerner
c361c97394 Enforce discussion renaming/deleting/post editing timed permissions 2015-08-05 19:21:33 +09:30
Toby Zerner
4c06e78b57 Allow/disallow signup per config 2015-08-05 18:19:26 +09:30
Toby Zerner
023eff95e3 Let users see themselves even if they can't see the forum 2015-08-05 18:12:09 +09:30
Toby Zerner
ff8dc5ef25 Enforce forum.view permission 2015-08-05 18:08:31 +09:30
Toby Zerner
ca8fee4685 Let users see their own email/activation status 2015-08-05 16:07:22 +09:30
Toby Zerner
42e382045a API: Add event for determining user groups for permissions 2015-08-05 16:06:55 +09:30
Toby Zerner
57e37e06ef Disable "start discussion" button if no permission 2015-08-05 16:06:25 +09:30
Toby Zerner
f42c3cd1ed Allow admins to delete users 2015-08-05 12:08:28 +09:30
Toby Zerner
1679f1e27b Implement edit user modal
EditUserHandler is a bit rough
2015-08-05 11:49:37 +09:30
Toby Zerner
f49d0e5341 Allow locale to be selected in footer 2015-08-05 09:50:57 +09:30
Toby Zerner
48df9bb678 Fix syntax error 2015-08-04 21:50:44 +09:30
Toby Zerner
187517a9c7 Remove ability for users to delete themselves 2015-08-04 21:35:41 +09:30
Toby Zerner
5fa7a8c555 Add the parsedBody to API request input 2015-08-04 21:22:40 +09:30
Franz Liedke
eee34598f1 Include editUser relationship when editing posts.
Closes flarum/core#214. Hopefully. :)
2015-08-04 13:15:56 +02:00
Toby Zerner
e091b037f3 Radically simplify user activity system
The activity system we were using was built around a separate table.
Whenever the user posted something, or deleted a post, we would sync
the table. The advantage of this was that we could aggregate activity
of all different types very efficiently.

It turns out that it came with a huge disadvantage: there was no
efficient way to enforce permissions on activity. If a user posted
something in a private tag, everyone could still see it on their
activity feed. My stopgap solution was to only sync activity for posts
that are viewable by guests, but that was way too limited.

It also turns out that aggregating activity of different types is
really not that useful, especially considering most of it is the user
making posts. So I've gotten rid of that whole overly-complicated
system, and just made the user profile display separate lists of posts
and discussions, retrieved from those respective APIs. The discussions
page is an actual discussion list too, which is pretty cool.

It's still technically possible to aggregate different activity types
(basically just aggregate API responses together), but we can do that
later if there's a need for it.

This is probably my favourite commit of the day :)
2015-08-04 18:44:22 +09:30
Toby Zerner
a2c3c4e51b Only add posted activity if the post is visible publicly
This is very restrictive behaviour and we'll probably need to think of
something a bit more powerful in the future. But it's a good stopgap.
2015-08-04 17:47:46 +09:30
Toby Zerner
667fe56947 Use morphTo instead of mappedMorphTo
Turns out we don't need MappedMorphTo after all.
2015-08-04 17:33:58 +09:30
Toby Zerner
556b93e367 Add admin client JS/LESS to extension stub 2015-08-04 17:18:45 +09:30
Toby Zerner
9700fbbb0b Add API to add translations to admin client
Again, I'll split up these APIs soon enough
2015-08-04 17:16:34 +09:30
Toby Zerner
7ed3834dc9 Include discussion last user relationship in response after creating post 2015-08-04 17:15:57 +09:30
Toby Zerner
5b3484d3c8 Improve error handling somewhat
- Fix composer crashing/not showing alert on error
- Make a general ValidationException which takes an array of field ⇒
messages to be outputted nicely by the API
2015-08-04 13:03:46 +09:30
Toby Zerner
2e4d38b3e7 Move config/permission actions to API; clean up cache flushing 2015-08-04 10:40:04 +09:30
Toby Zerner
83e8503df1 Rough implementation of appearance settings 2015-08-03 14:35:51 +09:30
Toby Zerner
70901b1420 Rough extension management implementation 2015-08-03 12:03:30 +09:30
Toby Zerner
66ee6e57ee Convert permission IDs into strings 2015-08-02 18:02:35 +09:30
Toby Zerner
025d8f691d Add API methods to add POST/DELETE routes to the API 2015-08-02 17:26:30 +09:30
Toby Zerner
6f09ba6591 Clean up 2015-07-31 20:17:17 +09:30
Toby Zerner
fde7afd3e2 Finish admin permissions page and clean up everything 2015-07-31 20:16:47 +09:30
Toby Zerner
5706c71c86 Convert email/password token date fields 2015-07-31 20:14:19 +09:30
Toby Zerner
ba41c5313a Allow for the addition of admin assets
I think the `BuildClientView` event should ultimately be split into two
separate events for the forum/admin clients, but this is fine for now.
2015-07-31 20:13:13 +09:30
Toby Zerner
4e0cfdc1b2 Allow for the addition of new API endpoints 2015-07-31 20:11:44 +09:30
Toby Zerner
cea8e7f567 Add group management actions to API 2015-07-31 20:10:49 +09:30
Toby Zerner
6641af3ac3 Refactor some model stuff out into traits 2015-07-31 20:09:31 +09:30
Toby Zerner
e204794b91 Allow custom variables to be set on the client app 2015-07-31 20:08:27 +09:30
Toby Zerner
513d896f51 Fix more aspects of the password reset process 2015-07-31 14:13:35 +09:30
Toby Zerner
8db17b3fb8 Fix password saving 2015-07-31 14:00:42 +09:30
Toby Zerner
42fd8e26c1 Begin implementing permissions page 2015-07-29 21:00:27 +09:30
Toby Zerner
f96cac6057 Implement basic settings page 2015-07-29 21:00:09 +09:30
Toby Zerner
e863bd53d3 Get admin area working again 2015-07-29 20:58:22 +09:30
Toby Zerner
d8d9cac7c3 Enable caching of minified formatter JS 2015-07-29 20:54:48 +09:30
Toby Zerner
97334bea12 Don't display notifications with deleted subjects 2015-07-28 17:15:09 +09:30
Toby Zerner
8f29949016 Fix email confirmation 2015-07-28 17:14:08 +09:30
Toby Zerner
02944548a1 Clean up 2015-07-28 15:35:03 +09:30
Toby Zerner
697cb2ed63 Supporting routing of URL with nothing after the discussion ID
closes flarum/core#181
2015-07-28 13:46:43 +09:30
Toby Zerner
8c18ff3349 Tweak TextFormatter JS settings 2015-07-28 12:44:58 +09:30
Toby Zerner
62a01c69a9 Make sure sort key exists 2015-07-28 12:27:59 +09:30
Toby Zerner
3489791932 Allow customisation of the client layout 2015-07-27 14:45:35 +09:30
Toby Zerner
153a5b7ce4 PERF: avoid reinstantiation of event subscribers 2015-07-27 11:53:47 +09:30
Toby Zerner
c0d57fd399 PERF: further simplify User::hasPermission() 2015-07-27 11:20:18 +09:30
Toby Zerner
07b4a5125f PERF: cache the results of User::hasPermssion() 2015-07-27 11:17:21 +09:30
Toby Zerner
b04e7f96c8 Cache model dates 2015-07-27 10:59:24 +09:30
Toby Zerner
e5e737eca4 Update LESS variable names 2015-07-24 10:03:11 +09:30
Toby Zerner
ae3bbc1700 Replace duplicate tags instead of erroring 2015-07-23 20:29:39 +09:30
Toby Zerner
c1b12c7fc9 Extract emoticons, BBCode, and Markdown into extensions 2015-07-23 20:24:41 +09:30
Toby Zerner
cb3004b6de Various fixes to extension generator/stub 2015-07-23 20:24:28 +09:30
Toby Zerner
c8e6fbc338 Pass correct param to notification email views 2015-07-23 16:39:56 +09:30
Toby Zerner
8c6e87760c Docblock cleanup 2015-07-23 14:35:17 +09:30
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
Toby Zerner
f928e746d9 Prevent formatter from being invoked if bio is empty 2015-06-08 09:34:39 +09:30
Franz Liedke
1962eeab72 Remove outdated column name from user table seeder 2015-06-07 22:04:11 +02:00
Franz Liedke
c2df8d5214 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
381e7a2c57 Usernames must only contain alphanumeric chars/dashes/underscores
Perhaps we can relax this a little bit, but right now these are the
only characters that are parsed for @mentions anyway
2015-06-04 11:19:23 +09:30
Toby Zerner
aae7678cea Really rough fulltext driver implementation 2015-06-04 11:11:56 +09:30
Toby Zerner
42851f425b 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
9487a56d61 Allow <hr> in posts 2015-06-03 18:12:15 +09:30
Toby Zerner
5d89618bbd Implement search on front end 2015-06-03 18:10:56 +09:30
Franz Liedke
9564778701 Upgrade to stable cookie dependency 2015-06-03 10:17:59 +02:00
Franz Liedke
5151a5aef5 Fix login response not containing the token 2015-06-03 03:41:09 +02:00
Franz Liedke
82ccf28072 Fix redirect after logout 2015-06-03 03:36:49 +02:00
Franz Liedke
ed79f7c4ea Fix middleware if cookie does not exist. 2015-06-03 03:36:17 +02:00
Franz Liedke
2ba7a2044b Fix redirect helper. 2015-06-03 03:35:30 +02:00
Franz Liedke
79480242a7 Use contracts for typehints where possible. 2015-06-03 03:21:24 +02:00
Franz Liedke
7383c14eae Remove lots of unneeded imports. 2015-06-03 03:20:58 +02:00
Franz Liedke
8c40c2b4ad Get rid of unneeded injected dependency. 2015-06-03 03:19:32 +02:00
Franz Liedke
203c21846c Use API client class in admin action, too 2015-06-03 03:18:33 +02:00
Franz Liedke
7b45ca3a78 Typehint container contract instead of application class.
This helps us in decoupling from Laravel, as we only need any
implementation of the container contract now.
2015-06-03 03:05:10 +02:00
Franz Liedke
c616cd811b Use the new client class to consume API actions 2015-06-03 02:40:24 +02:00
Franz Liedke
a94a9afdcc 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
d462eb585e Convert forum app to be PSR-7 compatible.
I also installed one new dependency: a helper library that makes it
easier to read and write cookies, given that there are no helper methods
for these purposes in the PSR-7 standard.
2015-06-03 02:04:57 +02:00
Franz Liedke
7f83552cbb Make JSON parameter middleware a bit more generic 2015-06-03 02:04:00 +02:00
Franz Liedke
33ae52a30c Fix responses returned by JSON helper. 2015-06-03 02:02:28 +02:00
Toby Zerner
6cf1dbe648 Add HTMLPurifier after formatters are run.
After a morning of searching, it seems there is no PHP Markdown library
that has built-in XSS/sanitization support. The recommended solution is
to use HTMLPurifier.

This actually works out OK, though, as it’s probably a good idea to
enforce sanitization regardless of which formatters are enabled, and to
not leave them with the responsibility of sanitization (it’s a big
responsibility). Since we cache rendered posts, the slow speed of
HTMLPurifier isn’t a concern.

Note that HTMLPurifier requires a file to be loaded by Composer, but
Studio does not yet support this, so for now I have included it
manually.
2015-06-02 11:36:25 +09:30
Toby Zerner
fb3038d128 Password cannot be null 2015-06-01 17:55:52 +09:30
Toby Zerner
82377f2302 Fix error on account registration 2015-06-01 17:55:41 +09:30
Toby Zerner
5d28fc2713 Only validate dirty attributes
To prevent unique-checking queries on every update
2015-06-01 12:26:44 +09:30
Toby Zerner
3334063740 Use pre-loaded state if applicable. closes flarum/core#89 2015-06-01 12:26:11 +09:30
Toby Zerner
bb1491e19e 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
0f9549f4b9 Remove default relationships from serializers 2015-06-01 12:24:06 +09:30
Toby Zerner
351775ef02 Add NotificationWillBeSent event 2015-06-01 08:52:04 +09:30
Toby Zerner
a1da95962d Move theme config to database 2015-05-31 11:18:19 +09:30
Toby Zerner
78e10ec541 Eager load notification relationships 2015-05-30 13:57:39 +09:30
Franz Liedke
a1f5060c05 Remove obsolete imports 2015-05-28 23:52:40 +02:00
Franz Liedke
8a57922833 For now, inject URL generator instead of providing helper method. 2015-05-28 23:46:56 +02:00
Franz Liedke
76114f2979 Implement helper for generating routes in API actions. 2015-05-27 23:59:41 +02:00
Franz Liedke
9526dbf210 Create URL generator interface.
Also bind a default implementation to the container.
2015-05-27 23:58:43 +02:00
Toby Zerner
2741923714 Improvements to change/forgot password 2015-05-27 16:25:44 +09:30
Toby Zerner
696bfe5a07 Improve email changing/confirmation stuff 2015-05-27 16:24:54 +09:30
Franz Liedke
7ab3437136 Switch admin app to new PSR-7 driven architecture 2015-05-27 03:02:10 +02:00
Franz Liedke
95677e05e3 Add another abstract action base class for dealing with returned views 2015-05-27 03:01:09 +02:00
Franz Liedke
cff0e96eaa Implement helper method for redirecting 2015-05-27 02:48:08 +02:00
Franz Liedke
05cecf080e Fixes to comply with PSR-2 2015-05-27 02:37:27 +02:00
Franz Liedke
97e43c5431 Update ForgotAction to comply with changes in base class 2015-05-27 01:58:39 +02:00
Franz Liedke
343da9fc40 Extract another middleware from API routing 2015-05-27 01:55:46 +02:00
Franz Liedke
3ff230dc26 Change API to use PSR-7 style requests and responses
This required some interface changes (mostly changing Laravel's or
Symfony's request and response classes to those of Zend's Diactoros.
Some smaller changes to the execution flow in a few of the abstract
action base classes, but nothing substantial.

Note: The request and response classes are immutable, so we usually
need to return new instances after modifying the old ones.
2015-05-27 01:55:05 +02:00
Franz Liedke
910d96f905 Fix a typo 2015-05-27 01:49:14 +02:00
Franz Liedke
be97f5f303 Implement a minimal router using FastRoute.
This will be able to dispatch PSR-7-style requests to any callback
that returns a proper response object.

Largely based on my original work for FluxBB 2.0.
2015-05-27 01:49:14 +02:00
Toby Zerner
1ec2a4c742 Update email address confirmation subject 2015-05-26 18:07:27 +09:30
Toby Zerner
e5532d9618 Roughly implement change password/email, delete account modals 2015-05-26 18:03:02 +09:30
Toby Zerner
85ba97ed5c Improve appearance/behaviour of login/signup/forgot modals 2015-05-26 16:25:25 +09:30
Toby Zerner
feb4676aa0 Very rough implementation of forgot password 2015-05-26 11:14:06 +09:30
Toby Zerner
d481a38029 Old code, don't need these! 2015-05-23 08:36:14 +09:30
Toby Zerner
f54acebaf0 Fix bad logic in edit permission that was allowing guests to edit posts. Closes #88 2015-05-21 15:53:59 +09:30
Toby Zerner
edc59f37e3 PSR-2: Remove empty lines 2015-05-20 12:33:26 +09:30
Toby Zerner
3c7078b423 New user activity feed API.
Originally the user activity feed was implemented using UNIONs. I was
looking at make an API to add activity “sources”, or extra UNION
queries (select from posts, mentions, etc.) but quickly realised that
this is too slow and there’s no way to make it scale.

So I’ve implemented an API which is very similar to how notifications
work (see previous commit). The `activity` table is an aggregation of
stuff that happens, and it’s kept in sync by an ActivitySyncer which is
used whenever a post it created/edited/deleted, a user is
mentioned/unmentioned, etc.

Again, the API is very simple (see Core\Activity\PostedActivity +
Core\Handlers\Events\UserActivitySyncer)
2015-05-20 12:30:27 +09:30
Toby Zerner
98b3d0f89e Simplify and improve notifications API.
It turns out that the idea of “sending” a notification is flawed. (What
happens if the notification subject is deleted shortly after? The
notified user would end up with a dud notification which would be
confusing. What about if a post is edited to mention an extra user? If
you sent out notifications, the users who’ve already been mentioned
would get a duplicate notification.)

Instead, I’ve introduced the idea of notification “syncing”. Whenever a
change is made to a piece of data (e.g. a post is created, edited, or
deleted), you make a common notification and “sync” it to a set of
users. The users who’ve received this notification before won’t get it
again. It will be sent out to new users, and hidden from users who’ve
received it before but are no longer recipients (e.g. users who’ve been
“unmentioned” in a post).

To keep track of this, we use the existing notifications database
table, with an added `is_deleted` column. The syncing/diffing is
handled all behind the scenes; the API is extremely simple (see
Core\Notifications\DiscussionRenamedNotification +
Core\Events\Handlers\DiscussionRenamedNotifier)
2015-05-20 12:24:01 +09:30
Toby Zerner
f2d1100ec3 Fix broken DeleteAction 2015-05-20 11:13:32 +09:30
Toby Zerner
5fede6fe6d Limit notifications to one per user when dispatching events 2015-05-19 11:24:43 +09:30
Toby Zerner
248c19de73 Experimenting with some new ways to handle config
For now I’ve chucked it on Flarum\Core as a static method, but
ultimately I think we will need a ConfigRepository abstraction (whether
it replaces or sits underneath the Flarum\Core static method I’m not
sure).

Also starting to think about multisite scenarios, I think this is
important. The Forum model could actually end up with a database table
behind it, and each forum would have its own config settings? Haven’t
really thought about it too hard yet…
2015-05-19 10:59:57 +09:30
Toby Zerner
0724aec77e Fix broken notification emailer 2015-05-19 10:53:17 +09:30
Toby Zerner
54c2eaff8e Fix notification preferences not being enabled by default 2015-05-19 10:12:19 +09:30
Toby Zerner
278ff7b9c2 Give all users guest permissions as well 2015-05-19 09:36:20 +09:30
Toby Zerner
811df6c278 Fix errors in DeleteAvatarAction/Command 2015-05-19 09:27:04 +09:30
Franz Liedke
1ab1631849 Fix the config table seeder
It should include the "extensions_enabled" key which is read
when initializing all extensions.
2015-05-19 01:53:37 +02:00
Franz Liedke
dd54803aaf Fix remaining PSR-2 issues. 2015-05-19 01:07:22 +02:00
Franz Liedke
7885c9a002 Fix coding standards to conform to PSR-2 2015-05-19 01:03:12 +02:00
Franz Liedke
7e4693a855 Fix code error, static methods can not be abstract. 2015-05-18 17:17:10 +02:00
Toby Zerner
8e24e7197e Rename ActivityPost to EventPost 2015-05-18 18:47:34 +09:30
Toby Zerner
1b4b03356a Better API error handling 2015-05-18 18:13:16 +09:30
Toby Zerner
4dfe6ee1d1 Add some extra optional functionality to the Extend\Permission API
- Automatically serialise the attribute
- Apply Permissible grant callbacks

Need to consider splitting the $permission property into two arguments
(currently have to explode by ‘.’)
2015-05-18 13:51:30 +09:30
Toby Zerner
7f48a98af8 Make discussion edit permission specific to renaming 2015-05-18 12:34:03 +09:30
Toby Zerner
50ea261c47 Update permissions table seeder with new structure 2015-05-18 12:31:38 +09:30
Toby Zerner
6522ecffbc Fix permission query error for Guest model. Fixes #84 2015-05-18 12:29:31 +09:30
Toby Zerner
4494001ef7 Fix error on discussion page 2015-05-18 08:00:14 +09:30
Toby Zerner
a577910d04 New object-based extension APIs 2015-05-17 10:19:54 +09:30
Toby Zerner
8e6adb9be0 Expose serializer/actor to extensions 2015-05-15 17:06:09 +09:30
Toby Zerner
b4e5f0e6e5 Simplify permissions and add API to register configurable ones
Lots of thought has gone into this; it will show up later when I do the
admin permissions interface / category permissions :)
2015-05-15 17:05:46 +09:30
Toby Zerner
9ca77d79a0 GitHub for Mac is silly, this should've been in the last commit 2015-05-14 22:41:08 +09:30
Toby Zerner
3925e5892c Rework notifications architecture
- The recipient(s) are the concern of the notifier/sender, not the
notification itself
- Allow “retraction” of notifications (e.g. if a discussion is
stickied, but then it is unstickied)
- Misc. cleanup
2015-05-14 22:41:08 +09:30
Toby Zerner
6517b1ec3e Fix user searching 2015-05-14 22:41:08 +09:30
Toby Zerner
23caaf668a Make MappedMorphTo available on all models
In case extensions want to add that kind of relationship to an existing
model (there’s no way to include traits at runtime)
2015-05-14 22:41:08 +09:30
Toby Zerner
9e81e9f955 Properly include to-many relations 2015-05-14 22:41:07 +09:30
Toby Zerner
c5420ef7df Include user in post creation response 2015-05-14 22:41:07 +09:30
Toby Zerner
9284db5076 Allow finding a post by discussion ID and number 2015-05-14 22:41:07 +09:30
Toby Zerner
781dc2ef0c New component for post excerpts, which will be shown in search results
Perhaps also in user activity stream. They are used in the mentions
extension.

In order to generate the excerpt, each formatter can implement a
“strip” method which basically converts block formatting into inline
formatting.
2015-05-14 22:41:05 +09:30
Toby Zerner
85fa9ca609 Fix incorrect attribute name 2015-05-11 12:12:00 +09:30
Toby Zerner
a1cd6417c7 Add API for adding a formatter 2015-05-11 12:11:26 +09:30
Toby Zerner
b4fd662000 Remove BasicFormatter; add LinkifyFormatter 2015-05-11 12:11:19 +09:30
Toby Zerner
e5f2355d17 Post can't be abstract because it needs to be instantiable for querying 2015-05-11 10:40:41 +09:30
Toby Zerner
d166757930 Extract mappedMorphTo function into a trait
Not sure if this is the best thing to do, it could also just be put on
the base Model class
2015-05-11 10:39:54 +09:30
Franz Liedke
825b4082de Copy the config.php file upon installation.
This allows us to know whether Flarum is already installed, so that
we can disable certain service providers when it isn't.

This should fix #67.
2015-05-08 20:44:53 +02:00
Franz Liedke
e1569beb00 Fix discussion seeder not using the correct post subtypes.
Related to #67.
2015-05-08 18:12:02 +02:00
Franz Liedke
2245b11bb1 Seed command: Only run seeders that have not been run as part of flarum:install command. 2015-05-08 15:15:09 +02:00
Franz Liedke
df8a035935 Remove obsolete line.
Related to #67.
2015-05-08 15:15:08 +02:00
Toby Zerner
023b8b9a9c Don't attempt deletion if the user doesn't have an avatar 2015-05-07 16:54:26 +09:30
Toby Zerner
c58fc07798 Actually use the calculated offset 2015-05-07 16:54:14 +09:30
Toby Zerner
b5169512cb Move some API error handling code around. It still sucks though 2015-05-07 16:08:20 +09:30
Toby Zerner
59d8d63acd Add preliminary avatar resizing 2015-05-07 13:59:07 +09:30
Toby Zerner
05e561d3d6 Add pagination links to JSON-API index actions 2015-05-07 08:22:15 +09:30
Toby Zerner
8e1f6db85d Change mergeInto return signature; only merge posts if same user 2015-05-07 06:38:40 +09:30
Toby Zerner
80aaf42a53 Fix signup error 2015-05-06 12:12:31 +09:30
Toby Zerner
bde9bf9378 Fix FontAwesome path 2015-05-06 12:12:22 +09:30
Toby Zerner
54f731942e Add user group badges 2015-05-06 11:25:19 +09:30
Toby Zerner
92c1ee26c8 Fix content attribute decoding into an object 2015-05-06 11:24:02 +09:30
Toby Zerner
e7ff776001 Collect gambits that were matched and applied 2015-05-06 11:23:35 +09:30
Toby Zerner
a4d3345b99 Add shortcut API to serialize attributes 2015-05-06 11:23:12 +09:30
Toby Zerner
9559ac1bb6 Delete previous avatar when uploading a new one 2015-05-06 11:22:35 +09:30
Toby Zerner
8258d4e504 Fix dud call in magic method 2015-05-05 17:31:29 +09:30
Toby Zerner
a822deaa98 Clean up post type heritable view arguments 2015-05-05 17:29:43 +09:30
Toby Zerner
8aa6253c59 Precursor to storing extension providers for later use 2015-05-05 17:05:47 +09:30
Toby Zerner
92a75fd786 Add a base ServiceProvider with useful public APIs 2015-05-05 14:30:45 +09:30
Toby Zerner
2850c1b38c Make NotificationSender compatibleWith method static 2015-05-05 14:29:57 +09:30
Toby Zerner
d13cb03e39 Return the post that was added/changed/deleted 2015-05-05 14:29:07 +09:30
Toby Zerner
f2056c4acf Clean up post type API 2015-05-05 14:28:40 +09:30
Toby Zerner
bf593504c7 Clean up event handlers 2015-05-05 14:27:47 +09:30
Toby Zerner
24481f3f77 Change API for serializer relationships 2015-05-05 14:26:53 +09:30
Toby Zerner
3726c97d5c Remove old code 2015-05-05 09:17:00 +09:30
Toby Zerner
f0219de93f Fix admin 2015-05-05 09:16:53 +09:30
Toby Zerner
56ef42f931 Add concept of "mergeable" activity posts
For example: when you rename a discussion, DiscussionRenamedPost is
created. If you rename it again immediately afterwards, then a new
DiscussionRenamedPost can be merged into the old one. This will either
result in the old one being updated with the new title, or it being
deleted all together if it was renamed back to the old title.
2015-05-04 12:19:25 +09:30
Toby Zerner
0a2c05379c Update TokenAction for new architecture 2015-05-04 10:30:56 +09:30
Toby Zerner
9af9dce740 Add ExtensionsServiceProvider to load enabled extensions 2015-05-04 08:56:19 +09:30
Toby Zerner
67f64b631a Pass action in RenderView event so that handler can access actor 2015-05-04 08:55:44 +09:30
Toby Zerner
850a49285b Add API to define custom model relationships 2015-05-04 08:55:03 +09:30
Toby Zerner
f03f046efe Add event to modify user search 2015-05-03 12:07:15 +09:30
Toby Zerner
d966c9831a Add event for registering user search gambits 2015-05-03 12:06:01 +09:30
Toby Zerner
b38878da80 Add delete avatar action 2015-05-03 12:05:18 +09:30
Toby Zerner
29be20c91a Fix incorrect function call 2015-05-03 12:04:57 +09:30
Toby Zerner
8f29679b46 Convert the rest of the API to new action architecture
Also make some tweaks:
- Merge SerializeAction::$include and
SerializeAction::$includeAvailable into a keyed boolean array
- Set defaults for SerializeAction::$limit and $limitMax
- Rename SerializeAction::$sortAvailable to $sortFields
2015-05-03 12:04:43 +09:30
Toby Zerner
ecdb2becd4 Assign user input to data property on EditDiscussionCommand 2015-05-02 09:01:27 +09:30
Toby Zerner
f67f34e287 Add removed posts as an API attribute 2015-05-02 09:00:22 +09:30
Toby Zerner
8ee9480205 Update discussion/post sort semantics inline with new API actions
Instead of $sort and $order being separate, they are now a single
array, allowing multiple sort criteria: `[‘foo’ => ‘asc', ‘bar’ =>
‘desc’]`
2015-05-02 09:00:07 +09:30
Toby Zerner
22ff8a203d Make sure serializers work with relations implemented with magic (via __call) 2015-05-02 08:58:28 +09:30
Toby Zerner
db31d9f772 Making a note that we should not use Actor as a singleton 2015-05-02 08:57:14 +09:30
Toby Zerner
a426fa6560 Update API action architecture
- An API action handles a Flarum\Api\Request, which is a simple object
containing an array of params, the actor, and optionally an HTTP
request object
- Most API actions use SerializeAction as a base, which parses request
input according to the JSON-API spec (creates a JsonApiRequest object),
runs the child class method to get data, then serializes it and assigns
it to a JsonApiResponse (standard HTTP response with a
Tobscure\JsonApi\Document as content)
- The JSON-API request input parsing is subject to restrictions as
defined by public static properties on the action (i.e. extensible)
- Also the actor is given to the serializer instance now, instead of
being a static property
2015-05-02 08:56:43 +09:30
Toby Zerner
288fd694a8 Extensibility: data when starting a new discussion 2015-05-02 08:39:44 +09:30
Toby Zerner
60e69ae7b9 Add an event to register discussion gambits 2015-05-02 08:12:30 +09:30
Toby Zerner
66b374b1c1 Add API to collect posts that were removed during an action
This is useful for both the Sticky and Categories extensions, where if
you sticky a discussion and then immediately unsticky it, or if you
move it to a category and then immediately move it back, the last
“activity” post will be removed.
2015-05-02 08:12:09 +09:30
Toby Zerner
a2fd60ed0c Define assets in a more appropriate spot, make extensible 2015-05-02 08:10:06 +09:30
Toby Zerner
c3aecbceaa Extract config into database 2015-05-02 08:07:51 +09:30
Toby Zerner
ac269683ed Merge remote-tracking branch 'upstream/master' 2015-04-25 22:45:27 +09:30
Toby Zerner
52b476dc6b Return more relations when a discussion is created 2015-04-25 22:37:25 +09:30
Toby Zerner
34d150b24b Fix read discussion command action 2015-04-25 22:37:04 +09:30
Toby Zerner
0548ebd54c Allow custom relation to be specified as string 2015-04-25 22:36:34 +09:30
Toby Zerner
8fdc1ba548 Add BootForum event so extensions can add assets 2015-04-25 22:35:41 +09:30
Toby Zerner
b6613dbdc2 Recompile assets every time a file changes 2015-04-25 22:34:56 +09:30
Toby Zerner
a57e3fc028 Use Less_Parser cache feature to speed up LESS generation 2015-04-25 22:34:46 +09:30
Toby Zerner
c6079c53c9 Fix email confirmation route 2015-04-25 22:34:33 +09:30
Toby Zerner
8491c4cbf8 Rename assets directory 2015-04-25 22:34:26 +09:30
Toby Zerner
b68a4711dc Replace Ember app with Mithril app 2015-04-25 22:28:39 +09:30
Franz Liedke
a4ccc020e7 Fix class name conflict. 2015-04-15 13:44:35 +02:00
Toby Zerner
6f67b8c247 Fix attribute serialisation event mutability 2015-04-03 17:04:59 +10:30
Toby Zerner
0bcaaaa9b9 Add an event to modify search queries 2015-04-03 17:04:41 +10:30
Toby Zerner
6898e0acbb Refactor Flarum\Web and Flarum\Admin
- In order to be consistent with the Ember/LESS naming scheme, renamed
Flarum\Web to Flarum\Forum.
- Moved common classes into Flarum\Support so that Flarum\Admin doesn’t
depend on Flarum\Forum. Also moved Actor into Flarum\Support as it
doesn’t belong in the domain.
2015-03-30 16:17:04 +10:30
Toby Zerner
8e0a27de49 Oops 2015-03-30 12:56:41 +10:30
Toby Zerner
3b4beaa6ca "See" a user on the initial page load too 2015-03-30 12:55:39 +10:30
Toby Zerner
a43957e1e2 Don't allow guests into the admin area 2015-03-30 12:43:55 +10:30
Toby Zerner
7051b608a0 Update administration page title 2015-03-30 10:42:13 +10:30
Toby Zerner
3886efffef Turns out putting a . there breaks Laravel 2015-03-29 22:27:37 +10:30
Toby Zerner
40a6d77e74 Big front-end asset/filestructure refactor
- Extract shared Ember components into a “flarum-common” ember-cli
addon. This can be used by both the forum + admin Ember apps, keeping
things DRY
- Move LESS styles into their own top-level directory and do a similar
thing (extract common styles)
- Add LESS/JS compilation and versioning to PHP (AssetManager)
- Set up admin entry point

(Theoretical) upgrade instructions:
- Delete everything in [app_root]/public
- Set up tooling in forum/admin Ember apps (npm install/update, bower
install/update) and then build them (ember build)
- php artisan vendor:publish
- Upgrade flarum/flarum repo (slight change in a config file)
- If you need to trigger a LESS/JS recompile, delete the .css/.js files
in [app_root]/public/flarum. I set up LiveReload to do this for me when
I change files in less/ or ember/

Todo:
- Start writing admin app!
- Remove bootstrap/font-awesome from repo and instead depend on their
composer packages? Maybe? (Bower is not an option here)
2015-03-29 22:13:26 +10:30
Toby Zerner
950d2f0eb9 Move forum ember app into a subdir, preparing for admin app to exist alongside 2015-03-28 19:10:52 +10:30
Toby Zerner
52a7b536c4 Fix scope removal of bindings 2015-03-28 16:31:26 +10:30
Toby Zerner
bc9be30a02 More powerful/extensible notifications
- Notifications can be delivered in multiple ways (alert, email)
- Different notification types can implement interfaces to allow
themselves to be delivered in these various ways
- User preferences for each notification type/method combination are
automatically registered
2015-03-28 15:43:58 +10:30
Toby Zerner
49c3fa09e6 Change "renamed" post type to more descriptive "discussionRenamed" 2015-03-28 15:43:58 +10:30
Toby Zerner
89eca757e6 Give MappedMorphTo a more generic property name 2015-03-28 15:43:58 +10:30
Toby Zerner
afa4b98c4a Only get posts with registered types.
This is so that if an extension adds a post type, and the database gets
populated with posts of that type, but then if the extension is
disabled, we wouldn’t want those posts to display because we would have
no knowledge about how to deal with/render them.
2015-03-28 15:43:58 +10:30
Toby Zerner
38ebb15334 Track user "last seen" time and display whether they are online or not
according to their preferences
2015-03-28 15:43:58 +10:30
Toby Zerner
359f44552e Implement user preferences API
Preferences must be registered (optionally with a callback to transform
data, and a default value) on the User model.
2015-03-28 15:43:57 +10:30
Ciarán O'Mara
be067ae1b6 Fix comment count update.
Addresses the following error when using pqsql.

[PDOException]
  SQLSTATE[42703]: Undefined column: 7 ERROR:  column "comment" does not exist
  LINE 1: ...d) FROM posts WHERE user_id = users.id and type = "comment")
2015-03-28 05:38:56 +11:00
Toby Zerner
257a3fde1a Refresh avatar display after uploading 2015-03-27 11:49:26 +10:30
Franz Liedke
9621e72b9b Fix order of arguments. 2015-03-26 22:03:55 +01:00
Franz Liedke
a19f35e8c1 Construct filesystem correctly. 2015-03-26 22:03:47 +01:00
Franz Liedke
18ccec4190 Pass newly configured filesystem disk to upload handler. 2015-03-26 22:01:58 +01:00
Franz Liedke
cf8e02977f Change name of avatar field in users table. 2015-03-26 20:59:06 +01:00
Franz Liedke
e4ed057557 Wire up instantiation of Flysystem adapter for avatar storage. 2015-03-25 14:26:38 +01:00
Franz Liedke
100a5038bf Add route and action for uploading user avatars. 2015-03-25 14:26:17 +01:00
Franz Liedke
a1f723671d Add simple implementation (command handler) for avatar upload. 2015-03-25 14:23:31 +01:00
Franz Liedke
7f66a77ede Add avatar handling to user model. 2015-03-25 14:21:50 +01:00
Franz Liedke
901b6b0839 Provide empty run() method.
This allows me to override the handle() method in subclasses (where
I need access to the request object) without having to overwrite
run(), too.

The class is still abstract.
2015-03-25 13:00:23 +01:00
Toby Zerner
3081fe2aa4 Fix DiscussionWasStarted event not being dispatched 2015-03-24 19:50:52 +10:30
Toby Zerner
8be486a31d Don't show deleted posts in the activity feed 2015-03-24 19:41:30 +10:30
Toby Zerner
43842623aa Only include visible posts in post linkage 2015-03-24 19:29:47 +10:30
Toby Zerner
c35b472e66 Fix non-comment post content serialization 2015-03-24 17:03:59 +10:30
Toby Zerner
193bb0b085 Fix error if there is no included data with user
i.e. if the logged in user is unconfirmed (doesn’t have any groups
attached)
2015-03-24 16:55:22 +10:30
Toby Zerner
4a1550215c Implement notifications 2015-03-24 15:07:38 +10:30
Toby Zerner
1d1025dcd2 Only show comment posts in activity feed 2015-03-24 15:07:11 +10:30
Toby Zerner
e62119964b All post types get numbers
Decided this is necessary because some notifications will need to link
to posts which are not comments (e.g. a “renamed” post)
2015-03-24 15:06:57 +10:30
Toby Zerner
a62e04f956 Upgrade to JSON-API RC3 + latest version of tobscure/json-api
Note: npm source for ember-json-api changed to a fork, but I still had
to apply a custom change to get polymorphic relationships to work (see
https://github.com/kurko/ember-json-api/pull/71#issuecomment-85257281)
2015-03-24 15:04:24 +10:30
Toby Zerner
3880ce70f0 Add user activity system 2015-03-17 17:06:12 +10:30
Toby Zerner
c3fd7679d3 Fix error when hiding/restoring posts 2015-03-17 17:01:42 +10:30
Toby Zerner
4804d95b37 Implement user "bio" field
Perhaps this should be an extension, but it is pretty essential and I
can’t think of many instances where it wouldn’t be wanted. Would be
very easy to extract later on if need be.
2015-03-12 10:38:18 +10:30
Toby Zerner
6ffba13205 Implement user searching & minor search refactor 2015-03-12 10:37:02 +10:30
Toby Zerner
2882ecd46e Rename user posts count to comments count 2015-03-12 10:34:59 +10:30
Toby Zerner
df75c68ac4 Fix welcome hero link for demo 2015-02-26 15:30:07 +10:30
Toby Zerner
f67098461d Use sender information from config 2015-02-26 15:23:09 +10:30
Toby Zerner
2884662723 Prepare welcome hero for demo 2015-02-26 13:30:13 +10:30
Toby Zerner
225a618713 Fix password hashing 2015-02-26 13:29:36 +10:30
Toby Zerner
57f4dc6091 Have a go at some error handling
Still not happy with how this is all fitting together. But good enough
for now
2015-02-26 12:48:23 +10:30
Toby Zerner
c09e47c434 Temporary fix for read marking 2015-02-26 12:46:27 +10:30
Toby Zerner
b4f3148e30 Remove Middleware suffix 2015-02-26 12:45:44 +10:30
Toby Zerner
f2fe0a2e1d Fix setting user to null, for now
Still need to flesh out the exact purpose/use of the Actor class
2015-02-26 12:45:29 +10:30
Toby Zerner
074b4d0989 Add model validation back in 2015-02-26 12:44:39 +10:30
Toby Zerner
a079535883 I dun goofed 2015-02-25 15:44:09 +10:30
Toby Zerner
6a0cbbbe70 Fix logout action 2015-02-25 15:36:25 +10:30
Toby Zerner
3c53e512de Fix bug causing wrong index to be returned 2015-02-25 15:36:17 +10:30
Toby Zerner
9ea482254c Finish signup process, including state restoration 2015-02-25 15:34:02 +10:30
Toby Zerner
2c46888db5 Upgrade to L5 + huge refactor + more. closes #2
New stuff:
- Signup + email confirmation.
- Updated authentication strategy with remember cookies. closes #5
- New search system with some example gambits! This is cool - check out
the source. Fulltext drivers will be implemented as decorators
overriding the EloquentPostRepository’s findByContent method.
- Lay down the foundation for bootstrapping the Ember app.
- Update Web layer’s asset manager to properly publish CSS/JS files.
- Console commands to run installation migrations and seeds.

Refactoring:
- New structure: move models, repositories, commands, and events into
their own namespaces, rather than grouping by entity.
- All events are classes.
- Use L5 middleware and command bus implementations.
- Clearer use of repositories and the Active Record pattern.
Repositories are used only for retrieval of ActiveRecord objects, and
then save/delete operations are called directly on those ActiveRecords.
This way, we don’t over-abstract at the cost of Eloquent magic, but
testing is still easy.
- Refactor of Web layer so that it uses the Actions routing
architecture.
- “Actor” concept instead of depending on Laravel’s Auth.
- General cleanup!
2015-02-24 20:33:18 +10:30
Toby Zerner
0e4e44c358 Preliminary email confirmation implementation
Whenever a user registers or changes their email, they are sent an
email containing a link which they must click to confirm it.

Upon registering, a user won’t be assigned to any groups and therefore
won’t have permission to do anything (but they can still log in!) Upon
confirming their email for the first time, their account will be
assigned to the Member group and thus “activated”.
2015-02-16 14:52:53 +10:30
Toby Zerner
b6ef1f296e Cleanup 2015-02-16 14:50:38 +10:30
Toby Zerner
9bb7001645 Better check for user property in command validators 2015-02-16 14:48:10 +10:30
Toby Zerner
540902cd7a Seed renamed posts properly 2015-02-13 11:44:19 +10:30
Toby Zerner
5e09fd7cd8 Explicit mapping of post type to class 2015-02-13 10:30:32 +10:30
Toby Zerner
011ae3603e Implement "renamed" posts
Record when the discussion was renamed, from what, and by whom.
Information is stored in the `content` field as a serialised JSON
object because proper polymorphism will be too difficult with Ember
Data and especially when extensions try to add new post types.
2015-02-13 10:23:38 +10:30
Toby Zerner
5229c5c06a Mark a discussion as read when it is created 2015-02-12 15:18:45 +10:30
Toby Zerner
6138825db6 Only show reply button if user has permission 2015-02-12 15:17:20 +10:30
Toby Zerner
36787bcf45 Implement hard deletion and rename soft delete to hide 2015-02-12 14:35:24 +10:30
Toby Zerner
cf88fda8c8 Always add discussion state information 2015-02-10 17:53:52 +10:30
Toby Zerner
e30ae7b7b8 Don't imply order on posts relationship 2015-02-10 17:53:16 +10:30
Toby Zerner
8e5cbcd196 Add unordered list formatting 2015-02-10 17:52:13 +10:30
Toby Zerner
624d3d70bb Refresh comments count when updating metadata 2015-02-10 17:51:39 +10:30
Toby Zerner
227f19ddf6 Change API attribute for hiding/restoring posts 2015-02-10 17:51:16 +10:30
Toby Zerner
f56da376da Prevent unnecessary events from being triggered 2015-02-10 17:49:42 +10:30
Toby Zerner
8e6011e8d0 API for marking all as read 2015-02-10 17:48:58 +10:30
Toby Zerner
af94f22334 Rejig post formatting 2015-02-09 09:49:48 +10:30