Modules separated
This commit is contained in:
		
					parent
					
						
							
								2d3296f697
							
						
					
				
			
			
				commit
				
					
						0979daddac
					
				
			
		
					 3 changed files with 45 additions and 30 deletions
				
			
		| 
						 | 
				
			
			@ -17,12 +17,7 @@ class NodeInfo extends BaseModule
 | 
			
		|||
	{
 | 
			
		||||
		$app = self::getApp();
 | 
			
		||||
 | 
			
		||||
		// @TODO: Replace with parameter from router
 | 
			
		||||
		// if the first argument is ".well-known", print the well-known text
 | 
			
		||||
		if (($app->argc > 1) && ($app->argv[0] == '.well-known')) {
 | 
			
		||||
			self::printWellKnown($app);
 | 
			
		||||
		// otherwise print the nodeinfo
 | 
			
		||||
		} elseif ($parameters['version'] == '1.0') {
 | 
			
		||||
		if ($parameters['version'] == '1.0') {
 | 
			
		||||
			self::printNodeInfo1($app);
 | 
			
		||||
		} elseif ($parameters['version'] == '2.0') {
 | 
			
		||||
			self::printNodeInfo2($app);
 | 
			
		||||
| 
						 | 
				
			
			@ -31,29 +26,6 @@ class NodeInfo extends BaseModule
 | 
			
		|||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * Prints the well-known nodeinfo redirect
 | 
			
		||||
	 *
 | 
			
		||||
	 * @param App $app
 | 
			
		||||
	 *
 | 
			
		||||
	 * @throws \Friendica\Network\HTTPException\NotFoundException
 | 
			
		||||
	 */
 | 
			
		||||
	private static function printWellKnown(App $app)
 | 
			
		||||
	{
 | 
			
		||||
		$nodeinfo = [
 | 
			
		||||
			'links' => [
 | 
			
		||||
				['rel'  => 'http://nodeinfo.diaspora.software/ns/schema/1.0',
 | 
			
		||||
				'href' => $app->getBaseURL() . '/nodeinfo/1.0'],
 | 
			
		||||
				['rel'  => 'http://nodeinfo.diaspora.software/ns/schema/2.0',
 | 
			
		||||
				'href' => $app->getBaseURL() . '/nodeinfo/2.0'],
 | 
			
		||||
			]
 | 
			
		||||
		];
 | 
			
		||||
 | 
			
		||||
		header('Content-type: application/json; charset=utf-8');
 | 
			
		||||
		echo json_encode($nodeinfo, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES);
 | 
			
		||||
		exit;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * Return the supported services
 | 
			
		||||
	 *
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										43
									
								
								src/Module/WellKnown/NodeInfo.php
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										43
									
								
								src/Module/WellKnown/NodeInfo.php
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,43 @@
 | 
			
		|||
<?php
 | 
			
		||||
 | 
			
		||||
namespace Friendica\Module\WellKnown;
 | 
			
		||||
 | 
			
		||||
use Friendica\App;
 | 
			
		||||
use Friendica\BaseModule;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Standardized way of exposing metadata about a server running one of the distributed social networks.
 | 
			
		||||
 * @see https://github.com/jhass/nodeinfo/blob/master/PROTOCOL.md
 | 
			
		||||
 */
 | 
			
		||||
class NodeInfo extends BaseModule
 | 
			
		||||
{
 | 
			
		||||
	public static function rawContent(array $parameters = [])
 | 
			
		||||
	{
 | 
			
		||||
		$app = self::getApp();
 | 
			
		||||
 | 
			
		||||
		self::printWellKnown($app);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * Prints the well-known nodeinfo redirect
 | 
			
		||||
	 *
 | 
			
		||||
	 * @param App $app
 | 
			
		||||
	 *
 | 
			
		||||
	 * @throws \Friendica\Network\HTTPException\NotFoundException
 | 
			
		||||
	 */
 | 
			
		||||
	private static function printWellKnown(App $app)
 | 
			
		||||
	{
 | 
			
		||||
		$nodeinfo = [
 | 
			
		||||
			'links' => [
 | 
			
		||||
				['rel'  => 'http://nodeinfo.diaspora.software/ns/schema/1.0',
 | 
			
		||||
				'href' => $app->getBaseURL() . '/nodeinfo/1.0'],
 | 
			
		||||
				['rel'  => 'http://nodeinfo.diaspora.software/ns/schema/2.0',
 | 
			
		||||
				'href' => $app->getBaseURL() . '/nodeinfo/2.0'],
 | 
			
		||||
			]
 | 
			
		||||
		];
 | 
			
		||||
 | 
			
		||||
		header('Content-type: application/json; charset=utf-8');
 | 
			
		||||
		echo json_encode($nodeinfo, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES);
 | 
			
		||||
		exit;
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -17,7 +17,7 @@ return [
 | 
			
		|||
 | 
			
		||||
	'/.well-known' => [
 | 
			
		||||
		'/host-meta'      => [Module\WellKnown\HostMeta::class,     [R::GET]],
 | 
			
		||||
		'/nodeinfo'       => [Module\NodeInfo::class,               [R::GET]],
 | 
			
		||||
		'/nodeinfo'       => [Module\WellKnown\NodeInfo::class,     [R::GET]],
 | 
			
		||||
		'/webfinger'      => [Module\Xrd::class,                    [R::GET]],
 | 
			
		||||
		'/x-social-relay' => [Module\WellKnown\XSocialRelay::class, [R::GET]],
 | 
			
		||||
	],
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue