Created
January 19, 2017 03:09
-
-
Save tohokuaiki/1ce77e677d58b3894b3a82010641caed to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
use \FeedWriter\ATOM ; | |
date_default_timezone_set( "Asia/Tokyo" ) ; | |
require_once dirname(__FILE__)."/FeedWriter/Item.php" ; | |
require_once dirname(__FILE__)."/FeedWriter/Feed.php" ; | |
require_once dirname(__FILE__)."/FeedWriter/ATOM.php" ; | |
class AtlasFeed | |
{ | |
private $feed; | |
private $applicaton ; | |
/** | |
* @brief | |
* @param | |
* @retval | |
*/ | |
function __construct($application) | |
{ | |
$this->application = $application; | |
$this->feed = new ATOM ; | |
$this->feed-> | |
setTitle("Atlassian ".$application." version list")-> | |
setDate(new DateTime()) ; | |
} | |
/** | |
* @brief | |
* @param | |
* @retval | |
*/ | |
function addJson($target_url, $use_cache = false) | |
{ | |
$cache_file = sprintf('%s/%s_%s.json', | |
dirname(__FILE__), | |
$this->application, | |
md5($target_url)); | |
if (!$use_cache || !file_exists($cache_file)){ | |
ob_start(); | |
system(sprintf('wget -O %s %s', $cache_file, $target_url)); | |
$json = ob_get_clean(); | |
} | |
$json = file_get_contents($cache_file); | |
$json = substr($json, strlen('downloads(')); | |
$json = substr($json, 0, -1); | |
$json = json_decode($json); | |
$this->feed->setLink($target_url) ; | |
foreach ($json as $release) { | |
$item = $this->feed->createNewItem() ; | |
$desc = sprintf("[size]=> %s\n[Release Notes]=> %s \n[Upgrade Notes]=> %s", | |
$release->size, | |
$release->releaseNotes, | |
$release->upgradeNotes | |
); | |
$this->feed->addItem($item->setTitle($release->description) | |
->setLink($release->zipUrl) | |
->setDate(strtotime($release->released)) | |
->setAuthor("Atlassian" ) | |
->setDescription($desc) | |
->setContent(nl2br($desc))); | |
} | |
return $this; | |
} | |
/** | |
* @brief | |
* @param | |
* @retval | |
*/ | |
function printFeed() | |
{ | |
$this->feed->printFeed(); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
require_once dirname(__FILE__).'/AtlasFeed.php'; | |
$feed = new AtlasFeed('confluence'); | |
$feed->addJson('https://my.atlassian.com/download/feeds/current/confluence.json')-> | |
addJson('https://my.atlassian.com/download/feeds/archived/confluence.json')-> | |
printFeed(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
require_once dirname(__FILE__).'/AtlasFeed.php'; | |
$feed = new AtlasFeed('jira'); | |
$feed->addJson('https://my.atlassian.com/download/feeds/current/jira-core.json')-> | |
addJson('https://my.atlassian.com/download/feeds/archived/jira-core.json')-> | |
addJson('https://my.atlassian.com/download/feeds/current/jira-servicedesk.json')-> | |
addJson('https://my.atlassian.com/download/feeds/archived/jira-servicedesk.json')-> | |
addJson('https://my.atlassian.com/download/feeds/current/jira-software.json')-> | |
addJson('https://my.atlassian.com/download/feeds/archived/jira-software.json')-> | |
addJson('https://my.atlassian.com/download/feeds/archived/jira.json')-> | |
printFeed(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment