updated template to handle file, style fixes

This commit is contained in:
are0h 2022-03-20 14:58:27 -07:00
parent fd4ff2ea52
commit a66377e597
7 changed files with 352 additions and 312 deletions

1
.gitignore vendored
View file

@ -6,6 +6,7 @@ dist
.DS_Store .DS_Store
*.sublime-project *.sublime-project
*.sublime-workspace *.sublime-workspace
*.code-workspace
assets assets
vendor vendor

View file

@ -7,132 +7,151 @@ class ThemeEngine
public $data = []; public $data = [];
public $loader; public $loader;
public $twig; public $twig;
public function __construct(string $themePath, string $themeAssetPath) public function __construct(string $themePath, string $themeAssetPath)
{ {
$var = []; $var = [];
$this->themePath = $themePath; $this->themePath = $themePath;
$this->themeAssetPath = $themeAssetPath; $this->themeAssetPath = $themeAssetPath;
$path = explode("/", $themeAssetPath); $path = explode('/', $themeAssetPath);
$this->themeFolder = $path[4]; $this->themeFolder = $path[4];
$this->settings = json_decode( $this->settings = json_decode(
file_get_contents("./data/settings.json"), file_get_contents('./data/settings.json'),
true true
); );
$this->posts = json_decode(file_get_contents("./data/posts.json"), true); $this->posts = json_decode(file_get_contents('./data/posts.json'), true);
$this->archives = json_decode( $this->archives = json_decode(
file_get_contents("./data/archives.json"), file_get_contents('./data/archives.json'),
true true
); );
$this->loader = new \Twig\Loader\FilesystemLoader( $this->loader = new \Twig\Loader\FilesystemLoader(
$themePath . "/" . $path[4] $themePath.'/'.$path[4]
); );
$this->twig = new \Twig\Environment($this->loader, []); $this->twig = new \Twig\Environment($this->loader, []);
$this->router($_SERVER["REQUEST_URI"]); $this->router($_SERVER['REQUEST_URI']);
} }
public function router(string $request) public function router(string $request)
{ {
$pageInfo = [ $pageInfo = [
"keywords" => $this->settings["keywords"], 'keywords' => $this->settings['keywords'],
"description" => $this->settings["description"], 'description' => $this->settings['description'],
"image" => $this->themeAssetPath . "/assets/images/global/default-bg.jpg", 'image' => $this->themeAssetPath.'/assets/images/global/default-bg.jpg',
]; ];
$featureList = explode(",", $this->posts["feature"]); $featureList = explode(',', $this->posts['feature']);
$fileList = explode(",", $this->posts["files"]); $fileList = explode(',', $this->posts['files']);
$images = []; $images = [];
$files = []; $files = [];
foreach ($featureList as $file) { foreach ($featureList as $file) {
$item = trim($file); $item = trim($file);
$ext = pathinfo($item, PATHINFO_EXTENSION); $ext = pathinfo($item, PATHINFO_EXTENSION);
if ($item != null || $item != "") { if ($item != null || $item != '') {
array_push($images, ["file" => $item, "type" => trim($ext)]); array_push($images, ['file' => $item, 'type' => trim($ext)]);
} }
} }
foreach ($fileList as $file) { foreach ($fileList as $file) {
$item = trim($file); $item = trim($file);
$ext = pathinfo($item, PATHINFO_EXTENSION); $ext = pathinfo($item, PATHINFO_EXTENSION);
if ($item != null || $item != "") { if ($item != null || $item != '') {
array_push($files, ["file" => $item, "type" => trim($ext)]); array_push($files, ['file' => $item, 'type' => trim($ext)]);
} }
} }
$menu = $this->settings["menu"]; $menu = $this->settings['menu'];
switch ($request) { switch ($request) {
case "/": case '/':
$recent = $this->posts["recent_posts"]; $recent = $this->posts['recent_posts'];
$featured = $this->posts["featured_posts"]; $featured = $this->posts['featured_posts'];
$template = "index.twig"; $template = 'index.twig';
$content = $this->posts["index-content"]; $content = $this->posts['index-content'];
$pageOptions = [ $pageOptions = [
"debug" => true, //for theme kit 'debug' => true, // for theme kit
"theme" => $this->themeFolder, //for theme kit 'theme' => $this->themeFolder, // for theme kit
"title" => "This is Fipamo", 'title' => 'This is Fipamo',
"dynamicRender" => $this->settings["dynamicRender"], 'dynamicRender' => $this->settings['dynamicRender'],
"background" => 'background' => $this->themeAssetPath.'/assets/images/global/default-bg.jpg',
$this->themeAssetPath . "/assets/images/global/default-bg.jpg", 'recent' => $recent,
"recent" => $recent, 'featured' => $featured,
"featured" => $featured, 'info' => $pageInfo,
"info" => $pageInfo, 'menu' => $menu,
"menu" => $menu, 'content' => $content,
"content" => $content, 'media' => $images,
'files' => $files,
]; ];
break; break;
case "/page": case '/page':
$content = $this->posts["content"]; $content = $this->posts['content'];
$meta = $this->posts["meta"]; $meta = $this->posts['meta'];
$template = $request . ".twig"; $template = $request.'.twig';
$pageOptions = [ $pageOptions = [
"debug" => true, //for theme kit 'debug' => true, // for theme kit
"theme" => $this->themeFolder, //for theme kit 'theme' => $this->themeFolder, // for theme kit
"title" => "Page Title", 'title' => 'Page Title',
"dynamicRender" => $this->settings["dynamicRender"], 'dynamicRender' => $this->settings['dynamicRender'],
"background" => 'background' => $this->themeAssetPath.'/assets/images/global/default-bg.jpg',
$this->themeAssetPath . "/assets/images/global/default-bg.jpg", 'content' => $content,
"content" => $content, 'meta' => $meta,
"meta" => $meta, 'info' => $pageInfo,
"info" => $pageInfo, 'menu' => $menu,
"menu" => $menu, 'media' => $images,
"media" => $images, 'files' => $files,
"files" => $files,
]; ];
break; break;
case "/tags": case '/tags':
$tags = $this->settings["tag_list"]; $tags = $this->settings['tag_list'];
$template = $this->themeFolder . "/tags.twig"; $template = 'tags.twig';
$pageOptions = [ $pageOptions = [
"debug" => true, //for theme kit 'debug' => true, // for theme kit
"theme" => $this->themeFolder, //for theme kit 'theme' => $this->themeFolder, // for theme kit
"title" => "Pages Tagged as Tag", 'title' => 'Pages Tagged as Tag',
"dynamicRender" => $this->settings["dynamicRender"], 'dynamicRender' => $this->settings['dynamicRender'],
"background" => 'background' => $this->themeAssetPath.'/assets/images/global/default-bg.jpg',
$this->themeAssetPath . "/assets/images/global/default-bg.jpg", 'tag_list' => $tags,
"tag_list" => $tags, 'info' => $pageInfo,
"info" => $pageInfo, 'menu' => $menu,
"menu" => $menu, 'media' => $images,
'files' => $files,
]; ];
break; break;
case "/archive": case '/archive':
$archive = $this->archives; $archive = $this->archives;
$template = $this->themeFolder . "/archive.twig"; $template = 'archive.twig';
$pageOptions = [ $pageOptions = [
"debug" => true, //for theme kit 'debug' => true, // for theme kit
"theme" => $this->themeFolder, //for theme kit 'theme' => $this->themeFolder, // for theme kit
"title" => "Archive", 'title' => 'Archive',
"dynamicRender" => $this->settings["dynamicRender"], 'dynamicRender' => $this->settings['dynamicRender'],
"background" => 'background' => $this->themeAssetPath.'/assets/images/global/default-bg.jpg',
$this->themeAssetPath . "/assets/images/global/default-bg.jpg", 'archives' => $archive['archives'],
"archives" => $archive, 'info' => $pageInfo,
"info" => $pageInfo, 'menu' => $menu,
"menu" => $menu, 'media' => $images,
'files' => $files,
]; ];
break; break;
default: default:
http_response_code(404); set_error_handler(function ($errno, $errstr, $errfile, $errline) {
require __DIR__ . "/views/404.php"; // throw new \ErrorException($errstr, $errno, 0, $errfile, $errline);
$error = $errstr;
});
$template = 'error.twig';
$pageOptions = [
'debug' => true, // for theme kit
'theme' => $this->themeFolder, // for theme kit
'title' => 'Uh oh',
'dynamicRender' => $this->settings['dynamicRender'],
'background' => $this->themeAssetPath.'/assets/images/global/default-bg.jpg',
'info' => $pageInfo,
'content' => "Uh Oh, so there's a problem.",
'menu' => $menu,
'media' => $images,
'files' => $files,
];
break; break;
} }

View file

@ -14,12 +14,36 @@
<div class="page"> <div class="page">
<p>{{content | raw}}</p> <p>{{content | raw}}</p>
<div> <div>
<div class="page_files">
<div class="page_doc">
<strong>Files</strong><br/>
{% for doc in files %}
{% if doc.type != "mp3" %}
{% set path = doc.file|split('/') %}
<a href="{{doc.file}}">{{path[6]}}</a>
{% endif %}
{% endfor %}
</div>
<div class="page_sounds">
<strong>Sounds</strong><br/>
{% for doc in files %}
{% if doc.type == "mp3" %}
<audio controls>
<source src="{{doc.file}}" type="audio/mpeg">
Your browser does not support the audio element.
</audio>
{% endif %}
{% endfor %}
</div>
</div>
<br/>
{{meta['who']}} dropped this {{ meta['when'] }}<br /> {{meta['who']}} dropped this {{ meta['when'] }}<br />
<strong>tags: </strong> <strong>tags: </strong>
{% for tag in meta['tags'] %} {% for tag in meta['tags'] %}
{% if dynamicRender is defined %} {% if dynamicRender is defined %}
{% if dynamicRender == 'false' %} {% if dynamicRender == 'true' %}
<a href="{{ "/tags/"~tag.slug }}">{{ tag.label }}</a> <a href="{{ "/tags/"~tag.slug }}">{{ tag.label }}</a>
{% else %} {% else %}
<a href="{{ "/tags/"~tag.slug~".html" }}">{{ tag.label }}</a> <a href="{{ "/tags/"~tag.slug~".html" }}">{{ tag.label }}</a>
@ -28,6 +52,7 @@
<a href="{{ "/tags/"~tag.slug~".html" }}">{{ tag.label }}</a> <a href="{{ "/tags/"~tag.slug~".html" }}">{{ tag.label }}</a>
{% endif %} {% endif %}
{% endfor %} {% endfor %}
</div> </div>
</div> </div>
</article> </article>

View file

@ -36,7 +36,7 @@ button, input[type=submit]
cursor: pointer cursor: pointer
border: 0 border: 0
padding: 10px 0 5px 0 padding: 10px 0 5px 0
@include object_transitions(.3s) transition: all 0.3s linear
select select
font: 14px $baseType font: 14px $baseType
@ -63,5 +63,3 @@ select
:-ms-input-placeholder :-ms-input-placeholder
font: 25px $baseType font: 25px $baseType
color: $white color: $white

View file

@ -1,13 +1,6 @@
@mixin text-drop-shadow($rgb_value, $opacity, $offsetX, $offsetY, $blur) @mixin text-drop-shadow($rgb_value, $opacity, $offsetX, $offsetY, $blur)
text-shadow: $offsetX $offsetY $blur rgba($rgb_value, $opacity) text-shadow: $offsetX $offsetY $blur rgba($rgb_value, $opacity)
@mixin object-transitions($rate)
-moz-transition: all $rate linear
-webkit-transition: all $rate linear
-o-transition: all $rate linear
transition: all $rate linear
@mixin background-opacity($rgb_value, $opacity) @mixin background-opacity($rgb_value, $opacity)
background: rgba($rgb_value, $opacity) background: rgba($rgb_value, $opacity)

View file

@ -6,7 +6,7 @@ html
overflow: hidden overflow: hidden
font: 400 1.2em/1.4em $baseType font: 400 1.2em/1.4em $baseType
body body
background: $white background: $white
margin: 0 margin: 0
padding: 0 padding: 0
@ -17,7 +17,7 @@ body
overflow-y: scroll overflow-y: scroll
overflow-x: hidden overflow-x: hidden
a a
color: $primary color: $primary
text-decoration: none text-decoration: none
border-bottom: 1px solid $highlight border-bottom: 1px solid $highlight
@ -25,26 +25,26 @@ a
&:hover &:hover
border-bottom: 1px solid $secondary border-bottom: 1px solid $secondary
code code
background: $black background: $black
color: $highlight color: $highlight
border-radius: 3px border-radius: 3px
padding: 3px padding: 3px
pre pre
background: $black background: $black
color: $highlight color: $highlight
border-radius: 3px border-radius: 3px
padding: 3px padding: 3px
code code
color: $secondary color: $secondary
background: none background: none
svg.icons svg.icons
width: 25px width: 25px
fill: $white fill: $white
header header
background: $primary background: $primary
height: 90% height: 90%
width: 100% width: 100%
@ -54,7 +54,7 @@ header
height: 90% height: 90%
position: absolute position: absolute
.slide .slide
@include object-transitions(.7s) transition: all 0.7s linear
width: 100% width: 100%
height: 100% height: 100%
position: absolute position: absolute
@ -97,9 +97,7 @@ header
&:hover &:hover
background: $secondary background: $secondary
.container
.container
z-index: 2 z-index: 2
background: $white background: $white
line-height: 30px line-height: 30px
@ -124,11 +122,19 @@ header
img img
display: block display: block
width: 100% width: 100%
h1 h1, h2
color: $primary color: $primary
p p
font: 300 1.25em/1.6em $baseType font: 300 1.25em/1.6em $baseType
//meta datea for page //meta datea for page
.page_files
.page_doc
a
background: $black
border-radius: 3px
color: $white
padding: 3px
margin: 0 5px 0 0
.meta .meta
font: 500 0.8em/1.3em $baseType font: 500 0.8em/1.3em $baseType
padding: 5px 0 0 0 padding: 5px 0 0 0
@ -164,6 +170,10 @@ header
color: $white color: $white
.index-lists, .page-title .index-lists, .page-title
max-width: 840px max-width: 840px
width: 80%
margin: 0 auto
padding: 20px 0 0 0
span span
font-size: 2em font-size: 2em
color: $secondary color: $secondary
@ -181,10 +191,7 @@ header
font-size: 1.5em font-size: 1.5em
line-height: 1.3 line-height: 1.3
footer
footer
background: $white background: $white
padding: 10px padding: 10px
color: $primary color: $primary
@ -198,11 +205,10 @@ footer
a a
color: $secondary color: $secondary
// RESPONSIVE
// RESPONSIVE @media only screen and (max-width: 640px)
header
@media only screen and (max-width: 640px)
header
nav nav
width: 98% width: 98%
span span
@ -214,8 +220,8 @@ header
.archive-month .archive-month
width: 45% width: 45%
@media only screen and (max-width: 480px) @media only screen and (max-width: 480px)
header header
nav nav
width: 96% width: 96%
.container .container
@ -229,12 +235,11 @@ header
.recent, .featured .recent, .featured
width: 100% !important width: 100% !important
@media only screen and (max-width: 375px)
@media only screen and (max-width: 375px) header
header
nav nav
width: 95% width: 95%
.container .container
article article
.index, .page .index, .page
margin: 0 margin: 0

View file

@ -15,4 +15,3 @@ h2
h3 h3
font-size: 1.5em font-size: 1.5em
font-weight: 300 font-weight: 300