diff --git a/app/Http/Controllers/BlogController.php b/app/Http/Controllers/BlogController.php index 54cea4c..b0ebbd5 100644 --- a/app/Http/Controllers/BlogController.php +++ b/app/Http/Controllers/BlogController.php @@ -9,6 +9,7 @@ use Illuminate\Support\Facades\Auth; use Illuminate\Database\QueryException; use Illuminate\Support\Facades\Storage; +use Illuminate\Support\Facades\Log; class BlogController extends Controller { @@ -47,7 +48,6 @@ public function like($id) "error" => "Blog already liked" ]); } - return redirect('/blog/' . $id); } @@ -65,14 +65,17 @@ public function insert() $id = request()->user()->id; $image = BlogController::getRequestImage(); - + + Log::info($image); + Log::info("Helllo"); $blog = Blog::create([ 'title' => request('title'), 'containt' => request('containt'), 'epilog' => request('epilog'), - 'image' => $image, 'user_id' => $id, ]); + if($image) $blog->image = $image; + $blog->save(); return redirect('/blog/' . $blog->id); } diff --git a/package-lock.json b/package-lock.json index 2aa13ed..b0baa0c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,5 +1,5 @@ { - "name": "blog", + "name": "blogbuntu", "lockfileVersion": 2, "requires": true, "packages": { diff --git a/resources/css/app.css b/resources/css/app.css index 92a7b68..add07ff 100644 --- a/resources/css/app.css +++ b/resources/css/app.css @@ -11,7 +11,10 @@ @layer utilities { .no-scrollbar { -ms-overflow-style: none; /* IE and Edge */ scrollbar-width: none; /* Firefox */ - } + } + .modal::backdrop { + background-color: rgba(0, 0, 0, 0.63); + } } :root { @@ -27,29 +30,53 @@ .md-content { } .md-content h1 { - + font-size: 45px; + border-bottom: 2px solid gray; + margin-top: 5px; } .md-content h2 { - + font-size: 40px; + border-bottom: 1px solid gray; + margin-top: 5px; } .md-content h3 { - + font-size: 30px; + margin-top: 5px; } .md-content h4 { - + font-size: 25px; + margin-top: 5px; } .md-content h5 { - + font-size: 20px; + margin-top: 5px; } .md-content p { + margin-top: 5px; +} +.md-content h6 { + font-size: 15px; + margin-top: 5px; } .md-content ul { - + margin-left: 20px; + margin-right: 20px; + list-style: circle; + margin-top: 5px; +} + +.md-content code { + width: 100%; + display: flex; + background-color: rgba(128, 128, 128, 0.13); + border-radius: 7px; + padding: 5px 10px 5px 10px; + margin-top: 15px; } \ No newline at end of file diff --git a/resources/js/blog.js b/resources/js/blog.js index 712ce62..8b3fc57 100644 --- a/resources/js/blog.js +++ b/resources/js/blog.js @@ -33,7 +33,7 @@ window.addEventListener("DOMContentLoaded", () => { addEvent(likeBtn, (btn) => { btn.addEventListener("click", (e) => { e.preventDefault(); - let id = document.querySelector(".btn-like").getAttribute("data-id"); + let id = e.target.getAttribute("data-id"); let token = document.querySelector('input[name=_token]').value; fetch(`/blog/like/${id}`, { method: "POST", @@ -64,7 +64,7 @@ window.addEventListener("DOMContentLoaded", () => { e.preventDefault(); let id = e.target.getAttribute("data-id"); let token = document.querySelector('input[name=_token]').value; - let form = document.querySelector('.update-form'); + let form = document.querySelector('#update-form'); let formData = new FormData(form); fetch(`/blog/${id}`, { method: "POST", @@ -72,8 +72,6 @@ window.addEventListener("DOMContentLoaded", () => { "X-CSRF-Token": token }, body: formData - }).then((res) => { - window.location.href = "/blog/" + id; }); }); }); diff --git a/resources/js/user.js b/resources/js/user.js index a5f4c54..abac59c 100644 --- a/resources/js/user.js +++ b/resources/js/user.js @@ -1,64 +1,78 @@ import './bootstrap'; +function addEvent(btn, func) { + if(btn) func(btn); +} + window.addEventListener("DOMContentLoaded", () => { let modal = document.querySelector('#modal-update'); let openModalBtn = document.querySelector("#open-modal"); - let closeModalBtn = document.querySelector(".close-modal"); - let deleteUserBtn = document.querySelector(".btn-user-delete"); - let updateUserBtn = document.querySelector(".btn-user-update"); - let followBtn = document.querySelector(".btn-follow"); + let closeModalBtn = document.querySelector("#close-modal"); + let deleteUserBtn = document.querySelector("#btn-user-delete"); + let updateUserBtn = document.querySelector("#btn-user-update"); + let followBtn = document.querySelector("#btn-follow"); - followBtn.addEventListener("click", (e) => { - e.preventDefault(); - let id = e.target.getAttribute("data-id"); - let token = document.querySelector('input[name=_token]').value; - fetch(`/follow/${id}`, { - method: "POST", - headers: { - "X-CSRF-Token": token - } - }).then((res) => { - if (res.status === 400) alert("Couldn't follow this user"); - //else if (res.status === 200) window.location.href = "/profile/" + id; + addEvent(followBtn, (btn) => { + btn.addEventListener("click", (e) => { + e.preventDefault(); + let id = e.target.getAttribute("data-id"); + let token = document.querySelector('input[name=_token]').value; + fetch(`/follow/${id}`, { + method: "POST", + headers: { + "X-CSRF-Token": token + } + }).then((res) => { + if (res.status === 400) alert("Couldn't follow this user"); + //else if (res.status === 200) window.location.href = "/profile/" + id; + }); }); }); - openModalBtn.addEventListener("click", (e) => { - modal.showModal(); + addEvent(openModalBtn, (btn) => { + btn.addEventListener("click", (e) => { + modal.showModal(); + }); }); - closeModalBtn.addEventListener("click", (e) => { - modal.close(); + addEvent(closeModalBtn, (btn) => { + btn.addEventListener("click", (e) => { + modal.close(); + }); }); - updateUserBtn.addEventListener("click", (e) => { - e.preventDefault(); - let id = e.target.getAttribute("data-id"); - let token = document.querySelector('input[name=_token]').value; - let form = document.querySelector('.update-form'); - let formData = new FormData(form); - fetch(`/user/${id}`, { - method: "POST", - headers: { - "X-CSRF-Token": token - }, - body: formData - }).then((res) => { - window.location.href = "/profile/" + id; + addEvent(updateUserBtn, (btn) => { + btn.addEventListener("click", (e) => { + e.preventDefault(); + let id = e.target.getAttribute("data-id"); + let token = document.querySelector('input[name=_token]').value; + let form = document.querySelector('#update-form'); + let formData = new FormData(form); + fetch(`/user/${id}`, { + method: "POST", + headers: { + "X-CSRF-Token": token + }, + body: formData + }).then((res) => { + window.location.href = "/profile/" + id; + }); }); }); - - deleteUserBtn.addEventListener("click", (e) => { - e.preventDefault(); - let id = e.target.getAttribute("data-id"); - let token = document.querySelector('input[name=_token]').value; - fetch(`/user/${id}`, { - method: "DELETE", - headers: { - "X-CSRF-Token": token - } - }).then((res) => { - window.location.href = "/" + + addEvent(deleteUserBtn, (btn) => { + btn.addEventListener("click", (e) => { + e.preventDefault(); + let id = e.target.getAttribute("data-id"); + let token = document.querySelector('input[name=_token]').value; + fetch(`/user/${id}`, { + method: "DELETE", + headers: { + "X-CSRF-Token": token + } + }).then((res) => { + window.location.href = "/" + }); }); }); -}) \ No newline at end of file +}); \ No newline at end of file diff --git a/resources/views/auth/login.blade.php b/resources/views/auth/login.blade.php index f71880a..d833913 100644 --- a/resources/views/auth/login.blade.php +++ b/resources/views/auth/login.blade.php @@ -1,11 +1,19 @@ @extends('base.layout') @section('content') -

Login

-
- @csrf -

Email

-

Password

- -
+
+
+

Login

+
+
+

Email :

+

Password :

+
+ @csrf + +
+
+
@endsection \ No newline at end of file diff --git a/resources/views/auth/register.blade.php b/resources/views/auth/register.blade.php index 6c4be13..630b981 100644 --- a/resources/views/auth/register.blade.php +++ b/resources/views/auth/register.blade.php @@ -1,15 +1,25 @@ @extends('base.layout') @section('content') -

Register

-
- @csrf -

Username

-

Name

-

Email

-

Description

-

Password

-
- -
+
+
+

Register

+
+
+

Username :

+

Name (Optional):

+

Email :

+

Description (Optional):

+

Password :

+
+ @csrf + +
+
+
@endsection \ No newline at end of file diff --git a/resources/views/auth/verify_email.blade.php b/resources/views/auth/verify_email.blade.php index f7e3e82..234a9d8 100644 --- a/resources/views/auth/verify_email.blade.php +++ b/resources/views/auth/verify_email.blade.php @@ -1,23 +1,17 @@ @extends('base.layout') @section('content') -
-

Email verification

- - @if(session('resent')) -
- A fresh verification link has been sent to your email address. +
+
+

Email verification

+
+

Before proceeding, please check your email for a verification link. If you did not receive the email,

+

+ @csrf + +
+

to request another.

- @endif - -
- Before proceeding, please check your email for a verification link. If you did not receive the email, -
- @csrf - . -
@endsection \ No newline at end of file diff --git a/resources/views/base/icon.blade.php b/resources/views/base/icon.blade.php index 32ab434..fba59f8 100644 --- a/resources/views/base/icon.blade.php +++ b/resources/views/base/icon.blade.php @@ -1,5 +1,5 @@
  • - +
  • \ No newline at end of file diff --git a/resources/views/base/layout.blade.php b/resources/views/base/layout.blade.php index 0e78b42..b7c1d61 100644 --- a/resources/views/base/layout.blade.php +++ b/resources/views/base/layout.blade.php @@ -7,7 +7,7 @@ BlogBuntu @vite('resources/css/app.css') - + @include('base.menu') @include('base.errors') @yield("content") diff --git a/resources/views/base/menu.blade.php b/resources/views/base/menu.blade.php index 1c1bf10..ef81608 100644 --- a/resources/views/base/menu.blade.php +++ b/resources/views/base/menu.blade.php @@ -1,4 +1,4 @@ -