Commit 4f62a972 authored by Michal Čihař's avatar Michal Čihař

Remove refernces to /media settings

Issue #605
Signed-off-by: default avatarMichal Čihař <michal@cihar.com>
parent 1e70bf97
......@@ -269,8 +269,7 @@ Some of exceptions you might want to include:
LOGIN_REQUIRED_URLS_EXCEPTIONS = (
r'/accounts/(.*)$', # Required for login
r'/media/(.*)$', # Required for development mode
r'/static/(.*)$', # Required for development mode
r'/static/(.*)$', # Required for development mode
r'/widgets/(.*)$', # Allowing public access to widgets
r'/data/(.*)$', # Allowing public access to data exports
r'/hooks/(.*)$', # Allowing public access to notification hooks
......
......@@ -679,14 +679,13 @@ links to static files into directory specified by ``STATIC_ROOT`` setting.
It is recommended to serve static files directly by your web server, you should
use that for following paths:
:file:`/media`
Serves :file:`media` directory from Weblate.
:file:`/static`
:file:`/static/`
Serves static files for Weblate and admin interface
(from defined by ``STATIC_ROOT``).
Additionally you should setup rewrite rule to serve :file:`media/favicon.ico`
as :file:`favicon.ico`.
:file:`/favicon.ico`
Should be rewritten to rewrite rule to serve :file:`/static/favicon.ico`
:file:`/robots.txt`
Should be rewritten to rewrite rule to serve :file:`/static/robots.txt`
.. seealso:: https://docs.djangoproject.com/en/stable/howto/deployment/
......
......@@ -6,6 +6,5 @@ WSGIPythonPath /usr/share/weblate
# Path to Weblate WSGI handler
WSGIScriptAlias /weblate "/usr/share/weblate/weblate/wsgi.py"
# Aliases to serve media and static files
Alias /weblate/media/ /usr/share/weblate/weblate/media/
Alias /static/admin /usr/lib/python2.7/site-packages/django/contrib/admin/static/admin/
# Aliases to serve static files
Alias /static/ /usr/share/weblate/data/static/
......@@ -8,20 +8,13 @@ WSGIPythonPath /usr/share/weblate
ServerAdmin admin@image.weblate.org
ServerName image.weblate.org
DocumentRoot /usr/share/weblate/weblate/media/
Alias /robots.txt /usr/share/weblate/data/static/robots.txt
Alias /favicon.ico /usr/share/weblate/data/static/favicon.ico
Alias /robots.txt /usr/share/weblate/weblate/media/robots.txt
Alias /favicon.ico /usr/share/weblate/weblate/media/favicon.ico
Alias /media/ /usr/share/weblate/weblate/media/
Alias /doc/ /usr/share/doc/packages/weblate/html/
Alias /static/ /usr/share/weblate/data/static/
<Directory /usr/share/weblate/weblate/data/static/>
Require all denied
</Directory>
<Directory /usr/share/weblate/weblate/media/>
<Directory /usr/share/weblate/data/static/>
Require all denied
</Directory>
......
......@@ -7,20 +7,17 @@ fastcgi.server = (
),
)
alias.url = (
"/media" => "/var/lib/django/weblate/weblate/media/",
"/static" => "/usr/share/weblate/data/static/",
)
url.rewrite-once = (
"^(/*media.*)$" => "$1",
"^(/*static.*)$" => "$1",
"^/*favicon\.ico$" => "/media/favicon.ico",
"^/*robots\.txt$" => "/media/robots.txt",
"^/*favicon\.ico$" => "/static/favicon.ico",
"^/*robots\.txt$" => "/static/robots.txt",
"^(/.*)$" => "/weblate.fcgi$1",
)
expire.url = (
"/media/" => "access 1 months",
"/static/" => "access 1 months",
"/favicon.ico" => "access 1 months",
)
......@@ -4,17 +4,12 @@ server {
root /path/to/weblate/weblate;
location /favicon.ico {
alias /path/to/weblate/weblate/media/favicon.ico;
expires 30d;
}
location /media/ {
alias /path/to/weblate/weblate/media/;
alias /path/to/weblate/data/static/favicon.ico;
expires 30d;
}
location /robots.txt {
alias /path/to/weblate/weblate/media/robots.txt;
alias /path/to/weblate/data/static/robots.txt;
expires 30d;
}
......
......@@ -80,6 +80,7 @@ sed -i 's@^BASE_DIR = .*@BASE_DIR = "%{WLDIR}/weblate"@g' weblate/settings.py
sed -i 's@^DATA_DIR = .*@DATA_DIR = "%{WLDATADIR}"@g' weblate/settings.py
sed -i "s@'ENGINE': 'django.db.backends.sqlite3'@'ENGINE': 'django.db.backends.mysql'@" weblate/settings.py
sed -i "s@'NAME': 'weblate.db'@'NAME': 'weblate'@" weblate/settings.py
sed -i "s@/usr/share/weblate/data@%{WLDATADIR}@" examples/apache.conf
%install
install -d %{buildroot}/%{WLDIR}
......
......@@ -93,7 +93,7 @@ def get_fallback_avatar_url(size):
Returns URL of fallback avatar.
"""
return os.path.join(
settings.MEDIA_URL,
settings.STATIC_URL,
'weblate-{0}.png'.format(size)
)
......@@ -103,8 +103,8 @@ def get_fallback_avatar(size):
Returns fallback avatar.
"""
fallback = os.path.join(
appsettings.BASE_DIR,
'media/weblate-{0}.png'.format(size)
appsettings.STATIC_ROOT,
'weblate-{0}.png'.format(size)
)
with open(fallback, 'r') as handle:
return handle.read()
......
......@@ -52,7 +52,7 @@ class RequireLoginMiddleware(object):
)
self.exceptions = self.get_setting_re(
'LOGIN_REQUIRED_URLS_EXCEPTIONS',
[r'/accounts/(.*)$', r'/media/(.*)$', r'/static/(.*)$']
[r'/accounts/(.*)$', r'/static/(.*)$']
)
def get_setting_re(self, name, default):
......
......@@ -292,7 +292,6 @@ TEMPLATE_CONTEXT_PROCESSORS = (
'django.contrib.auth.context_processors.auth',
'django.core.context_processors.debug',
'django.core.context_processors.i18n',
'django.core.context_processors.media',
'django.core.context_processors.request',
'django.core.context_processors.csrf',
'django.contrib.messages.context_processors.messages',
......
......@@ -757,13 +757,7 @@ urlpatterns = patterns(
)
),
# Media files
url(
r'^media/(?P<path>.*)$',
'django.views.static.serve',
{'document_root': settings.MEDIA_ROOT}
),
# Site wide search
url(
r'^search/$',
'weblate.trans.views.basic.search',
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment