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