Skip to content

Commit 18043dc

Browse files
committed
Merge remote-tracking branch 'origin/main'
# Conflicts: # resources/dist/build/manifest.json
2 parents 1502300 + de9b5cb commit 18043dc

File tree

7 files changed

+36
-45
lines changed

7 files changed

+36
-45
lines changed

resources/dist/build/assets/alt-redirect-addon-a954be4e.js

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

resources/js/components/AltRedirect.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ export default ({
134134
<th class="group to-column pr-8" style="width:8%">
135135
<span>Type</span>
136136
</th>
137-
<th class="group to-column pr-8">
137+
<th class="group to-column pr-8" style="width:15%">
138138
<span>Sites</span>
139139
</th>
140140
<th class="actions-column" style="width:13.4%"></th>
@@ -152,7 +152,7 @@ export default ({
152152
{{ item.redirect_type }}
153153
</td>
154154
<td>
155-
{{ item.sites.join(', ') }}
155+
{{ (item.sites && item.sites.length ) ? item.sites.join(', ') : "Unknown" }}
156156
</td>
157157
<td>
158158
<button @click="deleteRedirect(item.from, item.id)" class="btn"

resources/views/index.blade.php

Lines changed: 1 addition & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -14,33 +14,5 @@
1414
<!-- -->
1515
</div>
1616

17-
<!--<div class="card overflow-hidden p-0">
18-
<table data-size="sm" tabindex="0" class="data-table">
19-
<thead>
20-
<tr>
21-
<th class="group from-column sortable-column">
22-
<span>From</span>
23-
</th>
24-
<th class="group to-column pr-8">
25-
<span>To</span>
26-
</th>
27-
<th class="actions-column"></th>
28-
</tr>
29-
</thead>
30-
<tbody>
31-
@foreach ($data as $key => $value)
32-
<tr class="redirect-row outline-none">
33-
@foreach ($value as $key => $value)
34-
@if($key === 'sites')
35-
<td style="width:50%;">{{ implode(', ', $value) }}</td>
36-
@elseif ($key !== 'id')
37-
<td style="width:50%;">{{ $value }}</td>
38-
@endif
39-
@endforeach
40-
<td><button class="btn" style="color: #bc2626;">Remove</button></td>
41-
</tr>
42-
@endforeach
43-
</tbody>
44-
</table>
45-
</div>-->
17+
4618
@endsection

src/Helpers/Data.php

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ class Data
1313
public $data = [];
1414
public $regexData = [];
1515

16-
public function __construct($type)
16+
public function __construct($type, $onlyRegex = false)
1717
{
1818
$this->type = $type;
1919

@@ -28,15 +28,17 @@ public function __construct($type)
2828
$this->manager->disk()->makeDirectory('content/alt-redirect/alt-regex');
2929
}
3030

31-
$allRedirects = File::allFiles(base_path('/content/alt-redirect'));
32-
$allRedirects = collect($allRedirects)->sortByDesc(function ($file) {
33-
return $file->getCTime();
34-
});
35-
foreach ($allRedirects as $redirect) {
36-
$data = Yaml::parse(File::get($redirect));
37-
$this->data[] = $data;
31+
if(!$onlyRegex) {
32+
$allRedirects = File::allFiles(base_path('/content/alt-redirect'));
33+
$allRedirects = collect($allRedirects)->sortByDesc(function ($file) {
34+
return $file->getCTime();
35+
});
36+
foreach ($allRedirects as $redirect) {
37+
$data = Yaml::parse(File::get($redirect));
38+
$this->data[] = $data;
39+
}
3840
}
39-
41+
4042
$allRegexRedirects = File::allFiles(base_path('/content/alt-redirect/alt-regex'));
4143
$allRegexRedirects = collect($allRegexRedirects)->sortBy(function ($file) {
4244
return $file->getCTime();

src/Http/Controllers/AltRedirectController.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,9 @@ public function index()
3232
$fields = $fields->preProcess();
3333

3434
// Reset the directory to the old one
35-
Blueprint::setDirectory($oldDirectory);
35+
if ($oldDirectory) {
36+
Blueprint::setDirectory($oldDirectory);
37+
}
3638

3739
return view('alt-redirect::index', [
3840
'blueprint' => $blueprint->toPublishArray(),
@@ -46,7 +48,7 @@ public function create(Request $request)
4648
{
4749

4850
// Grab the old directory just in case
49-
$oldDirectory = Blueprint::directory();
51+
// $oldDirectory = Blueprint::directory();
5052

5153
$data = new Data('redirects');
5254

@@ -68,7 +70,7 @@ public function create(Request $request)
6870
$values = $data->all();
6971

7072
// Reset the directory to the old one
71-
Blueprint::setDirectory($oldDirectory);
73+
// Blueprint::setDirectory($oldDirectory);
7274

7375
return [
7476
'data' => $values
@@ -123,7 +125,7 @@ public function import(Request $request)
123125
'from' => $row[0],
124126
'to' => $row[1],
125127
'redirect_type' => $row[2],
126-
'sites' => explode(',', $row[3]),
128+
'sites' => isset($row[3]) ? explode(',', $row[3]) : false,
127129
'id' => $row[4] ?? uniqid(),
128130
];
129131
foreach ($currentData as $rdKey => $redirect) {

src/Http/Middleware/CheckForRedirects.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public function handle(Request $request, Closure $next, string ...$guards): Resp
3737
}
3838
}
3939

40-
$data = new Data('redirect');
40+
$data = new Data('redirect', true);
4141
foreach ($data->regexData as $redirect) {
4242
if (preg_match('#' . $redirect['from'] . '#', $uri)) {
4343
$redirectTo = preg_replace('#' . $redirect['from'] . '#', $redirect['to'], $uri);

0 commit comments

Comments
 (0)