mirror of
https://github.com/Kovah/LinkAce.git
synced 2025-01-17 05:08:21 +01:00
commit
b4670e395e
@ -3,12 +3,15 @@
|
||||
namespace App\Http\Controllers\Guest;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Controllers\Traits\HandlesQueryOrder;
|
||||
use App\Models\Link;
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class LinkController extends Controller
|
||||
{
|
||||
use HandlesQueryOrder;
|
||||
|
||||
/**
|
||||
* Display an overview of all links.
|
||||
*
|
||||
@ -21,7 +24,7 @@ class LinkController extends Controller
|
||||
->with('tags');
|
||||
|
||||
$orderBy = $request->input('orderBy', 'created_at');
|
||||
$orderDir = $request->input('orderDir', 'desc');
|
||||
$orderDir = $this->getOrderDirection($request);
|
||||
if ($orderBy === 'random') {
|
||||
$links->inRandomOrder();
|
||||
} else {
|
||||
|
@ -3,12 +3,15 @@
|
||||
namespace App\Http\Controllers\Guest;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Controllers\Traits\HandlesQueryOrder;
|
||||
use App\Models\LinkList;
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class ListController extends Controller
|
||||
{
|
||||
use HandlesQueryOrder;
|
||||
|
||||
/**
|
||||
* Display an overview of all lists.
|
||||
*
|
||||
@ -21,14 +24,14 @@ class ListController extends Controller
|
||||
->withCount('links')
|
||||
->orderBy(
|
||||
$request->input('orderBy', 'name'),
|
||||
$request->input('orderDir', 'asc')
|
||||
$this->getOrderDirection($request, 'asc')
|
||||
)
|
||||
->paginate(getPaginationLimit());
|
||||
|
||||
return view('guest.lists.index', [
|
||||
'lists' => $lists,
|
||||
'orderBy' => $request->input('orderBy', 'name'),
|
||||
'orderDir' => $request->input('orderDir', 'asc'),
|
||||
'orderDir' => $this->getOrderDirection($request, 'asc'),
|
||||
]);
|
||||
}
|
||||
|
||||
@ -47,7 +50,7 @@ class ListController extends Controller
|
||||
->publicOnly()
|
||||
->orderBy(
|
||||
$request->input('orderBy', 'title'),
|
||||
$request->input('orderDir', 'asc')
|
||||
$this->getOrderDirection($request, 'asc')
|
||||
)->paginate(getPaginationLimit());
|
||||
|
||||
return view('guest.lists.show', [
|
||||
@ -55,7 +58,7 @@ class ListController extends Controller
|
||||
'listLinks' => $links,
|
||||
'route' => $request->getBaseUrl(),
|
||||
'orderBy' => $request->input('orderBy', 'title'),
|
||||
'orderDir' => $request->input('orderDir', 'asc'),
|
||||
'orderDir' => $this->getOrderDirection($request, 'asc'),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
@ -3,12 +3,15 @@
|
||||
namespace App\Http\Controllers\Guest;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Controllers\Traits\HandlesQueryOrder;
|
||||
use App\Models\Tag;
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class TagController extends Controller
|
||||
{
|
||||
use HandlesQueryOrder;
|
||||
|
||||
/**
|
||||
* Display an overview of all lists.
|
||||
*
|
||||
@ -21,7 +24,7 @@ class TagController extends Controller
|
||||
->withCount('links')
|
||||
->orderBy(
|
||||
$request->input('orderBy', 'name'),
|
||||
$request->input('orderDir', 'asc')
|
||||
$this->getOrderDirection($request, 'asc')
|
||||
)
|
||||
->paginate(getPaginationLimit());
|
||||
|
||||
@ -29,7 +32,7 @@ class TagController extends Controller
|
||||
'tags' => $tags,
|
||||
'route' => $request->getBaseUrl(),
|
||||
'orderBy' => $request->input('orderBy', 'name'),
|
||||
'orderDir' => $request->input('orderDir', 'asc'),
|
||||
'orderDir' => $this->getOrderDirection($request, 'asc'),
|
||||
]);
|
||||
}
|
||||
|
||||
|
@ -3,6 +3,7 @@
|
||||
namespace App\Http\Controllers\Models;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Controllers\Traits\HandlesQueryOrder;
|
||||
use App\Http\Requests\Models\LinkStoreRequest;
|
||||
use App\Http\Requests\Models\LinkToggleCheckRequest;
|
||||
use App\Http\Requests\Models\LinkUpdateRequest;
|
||||
@ -15,6 +16,8 @@ use Illuminate\Http\Request;
|
||||
|
||||
class LinkController extends Controller
|
||||
{
|
||||
use HandlesQueryOrder;
|
||||
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*
|
||||
@ -24,13 +27,12 @@ class LinkController extends Controller
|
||||
public function index(Request $request): View
|
||||
{
|
||||
$orderBy = $request->input('orderBy', session()->get('links.index.orderBy', 'created_at'));
|
||||
$orderDir = $request->input('orderDir', session()->get('links.index.orderDir', 'desc'));
|
||||
$orderDir = $this->getOrderDirection($request, session()->get('links.index.orderDir', 'desc'));
|
||||
|
||||
session()->put('links.index.orderBy', $orderBy);
|
||||
session()->put('links.index.orderDir', $orderDir);
|
||||
|
||||
$links = Link::byUser()
|
||||
->with('tags');
|
||||
$links = Link::byUser()->with('tags');
|
||||
|
||||
if ($orderBy === 'random') {
|
||||
$links->inRandomOrder();
|
||||
|
@ -3,6 +3,7 @@
|
||||
namespace App\Http\Controllers\Models;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Controllers\Traits\HandlesQueryOrder;
|
||||
use App\Http\Requests\Models\ListStoreRequest;
|
||||
use App\Http\Requests\Models\ListUpdateRequest;
|
||||
use App\Models\LinkList;
|
||||
@ -14,6 +15,8 @@ use Illuminate\Http\Request;
|
||||
|
||||
class ListController extends Controller
|
||||
{
|
||||
use HandlesQueryOrder;
|
||||
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*
|
||||
@ -23,7 +26,7 @@ class ListController extends Controller
|
||||
public function index(Request $request): View
|
||||
{
|
||||
$orderBy = $request->input('orderBy', session()->get('lists.index.orderBy', 'name'));
|
||||
$orderDir = $request->input('orderDir', session()->get('lists.index.orderDir', 'asc'));
|
||||
$orderDir = $this->getOrderDirection($request, session()->get('lists.index.orderDir', 'asc'));
|
||||
|
||||
session()->put('lists.index.orderBy', $orderBy);
|
||||
session()->put('lists.index.orderDir', $orderDir);
|
||||
|
@ -3,6 +3,7 @@
|
||||
namespace App\Http\Controllers\Models;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Controllers\Traits\HandlesQueryOrder;
|
||||
use App\Http\Requests\Models\TagStoreRequest;
|
||||
use App\Http\Requests\Models\TagUpdateRequest;
|
||||
use App\Models\Tag;
|
||||
@ -14,6 +15,8 @@ use Illuminate\Http\Request;
|
||||
|
||||
class TagController extends Controller
|
||||
{
|
||||
use HandlesQueryOrder;
|
||||
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*
|
||||
@ -23,7 +26,7 @@ class TagController extends Controller
|
||||
public function index(Request $request): View
|
||||
{
|
||||
$orderBy = $request->input('orderBy', session()->get('tags.index.orderBy', 'name'));
|
||||
$orderDir = $request->input('orderDir', session()->get('tags.index.orderDir', 'asc'));
|
||||
$orderDir = $this->getOrderDirection($request, session()->get('tags.index.orderDir', 'asc'));
|
||||
|
||||
session()->put('tags.index.orderBy', $orderBy);
|
||||
session()->put('tags.index.orderDir', $orderDir);
|
||||
@ -91,7 +94,7 @@ class TagController extends Controller
|
||||
$links = $tag->links()->byUser()
|
||||
->orderBy(
|
||||
$request->input('orderBy', 'created_at'),
|
||||
$request->input('orderDir', 'desc')
|
||||
$this->getOrderDirection($request),
|
||||
)
|
||||
->paginate(getPaginationLimit());
|
||||
|
||||
@ -100,7 +103,7 @@ class TagController extends Controller
|
||||
'tagLinks' => $links,
|
||||
'route' => $request->getBaseUrl(),
|
||||
'orderBy' => $request->input('orderBy', 'created_at'),
|
||||
'orderDir' => $request->input('orderDir', 'desc'),
|
||||
'orderDir' => $this->getOrderDirection($request),
|
||||
]);
|
||||
}
|
||||
|
||||
|
14
app/Http/Controllers/Traits/HandlesQueryOrder.php
Normal file
14
app/Http/Controllers/Traits/HandlesQueryOrder.php
Normal file
@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Traits;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
trait HandlesQueryOrder
|
||||
{
|
||||
protected function getOrderDirection(Request $request, $default = 'desc'): string
|
||||
{
|
||||
$dir = $request->input('orderDir');
|
||||
return in_array($dir, ['asc', 'desc']) ? $dir : $default;
|
||||
}
|
||||
}
|
447
composer.lock
generated
447
composer.lock
generated
File diff suppressed because it is too large
Load Diff
8299
package-lock.json
generated
8299
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "linkace",
|
||||
"version": "1.12.1",
|
||||
"version": "1.12.2",
|
||||
"description": "A small, selfhosted bookmark manager with advanced features, built with Laravel and Docker",
|
||||
"homepage": "https://github.com/Kovah/LinkAce",
|
||||
"repository": {
|
||||
@ -19,7 +19,7 @@
|
||||
"sass-loader": "^13.2.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"bootstrap": "~5.2.3",
|
||||
"bootstrap": "^5.2.3",
|
||||
"tom-select": "^2.0.0"
|
||||
},
|
||||
"scripts": {
|
||||
|
16
resources/assets/sass/_variables.scss
vendored
16
resources/assets/sass/_variables.scss
vendored
@ -87,14 +87,14 @@ $color-contrast-light: $white;
|
||||
|
||||
|
||||
// Options
|
||||
$enable-dark-mode: false;
|
||||
$enable-caret: false;
|
||||
|
||||
|
||||
// Body
|
||||
$body-bg: $white;
|
||||
$body-color: $black;
|
||||
$body-color-pale: $gray-600;
|
||||
$body-color-muted: $gray;
|
||||
$body-bg: $white;
|
||||
$body-secondary-color: $gray-600;
|
||||
|
||||
|
||||
// Links
|
||||
@ -106,6 +106,7 @@ $link-hover-decoration: none;
|
||||
|
||||
|
||||
// Components
|
||||
$border-width: 1px;
|
||||
$border-radius-xs: .2rem;
|
||||
|
||||
$line-height-sm: 1.5;
|
||||
@ -115,13 +116,11 @@ $link-thumbnail-placeholder-color: $gray-200;
|
||||
|
||||
// Typography
|
||||
$font-family-sans-serif: "IBM Plex Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";
|
||||
|
||||
$font-weight-normal: 400;
|
||||
$font-size-base: 1rem;
|
||||
$font-size-xs: $font-size-base * .75;
|
||||
|
||||
$font-weight-normal: 400;
|
||||
|
||||
$text-muted: $body-color-muted;
|
||||
$text-muted: $body-secondary-color;
|
||||
|
||||
|
||||
// Tables
|
||||
@ -130,6 +129,7 @@ $table-dark-color: $white;
|
||||
|
||||
|
||||
// Buttons + Forms
|
||||
$input-color: $body-color;
|
||||
$input-border-color: $gray-300;
|
||||
$input-btn-focus-width: .15rem;
|
||||
$input-btn-padding-y-xs: .15rem;
|
||||
@ -139,6 +139,8 @@ $input-btn-line-height-xs: $line-height-sm;
|
||||
|
||||
$input-placeholder-color: $text-muted;
|
||||
|
||||
$input-btn-border-width: $border-width;
|
||||
|
||||
|
||||
// Buttons
|
||||
$btn-padding-y-xs: $input-btn-padding-y-xs;
|
||||
|
2
resources/assets/sass/custom/_app.scss
vendored
2
resources/assets/sass/custom/_app.scss
vendored
@ -108,7 +108,7 @@ a.badge {
|
||||
}
|
||||
|
||||
.text-pale {
|
||||
color: $body-color-pale;
|
||||
color: $body-secondary-color;
|
||||
}
|
||||
|
||||
.btn-xs {
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*!
|
||||
* Bootstrap v5.2.0 (https://getbootstrap.com/)
|
||||
* Bootstrap v5.3.0 (https://getbootstrap.com/)
|
||||
* Copyright 2011-2022 The Bootstrap Authors
|
||||
* Copyright 2011-2022 Twitter, Inc.
|
||||
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
|
||||
@ -9,6 +9,7 @@
|
||||
// Configuration
|
||||
//@import "~bootstrap/scss/functions";
|
||||
@import "~bootstrap/scss/variables";
|
||||
@import "~bootstrap/scss/variables-dark";
|
||||
@import "~bootstrap/scss/maps";
|
||||
@import "~bootstrap/scss/mixins";
|
||||
@import "~bootstrap/scss/utilities";
|
||||
|
@ -19,10 +19,11 @@ $select-color-optgroup: $white;
|
||||
$select-color-optgroup-text: $dropdown-header-color;
|
||||
$select-color-optgroup-border: $dropdown-divider-bg;
|
||||
$select-color-dropdown: $white;
|
||||
$select-color-dropdown-border-top: mix($input-border-color, $input-bg, 0.8);
|
||||
$select-color-dropdown-border-top: color-mix($input-border-color, $input-bg, 80%);
|
||||
$select-color-dropdown-item-active: $dropdown-link-hover-bg;
|
||||
$select-color-dropdown-item-active-text: $dropdown-link-hover-color;
|
||||
$select-color-dropdown-item-create-active-text: $dropdown-link-hover-color;
|
||||
$select-color-dropdown-item-create-text: rgba(red($select-color-text), green($select-color-text), blue($select-color-text), 0.5);
|
||||
$select-opacity-disabled: 0.5;
|
||||
$select-shadow-input: none;
|
||||
$select-shadow-input-focus: inset 0 1px 2px rgba($black, 0.15);
|
||||
|
@ -1,7 +1,7 @@
|
||||
# DOCKERFILE DEVELOPMENT
|
||||
# Installs MySQL Client for database exports, xDebug with PCov and Composer
|
||||
|
||||
FROM php:8.0-fpm
|
||||
FROM php:8.0.29-fpm
|
||||
WORKDIR /app
|
||||
|
||||
RUN apt-get update && apt-get install -y \
|
||||
|
@ -41,12 +41,31 @@ class LinkControllerTest extends TestCase
|
||||
|
||||
public function testIndexView(): void
|
||||
{
|
||||
$link = Link::factory()->create();
|
||||
Link::factory()->create(['url' => 'https://linkace.example.com/test', 'created_at' => now()->subDay()]);
|
||||
Link::factory()->create(['url' => 'https://the-new-linkace.com']);
|
||||
|
||||
$response = $this->get('links');
|
||||
$this->get('links')
|
||||
->assertOk()
|
||||
->assertSeeInOrder([
|
||||
'https://the-new-linkace.com',
|
||||
'https://linkace.example.com/test',
|
||||
]);
|
||||
|
||||
$response->assertOk()
|
||||
->assertSee($link->url);
|
||||
$this->flushSession();
|
||||
$this->get('links?orderBy=created_at&orderDir=asc')
|
||||
->assertOk()
|
||||
->assertSeeInOrder([
|
||||
'https://linkace.example.com/test',
|
||||
'https://the-new-linkace.com',
|
||||
]);
|
||||
|
||||
$this->flushSession();
|
||||
$this->get('links?orderBy=created_at&orderDir=wrong-asc')
|
||||
->assertOk()
|
||||
->assertSeeInOrder([
|
||||
'https://the-new-linkace.com',
|
||||
'https://linkace.example.com/test',
|
||||
]);
|
||||
}
|
||||
|
||||
public function testCreateView(): void
|
||||
|
@ -26,14 +26,34 @@ class ListControllerTest extends TestCase
|
||||
public function testIndexView(): void
|
||||
{
|
||||
LinkList::factory()->create([
|
||||
'name' => 'Test List',
|
||||
'name' => 'A Test List',
|
||||
'user_id' => $this->user->id,
|
||||
'created_at' => now()->subDay(),
|
||||
]);
|
||||
LinkList::factory()->create(['name' => 'Super New List', 'user_id' => $this->user->id]);
|
||||
|
||||
$response = $this->get('lists');
|
||||
$this->get('lists')
|
||||
->assertOk()
|
||||
->assertSeeInOrder([
|
||||
'A Test List',
|
||||
'Super New List',
|
||||
]);
|
||||
|
||||
$response->assertOk()
|
||||
->assertSee('Test List');
|
||||
$this->flushSession();
|
||||
$this->get('lists?orderBy=created_at&orderDir=desc')
|
||||
->assertOk()
|
||||
->assertSeeInOrder([
|
||||
'Super New List',
|
||||
'A Test List',
|
||||
]);
|
||||
|
||||
$this->flushSession();
|
||||
$this->get('lists?orderBy=created_at&orderDir=wrong-desc')
|
||||
->assertOk()
|
||||
->assertSeeInOrder([
|
||||
'A Test List',
|
||||
'Super New List',
|
||||
]);
|
||||
}
|
||||
|
||||
public function testIndexViewWithValidFilterResult(): void
|
||||
|
@ -26,13 +26,37 @@ class TagControllerTest extends TestCase
|
||||
public function testIndexView(): void
|
||||
{
|
||||
Tag::factory()->create([
|
||||
'name' => 'Test Tag',
|
||||
'name' => 'a-tag',
|
||||
'user_id' => $this->user->id,
|
||||
'created_at' => now()->subDay(),
|
||||
]);
|
||||
Tag::factory()->create([
|
||||
'name' => 'new-tag',
|
||||
'user_id' => $this->user->id,
|
||||
]);
|
||||
|
||||
$response = $this->get('tags');
|
||||
$this->get('tags')
|
||||
->assertOk()
|
||||
->assertSeeInOrder([
|
||||
'a-tag',
|
||||
'new-tag',
|
||||
]);
|
||||
|
||||
$response->assertOk()->assertSee('Test Tag');
|
||||
$this->flushSession();
|
||||
$this->get('tags?orderBy=created_at&orderDir=desc')
|
||||
->assertOk()
|
||||
->assertSeeInOrder([
|
||||
'new-tag',
|
||||
'a-tag',
|
||||
]);
|
||||
|
||||
$this->flushSession();
|
||||
$this->get('tags?orderBy=created_at&orderDir=wrong-desc')
|
||||
->assertOk()
|
||||
->assertSeeInOrder([
|
||||
'a-tag',
|
||||
'new-tag',
|
||||
]);
|
||||
}
|
||||
|
||||
public function testIndexViewWithValidFilterResult(): void
|
||||
|
Loading…
x
Reference in New Issue
Block a user