Skip to content

Commit da1777f

Browse files
authored
Merge pull request #28 from Kovah/dev
v0.0.4
2 parents d949746 + f098ca2 commit da1777f

File tree

14 files changed

+109
-78
lines changed

14 files changed

+109
-78
lines changed

app/Http/Controllers/App/ImportController.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,8 @@ public function doImport(DoImportRequest $request)
6464
'updated_at' => Carbon::now(),
6565
]);
6666

67+
Link::flushCache();
68+
6769
// Get all tags
6870
if (!empty($link['tags'])) {
6971
$tags = explode(' ', $link['tags']);
@@ -75,6 +77,8 @@ public function doImport(DoImportRequest $request)
7577
]);
7678

7779
$new_link->tags()->attach($new_tag->id);
80+
81+
Tag::flushCache();
7882
}
7983
}
8084

app/Http/Controllers/App/SearchController.php

Lines changed: 23 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,11 @@ public function getSearch()
3939
'search_description' => false,
4040
'private_only' => false,
4141
'only_category' => 0,
42-
'only_tag' => 0,
42+
'only_tags' => '',
4343
'order_by' => $this->order_by_options[0],
4444
])
4545
->with('categories', Category::byUser(auth()->user()->id)
46-
->orderBy('name', 'asc')->get())
47-
->with('tags', Tag::byUser(auth()->user()->id)
48-
->orderBy('name', 'asc')->get()
49-
);
46+
->orderBy('name', 'asc')->get());
5047
}
5148

5249
/**
@@ -55,22 +52,26 @@ public function getSearch()
5552
*/
5653
public function doSearch(SearchRequest $request)
5754
{
58-
// Get the query
59-
$raw_query = $request->get('query');
60-
$query = '%' . $raw_query . '%';
55+
$search_title = false;
56+
$search_description = false;
6157

6258
// Start building the search
63-
$search = Link::byUser(auth()->id())
64-
->where('url', 'like', $query);
59+
$search = Link::byUser(auth()->id());
6560

66-
// Also search for the title if applicable
67-
if ($search_title = $request->get('search_title', false)) {
68-
$search->orWhere('title', 'like', $query);
69-
}
61+
// Search for the URL
62+
if ($raw_query = $request->get('query', false)) {
63+
$query = '%' . $raw_query . '%';
64+
$search->where('url', 'like', $query);
65+
66+
// Also search for the title if applicable
67+
if ($search_title = $request->get('search_title', false)) {
68+
$search->orWhere('title', 'like', $query);
69+
}
7070

71-
// Also search for the title if applicable
72-
if ($search_description = $request->get('search_description', false)) {
73-
$search->orWhere('description', 'like', $query);
71+
// Also search for the title if applicable
72+
if ($search_description = $request->get('search_description', false)) {
73+
$search->orWhere('description', 'like', $query);
74+
}
7475
}
7576

7677
// Show private only if applicable
@@ -86,9 +87,9 @@ public function doSearch(SearchRequest $request)
8687
}
8788

8889
// Show by specific tag only if applicable
89-
if ($tag_id = $request->get('only_tag', false)) {
90-
$search->whereHas('tags', function ($query) use ($tag_id) {
91-
$query->where('id', $tag_id);
90+
if ($tag_names = $request->get('only_tags', false)) {
91+
$search->whereHas('tags', function ($query) use ($tag_names) {
92+
$query->whereIn('name', explode(',', $tag_names));
9293
});
9394
}
9495

@@ -110,13 +111,10 @@ public function doSearch(SearchRequest $request)
110111
'search_description' => $search_description,
111112
'private_only' => $private_only,
112113
'only_category' => $category_id,
113-
'only_tag' => $tag_id,
114+
'only_tags' => $tag_names,
114115
'order_by' => $orderby,
115116
])
116117
->with('categories', Category::byUser(auth()->user()->id)
117-
->orderBy('name', 'asc')->get())
118-
->with('tags', Tag::byUser(auth()->user()->id)
119-
->orderBy('name', 'asc')->get()
120-
);
118+
->orderBy('name', 'asc')->get());
121119
}
122120
}

app/Http/Controllers/FrontController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,6 @@ public function index()
2424
return view('welcome');
2525
}
2626

27-
return view('dashboard');
27+
return redirect()->route('dashboard');
2828
}
2929
}

app/Http/Controllers/Models/CategoryController.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ public function store(CategoryStoreRequest $request)
6161
// Set the user ID
6262
$data['user_id'] = auth()->user()->id;
6363

64-
$data['parent_category'] = isset($data['parent_category']) && $data['parent_category'] > 0 ?: null;
64+
$data['parent_category'] = isset($data['parent_category']) && $data['parent_category'] > 0 ? $data['parent_category'] : null;
6565

6666
// Create the new link
6767
$link = Category::create($data);
@@ -162,7 +162,7 @@ public function update(CategoryUpdateRequest $request, $id)
162162
$data = $request->all();
163163

164164
// Set the correct parent category
165-
$data['parent_category'] = isset($data['parent_category']) && $data['parent_category'] > 0 ?: null;
165+
$data['parent_category'] = isset($data['parent_category']) && $data['parent_category'] > 0 ? $data['parent_category'] : null;
166166

167167
// Update the existing category with new data
168168
$category->update($data);

app/Http/Requests/SearchRequest.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,6 @@ public function authorize()
2323
*/
2424
public function rules()
2525
{
26-
return [
27-
'query' => 'required',
28-
];
26+
return [];
2927
}
3028
}

app/Models/Category.php

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
use Illuminate\Database\Eloquent\Builder;
66
use Illuminate\Database\Eloquent\Collection;
77
use Illuminate\Database\Eloquent\SoftDeletes;
8+
use App\Models\Link;
9+
use App\Models\User;
810

911
/**
1012
* Class Category
@@ -64,7 +66,7 @@ public function scopeByUser($query, $user_id)
6466
*/
6567
public function scopeParentOnly($query)
6668
{
67-
return $query->where('parent_category', null);
69+
return $query->whereNull('parent_category');
6870
}
6971

7072
/*
@@ -77,30 +79,30 @@ public function scopeParentOnly($query)
7779
*/
7880
public function user()
7981
{
80-
return $this->belongsTo('App\Models\User', 'user_id');
82+
return $this->belongsTo(User::class, 'user_id');
8183
}
8284

8385
/**
8486
* @return \Illuminate\Database\Eloquent\Relations\HasMany
8587
*/
8688
public function links()
8789
{
88-
return $this->hasMany('App\Models\Link', 'category_id');
90+
return $this->hasMany(Link::class, 'category_id');
8991
}
9092

9193
/**
9294
* @return \Illuminate\Database\Eloquent\Relations\HasMany
9395
*/
9496
public function childCategories()
9597
{
96-
return $this->hasMany('App\Models\Category', 'parent_category');
98+
return $this->hasMany(Category::class, 'parent_category');
9799
}
98100

99101
/**
100102
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
101103
*/
102104
public function parentCategory()
103105
{
104-
return $this->belongsTo('App\Models\Category', 'parent_category');
106+
return $this->belongsTo(Category::class, 'parent_category');
105107
}
106108
}

composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
{
22
"name": "kovah/linkace",
3-
"description": "A small, selfhosted bookmark manager.",
3+
"description": "A small, selfhosted bookmark manager with advanced features, built with Laravel and Docker",
44
"license": "MIT",
55
"type": "project",
6-
"version": "0.0.3",
6+
"version": "0.0.4",
77
"require": {
88
"php": "^7.1.3",
99
"doctrine/dbal": "^2.8",

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "linkace",
3-
"version": "0.0.1",
4-
"description": "A small, selfhosted bookmark manager.",
3+
"version": "0.0.4",
4+
"description": "A small, selfhosted bookmark manager with advanced features, built with Laravel and Docker",
55
"homepage": "https://github.com/Kovah/LinkAce",
66
"repository": {
77
"type": "git",

resources/assets/sass/third-party/selectize/_selectize.scss

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,17 @@ $selectize-font-family: inherit !default;
77
$selectize-font-size: inherit !default;
88
$selectize-line-height: $input-btn-line-height !default; //formerly line-height-computed
99

10-
$selectize-color-text: gray("800") !default; //$gray-800
11-
$selectize-color-highlight: rgba(255, 237, 40, 0.4) !default;
10+
$selectize-color-text: $input-color !default; //$gray-800
11+
$selectize-color-highlight: $gray-400 !default;
1212
$selectize-color-input: $input-bg !default;
1313
$selectize-color-input-full: $input-bg !default;
1414
$selectize-color-input-error: theme-color("danger") !default;
1515
$selectize-color-input-error-focus: darken($selectize-color-input-error, 10%) !default;
1616
$selectize-color-disabled: $input-bg !default;
17-
$selectize-color-item: #efefef !default;
18-
$selectize-color-item-border: #999 !default;
17+
$selectize-color-item: $gray-300 !default;
18+
$selectize-color-item-border: $gray-500 !default;
1919
$selectize-color-item-active: $component-active-bg !default;
20-
$selectize-color-item-active-text: #fff !default;
20+
$selectize-color-item-active-text: $white !default;
2121
$selectize-color-item-active-border: rgba(0, 0, 0, 0) !default;
2222
$selectize-color-optgroup: $dropdown-bg !default;
2323
$selectize-color-optgroup-text: $dropdown-header-color !default;
@@ -29,9 +29,9 @@ $selectize-color-dropdown-item-active-text: $dropdown-link-hover-color !default;
2929
$selectize-color-dropdown-item-create-active-text: $dropdown-link-hover-color !default;
3030
$selectize-opacity-disabled: 0.5 !default;
3131
$selectize-shadow-input: none !default;
32-
$selectize-shadow-input-focus: inset 0 1px 2px rgba(0, 0, 0, 0.15) !default;
33-
$selectize-shadow-input-error: inset 0 1px 1px rgba(0, 0, 0, .075) !default;
34-
$selectize-shadow-input-error-focus: inset 0 1px 1px rgba(0, 0, 0, .075), 0 0 6px lighten($selectize-color-input-error, 20%) !default;
32+
$selectize-shadow-input-focus: inset 0 1px 2px rgba($black, 0.15) !default;
33+
$selectize-shadow-input-error: inset 0 1px 1px rgba($black, .075) !default;
34+
$selectize-shadow-input-error-focus: inset 0 1px 1px rgba($black, .075), 0 0 6px lighten($selectize-color-input-error, 20%) !default;
3535
$selectize-border: 1px solid $input-border-color !default;
3636
$selectize-border-radius: $input-border-radius !default;
3737

@@ -57,10 +57,10 @@ $selectize-font-smoothing: inherit !default;
5757
$selectize-font-size: 13px !default;
5858
$selectize-line-height: 18px !default;
5959

60-
$selectize-color-text: #303030 !default;
61-
$selectize-color-border: #d0d0d0 !default;
62-
$selectize-color-highlight: rgba(125, 168, 208, 0.2) !default;
63-
$selectize-color-input: #fff !default;
60+
$selectize-color-text: $gray-800 !default;
61+
$selectize-color-border: $gray-300 !default;
62+
$selectize-color-highlight: rgba($black, 0.2) !default;
63+
$selectize-color-input: $white !default;
6464
$selectize-color-input-full: $selectize-color-input !default;
6565
$selectize-color-disabled: #fafafa !default;
6666
$selectize-color-item: #f2f2f2 !default;
@@ -69,7 +69,7 @@ $selectize-color-item-border: #d0d0d0 !default;
6969
$selectize-color-item-active: #e8e8e8 !default;
7070
$selectize-color-item-active-text: $selectize-color-text !default;
7171
$selectize-color-item-active-border: #cacaca !default;
72-
$selectize-color-dropdown: #fff !default;
72+
$selectize-color-dropdown: $white !default;
7373
$selectize-color-dropdown-border: $selectize-color-border !default;
7474
$selectize-color-dropdown-border-top: #f0f0f0 !default;
7575
$selectize-color-dropdown-item-active: #f5fafd !default;
@@ -102,7 +102,7 @@ $selectize-margin-item-x: 3px !default;
102102
$selectize-margin-item-y: 3px !default;
103103

104104
$selectize-arrow-size: 5px !default;
105-
$selectize-arrow-color: #808080 !default;
105+
$selectize-arrow-color: $gray-600 !default;
106106
$selectize-arrow-offset: 15px !default;
107107

108108
$selectize-caret-margin: 0 2px 0 0 !default;
@@ -166,7 +166,7 @@ $selectize-caret-margin-rtl: 0 4px 0 -2px !default;
166166
padding: $selectize-padding-y $selectize-padding-x;
167167
display: inline-block;
168168
width: 100%;
169-
overflow: hidden;
169+
//overflow: hidden;
170170
position: relative;
171171
z-index: 1;
172172
@include selectize-box-sizing(border-box);
@@ -386,7 +386,7 @@ $selectize-caret-margin-rtl: 0 4px 0 -2px !default;
386386
background: #f2f2f2 !important;
387387
background: rgba(0, 0, 0, 0.06) !important;
388388
border: 0 none !important;
389-
@include selectize-box-shadow(inset 0 0 12px 4px #fff);
389+
@include selectize-box-shadow(inset 0 0 12px 4px $white);
390390
}
391391

392392
.ui-sortable-placeholder::after {

resources/lang/en/search.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
'results' => 'results',
55

66
'filter_by_category' => 'Filter by Category',
7-
'filter_by_tag' => 'Filter by Tag',
7+
'filter_by_tag' => 'Filter by Tag(s)',
88
'query' => 'Search for...',
99
'search_title' => 'Search Title',
1010
'search_description' => 'Search Description',

0 commit comments

Comments
 (0)