Replaced Moment with Carbon #84

Merged
Ghost merged 148 commits from develop into beta 2022-09-22 05:53:36 +02:00
6 changed files with 118 additions and 36 deletions
Showing only changes of commit a6b63ca551 - Show all commits

View file

@ -40,7 +40,7 @@ class ThemeController extends Controller
$view == 'index' ? $view == 'index' ?
$template = $currentTheme . '.index' : $template = $currentTheme . '.index' :
$template = $currentTheme . '.page'; $template = $currentTheme . '.page';
$page = $this->pages->getById('09E5A362-BA31-4AE2-9DEE-C93DFBE005C3'); $page = $this->pages->getById('532E2250-F8CB-4E87-9782-8AFBEE88DD5E');
$data = $this->sort->page($page); $data = $this->sort->page($page);
$pageData = [ $pageData = [
"debug" => "true", "debug" => "true",
@ -67,7 +67,7 @@ class ThemeController extends Controller
'theme' => $currentTheme, // for theme kit 'theme' => $currentTheme, // for theme kit
'title' => 'Pages Tagged as Tag', 'title' => 'Pages Tagged as Tag',
'dynamicRender' => $data['info']['dynamicRender'], 'dynamicRender' => $data['info']['dynamicRender'],
'tags' => $data['info']['tags'][3]['pages'], '$pages' => $data['info']['tags'][3]['pages'],
'info' => $data['info'], 'info' => $data['info'],
'menu' => $data['info']['menu'], 'menu' => $data['info']['menu'],
'media' => [ 'media' => [

View file

@ -64,7 +64,8 @@ class FipamoServiceProvider extends ServiceProvider
new ContentService(), new ContentService(),
new StringService(), new StringService(),
), ),
new SettingsService(new DocService()) new SettingsService(new DocService()),
new ContentService(),
); );
}); });

View file

@ -9,6 +9,7 @@ use App\Services\PaginateService;
use App\Services\StringService; use App\Services\StringService;
use App\Services\DocService; use App\Services\DocService;
use App\Services\SortingService; use App\Services\SortingService;
use App\Services\RenderService;
use Carbon\Carbon; use Carbon\Carbon;
class PageRepository implements PageRepositoryInterface class PageRepository implements PageRepositoryInterface
@ -20,6 +21,7 @@ class PageRepository implements PageRepositoryInterface
protected $strings; protected $strings;
protected $docs; protected $docs;
protected $sort; protected $sort;
protected $render;
public function __construct( public function __construct(
ContentService $contentService, ContentService $contentService,
@ -28,6 +30,7 @@ class PageRepository implements PageRepositoryInterface
StringService $stringService, StringService $stringService,
DocService $docService, DocService $docService,
SortingService $sortingService, SortingService $sortingService,
RenderService $renderService
) { ) {
$this->content = $contentService; $this->content = $contentService;
$this->settings = $settingsService; $this->settings = $settingsService;
@ -35,6 +38,7 @@ class PageRepository implements PageRepositoryInterface
$this->strings = $stringService; $this->strings = $stringService;
$this->docs = $docService; $this->docs = $docService;
$this->sort = $sortingService; $this->sort = $sortingService;
$this->render = $renderService;
$this->pages = $this->content->loadAllPages(); $this->pages = $this->content->loadAllPages();
} }
@ -123,11 +127,9 @@ class PageRepository implements PageRepositoryInterface
$this->settings->getGlobal()['renderOnSave'] == 'true' && $this->settings->getGlobal()['renderOnSave'] == 'true' &&
$this->settings->getGlobal()['dynamicRender'] == 'false' $this->settings->getGlobal()['dynamicRender'] == 'false'
) { ) {
//TODO: RENDER ENGINE STUFF $this->render->tags();
//$render = new Render(); $this->render->archive();
//$render->renderTags(); $this->render->pages();
//$render->renderArchive();
//$render->renderPages();
$message = 'Filed edited and rendered. NOICE.'; $message = 'Filed edited and rendered. NOICE.';
} else { } else {
$message = 'File edited. Nice work'; $message = 'File edited. Nice work';
@ -139,7 +141,6 @@ class PageRepository implements PageRepositoryInterface
//Settings::updateTags(); //Settings::updateTags();
// if new page added, update current index in Settings file // if new page added, update current index in Settings file
if ($task == 'create') { if ($task == 'create') {
//Settings::updateIndex();
$this->settings->updatePageIndex(); $this->settings->updatePageIndex();
} }

View file

@ -2,51 +2,129 @@
namespace App\Services; namespace App\Services;
use Illuminate\Support\Facades\File;
class RenderService class RenderService
{ {
private $sort; private $sort;
private $settings; private $settings;
private $contents;
private $pageInfo; private $pageInfo;
private $menu; private $menu;
private $background; private $background;
private $theme;
public function __construct(SortingService $sortingService, SettingsService $settingsService) public function __construct(
{ SortingService $sortingService,
SettingsService $settingsService,
ContentService $contentService
) {
$this->sort = $sortingService; $this->sort = $sortingService;
$this->settings = $settingsService; $this->settings = $settingsService;
$this->contents = $contentService;
$this->theme = $this->settings->getGlobal()['theme'];
} }
public function tag() public function archive()
{ {
$list = $this->sort->tags(); $template = $this->theme . '.archive';
foreach ($list as $item) { $data = $this->sort->archive();
$template = 'tags.twig'; $pageData = [
$pageOptions = [ 'theme' => $this->theme, // for theme kit
'title' => 'Pages Tagged as ' . $item['tag_name'], 'title' => 'Archives',
'background' => $this->pageInfo['image'], 'dynamicRender' => $data['info']['dynamicRender'],
'tag_list' => $item['pages'], 'archive' => $data['archive'],
'info' => $this->pageInfo, 'info' => $data['info'],
'menu' => $this->menu, 'menu' => $data['info']['menu'],
'media' => [['file' => $this->pageInfo['image'], 'type' => trim(pathinfo($this->pageInfo['image'], PATHINFO_EXTENSION))]], 'media' => [
]; ['file' => $data['info']['image'],
'type' => trim(pathinfo($data['info']['image'], PATHINFO_EXTENSION))]
],
];
$location = '../public/archive.html';
File::put(
$location,
view($template)
->with($pageData)
->render()
);
}
$html = $this->twig->render($template, $pageOptions); public function tags()
{
$data = $this->sort->tags();
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'],
'info' => $data['info'],
'menu' => $data['info']['menu'],
'pages' => $item['pages'],
'media' => [
['file' => $data['info']['image'],
'type' => trim(pathinfo($data['info']['image'], PATHINFO_EXTENSION))]
],
];
$location = '../public/tags/' . $item['slug'] . '.html'; $location = '../public/tags/' . $item['slug'] . '.html';
//if tags folder doesn't exist, make it
if (!is_dir('../public/tags')) { if (!is_dir('../public/tags')) {
mkdir('../public/tags', 0755, true); mkdir('../public/tags', 0755, true);
} else {
} }
if (!is_file($location)) { File::put(
file_put_contents($location, $html); $location,
view($template)
->with($pageData)
->render()
);
}
}
public function pages()
{
$pages = $this->contents->loadAllPages();
foreach ($pages as $page) {
$template;
$page['layout'] == 'index' ?
$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'],
];
if (str_contains($page['layout'], 'index')) {
$location = '../public/index.html';
} else { } else {
($new = fopen($location, 'w')) or die('Unable to open file!'); // if page is a menu item, render the page on public root
fwrite($new, $html); if ($page['menu'] == 'true') {
fclose($new); $location = '../public/' . $page['slug'] . '.html';
} else {
$dir = '../public/' . $page['path'];
if (!is_dir($dir)) {
mkdir($dir, 0755, true);
}
$location = '../public/' . $page['path'] . '/' . $page['slug'] . '.html';
}
} }
File::put($location, view($template)->with($pageData)->render());
} }
} }
} }

View file

@ -42,7 +42,7 @@
@endif @endif
@endforeach @endforeach
@else @else
@if($media != '') @if(isset($media[0]) && $media != '')
@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>
@ -53,6 +53,8 @@
@else @else
<div id="0" role="slide" style="background: url({{ $media[0]['file'] }}) no-repeat center center / cover"></div> <div id="0" role="slide" style="background: url({{ $media[0]['file'] }}) no-repeat center center / cover"></div>
@endif @endif
@else
<div id="0" role="slide" style="background: url({{ $info['image'] }}) no-repeat center center / cover"></div>
@endif @endif
@endif @endif
</div> </div>

View file

@ -5,15 +5,15 @@
@section('main-content') @section('main-content')
<article> <article>
<h1>{{ $title }}</h1> <h1>{{ $title }}</h1>
@foreach($tags as $tag) @foreach($pages as $page)
@if(isset($dynamicRender)) @if(isset($dynamicRender))
@if($dynamicRender == 'true') @if($dynamicRender == 'true')
<a href="{{ "/".$tag['path']."/".$tag['slug'] }}">{{ $tag['title'] }}</a><br/> <a href="{{ "/".$page['path']."/".$page['slug'] }}">{{ $page['title'] }}</a><br/>
@else @else
<a href="{{ "/".$tag['path']."/".$tag['slug'].".html" }}">{{ $tag['title'] }}</a><br/> <a href="{{ "/".$page['path']."/".$page['slug'].".html" }}">{{ $page['title'] }}</a><br/>
@endif @endif
@else @else
<a href="{{ "/".$tag['path']."/".$tag['slug'].".html" }}">{{ $tag['title'] }}</a><br/> <a href="{{ "/".$page['path']."/".$page['slug'].".html" }}">{{ $page['title'] }}</a><br/>
@endif @endif
@endforeach @endforeach
</article> </article>