Compare commits
2 Commits
f5fd828697
...
c3f01cee54
Author | SHA1 | Date |
---|---|---|
Dym Sohin | c3f01cee54 | |
Dym Sohin | a3f0284fc3 |
|
@ -27,7 +27,7 @@ class SessionController extends Controller
|
|||
|
||||
request()->session()->regenerate();
|
||||
|
||||
return redirect('/admin');
|
||||
return redirect('/dashboard');
|
||||
}
|
||||
|
||||
public function destroy()
|
||||
|
|
|
@ -0,0 +1,37 @@
|
|||
a
|
||||
, body
|
||||
, nav
|
||||
, input
|
||||
, form
|
||||
{
|
||||
display: flex;
|
||||
gap: 0.5rem
|
||||
}
|
||||
|
||||
body
|
||||
{
|
||||
margin:0;
|
||||
padding:0;
|
||||
}
|
||||
|
||||
nav
|
||||
{
|
||||
flex-direction: column;
|
||||
width: 10rem;
|
||||
padding: 1rem;
|
||||
}
|
||||
|
||||
main
|
||||
{
|
||||
padding: 1rem 0;
|
||||
}
|
||||
|
||||
input[type='search']
|
||||
{
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
form
|
||||
{
|
||||
flex-direction: column;
|
||||
}
|
|
@ -1,10 +0,0 @@
|
|||
<x-layout-admin>
|
||||
|
||||
<form class="col c w-30" method="post" name="edit_form" id="edit_form">
|
||||
<input type="text" name="title" class="w-30">
|
||||
<input type="text" name="slug" class="w-30" pattern="[A-Za-z0-9-]+" required>
|
||||
<textarea name="body" class="w-30"></textarea>
|
||||
<button onclick="edit_form.submit()">save</button>
|
||||
</form>
|
||||
|
||||
</x-layout-admin>
|
|
@ -1,3 +0,0 @@
|
|||
<x-layout-admin>
|
||||
|
||||
</x-layout-admin>
|
|
@ -1,3 +1,5 @@
|
|||
@if( 'hidden' !== $attributes['type'] )
|
||||
|
||||
<div class="x-input"
|
||||
title="{{ $attributes['title'] ?? $slot }}"
|
||||
>
|
||||
|
@ -14,4 +16,6 @@
|
|||
@error( "$slot" )
|
||||
<p class="error">{{ $message }}</p>
|
||||
@enderror
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@endif
|
|
@ -3,24 +3,32 @@
|
|||
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
|
||||
<meta charset="utf8">
|
||||
<title>{{ request()->path() }}</title>
|
||||
<link rel="stylesheet" type="text/css" href="/css/style.css">
|
||||
<link rel="stylesheet" type="text/css" href="/css/admin.css">
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
<nav class="c">
|
||||
<div class="buttons round">
|
||||
<x-nav-link class="orange">new</x-nav-link>
|
||||
<x-nav-link class="rose">list</x-nav-link>
|
||||
<x-nav-link class="pink">tags</x-nav-link>
|
||||
<x-nav-link class="teal">collections</x-nav-link>
|
||||
<x-nav-link class="gray">/</x-nav-link>
|
||||
</div>
|
||||
<form method="get" action="/search">
|
||||
<input type="search" name="q">
|
||||
<button type="submit">search</button>
|
||||
</form>
|
||||
<a href="/dashboard">articles</a>
|
||||
<a href="/new">new</a>
|
||||
<a href="/categories">categories</a>
|
||||
<a href="/collections">collections</a>
|
||||
<a href="/tags">tags</a>
|
||||
|
||||
@auth
|
||||
<form class="col c" method="post" name="logout_form" action="/logout">
|
||||
@csrf
|
||||
<button type="submit">Logout</button>
|
||||
</form>
|
||||
@endauth
|
||||
</nav>
|
||||
|
||||
|
||||
<main>
|
||||
@guest
|
||||
|
||||
<form class="col c" method="post" name="login_form" action="/login">
|
||||
@csrf
|
||||
<x-input type="email" :value="old('email')"
|
||||
|
@ -36,24 +44,7 @@
|
|||
|
||||
@auth
|
||||
{{ $slot }}
|
||||
|
||||
|
||||
<form class="col c" method="post" name="logout_form" action="/logout">
|
||||
@csrf
|
||||
<button type="submit">Logout</button>
|
||||
</form>
|
||||
@endauth
|
||||
</main>
|
||||
|
||||
<footer class="c">
|
||||
<form class="buttons round c" method="get" name="search_form">
|
||||
<input type="search" name="search" placeholder="search">
|
||||
<button onclick="search_form.submit()"
|
||||
class="gray" title="search"
|
||||
><span class="hidden">search</span>
|
||||
</button>
|
||||
<x-nav-link class="orange">rss</x-nav-link>
|
||||
</a>
|
||||
</form>
|
||||
</footer>
|
||||
|
||||
</body></html>
|
||||
</body></html>
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
<x-layout-admin>
|
||||
|
||||
<ol>
|
||||
@foreach($articles as $article)
|
||||
<li><a href="/{{ $article['slug'] }}">{{ $article['title'] ?? $article['slug'] }}</a>
|
||||
@endforeach
|
||||
</ol>
|
||||
|
||||
</x-layout-admin>
|
|
@ -0,0 +1,16 @@
|
|||
<x-layout-admin>
|
||||
|
||||
<form class="col c w-30" method="post" name="edit_form" action="/edit">
|
||||
@csrf
|
||||
<x-input name="id" type="hidden"
|
||||
value="{{ $id ?? 0 }}">
|
||||
<x-input name="title" class="w-30"
|
||||
value="{{ $title ?? '' }}">
|
||||
<x-input name="slug" class="w-30" pattern="[A-Za-z0-9-]+"
|
||||
value="{{ $slug ?? '' }}"
|
||||
required>
|
||||
<textarea name="body" class="w-30">{{ $body ?? '' }}</textarea>
|
||||
<button type="submit">Save</button>
|
||||
</form>
|
||||
|
||||
</x-layout-admin>
|
|
@ -0,0 +1,14 @@
|
|||
<x-layout>
|
||||
<main class="w-30 c">
|
||||
|
||||
<ul class="list">
|
||||
@foreach($items as $item)
|
||||
<li><a href="/{{ $item['slug'] }}">
|
||||
<img src="{{ $item['thumb'] ?? '' }}">
|
||||
<span>{{ $item['title'] ?? $item['slug'] }}</span>
|
||||
</a></li>
|
||||
@endforeach
|
||||
</ul>
|
||||
|
||||
</main>
|
||||
</x-layout>
|
|
@ -0,0 +1,12 @@
|
|||
<x-layout-admin>
|
||||
|
||||
<form class="col c w-30" method="post" name="new_form" action="/new">
|
||||
@csrf
|
||||
<x-input type="hidden">id</x-input>
|
||||
<x-input>title</x-input>
|
||||
<x-input pattern="[A-Za-z0-9-]+" required>slug</x-input>
|
||||
<textarea name="body"></textarea>
|
||||
<button type="submit">Create new</button>
|
||||
</form>
|
||||
|
||||
</x-layout-admin>
|
|
@ -21,20 +21,25 @@ Route::view('/code', 'code');
|
|||
Route::view('/notes', 'notes');
|
||||
|
||||
|
||||
Route::name('pages.list')->get('/list', function () {
|
||||
return view('list');
|
||||
Route::get('/new', function () {
|
||||
return view('new');
|
||||
});
|
||||
Route::name('admin.new')->get('/new', function () {
|
||||
return view('admin.edit');
|
||||
});
|
||||
Route::name('admin.edit')->get('/edit', function () {
|
||||
return view('admin.edit');
|
||||
});
|
||||
Route::name('admin.edit')->get('/edit/{slug}', function ($slug = null) {
|
||||
return view('admin.edit');
|
||||
|
||||
Route::get('/edit/{slug}', function (string $slug) {
|
||||
$article = Article::find($slug);
|
||||
|
||||
return view('edit',
|
||||
[ 'article' => $article
|
||||
, 'title' => $article['title']
|
||||
, 'slug' => $article['slug']
|
||||
, 'body' => $article['body']
|
||||
]);
|
||||
})->where('slug', '[A-Za-z0-9-]+');
|
||||
Route::name('admin.index')->get('/admin', function () {
|
||||
return view('admin.index');
|
||||
|
||||
Route::get('/dashboard', function () {
|
||||
return view('dashboard', [
|
||||
'articles' => Article::all(),
|
||||
]);
|
||||
});
|
||||
|
||||
|
||||
|
@ -45,6 +50,11 @@ Route::get('/login', [SessionController::class, 'create']);
|
|||
Route::post('/login', [SessionController::class, 'store']);
|
||||
Route::post('/logout', [SessionController::class, 'destroy']);
|
||||
|
||||
Route::get('/search/{search}', function (string $search) {
|
||||
return view('list',
|
||||
[ 'search' => $search ]
|
||||
);
|
||||
})->where('search', '.*');
|
||||
|
||||
|
||||
Route::get('/{slug}', function (string $slug) {
|
||||
|
@ -57,3 +67,4 @@ Route::get('/{slug}', function (string $slug) {
|
|||
, 'body' => $article['body']
|
||||
]);
|
||||
})->where('slug', '[A-Za-z0-9-]+');
|
||||
|
||||
|
|
Loading…
Reference in New Issue