forked from projects/fipamo
added getbyIndex for pages, urlencode page titles
the theme controller was grabbing the index by its page name, which was bad because that might change. that was replaced with a getById function since the index id will always be 0 since it's the first page. this is a seperate function from getByUuid which is a unique indentifier for each page which was being used interchangably before the fix. all of those references have been cleaned up to reference which type of id is needed there was also a bug that happened on rendering when there were special characters in the title. this was solved by saving the title as a urlencoded string and then just decodded when it was needed for display on the front end
This commit is contained in:
parent
a0f7bff67c
commit
c85e145774
8 changed files with 28 additions and 14 deletions
|
@ -88,7 +88,7 @@ class DashController extends Controller
|
|||
$title;
|
||||
$page = [];
|
||||
$views = [];
|
||||
$mode == 'edit' ? $page = $this->pages->getById($uuid) : $page = [];
|
||||
$mode == 'edit' ? $page = $this->pages->getByUuid($uuid) : $page = [];
|
||||
$mode == 'edit' ? $title = $page['title'] : $title = 'Add New';
|
||||
$mode == 'edit' ? $views = $this->themes->getCustomViews($page['layout']) : $views[] = 'page';
|
||||
|
||||
|
|
|
@ -56,14 +56,14 @@ class ThemeController extends Controller
|
|||
$page;
|
||||
if ($view == 'index') {
|
||||
$template = $currentTheme . '.index';
|
||||
$page = $this->pages->getBySlug('first');
|
||||
$page = $this->pages->getById(0);
|
||||
} else {
|
||||
$template = $currentTheme . '.page';
|
||||
//if coming from theme page, grabs id of latest page
|
||||
if ($id == null) {
|
||||
$id = $this->getPageID();
|
||||
$uuid = $this->getPageUUID();
|
||||
}
|
||||
$page = $this->pages->getById($id);
|
||||
$page = $this->pages->getByUuid($uuid);
|
||||
}
|
||||
$pageData = $this->sort->page($page);
|
||||
break;
|
||||
|
@ -88,7 +88,7 @@ class ThemeController extends Controller
|
|||
}
|
||||
}
|
||||
|
||||
private function getPageID()
|
||||
private function getPageUUID()
|
||||
{
|
||||
$book = $this->pages->getAll();
|
||||
$page = $book->where('layout', 'page')->first();
|
||||
|
|
|
@ -6,7 +6,9 @@ interface PageRepositoryInterface
|
|||
{
|
||||
public function getAll();
|
||||
|
||||
public function getByID($uuid);
|
||||
public function getById($id);
|
||||
|
||||
public function getByUuid($uuid);
|
||||
|
||||
public function getBySlug($slug);
|
||||
|
||||
|
|
|
@ -45,7 +45,15 @@ class PageRepository implements PageRepositoryInterface
|
|||
return $this->pages;
|
||||
}
|
||||
|
||||
public function getById($uuid)
|
||||
public function getById($id)
|
||||
{
|
||||
$page = $this->pages->where('id', $id)->first();
|
||||
//quick check to see if layout is set
|
||||
$page['layout'] == '' ? $page['layout'] = 'page' : $page['layout'] = $page['layout'];
|
||||
return $page;
|
||||
}
|
||||
|
||||
public function getByUuid($uuid)
|
||||
{
|
||||
$page = $this->pages->where('uuid', $uuid)->first();
|
||||
//quick check to see if layout is set
|
||||
|
@ -121,6 +129,7 @@ class PageRepository implements PageRepositoryInterface
|
|||
$id = $task != 'create' ? $body->id : $this->settings->getSettings()['library_stats']['current_index'];
|
||||
$uuid = $task != 'create' ? $body->uuid : createUUID();
|
||||
//set variables post body for saving
|
||||
$body->title = urlencode($body->title);
|
||||
$body->id = $id;
|
||||
$body->uuid = $uuid;
|
||||
$body->path = $path;
|
||||
|
|
|
@ -216,7 +216,7 @@ class SortingService
|
|||
array_push($recent, [
|
||||
'path' => $item['path'],
|
||||
'slug' => $item['slug'],
|
||||
'title' => $item['title'],
|
||||
'title' => urldecode($item['title']),
|
||||
'feature' => $item['feature'],
|
||||
]);
|
||||
}
|
||||
|
@ -226,7 +226,7 @@ class SortingService
|
|||
array_push($featured, [
|
||||
'path' => $item['path'],
|
||||
'slug' => $item['slug'],
|
||||
'title' => $item['title'],
|
||||
'title' => urldecode($item['title']),
|
||||
'feature' => $item['feature'],
|
||||
]);
|
||||
}
|
||||
|
@ -237,7 +237,7 @@ class SortingService
|
|||
"debug" => $debug,
|
||||
"theme" => $this->info['theme'],
|
||||
"status" => session('member') != null ? true : false,
|
||||
"title" => $page['title'],
|
||||
"title" => urldecode($page['title']),
|
||||
"meta" => $meta,
|
||||
"menu" => $this->settings->getMenu(),
|
||||
"info" => $this->info,
|
||||
|
|
|
@ -88,7 +88,7 @@ class InitService
|
|||
//create index file
|
||||
//TODO: upate path attribute to use env variable
|
||||
$index = [
|
||||
'id' => 1,
|
||||
'id' => 0,
|
||||
'uuid' => createUUID(),
|
||||
'title' => 'FIRST!',
|
||||
'imageList' => '/assets/images/global/default-bg.jpg',
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
@extends('frame')
|
||||
|
||||
@section('title', 'The Dash | Editing '. $title)
|
||||
|
||||
@php
|
||||
$title = urldecode($title);
|
||||
if($mode == 'edit')
|
||||
{
|
||||
$id = $page['id'];
|
||||
|
@ -30,6 +29,7 @@
|
|||
$files = "";
|
||||
}
|
||||
@endphp
|
||||
@section('title', 'The Dash | Editing '. $title)
|
||||
|
||||
@section('main-content')
|
||||
<section data-index="{{ $id }}" data-uuid="{{ $uuid }}" data-slug="{{ $slug }}" data-layout="{{ $layout }}" class="file-manager">
|
||||
|
|
|
@ -29,7 +29,10 @@ if($page['featured'] == 'true')
|
|||
</strong>
|
||||
<hr/>
|
||||
<strong>
|
||||
{{ $page['title'] }}
|
||||
@php
|
||||
$title = urldecode($page['title']);
|
||||
@endphp
|
||||
{{ $title }}
|
||||
</strong>
|
||||
<hr/>
|
||||
<button data-active="{{ $menu }}">
|
||||
|
|
Loading…
Reference in a new issue