Add (publish date): Change to datetime, show on view, save publishdate properly

add (composer): rss feed
This commit is contained in:
2023-07-31 00:21:18 +08:00
parent 3812976c0f
commit ad384c5fc2
44 changed files with 440 additions and 156 deletions

View File

@@ -90,13 +90,10 @@
<path d="M12 15v3"></path>
</svg>
</span>
<input
type="date"
<VueDatePicker
:timezone="timezone"
v-model="post.publish_date"
class="form-control"
placeholder="Select a date"
id="datepicker-icon-prepend"
/>
></VueDatePicker>
</div>
<button
@click="checkAndSave"
@@ -198,13 +195,22 @@ import { usePostStore } from "@/stores/postStore.js";
import axios from "axios";
import route from "ziggy-js/src/js/index";
import VueDatePicker from "@vuepic/vue-datepicker";
import "@vuepic/vue-datepicker/dist/main.css";
import { addMinutes } from "date-fns";
export default {
components: { VueEditorJs, List, Header },
components: { VueEditorJs, List, Header, VueDatePicker },
props: {
postId: {
type: Number, // The prop type is Number
default: null, // Default value if the prop is not provided
},
timezone: {
type: String,
default: null,
},
},
data() {
return {
@@ -302,7 +308,7 @@ export default {
errors.push("post title");
}
if (!(this.post.publish_date?.length > 0)) {
if (!(this.post.publish_date != null)) {
errors.push("publish date");
}
@@ -348,6 +354,15 @@ export default {
if (_item != null) {
if (key == "body") {
formData.append(key, JSON.stringify(_item));
} else if (key == "publish_date") {
if (_item instanceof Date) {
// Now utcDate is the equivalent UTC date of your original date
let isoDate = _item.toISOString();
formData.append(key, isoDate);
} else {
formData.append(key, _item);
}
} else {
formData.append(key, _item);
}
@@ -362,6 +377,9 @@ export default {
})
.then((response) => {
console.warn(response);
if (response.data.action == "redirect_back") {
history.back();
}
});
setTimeout(

View File

@@ -1,4 +1,4 @@
const Ziggy = {"url":"https:\/\/productalert.co","port":null,"defaults":{},"routes":{"debugbar.openhandler":{"uri":"_debugbar\/open","methods":["GET","HEAD"]},"debugbar.clockwork":{"uri":"_debugbar\/clockwork\/{id}","methods":["GET","HEAD"]},"debugbar.assets.css":{"uri":"_debugbar\/assets\/stylesheets","methods":["GET","HEAD"]},"debugbar.assets.js":{"uri":"_debugbar\/assets\/javascript","methods":["GET","HEAD"]},"debugbar.cache.delete":{"uri":"_debugbar\/cache\/{key}\/{tags?}","methods":["DELETE"]},"sanctum.csrf-cookie":{"uri":"sanctum\/csrf-cookie","methods":["GET","HEAD"]},"ignition.healthCheck":{"uri":"_ignition\/health-check","methods":["GET","HEAD"]},"ignition.executeSolution":{"uri":"_ignition\/execute-solution","methods":["POST"]},"ignition.updateConfig":{"uri":"_ignition\/update-config","methods":["POST"]},"api.auth.login.post":{"uri":"api\/login","methods":["POST"]},"api.auth.logout.post":{"uri":"api\/logout","methods":["POST"]},"api.admin.post.get":{"uri":"api\/admin\/post\/{id}","methods":["GET","HEAD"]},"api.admin.country-locales":{"uri":"api\/admin\/country-locales","methods":["GET","HEAD"]},"api.admin.categories":{"uri":"api\/admin\/categories\/{country_locale_slug}","methods":["GET","HEAD"]},"api.admin.authors":{"uri":"api\/admin\/authors","methods":["GET","HEAD"]},"api.admin.upload.cloud.image":{"uri":"api\/admin\/image\/upload","methods":["POST"]},"api.admin.post.upsert":{"uri":"api\/admin\/admin\/post\/upsert","methods":["POST"]},"login":{"uri":"login","methods":["GET","HEAD"]},"logout":{"uri":"logout","methods":["POST"]},"register":{"uri":"register","methods":["GET","HEAD"]},"password.request":{"uri":"password\/reset","methods":["GET","HEAD"]},"password.email":{"uri":"password\/email","methods":["POST"]},"password.reset":{"uri":"password\/reset\/{token}","methods":["GET","HEAD"]},"password.update":{"uri":"password\/reset","methods":["POST"]},"password.confirm":{"uri":"password\/confirm","methods":["GET","HEAD"]},"dashboard":{"uri":"admin","methods":["GET","HEAD"]},"about":{"uri":"admin\/about","methods":["GET","HEAD"]},"users.index":{"uri":"admin\/users","methods":["GET","HEAD"]},"posts.manage":{"uri":"admin\/posts","methods":["GET","HEAD"]},"posts.manage.edit":{"uri":"admin\/posts\/edit\/{post_id}","methods":["GET","HEAD"]},"posts.manage.new":{"uri":"admin\/posts\/new","methods":["GET","HEAD"]},"profile.show":{"uri":"admin\/profile","methods":["GET","HEAD"]},"profile.update":{"uri":"admin\/profile","methods":["PUT"]},"home":{"uri":"\/","methods":["GET","HEAD"]},"home.country":{"uri":"{country}","methods":["GET","HEAD"]},"home.country.posts":{"uri":"{country}\/posts","methods":["GET","HEAD"]},"home.country.post":{"uri":"{country}\/posts\/{post_slug}","methods":["GET","HEAD"]},"home.country.category":{"uri":"{country}\/{category}","methods":["GET","HEAD"]}}};
const Ziggy = {"url":"https:\/\/productalert.co","port":null,"defaults":{},"routes":{"debugbar.openhandler":{"uri":"_debugbar\/open","methods":["GET","HEAD"]},"debugbar.clockwork":{"uri":"_debugbar\/clockwork\/{id}","methods":["GET","HEAD"]},"debugbar.assets.css":{"uri":"_debugbar\/assets\/stylesheets","methods":["GET","HEAD"]},"debugbar.assets.js":{"uri":"_debugbar\/assets\/javascript","methods":["GET","HEAD"]},"debugbar.cache.delete":{"uri":"_debugbar\/cache\/{key}\/{tags?}","methods":["DELETE"]},"sanctum.csrf-cookie":{"uri":"sanctum\/csrf-cookie","methods":["GET","HEAD"]},"ignition.healthCheck":{"uri":"_ignition\/health-check","methods":["GET","HEAD"]},"ignition.executeSolution":{"uri":"_ignition\/execute-solution","methods":["POST"]},"ignition.updateConfig":{"uri":"_ignition\/update-config","methods":["POST"]},"api.auth.login.post":{"uri":"api\/login","methods":["POST"]},"api.auth.logout.post":{"uri":"api\/logout","methods":["POST"]},"api.admin.post.get":{"uri":"api\/admin\/post\/{id}","methods":["GET","HEAD"]},"api.admin.country-locales":{"uri":"api\/admin\/country-locales","methods":["GET","HEAD"]},"api.admin.categories":{"uri":"api\/admin\/categories\/{country_locale_slug}","methods":["GET","HEAD"]},"api.admin.authors":{"uri":"api\/admin\/authors","methods":["GET","HEAD"]},"api.admin.upload.cloud.image":{"uri":"api\/admin\/image\/upload","methods":["POST"]},"api.admin.post.upsert":{"uri":"api\/admin\/admin\/post\/upsert","methods":["POST"]},"feeds.main":{"uri":"posts.rss","methods":["GET","HEAD"]},"login":{"uri":"login","methods":["GET","HEAD"]},"logout":{"uri":"logout","methods":["POST"]},"register":{"uri":"register","methods":["GET","HEAD"]},"password.request":{"uri":"password\/reset","methods":["GET","HEAD"]},"password.email":{"uri":"password\/email","methods":["POST"]},"password.reset":{"uri":"password\/reset\/{token}","methods":["GET","HEAD"]},"password.update":{"uri":"password\/reset","methods":["POST"]},"password.confirm":{"uri":"password\/confirm","methods":["GET","HEAD"]},"dashboard":{"uri":"admin","methods":["GET","HEAD"]},"about":{"uri":"admin\/about","methods":["GET","HEAD"]},"users.index":{"uri":"admin\/users","methods":["GET","HEAD"]},"posts.manage":{"uri":"admin\/posts","methods":["GET","HEAD"]},"posts.manage.edit":{"uri":"admin\/posts\/edit\/{post_id}","methods":["GET","HEAD"]},"posts.manage.new":{"uri":"admin\/posts\/new","methods":["GET","HEAD"]},"profile.show":{"uri":"admin\/profile","methods":["GET","HEAD"]},"profile.update":{"uri":"admin\/profile","methods":["PUT"]},"home":{"uri":"\/","methods":["GET","HEAD"]},"home.country":{"uri":"{country}","methods":["GET","HEAD"]},"home.country.posts":{"uri":"{country}\/posts","methods":["GET","HEAD"]},"home.country.post":{"uri":"{country}\/posts\/{post_slug}","methods":["GET","HEAD"]},"home.country.category":{"uri":"{country}\/{category}","methods":["GET","HEAD"]}}};
if (typeof window !== 'undefined' && typeof window.Ziggy !== 'undefined') {
Object.assign(Ziggy.routes, window.Ziggy.routes);

View File

@@ -42,32 +42,38 @@
<td><img width="80" height="60" src="{{ $post->featured_image }}"
class="img-fluid rounded-2" alt=""></td>
<td>
@if($post->status === 'publish')
<span class="badge bg-success">{{ ucfirst($post->status) }}</span>
@elseif($post->status === 'future')
<span class="badge bg-primary">{{ ucfirst($post->status) }}</span>
@elseif($post->status === 'draft')
<span class="badge bg-secondary">{{ ucfirst($post->status) }}</span>
@elseif($post->status === 'private')
<span class="badge bg-info">{{ ucfirst($post->status) }}</span>
@elseif ($post->status == 'trash')
<span class="badge bg-danger">{{ ucfirst($post->status) }}</span>
@else
<span class="badge bg-secondary">{{ ucfirst($post->status) }}</span>
@endif
@if ($post->status === 'publish')
<span class="badge bg-success">{{ ucfirst($post->status) }}</span>
@elseif($post->status === 'future')
<span class="badge bg-primary">{{ ucfirst($post->status) }}</span>
@elseif($post->status === 'draft')
<span class="badge bg-secondary">{{ ucfirst($post->status) }}</span>
@elseif($post->status === 'private')
<span class="badge bg-info">{{ ucfirst($post->status) }}</span>
@elseif ($post->status == 'trash')
<span class="badge bg-danger">{{ ucfirst($post->status) }}</span>
@else
<span class="badge bg-secondary">{{ ucfirst($post->status) }}</span>
@endif
</td>
<td>
@if(!is_empty($post->post_category?->category?->country_locale_slug) && $post->status == 'publish')
<a
href="{{ route('home.country.post', ['country' => $post->post_category?->category?->country_locale_slug, 'post_slug' => $post->slug]) }}">{{ $post->title }}</a>
@if (!is_empty($post->post_category?->category?->country_locale_slug) && $post->status == 'publish')
<a
href="{{ route('home.country.post', ['country' => $post->post_category?->category?->country_locale_slug, 'post_slug' => $post->slug]) }}">{{ $post->title }}</a>
@else
{{ $post->title }}
{{ $post->title }}
@endif
</td>
<td>
Created at {{ $post->created_at->timezone(session()->get('timezone'))->isoFormat('Do MMMM YYYY, h:mm A') }}<br>
Updated {{ $post->updated_at->diffForhumans() }}
Created at
{{ $post->created_at->timezone(session()->get('timezone'))->isoFormat('Do MMMM YYYY, h:mm A') }}<br>
Updated {{ $post->updated_at->diffForhumans() }}<br>
@if ($post->status == 'publish')
Published at
{{ $post->publish_date->timezone(session()->get('timezone'))->isoFormat('Do MMMM YYYY, h:mm A') }}
@endif
</td>
<td>
<div><a href="{{ route('posts.manage.edit', ['post_id' => $post->id]) }}"

View File

@@ -5,23 +5,23 @@
<!-- Page title -->
<div class="page-header d-print-none">
<h2 class="page-title text-center justify-content-center">
<div class="align-self-center">
@if (!is_null($post))
Edit Post
@else
New Post
@endif
</div>
<div class="align-self-center">
@if (!is_null($post))
Edit Post
@else
New Post
@endif
</div>
</h2>
</div>
</div>
<div class="page-body">
<div class="container-xl">
@if (!is_null($post))
<post-editor :post-id="{{ $post->id }}"></post-editor>
@else
<post-editor></post-editor>
@endif
@if (!is_null($post))
<post-editor :post-id="{{ $post->id }}"></post-editor>
@else
<post-editor timezone="{{ session()->get('timezone') }}"></post-editor>
@endif
</div>
</div>
@endsection

View File

@@ -22,13 +22,14 @@
<a href="{{ route('home.country.post', ['country' => $country_locale->country_iso, 'post_slug' => $post->slug]) }}"
class="text-decoration-none">
<div class="card-img-top ratio ratio-16x9">
<div class="lqip-loader">
<!-- Use the LQIP image with the appropriate URL -->
<img src="{{ $post->featured_image }}" alt="Photo of {{ $post->name }}">
<!-- Use the final JPEG image with the appropriate URL -->
<img class="lqip-frozen" src="{{ $post->featured_image_lqip }}" alt="Placeholder image of {{ $post->name }}">
</div>
<div class="lqip-loader">
<!-- Use the LQIP image with the appropriate URL -->
<img src="{{ $post->featured_image }}" alt="Photo of {{ $post->name }}">
<!-- Use the final JPEG image with the appropriate URL -->
<img class="lqip-frozen" src="{{ $post->featured_image_lqip }}"
alt="Placeholder image of {{ $post->name }}">
</div>
</div>
</a>
@@ -85,13 +86,15 @@ class="text-decoration-none">{{ $post->title }}</a>
<a href="{{ route('home.country.post', ['country' => $country_locale->country_iso, 'post_slug' => $post->slug]) }}"
class="text-decoration-none">
<div class="img-fluid rounded-start ratio ratio-16x9">
<div class="lqip-loader">
<!-- Use the LQIP image with the appropriate URL -->
<img src="{{ $post->featured_image }}" alt="Photo of {{ $post->name }}">
<!-- Use the final JPEG image with the appropriate URL -->
<img class="lqip-frozen" src="{{ $post->featured_image_lqip }}" alt="Placeholder image of {{ $post->name }}">
</div>
<div class="lqip-loader">
<!-- Use the LQIP image with the appropriate URL -->
<img src="{{ $post->featured_image }}"
alt="Photo of {{ $post->name }}">
<!-- Use the final JPEG image with the appropriate URL -->
<img class="lqip-frozen" src="{{ $post->featured_image_lqip }}"
alt="Placeholder image of {{ $post->name }}">
</div>
</div>
</a>
</div>

View File

@@ -44,15 +44,16 @@
</div>
<a class="card-img-top"
href="{{ route('home.country.post', ['country' => $country_locale->country_iso, 'post_slug' => $post->slug]) }}">
<div class="img-fluid rounded-start ratio ratio-16x9">
<div class="lqip-loader">
<!-- Use the LQIP image with the appropriate URL -->
<img src="{{ $post->featured_image }}" alt="Photo of {{ $post->name }}">
<!-- Use the final JPEG image with the appropriate URL -->
<img class="lqip-frozen" src="{{ $post->featured_image_lqip }}" alt="Placeholder image of {{ $post->name }}">
</div>
</div>
<div class="img-fluid rounded-start ratio ratio-16x9">
<div class="lqip-loader">
<!-- Use the LQIP image with the appropriate URL -->
<img src="{{ $post->featured_image }}" alt="Photo of {{ $post->name }}">
<!-- Use the final JPEG image with the appropriate URL -->
<img class="lqip-frozen" src="{{ $post->featured_image_lqip }}"
alt="Placeholder image of {{ $post->name }}">
</div>
</div>
</a>
</div>

View File

@@ -43,15 +43,16 @@
</div>
<a class="card-img-top"
href="{{ route('home.country.post', ['country' => $country_locale->country_iso, 'post_slug' => $post->slug]) }}">
<div class="img-fluid rounded-start ratio ratio-16x9">
<div class="lqip-loader">
<!-- Use the LQIP image with the appropriate URL -->
<img src="{{ $post->featured_image }}" alt="Photo of {{ $post->name }}">
<!-- Use the final JPEG image with the appropriate URL -->
<img class="lqip-frozen" src="{{ $post->featured_image_lqip }}" alt="Placeholder image of {{ $post->name }}">
</div>
</div>
<div class="img-fluid rounded-start ratio ratio-16x9">
<div class="lqip-loader">
<!-- Use the LQIP image with the appropriate URL -->
<img src="{{ $post->featured_image }}" alt="Photo of {{ $post->name }}">
<!-- Use the final JPEG image with the appropriate URL -->
<img class="lqip-frozen" src="{{ $post->featured_image_lqip }}"
alt="Placeholder image of {{ $post->name }}">
</div>
</div>
</a>
</div>

View File

@@ -21,7 +21,13 @@
<span class="ms-2">
<small>
Written by {{ $post->author->name }}
{{ $post->author->name }}
</small>
</span>
<span class="ms-2">
<small>
{{ $post->publish_date->timezone(session()->get('timezone'))->isoFormat('Do MMMM YYYY, h:mm A') }}
</small>
</span>
</div>
@@ -31,15 +37,17 @@
<h2 class="h5">{{ $post->excerpt }}</h2>
</div>
<div class="mb-3">
<div class="img-fluid rounded-start ratio ratio-16x9">
<div class="lqip-loader">
<!-- Use the LQIP image with the appropriate URL -->
<img class="img-fluid rounded-2" src="{{ $post->featured_image }}" alt="Photo of {{ $post->name }}">
<!-- Use the final JPEG image with the appropriate URL -->
<img class="lqip-frozen img-fluid rounded-2" src="{{ $post->featured_image_lqip }}" alt="Placeholder image of {{ $post->name }}">
</div>
</div>
<div class="img-fluid rounded-start ratio ratio-16x9">
<div class="lqip-loader">
<!-- Use the LQIP image with the appropriate URL -->
<img class="img-fluid rounded-2" src="{{ $post->featured_image }}"
alt="Photo of {{ $post->name }}">
<!-- Use the final JPEG image with the appropriate URL -->
<img class="lqip-frozen img-fluid rounded-2" src="{{ $post->featured_image_lqip }}"
alt="Placeholder image of {{ $post->name }}">
</div>
</div>
</div>
<div class="mb-3">
{!! $post->html_body !!}

View File

@@ -2,15 +2,15 @@
<html lang="{{ str_replace('_', '-', app()->getLocale()) }}">
<head>
@include('googletagmanager::head')
@include('googletagmanager::head')
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
{!! SEOMeta::generate() !!}
{!! OpenGraph::generate() !!}
{!! Twitter::generate() !!}
{!! JsonLdMulti::generate() !!}
<meta property="fb:app_id" content="{{ config('seotools.fb_app_id') }}" />
{!! SEOMeta::generate() !!}
{!! OpenGraph::generate() !!}
{!! Twitter::generate() !!}
{!! JsonLdMulti::generate() !!}
<meta property="fb:app_id" content="{{ config('seotools.fb_app_id') }}" />
@vite('resources/sass/front-app.scss')

View File

@@ -4,26 +4,26 @@
<div class="col-6 col-md-2 mb-3">
<ul class="nav flex-column">
@foreach ($categories as $category)
@if ($category->id % 2 == 0)
<li class="nav-item mb-2">
<a class="nav-link p-0 text-body-secondary"
href="{{ route('home.country.category', ['country' => $category->country_locale_slug, 'category' => $category->slug]) }}">{{ $category->name }}</a>
</li>
@if ($category->id % 2 == 0)
<li class="nav-item mb-2">
<a class="nav-link p-0 text-body-secondary"
href="{{ route('home.country.category', ['country' => $category->country_locale_slug, 'category' => $category->slug]) }}">{{ $category->name }}</a>
</li>
@endif
@endforeach
@endforeach
</ul>
</div>
<div class="col-6 col-md-2 mb-3">
<ul class="nav flex-column">
@foreach ($categories as $category)
@if ($category->id % 2 == 1)
<li class="nav-item mb-2">
<a class="nav-link p-0 text-body-secondary"
href="{{ route('home.country.category', ['country' => $category->country_locale_slug, 'category' => $category->slug]) }}">{{ $category->name }}</a>
</li>
@if ($category->id % 2 == 1)
<li class="nav-item mb-2">
<a class="nav-link p-0 text-body-secondary"
href="{{ route('home.country.category', ['country' => $category->country_locale_slug, 'category' => $category->slug]) }}">{{ $category->name }}</a>
</li>
@endif
@endforeach
@endforeach
</ul>
</div>
@@ -51,7 +51,7 @@
</div>
@endif
{{-- <form>
{{-- <form>
<h5>Subscribe to our newsletter</h5>
<p>Monthly digest of what's new and exciting from us.</p>
<div class="d-flex flex-column flex-sm-row w-100 gap-2">

View File

@@ -1,4 +1,4 @@
@if($enabled)
<noscript><iframe src="https://www.googletagmanager.com/ns.html?id={{ $id }}"
height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
@if ($enabled)
<noscript><iframe src="https://www.googletagmanager.com/ns.html?id={{ $id }}" height="0" width="0"
style="display:none;visibility:hidden"></iframe></noscript>
@endif

View File

@@ -1,16 +1,27 @@
@if($enabled)
<script>
window.dataLayer = window.dataLayer || [];
@unless(empty($dataLayer->toArray()))
window.dataLayer.push({!! $dataLayer->toJson() !!});
@endunless
@foreach($pushData as $item)
window.dataLayer.push({!! $item->toJson() !!});
@endforeach
</script>
<script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
})(window,document,'script','dataLayer','{{ $id }}');</script>
@if ($enabled)
<script>
window.dataLayer = window.dataLayer || [];
@unless (empty($dataLayer->toArray()))
window.dataLayer.push({!! $dataLayer->toJson() !!});
@endunless
@foreach ($pushData as $item)
window.dataLayer.push({!! $item->toJson() !!});
@endforeach
</script>
<script>
(function(w, d, s, l, i) {
w[l] = w[l] || [];
w[l].push({
'gtm.start': new Date().getTime(),
event: 'gtm.js'
});
var f = d.getElementsByTagName(s)[0],
j = d.createElement(s),
dl = l != 'dataLayer' ? '&l=' + l : '';
j.async = true;
j.src =
'https://www.googletagmanager.com/gtm.js?id=' + i + dl;
f.parentNode.insertBefore(j, f);
})(window, document, 'script', 'dataLayer', '{{ $id }}');
</script>
@endif