diff --git a/cabot/settings.py b/cabot/settings.py index a12b6b8..3a18f2a 100644 --- a/cabot/settings.py +++ b/cabot/settings.py @@ -22,6 +22,8 @@ DATABASES = {'default': dj_database_url.parse(os.environ["DATABASE_URL"])} if not DEBUG: DATABASES['default']['OPTIONS'] = {'autocommit': True} +URL_PREFIX = os.environ.get('URL_PREFIX', '/').rstrip("/") + LOGIN_URL = reverse_lazy('login') 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 # trailing slash. # 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. # 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. # Example: "http://media.lawrence.com/static/" -STATIC_URL = '/static/' +STATIC_URL = '%s/static/' % URL_PREFIX # Additional locations of static files 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_URL = '/static/' +COMPRESS_URL = '%s/static/' % URL_PREFIX RECOVERY_SNIPPETS_WHITELIST = ( r'https?://[^.]+\.hackpad\.com/[^./]+\.js', diff --git a/cabot/urls.py b/cabot/urls.py index 2851c96..6617f9a 100644 --- a/cabot/urls.py +++ b/cabot/urls.py @@ -165,3 +165,8 @@ def append_plugin_urls(): ) append_plugin_urls() + +if settings.URL_PREFIX.strip('/'): + urlpatterns = patterns('', + ('^%s/' % settings.URL_PREFIX.strip('/'), include(urlpatterns)) + ) diff --git a/conf/development.env.example b/conf/development.env.example index dbcc3e3..0073ac6 100644 --- a/conf/development.env.example +++ b/conf/development.env.example @@ -10,6 +10,9 @@ PORT=5001 # 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: # http://en.wikipedia.org/wiki/List_of_tz_zones_by_name TIME_ZONE=Etc/UTC diff --git a/conf/production.env.example b/conf/production.env.example index 588f5c3..88ecb18 100644 --- a/conf/production.env.example +++ b/conf/production.env.example @@ -10,6 +10,9 @@ VENV=/home/ubuntu/venv # 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: # http://en.wikipedia.org/wiki/List_of_tz_zones_by_name TIME_ZONE=Etc/UTC