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;
|
$title;
|
||||||
$page = [];
|
$page = [];
|
||||||
$views = [];
|
$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' ? $title = $page['title'] : $title = 'Add New';
|
||||||
$mode == 'edit' ? $views = $this->themes->getCustomViews($page['layout']) : $views[] = 'page';
|
$mode == 'edit' ? $views = $this->themes->getCustomViews($page['layout']) : $views[] = 'page';
|
||||||
|
|
||||||
|
|
|
@ -56,14 +56,14 @@ class ThemeController extends Controller
|
||||||
$page;
|
$page;
|
||||||
if ($view == 'index') {
|
if ($view == 'index') {
|
||||||
$template = $currentTheme . '.index';
|
$template = $currentTheme . '.index';
|
||||||
$page = $this->pages->getBySlug('first');
|
$page = $this->pages->getById(0);
|
||||||
} else {
|
} else {
|
||||||
$template = $currentTheme . '.page';
|
$template = $currentTheme . '.page';
|
||||||
//if coming from theme page, grabs id of latest page
|
//if coming from theme page, grabs id of latest page
|
||||||
if ($id == null) {
|
if ($id == null) {
|
||||||
$id = $this->getPageID();
|
$uuid = $this->getPageUUID();
|
||||||
}
|
}
|
||||||
$page = $this->pages->getById($id);
|
$page = $this->pages->getByUuid($uuid);
|
||||||
}
|
}
|
||||||
$pageData = $this->sort->page($page);
|
$pageData = $this->sort->page($page);
|
||||||
break;
|
break;
|
||||||
|
@ -88,7 +88,7 @@ class ThemeController extends Controller
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private function getPageID()
|
private function getPageUUID()
|
||||||
{
|
{
|
||||||
$book = $this->pages->getAll();
|
$book = $this->pages->getAll();
|
||||||
$page = $book->where('layout', 'page')->first();
|
$page = $book->where('layout', 'page')->first();
|
||||||
|
|
|
@ -6,7 +6,9 @@ interface PageRepositoryInterface
|
||||||
{
|
{
|
||||||
public function getAll();
|
public function getAll();
|
||||||
|
|
||||||
public function getByID($uuid);
|
public function getById($id);
|
||||||
|
|
||||||
|
public function getByUuid($uuid);
|
||||||
|
|
||||||
public function getBySlug($slug);
|
public function getBySlug($slug);
|
||||||
|
|
||||||
|
|
|
@ -45,7 +45,15 @@ class PageRepository implements PageRepositoryInterface
|
||||||
return $this->pages;
|
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();
|
$page = $this->pages->where('uuid', $uuid)->first();
|
||||||
//quick check to see if layout is set
|
//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'];
|
$id = $task != 'create' ? $body->id : $this->settings->getSettings()['library_stats']['current_index'];
|
||||||
$uuid = $task != 'create' ? $body->uuid : createUUID();
|
$uuid = $task != 'create' ? $body->uuid : createUUID();
|
||||||
//set variables post body for saving
|
//set variables post body for saving
|
||||||
|
$body->title = urlencode($body->title);
|
||||||
$body->id = $id;
|
$body->id = $id;
|
||||||
$body->uuid = $uuid;
|
$body->uuid = $uuid;
|
||||||
$body->path = $path;
|
$body->path = $path;
|
||||||
|
|
|
@ -216,7 +216,7 @@ class SortingService
|
||||||
array_push($recent, [
|
array_push($recent, [
|
||||||
'path' => $item['path'],
|
'path' => $item['path'],
|
||||||
'slug' => $item['slug'],
|
'slug' => $item['slug'],
|
||||||
'title' => $item['title'],
|
'title' => urldecode($item['title']),
|
||||||
'feature' => $item['feature'],
|
'feature' => $item['feature'],
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
@ -226,7 +226,7 @@ class SortingService
|
||||||
array_push($featured, [
|
array_push($featured, [
|
||||||
'path' => $item['path'],
|
'path' => $item['path'],
|
||||||
'slug' => $item['slug'],
|
'slug' => $item['slug'],
|
||||||
'title' => $item['title'],
|
'title' => urldecode($item['title']),
|
||||||
'feature' => $item['feature'],
|
'feature' => $item['feature'],
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
@ -237,7 +237,7 @@ class SortingService
|
||||||
"debug" => $debug,
|
"debug" => $debug,
|
||||||
"theme" => $this->info['theme'],
|
"theme" => $this->info['theme'],
|
||||||
"status" => session('member') != null ? true : false,
|
"status" => session('member') != null ? true : false,
|
||||||
"title" => $page['title'],
|
"title" => urldecode($page['title']),
|
||||||
"meta" => $meta,
|
"meta" => $meta,
|
||||||
"menu" => $this->settings->getMenu(),
|
"menu" => $this->settings->getMenu(),
|
||||||
"info" => $this->info,
|
"info" => $this->info,
|
||||||
|
|
|
@ -88,7 +88,7 @@ class InitService
|
||||||
//create index file
|
//create index file
|
||||||
//TODO: upate path attribute to use env variable
|
//TODO: upate path attribute to use env variable
|
||||||
$index = [
|
$index = [
|
||||||
'id' => 1,
|
'id' => 0,
|
||||||
'uuid' => createUUID(),
|
'uuid' => createUUID(),
|
||||||
'title' => 'FIRST!',
|
'title' => 'FIRST!',
|
||||||
'imageList' => '/assets/images/global/default-bg.jpg',
|
'imageList' => '/assets/images/global/default-bg.jpg',
|
||||||
|
|
|
@ -1,8 +1,7 @@
|
||||||
@extends('frame')
|
@extends('frame')
|
||||||
|
|
||||||
@section('title', 'The Dash | Editing '. $title)
|
|
||||||
|
|
||||||
@php
|
@php
|
||||||
|
$title = urldecode($title);
|
||||||
if($mode == 'edit')
|
if($mode == 'edit')
|
||||||
{
|
{
|
||||||
$id = $page['id'];
|
$id = $page['id'];
|
||||||
|
@ -30,6 +29,7 @@
|
||||||
$files = "";
|
$files = "";
|
||||||
}
|
}
|
||||||
@endphp
|
@endphp
|
||||||
|
@section('title', 'The Dash | Editing '. $title)
|
||||||
|
|
||||||
@section('main-content')
|
@section('main-content')
|
||||||
<section data-index="{{ $id }}" data-uuid="{{ $uuid }}" data-slug="{{ $slug }}" data-layout="{{ $layout }}" class="file-manager">
|
<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>
|
</strong>
|
||||||
<hr/>
|
<hr/>
|
||||||
<strong>
|
<strong>
|
||||||
{{ $page['title'] }}
|
@php
|
||||||
|
$title = urldecode($page['title']);
|
||||||
|
@endphp
|
||||||
|
{{ $title }}
|
||||||
</strong>
|
</strong>
|
||||||
<hr/>
|
<hr/>
|
||||||
<button data-active="{{ $menu }}">
|
<button data-active="{{ $menu }}">
|
||||||
|
|
Loading…
Reference in a new issue