converted page, archive and tags files

the remaining base template pages have beeen converted to blade as well
as filling out the data they need to render being added to the sorting
service class

theming controller and and sorting service still need to be optimized
but they work so now they can be refined

once they have been cleaned up, the render service is class is ready to
be finished
This commit is contained in:
ro 2024-03-15 14:28:26 -06:00
parent ba2e75b186
commit 2f2955e865
No known key found for this signature in database
GPG key ID: 29B551CDBD4D3B50
13 changed files with 258 additions and 377 deletions

View file

@ -96,29 +96,71 @@ class ThemeController extends Controller
public function getView($view = 'index') public function getView($view = 'index')
{ {
$template = 'fipamo-default-v2.index'; $template;
$pageData = [];
switch ($view) { switch ($view) {
case "index":
case "page": case "page":
$template = 'fipamo-default-v2.page'; $view == 'index' ?
$template = 'fipamo-default-v2.index' :
$template = 'fipamo-default-v2.page';
$page = $this->pages->getById('09E5A362-BA31-4AE2-9DEE-C93DFBE005C3')->first();
$data = $this->sort->page($page);
$pageData = [
"debug" => "true",
"theme" => 'fipamo-default-v2',
"status" => $this->auth::status(),
"title" => "THEME PAGE",
"meta" => $data['meta'],
"menu" => $data['menu'],
"info" => $data['info'],
"media" => $data['media'],
"files" => $data['files'],
"content" => $data['content'],
"recent" => $data['recent'],
"feature" => $data['featured'],
"tags" => $data['tags'],
"dynamicRender" => $data['dynamicRender'],
];
break;
case "tags":
$template = 'fipamo-default-v2.tags';
$data = $this->sort->tags();
$pageData = [
'debug' => true, // for theme kit
'theme' => 'fipamo-default-v2', // for theme kit
'title' => 'Pages Tagged as Tag',
'dynamicRender' => $data['info']['dynamicRender'],
'tags' => $data['info']['tags'][3]['pages'],
'info' => $data['info'],
'menu' => $data['info']['menu'],
'media' => [
['file' => $data['info']['image'],
'type' => trim(pathinfo($data['info']['image'], PATHINFO_EXTENSION))]
],
];
break;
case "archives":
case "archive":
$template = 'fipamo-default-v2.archive';
$data = $this->sort->archive();
$pageData = [
'debug' => true, // for theme kit
'theme' => 'fipamo-default-v2', // for theme kit
'title' => 'Archives',
'dynamicRender' => $data['info']['dynamicRender'],
'archive' => $data['archive'],
'info' => $data['info'],
'menu' => $data['info']['menu'],
'media' => [
['file' => $data['info']['image'],
'type' => trim(pathinfo($data['info']['image'], PATHINFO_EXTENSION))]
],
];
break; break;
} }
if ($this->auth::status()) { if ($this->auth::status()) {
$page = $this->pages->getById('58E3D3DA-E7E4-4396-B4E5-0C30781C2F19')->first(); return view($template, $pageData);
$data = $this->sort->page($page);
return view($template, [
"debug" => "true",
"theme" => 'fipamo-default-v2',
"status" => $this->auth::status(),
"title" => "THEME PAGE",
"menu" => $data['menu'],
"page" => $page,
"info" => $data['info'],
"media" => $data['media'],
"content" => $data['content'],
"recent" => $data['recent'],
"feature" => $data['featured'],
"dynamicRender" => $data['dynamicRender'],
]);
} else { } else {
return redirect('dashboard/start'); return redirect('dashboard/start');
} }

View file

@ -12,6 +12,7 @@ class SettingsService
public function __construct(DocService $docService) public function __construct(DocService $docService)
{ {
$this->folks = json_decode(file_get_contents(env('FOLKS_PATH')), true); $this->folks = json_decode(file_get_contents(env('FOLKS_PATH')), true);
$this->tags = json_decode(file_get_contents(env('TAGS_PATH')), true);
$this->docs = $docService; $this->docs = $docService;
} }
@ -37,6 +38,11 @@ class SettingsService
return $this->settings['menu']; return $this->settings['menu'];
} }
public function getTags()
{
return $this->tags;
}
public function getFolks() public function getFolks()
{ {
return $this->folks; return $this->folks;

View file

@ -42,7 +42,25 @@ class SortingService
} }
} }
} }
return $this->p_tags; $global = $this->settings->getGlobal();
$tagData = [];
$pageInfo = [
'keywords' => isset($global['keywords'])
? $global['keywords']
: 'fipamo, blog, jamstack, php, markdown, js',
'menu' => $this->settings->getMenu(),
'tags' => $this->settings->getTags(),
'description' => $global['descriptions'],
'image' => $global['base_url'] . $global['background'],
'baseURL' => $global['base_url'],
'dynamicRender' => $global['dynamicRender'],
];
$tagData = [
'tags' => $this->p_tags,
'info' => $pageInfo,
];
return $tagData;
} }
private function tagPages($tag, $pages) private function tagPages($tag, $pages)
@ -114,7 +132,25 @@ class SortingService
'year_data' => $sorted, 'year_data' => $sorted,
]); ]);
} }
return $this->p_archive; $global = $this->settings->getGlobal();
$archive_data = [];
$pageInfo = [
'keywords' => isset($global['keywords'])
? $global['keywords']
: 'fipamo, blog, jamstack, php, markdown, js',
'menu' => $this->settings->getMenu(),
'tags' => $this->settings->getTags(),
'description' => $global['descriptions'],
'image' => $global['base_url'] . $global['background'],
'baseURL' => $global['base_url'],
'dynamicRender' => $global['dynamicRender'],
];
$archiveData = [
'archive' => $this->p_archive,
'info' => $pageInfo,
];
return $archiveData;
} }
public function page($page) public function page($page)
@ -164,65 +200,52 @@ class SortingService
} }
} }
//TODO: get rid of if statement and always return recent and featured //TODO: get rid of if statement and always return recent and featured
if ($page['layout'] == 'index') { $recent = [];
$recent = []; $featured = [];
$featured = []; $limit = 4;
$limit = 4; $pages = $this->contents->loadAllPages();
$pages = $this->contents->loadAllPages(); foreach ($pages as $item) {
foreach ($pages as $item) { if (
if ( !$item['deleted'] &&
!$item['deleted'] && $item['published'] &&
$item['published'] && $item['menu'] != 'true'
$item['menu'] != 'true' ) {
) { if (count($recent) < $limit) {
if (count($recent) < $limit) { array_push($recent, [
array_push($recent, [ 'path' => $item['path'],
'slug' => $item['slug'],
'title' => $item['title'],
'feature' => $item['feature'],
]);
}
if ($item['featured'] == true) {
if (count($featured) < $limit) {
array_push($featured, [
'path' => $item['path'], 'path' => $item['path'],
'slug' => $item['slug'], 'slug' => $item['slug'],
'title' => $item['title'], 'title' => $item['title'],
'feature' => $item['feature'], 'feature' => $item['feature'],
]); ]);
} }
if ($item['featured'] == true) {
if (count($featured) < $limit) {
array_push($featured, [
'path' => $item['path'],
'slug' => $item['slug'],
'title' => $item['title'],
'feature' => $item['feature'],
]);
}
}
} }
} }
$pageOptions = [
'title' => $page['title'],
'background' => $page['feature'],
'content' => $page['html'], // $cleaned,
'meta' => $meta,
'recent' => $recent,
'featured' => $featured,
'info' => $pageInfo,
'menu' => $this->settings->getMenu(),
'dynamicRender' => $global['dynamicRender'],
'media' => $page['media'],
'files' => $page['docs'],
];
} else {
$pageOptions = [
'title' => $page['title'],
'background' => $page['feature'],
'content' => $page['html'], // $cleaned,
'meta' => $meta,
'info' => $pageInfo,
'menu' => $this->settings->getMenu(),
'dynamicRender' => $global['dynamicRender'],
'media' => $page['media'],
'files' => $page['docs'],
];
} }
$pageOptions = [
'title' => $page['title'],
'background' => $page['feature'],
'content' => $page['html'],
'meta' => $meta,
'recent' => $recent,
'featured' => $featured,
'info' => $pageInfo,
'menu' => $this->settings->getMenu(),
'dynamicRender' => $global['dynamicRender'],
'media' => $page['media'],
'files' => $page['docs'],
'tags' => $meta['tags'],
];
return $pageOptions; return $pageOptions;
} }
} }

View file

@ -0,0 +1,33 @@
@extends('fipamo-default-v2.base')
@section('title', $title)
@section('main-content')
<article>
<h1>{{ $title }}</h1>
<div role="archives">
@foreach($archive as $item)
<div role="archive-$item">
<h2>{{ $item['year'] }}</h2>
@foreach($item['year_data'] as $data)
<div role="archive-month">
<h3>{{ $data['full_month'] }}</h3>
@foreach($data['pages'] as $page)
@if(isset($dynamicRender))
@if($dynamicRender == 'true')
<a href="{{ "/".$item['year']."/".$data['month']."/".$page['slug'] }}">{{ $page['title'] }}</a><br/>
@else
<a href="{{ "/".$item['year']."/".$data['month']."/".$page['slug'].".html" }}">{{ $page['title'] }}</a><br/>
@endif
@else
<a href="{{ "/".$item['year']."/".$data['month']."/".$page['slug'] }}">{{ $page['title'] }}</a><br/>
@endif
@endforeach
</div>
@endforeach
</div>
@endforeach
</div>
</article>
@endsection

View file

@ -1,37 +0,0 @@
{% extends "frame.twig" %}
{% block title %}
{{ title }}
{% endblock %}
{% block mainContent %}
<article>
<h1>{{ title }}</h1>
<div role="archives">
{% for item in archives %}
<div role="archive-item">
<h2>{{ item.year }}</h2>
{% for data in item.year_data %}
<div role="archive-month">
<h3>{{ data.full_month }}</h3>
{% for page in data.pages %}
{% if dynamicRender is defined %}
{% if dynamicRender == 'true' %}
<a href="{{ "/"~item.year~"/"~data.month~"/"~page.slug }}">{{ page.title }}</a><br/>
{% else %}
<a href="{{ "/"~item.year~"/"~data.month~"/"~page.slug~".html" }}">{{ page.title }}</a><br/>
{% endif %}
{% else %}
<a href="{{ "/"~item.year~"/"~data.month~"/"~page.slug~".html" }}">{{ page.title }}</a><br/>
{% endif %}
{% endfor %}
</div>
{% endfor %}
</div>
{% endfor %}
</div>
</article>
{% endblock %}

View file

@ -25,8 +25,8 @@
<body> <body>
<header> <header>
<div role="slide-show"> <div role="slide-show">
@if(count($page['media'])>1) @if(count($media)>1)
@foreach($page['media'] as $item) @foreach($media as $item)
@if($item['type'] == "mp4") @if($item['type'] == "mp4")
<div id="{{$loop->index}}" role="slide"> <div id="{{$loop->index}}" role="slide">
<video controls autoplay muted> <video controls autoplay muted>
@ -45,9 +45,7 @@
@if($media[0]['type'] == "mp4") @if($media[0]['type'] == "mp4")
<div id="0" role="slide"> <div id="0" role="slide">
<video controls autoplay muted> <video controls autoplay muted>
<source src="{{$media[0]['file']}}" type="video/mp4"> <source src="{{$media[0]['file']}}" type="video/mp4">
Please get a better browser. They're free. Please get a better browser. They're free.
</video> </video>
</div> </div>
@ -86,7 +84,6 @@
@show @show
@endspaceless @endspaceless
</div> </div>
<footer> <footer>
<div class="inner"> <div class="inner">
@if(isset($dynamicRender)) @if(isset($dynamicRender))

View file

@ -1,18 +0,0 @@
{% extends "frame.twig" %}
{% block title %}
{{ title }}
{% endblock %}
{% block mainContent %}
<section>
<div class="page-title">
<span>{{title}}</span>
</div>
</section>
<article>
<div class="page">
<p>{{content | raw}}</p>
</div>
</article>
{% endblock %}

View file

@ -1,110 +0,0 @@
<!DOCTYPE html>
{% if debug is defined %}
{% set assetPath = theme~'/assets/' %}
{% else %}
{% set assetPath = '/assets/' %}
{% endif %}
<html>
<head>
<title>
{% block title %}
{{ title }}
{% endblock %}
</title>
<meta charset="UTF-8"/>
<meta name="theme-color" content="#fc6399"/>
<meta name='viewport' content='width=device-width, initial-scale=1.0'/>
<meta name="keywords" content="{{ info['keywords'] }}"/>
<meta name="description" content="{{ info['description'] }} "/>
<meta http-equiv="content-type" content="text/html; charset=utf-8"/>
<meta property="og:image" content="{{ info["image"] }}"/>
<meta name="twitter:image" content="{{ info["image"] }}"/>
<link rel="stylesheet" type="text/css" href="{{ assetPath~"css/start.css?=ffgfg" }}">
</head>
<body>
<header>
<div role="slide-show">
{% if media|length > 1 %}
{% for item in media %}
{% if item.type == "mp4" %}
<div id="{{ loop.index0 }}" role="slide">
<video controls autoplay muted>
<source src="{{ item.file }}" type="video/mp4">
Please get a better browser. They're free.
</video>
</div>
{% else %}
<div id="{{ loop.index0 }}" role="slide" class="hide" style="background: url({{ item.file }}) no-repeat center center / cover"></div>
{% endif %}
{% endfor %}
{% else %}
{% if media[0] != '' %}
{% if media[0].type == "mp4" %}
<div id="0" role="slide">
<video controls autoplay muted>
<source src="{{ media[0].file }}" type="video/mp4">
Please get a better browser. They're free.
</video>
</div>
{% else %}
<div id="0" role="slide" style="background: url({{ media[0].file }}) no-repeat center center / cover"></div>
{% endif %}
{% else %}
{% endif %}
{% endif %}
</div>
<nav>
{% apply spaceless %}
<div role="nav-left">
<a href="/" role="home-link">
<img id="logo" src="{{ assetPath~"/images/global/the-logo.svg" }}"/>
</a>
</div>
<div role="nav-right">
{% if menu is defined %}
{% for link in menu %}
{% if dynamicRender is defined %}
{% if dynamicRender == 'true' %}
<a href="{{ "/"~link.slug }}" role="menu-link">{{ link.title }}</a><br/>
{% else %}
<a href="{{ "/"~link.slug~".html" }}" role="menu-link">{{ link.title }}</a><br/>
{% endif %}
{% else %}
<a href="{{ "/"~link.slug~".html" }}" role="menu-link">{{ link.title }}</a><br/>
{% endif %}
{% endfor %}
{% endif %}
</div>
{% endapply %}
</nav>
</header>
<main>
{% apply spaceless %}
{% block mainContent %}{% endblock %}
{% endapply %}
</main>
<footer>
<div class="inner">
{% if dynamicRender is defined %}
{% if dynamicRender == 'true' %}
<a href="/archives">Archives</a><br/>
{% else %}
<a href="/archives.html">Archives</a><br/>
{% endif %}
{% else %}
<a href="/archives.html">Archives</a><br/>
{% endif %}
© 2022 Fipamo
</div>
</footer>
<script src="{{ assetPath~"scripts/ThemeStart.js" }}" type="module"></script>
</body>
</html>

View file

@ -1,57 +0,0 @@
{% extends "frame.twig" %}
{% block title %}
{{ title }}
{% endblock %}
{% block mainContent %}
<article>
<h1>{{ title }}</h1>
<p>{{ content | raw }}</p>
</article>
<section role="page-meta">
<div>
<h2>RECENT</h2>
{% for item in recent %}
{% if dynamicRender is defined %}
{% if dynamicRender == 'true' %}
<a href="{{ "/"~item.path~"/"~item.slug }}">
{{ item.title }}
</a><br/>
{% else %}
<a href="{{ "/"~item.path~"/"~item.slug~".html" }}">
{{ item.title }}
</a><br/>
{% endif %}
{% else %}
<a href="{{ "/"~item.path~"/"~item.slug~".html" }}">
{{ item.title }}
</a><br/>
{% endif %}
{% endfor %}
</div>
<div>
<h2>FEATURED</h2>
{% for item in featured %}
{% if dynamicRender is defined %}
{% if dynamicRender == 'true' %}
<a href="{{ "/"~item.path~"/"~item.slug }}">
{{ item.title }}
</a><br/>
{% else %}
<a href="{{ "/"~item.path~"/"~item.slug~".html" }}">
{{ item.title }}
</a><br/>
{% endif %}
{% else %}
<a href="{{ "/"~item.path~"/"~item.slug~".html" }}">
{{ item.title }}
</a><br/>
{% endif %}
{% endfor %}
</div>
</section>
{% endblock %}

View file

@ -0,0 +1,62 @@
@extends('fipamo-default-v2.base')
@section('title', $title)
@section('main-content')
<article>
<h1>{{ $title }}</h1>
<p>{!!$content!!}</p>
</article>
<section role="page-meta">
<div>
<h2>Files</h2>
@foreach($files as $file)
@if($file['type'] != 'mp3')
@php
$fileName = explode("/", $file['file']);
@endphp
<a href="{{ $file['file'] }}">{{ $fileName[6] }}</a>
@endif
@endforeach
</div>
<div>
<h2>Sounds</h2>
@foreach($files as $file)
@if($file['type'] == 'mp3')
<audio controls>
<source src="{{ $file['file'] }}" type="audio/mpeg">
Your browser does not support the audio element.
</audio>
@endif
@endforeach
</div>
<div>
<h2>Info</h2>
{{ $meta['who'] }}
dropped this
{{ $meta['when'] }}<br/>
</div>
<div>
<h2>Tags</h2>
@foreach($tags as $tag)
@if(isset($dynamicRender))
@if($dynamicRender == 'true')
<a href="{{ "/tags/".$tag['slug'] }}">
{{ $tag['label'] }}
</a><br/>
@else
<a href="{{ "/tags/".$tag['slug'].".html" }}">
{{ $tag['label'] }}
</a><br/>
@endif
@else
<a href="{{ "/tags/".$tag['slug'].".html" }}">
{{ $tag['label'] }}
</a><br/>
@endif
@endforeach
</div>
</section>
@endsection

View file

@ -1,57 +0,0 @@
{% extends "frame.twig" %}
{% block title %}
{{ title }}
{% endblock %}
{% block mainContent %}
<article>
<h1>{{ title }}</h1>
<p>{{ content | raw }}</p>
</article>
<section role="page-meta">
<div>
<h2>Files</h2>
{% for doc in files %}
{% if doc.type != "mp3" %}
{% set path = doc.file|split('/') %}
<a href="{{ doc.file }}">{{ path[6] }}</a>
{% endif %}
{% endfor %}
</div>
<div>
<h2>Sounds</h2>
{% 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>
<h2>Info</h2>
{{ meta['who'] }}
dropped this
{{ meta['when'] }}<br/>
</div>
<div>
<h2>Tags</h2>
{% for tag in meta['tags'] %}
{% if dynamicRender is defined %}
{% if dynamicRender == 'true' %}
<a href="{{ "/tags/"~tag.slug }}">{{ tag.label }}</a>
{% else %}
<a href="{{ "/tags/"~tag.slug~".html" }}">{{ tag.label }}</a>
{% endif %}
{% else %}
<a href="{{ "/tags/"~tag.slug~".html" }}">{{ tag.label }}</a>
{% endif %}
{% endfor %}
</div>
</section>
{% endblock %}

View file

@ -0,0 +1,20 @@
@extends('fipamo-default-v2.base')
@section('title', $title)
@section('main-content')
<article>
<h1>{{ $title }}</h1>
@foreach($tags as $tag)
@if(isset($dynamicRender))
@if($dynamicRender == 'true')
<a href="{{ "/".$tag['path']."/".$tag['slug'] }}">{{ $tag['title'] }}</a><br/>
@else
<a href="{{ "/".$tag['path']."/".$tag['slug'].".html" }}">{{ $tag['title'] }}</a><br/>
@endif
@else
<a href="{{ "/".$tag['path']."/".$tag['slug'].".html" }}">{{ $tag['title'] }}</a><br/>
@endif
@endforeach
</article>
@endsection

View file

@ -1,23 +0,0 @@
{% extends "frame.twig" %}
{% block title %}
{{ title }}
{% endblock %}
{% block mainContent %}
<article>
<h1>{{ title }}</h1>
{% for tag in tag_list %}
{% if dynamicRender is defined %}
{% if dynamicRender == 'true' %}
<a href="{{ "/"~tag.path~"/"~tag.slug }}">{{ tag.title }}</a><br/>
{% else %}
<a href="{{ "/"~tag.path~"/"~tag.slug~".html" }}">{{ tag.title }}</a><br/>
{% endif %}
{% else %}
<a href="{{ "/"~tag.path~"/"~tag.slug~".html" }}">{{ tag.title }}</a><br/>
{% endif %}
{% endfor %}
</article>
{% endblock %}