mirror of
https://github.com/pgadmin-org/pgadmin4.git
synced 2025-02-25 18:55:31 -06:00
Fix paths under non-standard virtual directories. Fixes #2563
This commit is contained in:
parent
617e9dbb3a
commit
178d583bcd
@ -14,7 +14,7 @@ import os, sys
|
|||||||
from collections import defaultdict
|
from collections import defaultdict
|
||||||
from importlib import import_module
|
from importlib import import_module
|
||||||
|
|
||||||
from flask import Flask, abort, request, current_app, session
|
from flask import Flask, abort, request, current_app, session, url_for
|
||||||
from flask_babel import Babel, gettext
|
from flask_babel import Babel, gettext
|
||||||
from flask_htmlmin import HTMLMIN
|
from flask_htmlmin import HTMLMIN
|
||||||
from flask_login import user_logged_in
|
from flask_login import user_logged_in
|
||||||
@ -89,13 +89,39 @@ class PgAdmin(Flask):
|
|||||||
|
|
||||||
@property
|
@property
|
||||||
def exposed_endpoint_url_map(self):
|
def exposed_endpoint_url_map(self):
|
||||||
|
#############################################################
|
||||||
|
# To handle WSGI paths
|
||||||
|
# If user has setup application under WSGI alias
|
||||||
|
# like 'localhost/pgadmin4' then we have to append '/pgadmin4'
|
||||||
|
# into endpoints
|
||||||
|
#############################################################
|
||||||
|
import config
|
||||||
|
is_wsgi_root_present = False
|
||||||
|
if config.SERVER_MODE:
|
||||||
|
pgadmin_root_path = url_for('browser.index')
|
||||||
|
if pgadmin_root_path != '/browser/':
|
||||||
|
is_wsgi_root_present = True
|
||||||
|
wsgi_root_path = pgadmin_root_path.replace(
|
||||||
|
'/browser/', ''
|
||||||
|
)
|
||||||
|
|
||||||
|
def get_full_url_path(url):
|
||||||
|
"""
|
||||||
|
Generate endpoint URL at per WSGI alias
|
||||||
|
"""
|
||||||
|
if is_wsgi_root_present and url:
|
||||||
|
return wsgi_root_path + url
|
||||||
|
else:
|
||||||
|
return url
|
||||||
|
|
||||||
|
# Fetch all endpoints and their respective url
|
||||||
for rule in current_app.url_map.iter_rules('static'):
|
for rule in current_app.url_map.iter_rules('static'):
|
||||||
yield rule.endpoint, rule.rule
|
yield rule.endpoint, get_full_url_path(rule.rule)
|
||||||
|
|
||||||
for module in self.submodules:
|
for module in self.submodules:
|
||||||
for endpoint in module.exposed_endpoints:
|
for endpoint in module.exposed_endpoints:
|
||||||
for rule in current_app.url_map.iter_rules(endpoint):
|
for rule in current_app.url_map.iter_rules(endpoint):
|
||||||
yield rule.endpoint, rule.rule
|
yield rule.endpoint, get_full_url_path(rule.rule)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def javascripts(self):
|
def javascripts(self):
|
||||||
|
@ -41,14 +41,14 @@
|
|||||||
slickgrid: "{{ url_for('static', filename='js/generated/slickgrid') }}",
|
slickgrid: "{{ url_for('static', filename='js/generated/slickgrid') }}",
|
||||||
codemirror: "{{ url_for('static', filename='js/generated/codemirror') }}",
|
codemirror: "{{ url_for('static', filename='js/generated/codemirror') }}",
|
||||||
datagrid: "{{ url_for('static', filename='js/generated/datagrid') }}",
|
datagrid: "{{ url_for('static', filename='js/generated/datagrid') }}",
|
||||||
sqleditor: "{{ url_for('static', filename='js/generated/sqleditor') }}"
|
sqleditor: "{{ url_for('static', filename='js/generated/sqleditor') }}",
|
||||||
,'browser_node': "{{ url_for('static', filename='js/generated/browser_node') }}"
|
'browser_node': "{{ url_for('static', filename='js/generated/browser_node') }}",
|
||||||
,'pgadmin.browser.utils': "/browser/js/utils"
|
'pgadmin.browser.utils': "{{ url_for('browser.index') }}" + "js/utils",
|
||||||
,'pgadmin.browser.endpoints': "/browser/js/endpoints"
|
'pgadmin.browser.endpoints': "{{ url_for('browser.index') }}" + "js/endpoints",
|
||||||
,'pgadmin.browser.messages': "/browser/js/messages"
|
'pgadmin.browser.messages': "{{ url_for('browser.index') }}" + "js/messages",
|
||||||
,'pgadmin.server.supported_servers': "/browser/server/supported_servers"
|
'pgadmin.server.supported_servers': "{{ url_for('browser.index') }}" + "server/supported_servers",
|
||||||
,'pgadmin.user_management.current_user': "/user_management/current_user"
|
'pgadmin.user_management.current_user': "{{ url_for('user_management.index') }}" + "current_user",
|
||||||
,'translations': "/tools/translations"
|
'translations': "{{ url_for('tools.index') }}" + "translations"
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user