mirror of https://github.com/status-im/cabot.git
add a URL_PREFIX environment variable
this adds the ability to add a prefix to all generated URLs so placing cabot under a subdirectory of a web server is possible, such as with a reverse proxy. resolves #321
This commit is contained in:
parent
39f0cfe1c1
commit
526c7f97e9
|
@ -22,6 +22,8 @@ DATABASES = {'default': dj_database_url.parse(os.environ["DATABASE_URL"])}
|
||||||
if not DEBUG:
|
if not DEBUG:
|
||||||
DATABASES['default']['OPTIONS'] = {'autocommit': True}
|
DATABASES['default']['OPTIONS'] = {'autocommit': True}
|
||||||
|
|
||||||
|
URL_PREFIX = os.environ.get('URL_PREFIX', '/').rstrip("/")
|
||||||
|
|
||||||
LOGIN_URL = reverse_lazy('login')
|
LOGIN_URL = reverse_lazy('login')
|
||||||
|
|
||||||
USE_TZ = True
|
USE_TZ = True
|
||||||
|
@ -58,7 +60,7 @@ MEDIA_ROOT = os.path.join(PROJECT_ROOT, 'media/')
|
||||||
# URL that handles the media served from MEDIA_ROOT. Make sure to use a
|
# URL that handles the media served from MEDIA_ROOT. Make sure to use a
|
||||||
# trailing slash.
|
# trailing slash.
|
||||||
# Examples: "http://media.lawrence.com/media/", "http://example.com/media/"
|
# Examples: "http://media.lawrence.com/media/", "http://example.com/media/"
|
||||||
MEDIA_URL = '/media/'
|
MEDIA_URL = '%s/media/' % URL_PREFIX
|
||||||
|
|
||||||
# Absolute path to the directory static files should be collected to.
|
# Absolute path to the directory static files should be collected to.
|
||||||
# Don't put anything in this directory yourself; store your static files
|
# Don't put anything in this directory yourself; store your static files
|
||||||
|
@ -70,7 +72,7 @@ COMPRESS_ROOT = STATIC_ROOT
|
||||||
|
|
||||||
# URL prefix for static files.
|
# URL prefix for static files.
|
||||||
# Example: "http://media.lawrence.com/static/"
|
# Example: "http://media.lawrence.com/static/"
|
||||||
STATIC_URL = '/static/'
|
STATIC_URL = '%s/static/' % URL_PREFIX
|
||||||
|
|
||||||
# Additional locations of static files
|
# Additional locations of static files
|
||||||
STATICFILES_DIRS = [os.path.join(PROJECT_ROOT, 'static')]
|
STATICFILES_DIRS = [os.path.join(PROJECT_ROOT, 'static')]
|
||||||
|
@ -153,7 +155,7 @@ EMAIL_USE_TLS = os.environ.get('SES_USE_TLS', 0)
|
||||||
|
|
||||||
COMPRESS_OFFLINE = not DEBUG
|
COMPRESS_OFFLINE = not DEBUG
|
||||||
|
|
||||||
COMPRESS_URL = '/static/'
|
COMPRESS_URL = '%s/static/' % URL_PREFIX
|
||||||
|
|
||||||
RECOVERY_SNIPPETS_WHITELIST = (
|
RECOVERY_SNIPPETS_WHITELIST = (
|
||||||
r'https?://[^.]+\.hackpad\.com/[^./]+\.js',
|
r'https?://[^.]+\.hackpad\.com/[^./]+\.js',
|
||||||
|
|
|
@ -165,3 +165,8 @@ def append_plugin_urls():
|
||||||
)
|
)
|
||||||
|
|
||||||
append_plugin_urls()
|
append_plugin_urls()
|
||||||
|
|
||||||
|
if settings.URL_PREFIX.strip('/'):
|
||||||
|
urlpatterns = patterns('',
|
||||||
|
('^%s/' % settings.URL_PREFIX.strip('/'), include(urlpatterns))
|
||||||
|
)
|
||||||
|
|
|
@ -10,6 +10,9 @@ PORT=5001
|
||||||
|
|
||||||
# You shouldn't need to change anything above this line
|
# You shouldn't need to change anything above this line
|
||||||
|
|
||||||
|
# Base path to include before generated URLs. If not defined, uses `/`
|
||||||
|
# URL_PREFIX=/
|
||||||
|
|
||||||
# Local time zone for this installation. Choices can be found here:
|
# Local time zone for this installation. Choices can be found here:
|
||||||
# http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
|
# http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
|
||||||
TIME_ZONE=Etc/UTC
|
TIME_ZONE=Etc/UTC
|
||||||
|
|
|
@ -10,6 +10,9 @@ VENV=/home/ubuntu/venv
|
||||||
|
|
||||||
# You shouldn't need to change anything above this line
|
# You shouldn't need to change anything above this line
|
||||||
|
|
||||||
|
# Base path to include before generated URLs. If not defined, uses `/`
|
||||||
|
# URL_PREFIX=/
|
||||||
|
|
||||||
# Local time zone for this installation. Choices can be found here:
|
# Local time zone for this installation. Choices can be found here:
|
||||||
# http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
|
# http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
|
||||||
TIME_ZONE=Etc/UTC
|
TIME_ZONE=Etc/UTC
|
||||||
|
|
Loading…
Reference in New Issue