Add a build information file

This commit is contained in:
Michiel Sikma 2017-01-07 17:58:34 +01:00
parent 46fd88a36f
commit 2e673b614f
No known key found for this signature in database
GPG Key ID: ABBA426CD282C020
6 changed files with 138 additions and 4 deletions

View File

@ -122,6 +122,8 @@ $s['scss_output'] = 'pokesprite.scss';
$s['js_output'] = 'pokesprite.js';
// Output name of the HTML overview
$s['html_output'] = 'overview.html';
// Output name of the HTML file with build information
$s['html_build_output'] = 'files.html';
// Output name of the Markdown overview
$s['md_output'] = 'overview.md';
// Resources directory name
@ -132,6 +134,8 @@ $s['scss_tpl'] = 'pokesprite-tpl.scss';
$s['js_tpl'] = 'pokesprite-tpl.js';
// HTML template file
$s['html_tpl'] = 'overview-tpl.html';
// HTML template file for the build information
$s['html_build_tpl'] = 'files-tpl.html';
// Usage template file
$s['usage_tpl'] = 'usage.tpl';
// Whether to generate a Markdown overview

View File

@ -18,6 +18,8 @@ class IconOverview extends IconTplFactory
public $icon_list;
/** @var ?string[] The generated overview markup, by format. */
public $overview;
/** @var ?string[] The generated build overview markup, by format. */
public $build_overview;
/** @var string Empty cell content. */
public $empty_cell = '';
@ -45,6 +47,20 @@ class IconOverview extends IconTplFactory
return $this->overview[$format];
}
/**
* Returns build overview markup code.
*
* @param string $format The format to generate the overview in.
* @return string Overview markup code.
*/
public function get_build_overview($format='html')
{
if (empty($this->build_overview[$format])) {
$this->generate_build_overview($format);
}
return $this->build_overview[$format];
}
/**
* Generates overview markup code.
*
@ -61,6 +77,19 @@ class IconOverview extends IconTplFactory
}
}
/**
* Generates build overview markup code.
*
* @param string $format The format to generate the overview in.
*/
public function generate_build_overview($format='html')
{
if ($format == 'html') {
// Actually, this is the only one we do.
$this->generate_build_overview_html();
}
}
/**
* Generates overview markup code, Markdown version.
*
@ -289,6 +318,36 @@ class IconOverview extends IconTplFactory
return empty($name) ? $this->empty_cell_content : $name;
}
/**
* Generates build overview markup code, HTML version.
*
* @return string Build overview markup code.
*/
public function generate_build_overview_html()
{
// Allow the template to use the minified version too.
$js_output_min = str_replace(
'.js',
'.min.js',
Settings::get('js_output')
);
// Decorate the template with our generated markup.
$markup = $this->decorate_tpl_with_defaults($this->tpl, array(
'resources_dir' => Settings::get('resources_dir'),
'js_output' => Settings::get('js_output'),
'js_output_min' => $js_output_min,
'icons_amount' => htmlspecialchars(count($this->icon_list)),
'script_date' => Settings::get('script_date'),
'css_output' => str_replace('.scss', '.css', Settings::get('scss_output')),
'title_str_html' => htmlspecialchars(Settings::get('title_str')),
'script_date_html' => htmlspecialchars(Settings::get('script_date')),
'website_html' => htmlspecialchars(Settings::get('website')),
));
$this->build_overview['html'] = $this->process_output($markup);
}
/**
* Generates overview markup code, HTML version.
*
@ -395,6 +454,7 @@ class IconOverview extends IconTplFactory
'css_output' => str_replace('.scss', '.css', Settings::get('scss_output')),
'title_str_html' => htmlspecialchars(Settings::get('title_str')),
'script_date_html' => htmlspecialchars(Settings::get('script_date')),
'icons_amount' => htmlspecialchars(count($this->icon_list)),
'website_html' => htmlspecialchars(Settings::get('website')),
));

View File

@ -368,6 +368,14 @@ if ($generate_markdown) {
file_put_contents($dir_output.$md_output, $overview_md);
}
// Generate a page about the build too.
$icon_overview->register_tpl($resources_dir.$html_build_tpl);
$overview = $icon_overview->get_build_overview('html');
if (file_exists($dir_output.$html_build_output)) {
unlink($dir_output.$html_build_output);
}
file_put_contents($dir_output.$html_build_output, $overview);
// With the image and the overview done, let's generate the SCSS.
print(I18n::l('scss_generating'));
$icon_styler->register_vars($base_vars);

45
resources/files-tpl.html Normal file
View File

@ -0,0 +1,45 @@
<!doctype html>
<html xmlns="http://www.w3.org/1999/xhtml" lang="en">
<!--
{{$title_str}} {{$revision}} {{$website_txt}}
{{$copyright_str}}
{{$copyright_gf}}
{{$copyright_contrib_notice}}
{{$generated_on}}
-->
<head>
<meta charset="utf-8" />
<title>{{$title_str}} {{$revision}} Files</title>
<!-- Pokémon icons -->
<link type="text/css" href="{{$css_output}}" rel="stylesheet" media="screen" />
<script charset="utf-8" src="{{$js_output_min}}" ></script>
<!-- Overview CSS (generated from {{$resources_dir}}overview.scss) -->
<link type="text/css" href="overview.css" rel="stylesheet" media="screen" />
</head>
<body>
<div id="top">
<div class="description">
<div class="header">
<h1>PokéSprite</h1>
<p>Pokémon icon database and sprite sheet generator</p>
</div>
<div class="docs-container">
<h2>Files ({{$revision}})</h2>
<p>To implement PokéSprite on a website, you need to include one CSS file, one JS file and one image. Depending on where you want to keep the image, you'll need to edit the CSS file to point to the right location.</p>
<p>Generated on <span class="time">{{$script_date_html}}</span> (<span class="amount">{{$icons_amount}}</span> icons).</p>
<p class="build-section"><strong>Standard build:</strong></p>
<p>Contains Pokémon (regular and shiny; with forms, with right-facing alternate icons), and items.</p>
<ul>
<li><a href="pokesprite.css">pokesprite.css</a></li>
<li><a href="pokesprite.min.js">pokesprite.min.js</a></li>
<li><a href="pokesprite.png">pokesprite.png</a></li>
</ul>
<p>For more information about the project, visit <a href="{{$website_html}}">{{$website_html}}</a>.</p>
<p><a href="/">Back to overview.</a></p>
</div>
</div>
</div>
</body>
</html>

View File

@ -29,12 +29,25 @@
<body>
<div id="top">
<div class="description">
<h1>{{$title_str}} {{$revision}} Icon Overview</h1>
<p>The following list is a complete overview of all icons and the HTML necessary to display them. It was generated on <span class="time">{{$script_date_html}}</span>.</p>
<p>For more information about the project, visit <a href="{{$website_html}}">{{$website_html}}</a>.</p>
<div class="header">
<h1>PokéSprite</h1>
<p>Pokémon icon database and sprite sheet generator</p>
</div>
<div class="docs-container">
<h2>Icon overview ({{$revision}})</h2>
<p>The following list is a complete overview of all icons and the HTML necessary to display them.</p>
<p>Generated on <span class="time">{{$script_date_html}}</span> (<span class="amount">{{$icons_amount}}</span> icons).</p>
</div>
</div>
<div class="description">
{{$icons}}
<p>End of overview. <a href="#top">Back to top.</a></p>
</div>
<div class="description">
<div class="docs-container">
<p>For more information about the project, visit <a href="{{$website_html}}">{{$website_html}}</a>.</p>
<p><a href="/">Back to overview.</a></p>
</div>
</div>
</div>
</body>
</html>

View File

@ -101,6 +101,10 @@ html, body {
p {
margin: 0 0 6px;
&.build-section {
margin-top: 15px;
}
&.center {
text-align: center;
}