Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 725589a

Browse files
committed
Allow PLA to be served in a subpath, when behind a proxy. Closes #376
1 parent 3b30e3e commit 725589a

File tree

7 files changed

+42
-21
lines changed

7 files changed

+42
-21
lines changed

‎app/Http/Controllers/HomeController.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class HomeController extends Controller
3030
public function frame(Request $request,?Collection $old=NULL): \Illuminate\View\View
3131
{
3232
// If our index was not render from a root url, then redirect to it
33-
if (($request->root().'/' !== url()->previous()) && $request->method() === 'POST')
33+
if (($request->root().($request->getBasePath() ? '' : '/') !== url()->previous()) && ($request->method() === 'POST'))
3434
abort(409);
3535

3636
$key = request_key($request->get('_key',old('_key',old('dn'))));

‎public/css/fixes.css‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ body {
55
*/
66

77
.logo-src {
8-
background: url('/images/logo-h.png');
8+
background: url('../images/logo-h.png');
99
width: 152px !important;
1010
}
1111

‎public/js/custom.js‎

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ function expandChildren(node) {
1313

1414
function getNode(item) {
1515
$.ajax({
16-
url: '/frame',
16+
url: web_base+'/frame',
1717
method: 'POST',
1818
data: { _key: item },
1919
dataType: 'html',
@@ -37,11 +37,27 @@ function getNode(item) {
3737
$('.main-content').empty().append(e.responseText);
3838
break;
3939
case 409: // Not in root
40+
// There is an unusual problem, that location.replace() is not being replaced, when, for example:
41+
// * When running in a subpath
42+
// * The rendered URL has a slash on the end
43+
// * The rendered page is a form, etc /entry/add, and the user clicks on the tree
44+
workaround = location.href;
45+
location.assign(web_base+'/#'+item);
46+
47+
if ((web_base_path === '/') && (location.pathname === '/'))
48+
location.reload();
49+
50+
else if ((! location.href.match('/\/$/')) && (workaround !== location.href))
51+
location.reload();
52+
53+
break;
4054
case 419: // Session Expired
41-
location.replace('/#'+item);
42-
// When the session expires, and we are in the tree, we need to force a reload
43-
if (location.pathname === '/')
55+
workaround = location.href;
56+
location.replace(web_base+'/#'+item);
57+
58+
if ((! location.href.match('/\/$/')) && (workaround !== location.href))
4459
location.reload();
60+
4561
break;
4662
case 500:
4763
case 555: // Missing Method
@@ -59,7 +75,7 @@ $(document).ready(function() {
5975
if (typeof basedn !== 'undefined') {
6076
sources = basedn;
6177
} else {
62-
sources = { method: 'POST', url: '/ajax/bases' };
78+
sources = { method: 'POST', url: web_base+'/ajax/bases' };
6379
}
6480

6581
// Attach the fancytree widget to an existing <div id="tree"> element
@@ -96,7 +112,7 @@ $(document).ready(function() {
96112
lazyLoad: function(event,data) {
97113
data.result = {
98114
method: 'POST',
99-
url: '/ajax/children',
115+
url: web_base+'/ajax/children',
100116
data: {_key: data.node.data.item,create: true}
101117
};
102118

‎resources/themes/architect/views/layouts/partials/htmlheader.blade.php‎

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,39 +6,40 @@
66
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no, shrink-to-fit=no"/>
77
<meta name="description" content="phpLDAPadmin - A web interface into LDAP data management">
88
<meta name="msapplication-tap-highlight" content="no">
9+
<base href="{{ request()->root() }}"/>
910

1011
<!-- CSRF Token -->
1112
<meta name="csrf-token" content="{{ csrf_token() }}">
1213

1314
<title>{{ config('app.name') }} - @yield('htmlheader_title','🥇 An LDAP Administration Tool')</title>
14-
<link rel="shortcut icon" href="/{{ config('app.favicon','favicon.png') }}"/>
15+
<link rel="shortcut icon" href="{{ asset(config('app.favicon','favicon.png')) }}"/>
1516

1617
<!-- App CSS -->
17-
<link rel="stylesheet" href="{{ asset('/css/app.css') }}">
18+
<link rel="stylesheet" href="{{ asset('css/app.css') }}">
1819

1920
<!-- Google Font: Source Sans Pro -->
2021
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family={{ str_replace(' ','+',config('app.font') ?: 'IBM Plex Sans') }}:wght@300&display=swap">
2122

2223
<!-- Country Flags -->
23-
<link rel="stylesheet" href="{{ asset('/css/flags/flags16-both.css') }}">
24-
<link rel="stylesheet" href="{{ asset('/css/flags/flags32-both.css') }}">
24+
<link rel="stylesheet" href="{{ asset('css/flags/flags16-both.css') }}">
25+
<link rel="stylesheet" href="{{ asset('css/flags/flags32-both.css') }}">
2526

2627
@if(file_exists('css/fixes.css'))
2728
<!-- CSS Fixes -->
28-
<link rel="stylesheet" href="{{ asset('/css/fixes.css') }}">
29+
<link rel="stylesheet" href="{{ asset('css/fixes.css') }}">
2930
@endif
3031

3132
@if(file_exists('css/custom.css'))
3233
<!-- Custom CSS -->
33-
<link rel="stylesheet" href="{{ asset('/css/custom.css') }}">
34+
<link rel="stylesheet" href="{{ asset('css/custom.css') }}">
3435
@endif
3536

3637
<!-- Page Styles -->
3738
@yield('page-styles')
3839
{{--
3940
@if(file_exists('css/print.css'))
4041
<!-- Printing Modifications -->
41-
<link rel="stylesheet" href="{{ asset('/css/print.css') }}">
42+
<link rel="stylesheet" href="{{ asset('css/print.css') }}">
4243
@endif
4344
--}}
4445
</head>

‎resources/themes/architect/views/layouts/partials/scripts.blade.php‎

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
1-
<script type="text/javascript" src="{{ asset('/js/vendor.js') }}"></script>
2-
<script type="text/javascript" src="{{ asset('/js/manifest.js') }}"></script>
3-
<script type="text/javascript" src="{{ asset('/js/app.js') }}"></script>
1+
<script type="text/javascript" src="{{ asset('js/vendor.js') }}"></script>
2+
<script type="text/javascript" src="{{ asset('js/manifest.js') }}"></script>
3+
<script type="text/javascript" src="{{ asset('js/app.js') }}"></script>
44

55
<script type="text/javascript">
6+
const web_base = '{{ request()->root() }}';
7+
const web_base_path = '{{ Request::header('X-Forwarded-Prefix','/') }}'
8+
69
// Our CSRF token to each interaction
710
$.ajaxSetup({
811
headers: {

‎resources/themes/architect/views/layouts/partials/topmenu.blade.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@
229229
if (! item.value)
230230
return item.name+'=';
231231
232-
location.replace('/#'+item.value);
232+
location.replace(web_base+'/#'+item.value);
233233
location.reload();
234234
return '';
235235
},

‎resources/views/frames/dn.blade.php‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -190,8 +190,9 @@ function editmode() {
190190
191191
$(document).ready(function() {
192192
$('button[id=entry-create]').on('click',function(item) {
193-
location.replace('/#{{ Crypt::encryptString(sprintf('*%s|%s','create',$dn)) }}');
194-
location.reload();
193+
location.replace(web_base+'/#{{ Crypt::encryptString(sprintf('*%s|%s','create',$dn)) }}');
194+
if (web_base_path === '/')
195+
location.reload();
195196
});
196197
197198
$('button[id=entry-edit]').on('click',function(item) {

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /