Reason: trying to make unique string for every possible argument in
global fashion is difficult. For example it would make sense for
EditPostRelationsJob to accept argument named "post-ids", but it
wouldn't make much sense for AddPostJob to accept "post-ids" since it
doesn't tell much. Thus, common arguments are going to be defined in
top-level AbstractJob for ease of control, while more job-specific
arguments are going to be specified in respective job implementations.
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.
When trying to search for hidden or disliked posts, it was impossible to search
by any aliases because of some hardcoded stuff. This commit removes the
hardcoded part altogether and fixes aliases support for these search terms.
* Added few new operators that were left hardcoded
* Changed "Operator" to "Functor"
* Better hierarchy - less mess
* Serialized SQL queries should contain fewer braces
Instead of showing comments chronologically, group them into posts, then sort
the posts by last comment date. Reason: improved comment context delivery
makes discussion bumping possible (no matter how old it is) and discussion is
what comments are about.
Comment count is limited to 5 per post.
Instead of getting all three rows at once using abs(id1-id2)<=1, it now asks DB
explicitly about id-1 and id+1. Even though it uses more SQL queries, it's
actually slightly faster.
If user is in mass tag mode and changes target tag but doesn't change the
query, he now remains at the same page. (Concerns only users who have disabled
endless scrolling.)
Reason: until now, PostSearchService was using magic to get around the biggest
limitation of SqlQuery.php: it didn't support arbitrary order of operations.
You couldn't join with something and tell then to select something from it.
Additionally, forging UPDATE queries was a joke. The new Sql* classes replace
SqlQuery completely and address these issues. Using Sql* classes might be
tedious and ugly at times, but it is necessary step to improve model layer
maintainability.
It is by no menas complete implementation of SQL grammar, but for current needs
it's enough, and, what's most important, it is easily extensible.
Additional changes:
* Added sorting style aliases
- fav_count
- tag_count
- comment_count
* Sorting by multiple tokens in post search is now possible
* Searching for disliked posts with "special:disliked" always yields results
(even if user has disabled showing disliked posts by default)
* More maintainable next/prev post support
Following privileges for post actions can now understand different settings for
everyone and for uploader:
* Scoring posts
* Featuring posts
* Flagging posts
* Favoriting posts
Additionally, privilege for flagging users can now understand different
settings for everyone and for the user that is currently logged in.
In other words: with this update admin can configure privileges so that scoring
own posts or flagging oneself will be prohibited, while scoring other people's
posts or flagging others will be okay.
CSS for comments wasn't included in post-view.phtml. This manifested when user
posted a comment thruogh it (AJAX requests don't append CSS from AJAXed pages,
so added it in parent view).
Styles, scripts and page titles are no longer set from controllers level.
Changed because it was breaking MVC pattern and led to spaghetti code.
Also, optimized JS/CSS inclusions a bit.
Pages load 1.5-2x faster
Exception trace in JSON is now represented as an array
Fixed pagination of default favorites page in user pages
Fixed thumbnail size validation for non-square thumbnails
If tag/user/whatever from last search was deleted after viewing a post,
refreshing the page with that post would yield "Invalid tag/user/whatever"
error.
I changed it so that when retrieving previous/next post for latest search query
throws any errors, saved search query gets resetted to empty one.
- Fixed broken negative searches
- Faster search by tag / comment / submit / favorites (useless nested joins
replaced to entity prefetch). Side effect: searching for nonexistent tags,
users etc yields informative errors instead of "no posts to show")
- Fixed duplicated column in order clause ("ORDER BY id DESC, id DESC")
- No random chdir() calls
- No more exceptions when executing scripts from dirs other than root
- find-posts.php prints absolute paths making piping more useful
- Most of model-related code moved from controllers to model classes, much
fewer calls to R::whatever() in controllers
- Post editing and uploading shares the same code, thus making implementing
stuff easier in the future
- Added support for default bean wiring, no more calls to R::preload() all over
the place
- More robust concurrent post editing detection
If delta between pages in paginator is greater than 2, it adds "..." inbetween.
If delta is equal to 2, it adds missing page link instead.
Examples:
1,4,5 gets converted to 1,...,4,5
1,3,4 gets converted to 1,2,3,4