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":
$view == 'index' ?
$template = 'fipamo-default-v2.index' :
$template = 'fipamo-default-v2.page'; $template = 'fipamo-default-v2.page';
break; $page = $this->pages->getById('09E5A362-BA31-4AE2-9DEE-C93DFBE005C3')->first();
}
if ($this->auth::status()) {
$page = $this->pages->getById('58E3D3DA-E7E4-4396-B4E5-0C30781C2F19')->first();
$data = $this->sort->page($page); $data = $this->sort->page($page);
return view($template, [ $pageData = [
"debug" => "true", "debug" => "true",
"theme" => 'fipamo-default-v2', "theme" => 'fipamo-default-v2',
"status" => $this->auth::status(), "status" => $this->auth::status(),
"title" => "THEME PAGE", "title" => "THEME PAGE",
"meta" => $data['meta'],
"menu" => $data['menu'], "menu" => $data['menu'],
"page" => $page,
"info" => $data['info'], "info" => $data['info'],
"media" => $data['media'], "media" => $data['media'],
"files" => $data['files'],
"content" => $data['content'], "content" => $data['content'],
"recent" => $data['recent'], "recent" => $data['recent'],
"feature" => $data['featured'], "feature" => $data['featured'],
"tags" => $data['tags'],
"dynamicRender" => $data['dynamicRender'], "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;
}
if ($this->auth::status()) {
return view($template, $pageData);
} 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,7 +200,6 @@ 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;
@ -200,7 +235,7 @@ class SortingService
$pageOptions = [ $pageOptions = [
'title' => $page['title'], 'title' => $page['title'],
'background' => $page['feature'], 'background' => $page['feature'],
'content' => $page['html'], // $cleaned, 'content' => $page['html'],
'meta' => $meta, 'meta' => $meta,
'recent' => $recent, 'recent' => $recent,
'featured' => $featured, 'featured' => $featured,
@ -209,20 +244,8 @@ class SortingService
'dynamicRender' => $global['dynamicRender'], 'dynamicRender' => $global['dynamicRender'],
'media' => $page['media'], 'media' => $page['media'],
'files' => $page['docs'], 'files' => $page['docs'],
'tags' => $meta['tags'],
]; ];
} 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'],
];
}
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 %}