mirror of
https://git.friendi.ca/friendica/friendica-addons.git
synced 2024-11-19 00:03:42 +00:00
[advancedcontentfilter] Fix formatting in src/middlewares and doc/advancedcontentfilter
This commit is contained in:
parent
b02724f867
commit
acce253d8e
2 changed files with 14 additions and 19 deletions
|
@ -45,14 +45,11 @@ A post will be collapsed if at least one rule matches, but all matching rule nam
|
||||||
- **booleans** - `true` and `false`.
|
- **booleans** - `true` and `false`.
|
||||||
- **null** - `null`.
|
- **null** - `null`.
|
||||||
|
|
||||||
A backslash (``\``) must be escaped by 4 backslashes (``\\\\``) in a string
|
A backslash (``\``) must be escaped by 4 backslashes (``\\\\``) in a string and 8 backslashes (``\\\\\\\\``) in a regex::
|
||||||
and 8 backslashes (``\\\\\\\\``) in a regex::
|
|
||||||
|
|
||||||
`"a\\\\b" matches "/^a\\\\\\\\b$/"`
|
`"a\\\\b" matches "/^a\\\\\\\\b$/"`
|
||||||
|
|
||||||
Control characters (e.g. ``\n``) in expressions are replaced with
|
Control characters (e.g. ``\n``) in expressions are replaced with whitespace. To avoid this, escape the sequence with a single backslash (e.g. ``\\n``).
|
||||||
whitespace. To avoid this, escape the sequence with a single backslash
|
|
||||||
(e.g. ``\\n``).
|
|
||||||
|
|
||||||
### Supported Operators
|
### Supported Operators
|
||||||
|
|
||||||
|
@ -85,13 +82,11 @@ The component comes with a lot of operators:
|
||||||
* ``>=`` (greater than or equal to)
|
* ``>=`` (greater than or equal to)
|
||||||
* ``matches`` (regex match)
|
* ``matches`` (regex match)
|
||||||
|
|
||||||
To test if a string does *not* match a regex, use the logical ``not``
|
To test if a string does *not* match a regex, use the logical ``not`` operator in combination with the ``matches`` operator:
|
||||||
operator in combination with the ``matches`` operator:
|
|
||||||
|
|
||||||
'not ("foo" matches "/bar/")'
|
`not ("foo" matches "/bar/")`
|
||||||
|
|
||||||
You must use parenthesis because the unary operator ``not`` has precedence
|
You must use parenthesis because the unary operator ``not`` has precedence over the binary operator ``matches``.
|
||||||
over the binary operator ``matches``.
|
|
||||||
|
|
||||||
#### Logical Operators
|
#### Logical Operators
|
||||||
|
|
||||||
|
|
|
@ -5,8 +5,8 @@ $container = $slim->getContainer();
|
||||||
// Error handler based off https://stackoverflow.com/a/48135009/757392
|
// Error handler based off https://stackoverflow.com/a/48135009/757392
|
||||||
$container['errorHandler'] = function () {
|
$container['errorHandler'] = function () {
|
||||||
return function(Psr\Http\Message\RequestInterface $request, Psr\Http\Message\ResponseInterface $response, Exception $exception)
|
return function(Psr\Http\Message\RequestInterface $request, Psr\Http\Message\ResponseInterface $response, Exception $exception)
|
||||||
{
|
{
|
||||||
$responseCode = 500;
|
$responseCode = 500;
|
||||||
|
|
||||||
if (is_a($exception, 'Friendica\Network\HTTPException')) {
|
if (is_a($exception, 'Friendica\Network\HTTPException')) {
|
||||||
$responseCode = $exception->httpcode;
|
$responseCode = $exception->httpcode;
|
||||||
|
@ -14,17 +14,17 @@ $container['errorHandler'] = function () {
|
||||||
|
|
||||||
$errors['message'] = $exception->getMessage();
|
$errors['message'] = $exception->getMessage();
|
||||||
|
|
||||||
$errors['responseCode'] = $responseCode;
|
$errors['responseCode'] = $responseCode;
|
||||||
|
|
||||||
return $response
|
return $response
|
||||||
->withStatus($responseCode)
|
->withStatus($responseCode)
|
||||||
->withJson($errors);
|
->withJson($errors);
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
$container['notFoundHandler'] = function () {
|
$container['notFoundHandler'] = function () {
|
||||||
return function ()
|
return function ()
|
||||||
{
|
{
|
||||||
throw new \Friendica\Network\HTTPException\NotFoundException(L10n::t('Method not found'));
|
throw new \Friendica\Network\HTTPException\NotFoundException(L10n::t('Method not found'));
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue