blob: 3437098d40e8b2e961c28c39f9f2893e57d3376e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
|
@extends('template')
@section('content')
<main>
<h1>Add Link</h1>
@if ($errors->any())
<div style="color: red; margin-bottom: 1rem;">
<ul>
@foreach ($errors->all() as $error)
<li>{{ $error }}</li>
@endforeach
</ul>
</div>
@endif
@if (session('success'))
<div style="color: green; margin-bottom: 1rem;">
{{ session('success') }}
</div>
@endif
{{-- Single link form --}}
<section>
<h2>Add a Single Link</h2>
<form method="POST" action="{{ route('l.store') }}">
@csrf
<div style="margin-bottom: 0.5rem;">
<label for="label">Label</label><br>
<input type="text" name="label" id="label" value="{{ old('label') }}" required minlength="2" maxlength="255">
</div>
<div style="margin-bottom: 0.5rem;">
<label for="url">URL</label><br>
<input type="url" name="url" id="url" value="{{ old('url') }}" required minlength="3">
</div>
<div style="margin-bottom: 0.5rem;">
<label for="description">Description</label><br>
<textarea name="description" id="description" rows="3">{{ old('description') }}</textarea>
</div>
<button type="submit">Add Link</button>
</form>
</section>
{{-- JSON import form — admin only --}}
@if(Auth::check() && Auth::user()->isAdmin())
<section style="margin-top: 2rem; border-top: 1px solid #ccc; padding-top: 1rem;">
<h2>Bulk Import from JSON</h2>
<p>Upload a JSON file containing an array of link objects. Each object should have at least a <code>url</code> field. Optional fields: <code>label</code>, <code>description</code>, <code>tags</code> (array of strings). Maximum 500 entries per file. Duplicate URLs will be skipped.</p>
<details style="margin-bottom: 1rem;">
<summary>Example JSON format</summary>
<pre>[
{
"url": "https://example.com",
"label": "Example Site",
"tags": ["web", "reference"],
"description": "An example website."
}
]</pre>
</details>
<form method="POST" action="{{ route('l.import') }}" enctype="multipart/form-data">
@csrf
<div style="margin-bottom: 0.5rem;">
<label for="json_file">JSON File</label><br>
<input type="file" name="json_file" id="json_file" accept=".json,.txt" required>
</div>
<button type="submit">Import Links</button>
</form>
</section>
@endif
</main>
@endsection
|