Replaced Moment with Carbon #84
5 changed files with 78 additions and 150 deletions
|
@ -41,58 +41,16 @@ class ThemeController extends Controller
|
|||
$template = $currentTheme . '.index' :
|
||||
$template = $currentTheme . '.page';
|
||||
$page = $this->pages->getById('532E2250-F8CB-4E87-9782-8AFBEE88DD5E');
|
||||
$data = $this->sort->page($page);
|
||||
$pageData = [
|
||||
"debug" => "true",
|
||||
"theme" => $currentTheme,
|
||||
"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'],
|
||||
];
|
||||
$pageData = $this->sort->page($page);
|
||||
break;
|
||||
case "tags":
|
||||
$template = $currentTheme . '.tags';
|
||||
$data = $this->sort->tags();
|
||||
$pageData = [
|
||||
'debug' => true, // for theme kit
|
||||
'theme' => $currentTheme, // for theme kit
|
||||
'title' => 'Pages Tagged as Tag',
|
||||
'dynamicRender' => $data['info']['dynamicRender'],
|
||||
'$pages' => $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))]
|
||||
],
|
||||
];
|
||||
$pageData = $this->sort->tags();
|
||||
break;
|
||||
case "archives":
|
||||
case "archive":
|
||||
$template = $currentTheme . '.archive';
|
||||
$data = $this->sort->archive();
|
||||
$pageData = [
|
||||
'debug' => true, // for theme kit
|
||||
'theme' => $currentTheme, // 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))]
|
||||
],
|
||||
];
|
||||
$pageData = $this->sort->archive();
|
||||
break;
|
||||
}
|
||||
if ($this->auth::status()) {
|
||||
|
|
|
@ -6,7 +6,6 @@ use App\Interfaces\PageRepositoryInterface;
|
|||
use App\Services\SettingsService;
|
||||
use App\Services\ContentService;
|
||||
use App\Services\PaginateService;
|
||||
use App\Services\StringService;
|
||||
use App\Services\DocService;
|
||||
use App\Services\SortingService;
|
||||
use App\Services\RenderService;
|
||||
|
@ -18,7 +17,6 @@ class PageRepository implements PageRepositoryInterface
|
|||
protected $setttings;
|
||||
protected $paginate;
|
||||
protected $pages;
|
||||
protected $strings;
|
||||
protected $docs;
|
||||
protected $sort;
|
||||
protected $render;
|
||||
|
@ -27,7 +25,6 @@ class PageRepository implements PageRepositoryInterface
|
|||
ContentService $contentService,
|
||||
SettingsService $settingsService,
|
||||
PaginateService $paginateService,
|
||||
StringService $stringService,
|
||||
DocService $docService,
|
||||
SortingService $sortingService,
|
||||
RenderService $renderService
|
||||
|
@ -35,7 +32,6 @@ class PageRepository implements PageRepositoryInterface
|
|||
$this->content = $contentService;
|
||||
$this->settings = $settingsService;
|
||||
$this->paginate = $paginateService;
|
||||
$this->strings = $stringService;
|
||||
$this->docs = $docService;
|
||||
$this->sort = $sortingService;
|
||||
$this->render = $renderService;
|
||||
|
@ -103,7 +99,7 @@ class PageRepository implements PageRepositoryInterface
|
|||
|
||||
// grab current index from settings and update
|
||||
$id = $task != 'create' ? $body->id : $this->settings->getSettings()['library_stats']['current_index'];
|
||||
$uuid = $task != 'create' ? $body->uuid : $this->strings::createUUID();
|
||||
$uuid = $task != 'create' ? $body->uuid : createUUID();
|
||||
//set variables post body for saving
|
||||
$body->id = $id;
|
||||
$body->uuid = $uuid;
|
||||
|
|
|
@ -57,20 +57,8 @@ class RenderService
|
|||
public function archive()
|
||||
{
|
||||
$template = $this->theme . '.archive';
|
||||
$data = $this->sort->archive();
|
||||
$pageData = [
|
||||
'theme' => $this->theme, // 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))]
|
||||
],
|
||||
];
|
||||
$location = '../public/archive.html';
|
||||
$pageData = $this->sort->archive(false);
|
||||
$location = '../public/archives.html';
|
||||
File::put(
|
||||
$location,
|
||||
view($template)
|
||||
|
@ -81,21 +69,18 @@ class RenderService
|
|||
|
||||
public function tags()
|
||||
{
|
||||
$data = $this->sort->tags();
|
||||
$data = $this->sort->tags(false);
|
||||
foreach ($data['tags'] as $item) {
|
||||
//$template = 'tags.twig';
|
||||
$template = $this->theme . '.tags';
|
||||
$pageData = [
|
||||
'theme' => $this->theme, // for theme kit
|
||||
'title' => 'Pages Tagged as ' . $item['tag_name'],
|
||||
'dynamicRender' => $data['info']['dynamicRender'],
|
||||
'dynamicRender' => $data['dynamicRender'],
|
||||
'info' => $data['info'],
|
||||
'menu' => $data['info']['menu'],
|
||||
'menu' => $data['menu'],
|
||||
'pages' => $item['pages'],
|
||||
'media' => [
|
||||
['file' => $data['info']['image'],
|
||||
'type' => trim(pathinfo($data['info']['image'], PATHINFO_EXTENSION))]
|
||||
],
|
||||
'media' => $data['media'],
|
||||
];
|
||||
|
||||
$location = '../public/tags/' . $item['slug'] . '.html';
|
||||
|
@ -122,22 +107,7 @@ class RenderService
|
|||
$template = $this->theme . '.index' :
|
||||
$template = $this->theme . '.page';
|
||||
|
||||
$data = $this->sort->page($page);
|
||||
$pageData = [
|
||||
"theme" => $this->theme,
|
||||
"status" => false,
|
||||
"title" => $data['title'],
|
||||
"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'],
|
||||
];
|
||||
$pageData = $this->sort->page($page, false);
|
||||
|
||||
if (str_contains($page['layout'], 'index')) {
|
||||
$location = '../public/index.html';
|
||||
|
|
|
@ -14,6 +14,7 @@ class SortingService
|
|||
private $settings;
|
||||
private $contents;
|
||||
private $themes;
|
||||
private $info = [];
|
||||
|
||||
public function __construct(
|
||||
SettingsService $settingsService,
|
||||
|
@ -23,9 +24,22 @@ class SortingService
|
|||
$this->settings = $settingsService;
|
||||
$this->contents = $contentService;
|
||||
$this->themes = $themeService;
|
||||
$global = $this->settings->getGlobal();
|
||||
$this->info = [
|
||||
'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'],
|
||||
'theme' => $global['theme'],
|
||||
];
|
||||
}
|
||||
|
||||
public function tags()
|
||||
public function tags($debug = true)
|
||||
{
|
||||
$pages = $this->contents->loadAllPages();
|
||||
foreach ($pages as $page) {
|
||||
|
@ -44,24 +58,23 @@ class SortingService
|
|||
}
|
||||
}
|
||||
}
|
||||
$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,
|
||||
'debug' => $debug, // for theme kit
|
||||
'tags' => $this->p_tags,
|
||||
'theme' => $this->info['theme'], // for theme kit
|
||||
'title' => 'Pages Tagged as Tag',
|
||||
'dynamicRender' => $this->info['dynamicRender'],
|
||||
'pages' => $this->settings->getTags()[3]['pages'],
|
||||
'info' => $this->info,
|
||||
'menu' => $this->settings->getMenu(),
|
||||
'media' => [
|
||||
['file' => $this->info['image'],
|
||||
'type' => trim(pathinfo($this->info['image'], PATHINFO_EXTENSION))]
|
||||
]
|
||||
];
|
||||
|
||||
return $tagData;
|
||||
}
|
||||
|
||||
|
@ -84,18 +97,15 @@ class SortingService
|
|||
return $tagged;
|
||||
}
|
||||
|
||||
public function archive()
|
||||
public function archive($debug = true)
|
||||
{
|
||||
$pages = $this->contents->loadAllPages();
|
||||
$years = [];
|
||||
$archive = [];
|
||||
foreach ($pages as $page) {
|
||||
// $year = date("Y", date($page["rawCreated"]));
|
||||
$date = explode('/', $page['path']);
|
||||
// echo $page["title"] . " : " . $year . "\n";
|
||||
if (!find($years, ['year' => trim($date[0])])) {
|
||||
$findPages = filter($pages, ['createdYear' => trim($date[0])]);
|
||||
// var_dump($findPages);
|
||||
array_push(
|
||||
$years,
|
||||
[
|
||||
|
@ -108,7 +118,6 @@ class SortingService
|
|||
foreach ($years as $year) {
|
||||
$sorted = [];
|
||||
$filtered = filter($pages, ['createdYear' => $year['year']]);
|
||||
|
||||
foreach ($filtered as $obj) {
|
||||
$month = date('m', date($obj['rawCreated']));
|
||||
if (!find($sorted, ['month' => $month])) {
|
||||
|
@ -134,41 +143,29 @@ class SortingService
|
|||
'year_data' => $sorted,
|
||||
]);
|
||||
}
|
||||
$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,
|
||||
'debug' => $debug, // for theme kit
|
||||
'theme' => $this->info['theme'], // for theme kit
|
||||
'title' => 'Archives',
|
||||
'dynamicRender' => $this->info['dynamicRender'],
|
||||
'archive' => $this->p_archive,
|
||||
'info' => $this->info,
|
||||
'menu' => $this->settings->getMenu(),
|
||||
'media' => [
|
||||
['file' => $this->info['image'],
|
||||
'type' => trim(pathinfo($this->info['image'], PATHINFO_EXTENSION))]
|
||||
],
|
||||
];
|
||||
|
||||
return $archiveData;
|
||||
}
|
||||
|
||||
public function page($page)
|
||||
public function page($page, $debug = true)
|
||||
{
|
||||
$global = $this->settings->getGlobal();
|
||||
$pageOptions = [];
|
||||
|
||||
$pageInfo = [
|
||||
'keywords' => isset($global['keywords'])
|
||||
? $global['keywords']
|
||||
: 'fipamo, blog, jamstack, php, markdown, js',
|
||||
'description' => $global['descriptions'],
|
||||
'image' => $global['base_url'] . $global['background'],
|
||||
'baseURL' => $global['base_url'],
|
||||
];
|
||||
$tags = [];
|
||||
$tags = [];
|
||||
if (isset($page['tags'])) {
|
||||
$taglist = explode(',', $page['tags']);
|
||||
foreach ($taglist as $tag) {
|
||||
|
@ -194,8 +191,8 @@ class SortingService
|
|||
$ext = pathinfo($item, PATHINFO_EXTENSION);
|
||||
|
||||
if ($ext != 'mp4' && !$set) {
|
||||
$pageInfo['image'] = $pageInfo['baseURL'] . $item;
|
||||
$set = true;
|
||||
$this->info['image'] = $this->info['baseURL'] . $item;
|
||||
$set = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -231,21 +228,23 @@ class SortingService
|
|||
}
|
||||
}
|
||||
|
||||
$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'],
|
||||
$pageData = [
|
||||
"debug" => $debug,
|
||||
"theme" => $this->info['theme'],
|
||||
"status" => session('member') != null ? true : false,
|
||||
"title" => $page['title'],
|
||||
"meta" => $meta,
|
||||
"menu" => $this->settings->getMenu(),
|
||||
"info" => $this->info,
|
||||
"media" => $page['media'],
|
||||
"files" => $page['docs'],
|
||||
"content" => $page['html'],
|
||||
"recent" => $recent,
|
||||
"feature" => $featured,
|
||||
"tags" => $meta['tags'],
|
||||
"dynamicRender" => $this->info['dynamicRender'],
|
||||
];
|
||||
return $pageOptions;
|
||||
return $pageData;
|
||||
}
|
||||
|
||||
public function navigation()
|
||||
|
|
|
@ -2,7 +2,12 @@
|
|||
@php
|
||||
if(isset($debug))
|
||||
{
|
||||
$assetPath = '/theme/';
|
||||
if($debug)
|
||||
{
|
||||
$assetPath = '/theme/';
|
||||
}else{
|
||||
$assetPath = '/assets/';
|
||||
}
|
||||
}else{
|
||||
$assetPath = '/assets/';
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue