Skip to content

Commit e93f551

Browse files
committed
work in progress
1 parent 6e35107 commit e93f551

File tree

7 files changed

+125
-1
lines changed

7 files changed

+125
-1
lines changed

config/iframes.php

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,28 @@
11
<?php
2-
// config for Headerx/ClassName
2+
33
return [
44

5+
'theme' => 'jetstream',
6+
7+
/**
8+
* The Route prefix under which views should be loaded in an iframe.
9+
* This can be useful when you want to keep the appearance of the
10+
* but the view contains css or javascript which is incompatible.
11+
*/
12+
'internal_iframe_prefix' => env('INTERNAL_IFRAME_PREFIX', 'iframes'),
13+
14+
/**
15+
* The Route prefix under which to load external iframes,
16+
* such as from subdomains, static sites, or services
17+
* running on another backend platform or framework
18+
*/
19+
'external_iframe_prefix' => env('EXTERNAL_IFRAME_PREFIX', 'extras'),
20+
21+
/**
22+
* The key in the query string which will
23+
* be used to load external sites inside
24+
* an iframe.
25+
*/
26+
'external_link_key' => env('EXTERNAL_LINK_KEY', '?external_link='),
27+
528
];

resources/views/.gitkeep

Whitespace-only changes.
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<x-app-layout>
2+
<div class="w-full h-screen frameHolder">
3+
<iframe
4+
name='mainFrame'
5+
id="mainFrame"
6+
class="w-full h-full mainFrame"
7+
frameborder="0"
8+
noresize='noresize'
9+
scrolling='auto'
10+
src="{{ $frame }}"
11+
class="mainFrame">
12+
</iframe>
13+
</div>
14+
</x-app-layout>
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<x-app-layout>
2+
@if(!empty($_GET))
3+
4+
<div class="w-full h-screen frameHolder">
5+
<iframe
6+
name='mainFrame'
7+
id="mainFrame"
8+
class="w-full h-full mainFrame"
9+
frameborder="0"
10+
noresize='noresize'
11+
scrolling='auto'
12+
src="{{ url($frame . '?' . http_build_query($_GET)) }}"
13+
class="maniFrame">
14+
</iframe>
15+
</div>
16+
@else
17+
18+
<div class="w-full h-screen frameHolder">
19+
<iframe
20+
name='mainFrame'
21+
id="mainFrame"
22+
class="w-full h-full mainFrame"
23+
frameborder="0"
24+
noresize='noresize'
25+
scrolling='auto'
26+
src="{{ url($frame) }}"
27+
class="mainFrame">
28+
</iframe>
29+
</div>
30+
31+
@endif
32+
</x-app-layout>

routes/iframes.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<?php
2+
3+
use App\Core\App\Controllers\Iframes\ExternalIframeController;
4+
use App\Core\App\Controllers\Iframes\InternalIframeController;
5+
use Illuminate\Support\Facades\Route;
6+
7+
Route::any('/'.config('iframes.internal_iframe_prefix').'/{path}', InternalIframeController::class)->where('path', '(.*)');
8+
9+
Route::get('/'.config('iframes.external_iframe_prefix'), ExternalIframeController::class);
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?php
2+
3+
namespace App\Core\App\Controllers\Iframes;
4+
5+
use App\Http\Controllers\Controller;
6+
use Illuminate\Http\Request;
7+
8+
class ExternalIframeController extends Controller
9+
{
10+
public function __invoke(Request $request)
11+
{
12+
if ($request->has(str_replace(['?', '='], '', config('iframes.external_link_query')))) {
13+
$iframeSource = $request->{str_replace(['?', '='], '', config('iframes.external_link_query'))};
14+
return view('headerx::'.config('iframes.theme').'.external-iframe', ['iframeSource' => $iframeSource]);
15+
}
16+
abort('404');
17+
}
18+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<?php
2+
3+
namespace App\Core\App\Controllers\Iframes;
4+
5+
use App\Http\Controllers\Controller;
6+
use Illuminate\Contracts\View\View;
7+
8+
class InternalIframeController extends Controller
9+
{
10+
public function __invoke(string $path): View
11+
{
12+
$query_string = '';
13+
14+
15+
$uri = explode('?', $_SERVER['REQUEST_URI']);
16+
17+
if (count($uri) > 1) {
18+
$query_string = $uri[1];
19+
}
20+
21+
parse_str($query_string, $_GET);
22+
23+
return view('headerx::'.config('iframes.theme').'.index', [
24+
'iframeSource' => $path,
25+
'$_GET' => $query_string
26+
]);
27+
}
28+
}

0 commit comments

Comments
 (0)