forked from friendica/friendica-addons
		
	[advancedcontentfilter] Add addon files
- Add hooks - Add mini-API module powered by Slim - Add addon settings page powered by VueJS - Add translation strings - Add help page
This commit is contained in:
		
					parent
					
						
							
								20862be7d0
							
						
					
				
			
			
				commit
				
					
						b02724f867
					
				
			
		
					 9 changed files with 1396 additions and 0 deletions
				
			
		
							
								
								
									
										30
									
								
								advancedcontentfilter/src/middlewares.php
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										30
									
								
								advancedcontentfilter/src/middlewares.php
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,30 @@
 | 
			
		|||
<?php
 | 
			
		||||
 | 
			
		||||
$container = $slim->getContainer();
 | 
			
		||||
 | 
			
		||||
// Error handler based off https://stackoverflow.com/a/48135009/757392
 | 
			
		||||
$container['errorHandler'] = function () {
 | 
			
		||||
	return function(Psr\Http\Message\RequestInterface $request, Psr\Http\Message\ResponseInterface $response, Exception $exception)
 | 
			
		||||
    {
 | 
			
		||||
        $responseCode = 500;
 | 
			
		||||
 | 
			
		||||
		if (is_a($exception, 'Friendica\Network\HTTPException')) {
 | 
			
		||||
			$responseCode = $exception->httpcode;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		$errors['message'] = $exception->getMessage();
 | 
			
		||||
 | 
			
		||||
        $errors['responseCode'] = $responseCode;
 | 
			
		||||
 | 
			
		||||
        return $response
 | 
			
		||||
            ->withStatus($responseCode)
 | 
			
		||||
            ->withJson($errors);
 | 
			
		||||
    };
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
$container['notFoundHandler'] = function () {
 | 
			
		||||
    return function ()
 | 
			
		||||
	{
 | 
			
		||||
		throw new \Friendica\Network\HTTPException\NotFoundException(L10n::t('Method not found'));
 | 
			
		||||
    };
 | 
			
		||||
};
 | 
			
		||||
							
								
								
									
										22
									
								
								advancedcontentfilter/src/routes.php
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										22
									
								
								advancedcontentfilter/src/routes.php
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,22 @@
 | 
			
		|||
<?php
 | 
			
		||||
 | 
			
		||||
// Routes
 | 
			
		||||
 | 
			
		||||
/* @var $slim Slim\App */
 | 
			
		||||
$slim->group('/advancedcontentfilter/api', function () {
 | 
			
		||||
	/* @var $this Slim\App */
 | 
			
		||||
	$this->group('/rules', function () {
 | 
			
		||||
		/* @var $this Slim\App */
 | 
			
		||||
		$this->get('', 'advancedcontentfilter_get_rules');
 | 
			
		||||
		$this->post('', 'advancedcontentfilter_post_rules');
 | 
			
		||||
 | 
			
		||||
		$this->get('/{id}', 'advancedcontentfilter_get_rules_id');
 | 
			
		||||
		$this->put('/{id}', 'advancedcontentfilter_put_rules_id');
 | 
			
		||||
		$this->delete('/{id}', 'advancedcontentfilter_delete_rules_id');
 | 
			
		||||
	});
 | 
			
		||||
 | 
			
		||||
	$this->group('/variables', function () {
 | 
			
		||||
		/* @var $this Slim\App */
 | 
			
		||||
		$this->get('/{guid}', 'advancedcontentfilter_get_variables_guid');
 | 
			
		||||
	});
 | 
			
		||||
});
 | 
			
		||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue