Skip to content

Commit

Permalink
Attogram Games v4.0.0 - style
Browse files Browse the repository at this point in the history
  • Loading branch information
attogram committed May 21, 2019
1 parent 1a7c8fc commit 4a16be6
Show file tree
Hide file tree
Showing 5 changed files with 71 additions and 48 deletions.
72 changes: 36 additions & 36 deletions _build/games.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,6 @@
'mobile' => true,
'desktop' => true,
],
'life' => [
'name' => 'Life',
'tag' => 'conway\'s game',
'git' => 'https://github.com/copy/life.git',
'mobile' => true,
'desktop' => true,
],
'tower' => [
'name' => 'Tower',
'tag' => 'build up',
Expand All @@ -73,27 +66,13 @@
'mobile' => true,
'desktop' => true,
],
'chess' => [
'name' => 'Chess',
'tag' => 'e2 to e4',
'git' => 'https://github.com/attogram/chess.git',
'mobile' => true,
'desktop' => true,
],
'hexgl-lite' => [
'name' => 'HexGL',
'tag' => 'racing pod',
'git' => 'https://github.com/attogram/HexGL-lite.git',
'mobile' => false,
'desktop' => true,
],
'html5-asteroids' => [
'name' => 'Asteroids',
'tag' => 'retro asteroids',
'git' => 'https://github.com/dmcinnes/HTML5-Asteroids.git',
'mobile' => false,
'desktop' => true,
],
'wolf3d' => [
'name' => 'Wolf3d',
'tag' => 'classic FPS',
Expand Down Expand Up @@ -130,6 +109,14 @@
'mobile' => false,
'desktop' => true,
],
'loderunner_totalrecall' => [
'name' => 'Lode Runner',
'tag' => 'run, dig, old style',
'git' => 'https://github.com/SimonHung/LodeRunner_TotalRecall.git',
'index' => 'lodeRunner.html',
'mobile' => false,
'desktop' => true,
],
'hyperspace-garbage-collection' => [
'name' => 'Hyperspace G',
'tag' => 'collect garbage',
Expand All @@ -144,6 +131,13 @@
'mobile' => true,
'desktop' => true,
],
'the-house' => [
'name' => 'The House',
'tag' => 'Explore your home',
'git' => 'https://github.com/arturkot/the-house-game.git',
'mobile' => false,
'desktop' => true,
],
'dead-valley' => [
'name' => 'Dead Valley',
'tag' => 'survival',
Expand All @@ -165,14 +159,6 @@
'mobile' => false,
'desktop' => true,
],
'loderunner_totalrecall' => [
'name' => 'Lode Runner',
'tag' => 'run, dig, old style',
'git' => 'https://github.com/SimonHung/LodeRunner_TotalRecall.git',
'index' => 'lodeRunner.html',
'mobile' => false,
'desktop' => true,
],
'raging-gardens' => [
'name' => 'Raging Gardens',
'tag' => 'farting ninja rabbits',
Expand All @@ -196,20 +182,41 @@
'mobile' => true,
'desktop' => true,
],
'life' => [
'name' => 'Life',
'tag' => 'conway\'s game',
'git' => 'https://github.com/copy/life.git',
'mobile' => true,
'desktop' => true,
],
'html5-hearts' => [
'name' => 'Hearts',
'tag' => 'card game',
'git' => 'https://github.com/yyjhao/html5-hearts.git',
'mobile' => false,
'desktop' => true,
],
'chess' => [
'name' => 'Chess',
'tag' => 'e2 to e4',
'git' => 'https://github.com/attogram/chess.git',
'mobile' => true,
'desktop' => true,
],
'mah-jongg' => [
'name' => 'Mah-jongg',
'tag' => 'Tianjin 天津麻将',
'git' => 'https://github.com/tiansh/tjmj.git',
'mobile' => false,
'desktop' => true,
],
'html5-asteroids' => [
'name' => 'Asteroids',
'tag' => 'retro asteroids',
'git' => 'https://github.com/dmcinnes/HTML5-Asteroids.git',
'mobile' => false,
'desktop' => true,
],
'missile-game' => [
'name' => 'Missile Game',
'tag' => 'fly thru it',
Expand All @@ -224,13 +231,6 @@
'mobile' => true,
'desktop' => true,
],
'the-house' => [
'name' => 'The House',
'tag' => 'Explore your home',
'git' => 'https://github.com/arturkot/the-house-game.git',
'mobile' => true,
'desktop' => true,
],
'javascript-piano' => [
'name' => 'Piano J',
'tag' => 'synthy javascript',
Expand Down
28 changes: 23 additions & 5 deletions _build/src/AttogramGames.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

namespace Attogram\Games;

use DateTime;
use Exception;

use function chdir;
Expand All @@ -25,7 +26,7 @@

class AttogramGames
{
const VERSION = '3.3.1';
const VERSION = '4.0.0';

/** @var string */
private $title;
Expand Down Expand Up @@ -242,6 +243,9 @@ private function updateGames()
}
}

/**
* @throws Exception
*/
private function initTemplates()
{
$cssFile = 'css.css';
Expand All @@ -253,15 +257,29 @@ private function initTemplates()
$this->header = is_readable($this->customDirectory . $headerFile)
? file_get_contents($this->customDirectory . $headerFile)
: file_get_contents($this->templatesDirectory . $headerFile);
$this->header = str_replace('{{CSS}}', "<style>{$this->css}</style>", $this->header);
$this->header = str_replace('{{TITLE}}', $this->title, $this->header);
$this->header = str_replace('{{HEADLINE}}', $this->headline, $this->header);
$this->header = $this->transposeTemplate($this->header);

$footerFile = 'footer.html';
$this->footer = is_readable($this->customDirectory . $footerFile)
? file_get_contents($this->customDirectory . $footerFile)
: file_get_contents($this->templatesDirectory . $footerFile);
$this->footer = str_replace('{{VERSION}}', 'v' . self::VERSION, $this->footer);
$this->footer = $this->transposeTemplate($this->footer);
}

/**
* @param string $template
* @return string
* @throws Exception
*/
private function transposeTemplate(string $template)
{
$template = str_replace('{{CSS}}', $this->css, $template);
$template = str_replace('{{TITLE}}', $this->title, $template);
$template = str_replace('{{HEADLINE}}', $this->headline, $template);
$template = str_replace('{{VERSION}}', 'v' . self::VERSION, $template);
$template = str_replace('{{DATETIME_UTC}}', gmdate('Y-m-d H:i:s'), $template);

return $template;
}

private function buildMenu()
Expand Down
8 changes: 4 additions & 4 deletions _build/templates/css.css
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
body { background-color: lightslategray; font-family: sans-serif; margin: 20px; }
body { background-color: lightslategray; font-family: sans-serif; margin: 0; }
a, a:visited { color: darkblue; text-decoration: none; }
a:hover { background-color: greenyellow; color: black; }
footer { font-size: small; margin-top: 40px; }
img { border: 1px solid darkgrey; }
h1 { color: whitesmoke; font-size: 130%; margin-bottom: 10px; }
.list { display: flex; flex-wrap: wrap; }
.headline { background-color: black; color: honeydew; font-size: 145%; font-weight: bold; margin: 0; text-align: center; }
.list { display: flex; flex-wrap: wrap; margin: 10px; }
.game { background-color: white; border: 1px solid black; margin: 5px; padding: 10px 5px 0 5px; text-align: center; width: 118px;}
.game:hover{ background-color: greenyellow; }
.platform { background-color: transparent; color: grey; font-size: small; padding: 2px; text-align: right; }
footer { color: darkslategrey; font-family: monospace; font-size: small; font-style: italic; padding: 20px; }
4 changes: 3 additions & 1 deletion _build/templates/footer.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<footer>
Powered by <a href="https://github.com/attogram/games" target="_blank">attogram/games</a> {{VERSION}}
<p>{{HEADLINE}}</p>
<p>last updated: {{DATETIME_UTC}} UTC</p>
<p>powered by <a href="https://github.com/attogram/games" target="_blank">attogram/games</a> {{VERSION}}</p>
</footer>
</body>
</html>
7 changes: 5 additions & 2 deletions _build/templates/header.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>{{TITLE}}</title>
{{CSS}}
<style>{{CSS}}</style>
</head>
<body><h1>{{HEADLINE}}</h1>
<body>
<div class="headline">
{{HEADLINE}}
</div>

0 comments on commit 4a16be6

Please sign in to comment.