/** * Converts markdown text to HTML. * * @param string $text The markdown formatted text. * * @return string */ function Markdown($text) { static $parser; if (!isset($parser)) { $parser = new ElephantMarkdown(); } return $parser->transform($text); }
/** * Execute the application. * * @return void * * @since 11.3 */ public function execute() { // Import the JHttp class that will connect with the Github API. jimport('joomla.client.http'); // Get a list of the merged pull requests. $merged = $this->getMergedPulls(); $html = '<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>Joomla Platform pull request log</title> </head> <body>'; // Set the maximum number of pages (and runaway failsafe). $cutoff = 10; $page = 1; while ($cutoff--) { // Get a page of issues. $issues = $this->getIssues($page++); // Check if we've gone past the last page. if (empty($issues)) { break; } $html .= PHP_EOL . ' <ul>'; // Loop through each pull. foreach ($issues as $issue) { // Check if the issue has been merged. if (empty($issue->pull_request->html_url)) { continue; } // Check if the pull has been merged. if (!in_array($issue->number, $merged)) { continue; } $html .= PHP_EOL . ' <li>'; $html .= PHP_EOL . ' <p>'; // Prepare the link to the pull. $html .= '[<a href="' . $issue->html_url . '" title="Closed ' . $issue->closed_at . '">'; $html .= '#' . $issue->number; $html .= '</a>] <strong>' . $issue->title . '</strong>'; $html .= ' (<a href="https://github.com/' . $issue->user->login . '">' . $issue->user->login . '</a>)'; if (trim($issue->body)) { // Parse the markdown formatted description of the pull. // Note, this doesn't account for all the Github flavoured markdown, but it's close. $html .= ElephantMarkdown::parse($issue->body); } $html .= PHP_EOL . ' </li>'; } $html .= PHP_EOL . ' </ul>'; } $html .= PHP_EOL . ' </body>'; $html .= PHP_EOL . '</html>'; // Check if the output folder exists. if (!is_dir('./docs')) { mkdir('./docs'); } // Write the file. file_put_contents('./docs/changelog.html', $html); // Close normally. $this->close(); }