Files
pathfinder/app/Controller/Api/GitHub.php
Mark Friedrich a5f29ee2eb - NEW "Thera connections" UI module, closed #829
- Upgraded "[_pathfinder_esi_](https://github.com/exodus4d/pathfinder_esi)" Web API client`v1.3.2` → `v2.0.0`
- Fixed a js bug where current active(selected) system becomes deselected after system was dragged on map
- Fixed a js bug where new auto mapped systems (e.g. after jump) were positioned outside current map scroll viewport
- Fixed a js bug where map sync failed after map tabs switch
- Fixed blurry map when map zoom was changed
- Fixed multiple minor JS bugs where map render/update failed
2020-03-02 16:42:36 +01:00

85 lines
2.6 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<?php /** @noinspection PhpUndefinedMethodInspection */
/**
* Created by PhpStorm.
* User: exodus4d
* Date: 16.01.16
* Time: 03:34
*/
namespace Exodus4D\Pathfinder\Controller\Api;
use Exodus4D\Pathfinder\Lib\Config;
use Exodus4D\Pathfinder\Controller;
/**
* Github controller
* Class Route
* @package Controller\Api
*/
class GitHub extends Controller\Controller {
/**
* get release information from GitHub
* @param \Base $f3
*/
public function releases(\Base $f3){
$releaseCount = 4;
$return = (object) [];
$return->releasesData = [];
$return->version = (object) [];
$return->version->current = Config::getPathfinderData('version');
$return->version->last = '';
$return->version->delta = null;
$return->version->dev = false;
$releases = $f3->gitHubClient()->send('getProjectReleases', 'exodus4d/pathfinder', $releaseCount);
foreach($releases as $key => &$release){
// check version ------------------------------------------------------------------------------------------
if($key === 0){
$return->version->last = $release['name'];
if(version_compare( $return->version->current, $return->version->last, '>')){
$return->version->dev = true;
}
}
if(
!$return->version->dev &&
version_compare($release['name'], $return->version->current, '>=')
){
$return->version->delta = ($key === count($releases) - 1) ? '>= ' . $key : $key;
}
// format body ------------------------------------------------------------------------------------
$body = $release['body'];
// remove "update information" from release text
// -> keep everything until first "***" -> horizontal line
if( ($pos = strpos($body, '***')) !== false){
$body = substr($body, 0, $pos);
}
// convert list style
$body = str_replace(' - ', '* ', $body);
// convert Markdown to HTML -> use either gitHub API (in oder to create abs, issue links)
// -> or F3´s markdown as fallback
$html = $f3->gitHubClient()->send('markdownToHtml', 'exodus4d/pathfinder', $body);
if(!empty($html)){
$body = $html;
}else{
$body = \Markdown::instance()->convert(trim($body));
}
$release['body'] = $body;
}
$return->releasesData = $releases;
echo json_encode($return);
}
}