From dee16fbf708bcb172991f703dca6025da49a0ea7 Mon Sep 17 00:00:00 2001 From: "S.Wolfertz" Date: Wed, 30 Jan 2019 13:29:49 +0100 Subject: [PATCH 1/7] DocComment: "moons" to "seasons" for seasons --- app/Models/Calendar.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Models/Calendar.php b/app/Models/Calendar.php index 0e7a49b2e0..b1b475b57d 100644 --- a/app/Models/Calendar.php +++ b/app/Models/Calendar.php @@ -203,7 +203,7 @@ public function moons() } /** - * Get the moons + * Get the seasons * @return null */ public function seasons() From 6f414ed08bac01767caa209bf4afbe9111d6f458 Mon Sep 17 00:00:00 2001 From: "S.Wolfertz" Date: Wed, 30 Jan 2019 13:46:09 +0100 Subject: [PATCH 2/7] UI: retain responsiveness for login page on screens below 420px --- public/css/front.css | 1 + 1 file changed, 1 insertion(+) diff --git a/public/css/front.css b/public/css/front.css index 337f0c2c52..fbc44303b8 100644 --- a/public/css/front.css +++ b/public/css/front.css @@ -1192,6 +1192,7 @@ ul.pagination li span { .register-page .login-box, .register-page .register-box { width: 420px; + max-width: 90%; } .login-page .login-box .login-box-body, From 68e15d4fc93e52f495696fe69210c8466247b83c Mon Sep 17 00:00:00 2001 From: "J. Payne" Date: Thu, 31 Jan 2019 19:10:36 +0100 Subject: [PATCH 3/7] Entity Mentions - Update Mentions #278 --- .../Commands/GenerateEntityMentionMap.php | 46 +++++++++++++++++-- app/Services/EntityMappingService.php | 19 ++++++-- 2 files changed, 57 insertions(+), 8 deletions(-) diff --git a/app/Console/Commands/GenerateEntityMentionMap.php b/app/Console/Commands/GenerateEntityMentionMap.php index 2f2cde2330..f351b57f6e 100644 --- a/app/Console/Commands/GenerateEntityMentionMap.php +++ b/app/Console/Commands/GenerateEntityMentionMap.php @@ -32,6 +32,8 @@ class GenerateEntityMentionMap extends Command */ protected $entityCount = 0; protected $mapCount = 0; + protected $mapTotalCount = 0; + protected $redirectFixed = 0; /** * @var EntityMappingService @@ -55,6 +57,8 @@ public function __construct(EntityMappingService $entityMappingService) */ public function handle() { + $start = date('H:i:s'); + $this->info("START " . $start); $entities = [ //'App\Models\Campaign', 'App\Models\Character', @@ -75,6 +79,27 @@ public function handle() EntityMention::truncate(); foreach ($entities as $entity) { + $this->info("Entity $entity"); + // Let's first fix those awful redirects + $this->redirectFixed = 0; + $model = new $entity; + $model->with('entity')->where('entry', 'like', '%redirect?what=%')->chunk(1000, function ($models) use ($entity) { + foreach ($models as $model) { + + /** @var MiscModel $model */ + $pattern = '(.*?)<(.*?)>'; + $model->entry = preg_replace("`$pattern`i", '$2', $model->entry); + if ($model->isDirty('entry')) { + $this->redirectFixed++; + $model->timestamps = false; + $model->save(); + } + } + }); + $this->info("- Fixed {$this->redirectFixed} redirects."); + $this->mapTotalCount += $this->mapCount; + + $this->mapCount = 0; $model = new $entity; $model->with('entity')->where('entry', 'like', '%data-toggle="tooltip"%')->chunk(5000, function ($models) use ($entity) { foreach ($models as $model) { @@ -84,10 +109,14 @@ public function handle() $this->mapCount += $this->entityMapping->mapModel($model); } }); + $this->info("- Created {$this->mapCount} maps.\n"); + $this->mapTotalCount += $this->mapCount; } // Entity Notes - EntityNote::where('entry', 'like', '%data-toggle="tooltip"%')->chunk(5000, function ($models) use ($entity) { + $this->info("Entity Notes"); + $this->mapCount = 0; + EntityNote::where('entry', 'like', '%data-toggle="tooltip"%')->chunk(5000, function ($models) { foreach ($models as $model) { $this->entityCount++; /** @var EntityNote $model */ @@ -95,18 +124,25 @@ public function handle() $this->mapCount += $this->entityMapping->mapEntityNote($model); } }); + $this->info("- Created {$this->mapCount} maps.\n"); + $this->mapTotalCount += $this->mapCount; - // Entity Notes - Campaign::where('entry', 'like', '%data-toggle="tooltip"%')->chunk(5000, function ($models) use ($entity) { + // Campaigns + $this->info("Campaigns"); + $this->mapCount = 0; + Campaign::where('entry', 'like', '%data-toggle="tooltip"%')->chunk(5000, function ($models) { foreach ($models as $model) { $this->entityCount++; - /** @var EntityNote $model */ + /** @var Campaign $model */ $this->info("Checking campaign:" . $model->id); $this->mapCount += $this->entityMapping->mapCampaign($model); } }); + $this->info("- Created {$this->mapCount} maps.\n"); + $this->mapTotalCount += $this->mapCount; - $this->info("Updated {$this->entityCount} entities and created {$this->mapCount} maps."); + $this->info("Updated {$this->entityCount} entities and created {$this->mapTotalCount} maps."); + $this->info("END " . date('H:i:s') . " ($start)"); return true; } diff --git a/app/Services/EntityMappingService.php b/app/Services/EntityMappingService.php index 79907618fe..bc94db2435 100644 --- a/app/Services/EntityMappingService.php +++ b/app/Services/EntityMappingService.php @@ -54,15 +54,21 @@ public function mapModel(MiscModel $model) $type = $data['type']; $id = $data['id']; + // Old redirects or mapping to something else (like the map of a location) that doesn't have a tooltip + if ($id == 'redirect' || empty($data['name'])) { + continue; + } + $singularType = array_get($this->typeMapping, $type, false); if ($singularType === false) { + dump($mentions); throw new Exception("Unknown type $type"); } /** @var Entity $entity */ $entity = Entity::where(['type' => $singularType, 'entity_id' => $id])->first(); if ($entity) { - $this->log("- Mentions " . $entity->id); + //$this->log("- Mentions " . $entity->id); $mention = new EntityMention(); $mention->entity_id = $model->entity->id; @@ -127,19 +133,26 @@ protected function map($model) $type = $data['type']; $id = $data['id']; + // Old redirects or mapping to something else (like the map of a location) that doesn't have a tooltip + if ($id == 'redirect' || empty($data['name'])) { + continue; + } + $singularType = array_get($this->typeMapping, $type, false); if ($singularType === false) { + + dump($data); throw new Exception("Unknown type $type"); } /** @var Entity $entity */ $target = Entity::where(['type' => $singularType, 'entity_id' => $id])->first(); if ($target) { - $this->log("- Mentions " . $model->id); + //$this->log("- Mentions " . $model->id); // Do we already have this mention mapped? if (!empty($existingTargets[$target->id])) { - $this->log("- already have mapping"); + //$this->log("- already have mapping"); unset($existingTargets[$target->id]); $existingMappings++; } else { From 60a1d8d4dfe4e2827e9ade29620391942bb38fca Mon Sep 17 00:00:00 2001 From: "J. Payne" Date: Thu, 31 Jan 2019 19:22:18 +0100 Subject: [PATCH 4/7] Entity Mentions - Update Mentions #278 --- .../Commands/GenerateEntityMentionMap.php | 20 +++++++++++++++---- app/Services/EntityMappingService.php | 5 ++--- 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/app/Console/Commands/GenerateEntityMentionMap.php b/app/Console/Commands/GenerateEntityMentionMap.php index f351b57f6e..73d2e6b6d3 100644 --- a/app/Console/Commands/GenerateEntityMentionMap.php +++ b/app/Console/Commands/GenerateEntityMentionMap.php @@ -85,7 +85,6 @@ public function handle() $model = new $entity; $model->with('entity')->where('entry', 'like', '%redirect?what=%')->chunk(1000, function ($models) use ($entity) { foreach ($models as $model) { - /** @var MiscModel $model */ $pattern = '(.*?)<(.*?)>'; $model->entry = preg_replace("`$pattern`i", '$2', $model->entry); @@ -99,15 +98,20 @@ public function handle() $this->info("- Fixed {$this->redirectFixed} redirects."); $this->mapTotalCount += $this->mapCount; + // Mapping $this->mapCount = 0; $model = new $entity; $model->with('entity')->where('entry', 'like', '%data-toggle="tooltip"%')->chunk(5000, function ($models) use ($entity) { + $bar = $this->output->createProgressBar(count($models)); + $bar->start(); foreach ($models as $model) { $this->entityCount++; /** @var MiscModel $model */ - $this->info("Checking " . $model->getTable() . ":" . $model->id); + //$this->info("Checking " . $model->getTable() . ":" . $model->id); $this->mapCount += $this->entityMapping->mapModel($model); + $bar->advance(); } + $bar->finish(); }); $this->info("- Created {$this->mapCount} maps.\n"); $this->mapTotalCount += $this->mapCount; @@ -117,12 +121,16 @@ public function handle() $this->info("Entity Notes"); $this->mapCount = 0; EntityNote::where('entry', 'like', '%data-toggle="tooltip"%')->chunk(5000, function ($models) { + $bar = $this->output->createProgressBar(count($models)); + $bar->start(); foreach ($models as $model) { $this->entityCount++; /** @var EntityNote $model */ - $this->info("Checking entity_note:" . $model->id); + //$this->info("Checking entity_note:" . $model->id); $this->mapCount += $this->entityMapping->mapEntityNote($model); + $bar->advance(); } + $bar->finish(); }); $this->info("- Created {$this->mapCount} maps.\n"); $this->mapTotalCount += $this->mapCount; @@ -131,12 +139,16 @@ public function handle() $this->info("Campaigns"); $this->mapCount = 0; Campaign::where('entry', 'like', '%data-toggle="tooltip"%')->chunk(5000, function ($models) { + $bar = $this->output->createProgressBar(count($models)); + $bar->start(); foreach ($models as $model) { $this->entityCount++; /** @var Campaign $model */ - $this->info("Checking campaign:" . $model->id); + //$this->info("Checking campaign:" . $model->id); $this->mapCount += $this->entityMapping->mapCampaign($model); + $bar->advance(); } + $bar->finish(); }); $this->info("- Created {$this->mapCount} maps.\n"); $this->mapTotalCount += $this->mapCount; diff --git a/app/Services/EntityMappingService.php b/app/Services/EntityMappingService.php index bc94db2435..150388f430 100644 --- a/app/Services/EntityMappingService.php +++ b/app/Services/EntityMappingService.php @@ -77,7 +77,7 @@ public function mapModel(MiscModel $model) $createdMappings++; } else { - $this->log("- Unknown entity of type $singularType and id $id"); + //$this->log("- Unknown entity of type $singularType and id $id"); } } @@ -140,7 +140,6 @@ protected function map($model) $singularType = array_get($this->typeMapping, $type, false); if ($singularType === false) { - dump($data); throw new Exception("Unknown type $type"); } @@ -170,7 +169,7 @@ protected function map($model) $createdMappings++; } } else { - $this->log("- Unknown entity of type $singularType and id $id"); + //$this->log("- Unknown entity of type $singularType and id $id"); } } From 026710e5c5a03c457ca88d1af216d42290da96af Mon Sep 17 00:00:00 2001 From: "J. Payne" Date: Thu, 31 Jan 2019 20:26:59 +0100 Subject: [PATCH 5/7] Entity Mentions - Update Mentions #278 --- app/Services/EntityMappingService.php | 6 ++++-- app/Traits/ExportableTrait.php | 13 +++++++------ 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/app/Services/EntityMappingService.php b/app/Services/EntityMappingService.php index 150388f430..0126a065e0 100644 --- a/app/Services/EntityMappingService.php +++ b/app/Services/EntityMappingService.php @@ -195,6 +195,8 @@ public function updateMentions(Entity $entity, $url = null) $name = $entity->name; $entityLink = !empty($url) ? $url : $entity->url(); + + //$entityLink = str_replace('http://kanka.loc', 'https://kanka.io', $entityLink); // Replace the link's locale to avoid issues when people use several languages $entityLinkSegments = explode('/', $entityLink); $entityLinkSegments[3] = '(.){2,5}'; @@ -204,7 +206,7 @@ public function updateMentions(Entity $entity, $url = null) // Just text, no tooltip $patternNoTooltip = '(.*?)'; // We need to go 0.300 as the text is encoded, so some html entities will make it longer. It's not great - $patternTooltip = '(.*?)'; + $patternTooltip = '(.*?)'; $replace = '' . $name . ''; if (!empty($tooltip)) { @@ -214,12 +216,12 @@ public function updateMentions(Entity $entity, $url = null) // dump($patternNoTooltip); // dump($patternTooltip); // dump($replace); - /** @var EntityMention $target */ foreach ($entity->targetMentions()->with(['entity', 'campaign', 'entityNote'])->get() as $target) { // We've got a target, we need to update its entry field $realTarget = $target->isEntityNote() ? $target->entityNote : ($target->isCampaign() ? $target->campaign : $target->entity->child); $text = $realTarget->entry; + // dump($text); $text = preg_replace("`$patternNoTooltip`i", $replace, $text); $text = preg_replace("`$patternTooltip`i", $replace, $text); diff --git a/app/Traits/ExportableTrait.php b/app/Traits/ExportableTrait.php index 167b42fbe2..a0727b93dd 100644 --- a/app/Traits/ExportableTrait.php +++ b/app/Traits/ExportableTrait.php @@ -28,13 +28,14 @@ public function export() } // Entity values - $foreigns = ['notes', 'attributes', 'relationships']; - foreach ($foreigns as $foreign) { - // Have to do the ()->get because of attributes being otherwise something else - foreach ($this->entity->$foreign()->get() as $model) { - $json[$foreign][] = $model->toArray(); + if (!empty($this->entity)) { + $foreigns = ['notes', 'attributes', 'relationships']; + foreach ($foreigns as $foreign) { + // Have to do the ()->get because of attributes being otherwise something else + foreach ($this->entity->$foreign()->get() as $model) { + $json[$foreign][] = $model->toArray(); + } } - } return json_encode($json); From 11c666a324926cb7b1b1578665dc54ee142ee88a Mon Sep 17 00:00:00 2001 From: "J. Payne" Date: Thu, 31 Jan 2019 21:10:02 +0100 Subject: [PATCH 6/7] Relations: Use modal UI --- resources/views/cruds/_relations.blade.php | 6 ++-- .../views/cruds/relations/create.blade.php | 28 ++++++++----------- .../views/cruds/relations/edit.blade.php | 28 ++++++++----------- 3 files changed, 28 insertions(+), 34 deletions(-) diff --git a/resources/views/cruds/_relations.blade.php b/resources/views/cruds/_relations.blade.php index 397cb0bb7b..1f01778573 100644 --- a/resources/views/cruds/_relations.blade.php +++ b/resources/views/cruds/_relations.blade.php @@ -14,7 +14,7 @@ @endif @can('relation', [$model, 'add']) - + {{ trans('crud.relations.actions.add') }} @endcan @@ -48,7 +48,9 @@ @endif @can('relation', [$model, 'edit']) - {{ trans('crud.edit') }} + {{ trans('crud.edit') }} @endcan @can('relation', [$model, 'delete']) {!! Form::open(['method' => 'DELETE', 'route' => [$name . '.relations.destroy', $name => $model, 'relation' => $relation], 'style'=>'display:inline']) !!} diff --git a/resources/views/cruds/relations/create.blade.php b/resources/views/cruds/relations/create.blade.php index c442391ff2..08a9bfe744 100644 --- a/resources/views/cruds/relations/create.blade.php +++ b/resources/views/cruds/relations/create.blade.php @@ -1,4 +1,4 @@ -@extends('layouts.app', [ +@extends('layouts.' . (request()->ajax() ? 'ajax' : 'app'), [ 'title' => trans('relations.create.title', ['name' => $model->name]), 'description' => trans('relations.create.description'), 'breadcrumbs' => [ @@ -9,25 +9,21 @@ ]) @section('content') -
-
-
-
- @include('partials.errors') +
+
+ @include('partials.errors') - {!! Form::open(array('route' => [$route . '.store', $model->id], 'method'=>'POST', 'data-shortcut' => "1")) !!} - @include('cruds.relations._form') + {!! Form::open(array('route' => [$route . '.store', $model->id], 'method'=>'POST', 'data-shortcut' => "1")) !!} + @include('cruds.relations._form') - {!! Form::hidden('owner_id', $model->entity->id) !!} + {!! Form::hidden('owner_id', $model->entity->id) !!} -
- - {!! trans('crud.or_cancel', ['url' => (!empty($cancel) ? $cancel : url()->previous() . (strpos(url()->previous(), '#relation') === false ? '#relation' : null))]) !!} -
- - {!! Form::close() !!} -
+
+ + {!! trans('crud.or_cancel', ['url' => (!empty($cancel) ? $cancel : url()->previous() . (strpos(url()->previous(), '#relation') === false ? '#relation' : null))]) !!}
+ + {!! Form::close() !!}
@endsection diff --git a/resources/views/cruds/relations/edit.blade.php b/resources/views/cruds/relations/edit.blade.php index 177424c145..c9bcb95835 100644 --- a/resources/views/cruds/relations/edit.blade.php +++ b/resources/views/cruds/relations/edit.blade.php @@ -1,4 +1,4 @@ -@extends('layouts.app', [ +@extends('layouts.' . (request()->ajax() ? 'ajax' : 'app'), [ 'title' => trans('relations.edit.title', ['name' => $model->name]), 'description' => trans('relations.edit.description'), 'breadcrumbs' => [ @@ -9,25 +9,21 @@ ] ]) @section('content') -
-
-
-
- @include('partials.errors') +
+
+ @include('partials.errors') - {!! Form::model($relation, ['method' => 'PATCH', 'route' => [$route . '.update', $model->id, $relation->id], 'data-shortcut' => "1"]) !!} - @include('cruds.relations._form') + {!! Form::model($relation, ['method' => 'PATCH', 'route' => [$route . '.update', $model->id, $relation->id], 'data-shortcut' => "1"]) !!} + @include('cruds.relations._form') - {!! Form::hidden('owner_id', $model->entity->id) !!} + {!! Form::hidden('owner_id', $model->entity->id) !!} -
- - {!! trans('crud.or_cancel', ['url' => (!empty($cancel) ? $cancel : url()->previous() . (strpos(url()->previous(), '#relation') === false ? '#relation' : null))]) !!} -
- - {!! Form::close() !!} -
+
+ + {!! trans('crud.or_cancel', ['url' => (!empty($cancel) ? $cancel : url()->previous() . (strpos(url()->previous(), '#relation') === false ? '#relation' : null))]) !!}
+ + {!! Form::close() !!}
@endsection From 2e0c3a8403ed898e507fadcc5d4b701a62f97c72 Mon Sep 17 00:00:00 2001 From: "J. Payne" Date: Fri, 1 Feb 2019 08:34:29 +0100 Subject: [PATCH 7/7] Add frontend footer to the error pages --- resources/views/front/footer.blade.php | 76 ++++++++++++++++++++++++ resources/views/layouts/error.blade.php | 28 ++------- resources/views/layouts/front.blade.php | 77 +------------------------ 3 files changed, 82 insertions(+), 99 deletions(-) create mode 100644 resources/views/front/footer.blade.php diff --git a/resources/views/front/footer.blade.php b/resources/views/front/footer.blade.php new file mode 100644 index 0000000000..d5ab265a02 --- /dev/null +++ b/resources/views/front/footer.blade.php @@ -0,0 +1,76 @@ + \ No newline at end of file diff --git a/resources/views/layouts/error.blade.php b/resources/views/layouts/error.blade.php index 6de05a5b50..18e0aaf175 100644 --- a/resources/views/layouts/error.blade.php +++ b/resources/views/layouts/error.blade.php @@ -16,6 +16,9 @@ function gtag(){dataLayer.push(arguments);} + + + {{ $error }} - {{ config('app.name', 'Kanka') }} @@ -26,7 +29,6 @@ function gtag(){dataLayer.push(arguments);} - @@ -106,28 +108,7 @@ function gtag(){dataLayer.push(arguments);} @yield('content') - +@include('front.footer') @@ -160,6 +141,7 @@ function gtag(){dataLayer.push(arguments);} +