Right now there's a lot of messy code in controllers. Furthermore, there
is no way to interact with szurubooru via vanilla HTTP, since API is
next to non-existent. So, basing upon my experiences from another
project, I plan to:
- Create actual API. It is going to consist of well-defined "jobs" that
do things currently done by controllers. Benefits of such approach are
as follows:
- defining them in their own classes allows to clean up code a lot,
- it allows to abstract from input method (POST data, part of URL,
whatever), and leave processing of these to controllers,
- it allows to make proxy controller, whose purpose would be to let
users interact with API (jobs) directly in well-documented and
consistent way.
- Make controllers responsible only for mediating between views and API.
Behavior of these may remain inconsistent, since views they're talking
to are also messy to begin with. Such controllers might be removed
altogether in the future in favor of making views talk to API directly
through previously mentioned ApiController.
- Organize all sorts of privilege checking and possibly other stuff into
methods within jobs.
- Actually distinguish POST from GET requests.
- Leave POST-only controller methods as Actions, but rename GET-only
methods to Views. Example: editAction for editing comments, but
listView for showing comment list. The choice of these suffixes might
be subject to changes in future.
- Get rid of ?json and $context->transport. They now look like disease
to me.
This commit introduces job system and converts CommentController to use
the new API.
Since the purpose that StatusHelper was mainly created for no longer
holds, it was simplified to Messenger. It is now is used to transport
simple messages to views and still transports info whether the message
is about success or failure.
Markdown Extra that we recently switched to has different implementation from
Markdown (including, but not limited to, regexes), so some of the overwritten
callbacks stopped working.