Skip to content

Commit

Permalink
Merge pull request #4489 from rtfd/davidfischer/all-static-collectstatic
Browse files Browse the repository at this point in the history
All static media is run through "collectstatic"
  • Loading branch information
ericholscher authored Aug 14, 2018
2 parents 5f993a0 + a9e9e8a commit ce3e4f9
Show file tree
Hide file tree
Showing 8 changed files with 25 additions and 26 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ media/json
media/man
media/pdf
media/static
/static
node_modules
package-lock.json
readthedocs/rtd_tests/builds
Expand Down
1 change: 1 addition & 0 deletions media/font/fontawesome_webfont.woff2
2 changes: 1 addition & 1 deletion media/fonts
2 changes: 1 addition & 1 deletion readthedocs/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ def USE_PROMOS(self): # noqa
PRODUCTION_MEDIA_ARTIFACTS = os.path.join(PRODUCTION_ROOT, 'media')

# Assets and media
STATIC_ROOT = os.path.join(SITE_ROOT, 'media/static/')
STATIC_ROOT = os.path.join(SITE_ROOT, 'static')
STATIC_URL = '/static/'
MEDIA_ROOT = os.path.join(SITE_ROOT, 'media/')
MEDIA_URL = '/media/'
Expand Down
12 changes: 0 additions & 12 deletions readthedocs/templates/admin.html

This file was deleted.

6 changes: 3 additions & 3 deletions readthedocs/templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
{% block extra_metas %}{% endblock extra_metas %}

<link rel="icon" type="image/png" href="{{ MEDIA_URL }}images/favicon.png">
<link rel="icon" type="image/png" href="{% static 'images/favicon.png' %}">

<!-- title -->
<title>{% block title %}{% endblock %}{% block head_title %}{% endblock %} | {% block branding %}Read the Docs {% endblock %}</title>
Expand Down Expand Up @@ -47,7 +47,7 @@
<!-- End Google Analytics -->

<!-- css -->
<link rel="stylesheet" href="{{ MEDIA_URL }}css/core.css">
<link rel="stylesheet" href="{% static 'css/core.css' %}">
{% block extra_links %}{% endblock %}

<!-- jquery -->
Expand All @@ -58,7 +58,7 @@
require('jquery');
</script>

<script src="{{ MEDIA_URL }}javascript/base.js"></script>
<script src="{% static 'javascript/base.js' %}"></script>
<script src="{% static 'core/js/site.js' %}"></script>
<script>
var site = require('core/site');
Expand Down
3 changes: 2 additions & 1 deletion readthedocs/templates/builds/build_list.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{% extends "projects/base_project.html" %}

{% load i18n %}
{% load static %}

{% load pagination_tags %}
{% load privacy_tags %}
Expand Down Expand Up @@ -74,7 +75,7 @@ <h1>{% trans "Recent Builds" %}</h1>

{% block extra_scripts %}
{{ block.super }}
<script type="text/javascript" src="{{ MEDIA_URL }}javascript/build_updater.js"></script>
<script type="text/javascript" src="{% static 'javascript/build_updater.js' %}"></script>

<script type="text/javascript">
$(function() {
Expand Down
24 changes: 16 additions & 8 deletions readthedocs/urls.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
# pylint: disable=missing-docstring
from __future__ import absolute_import

import os
from functools import reduce
from operator import add

from django.conf.urls import url, include
from django.contrib import admin
from django.conf import settings
from django.conf.urls.static import static
from django.views.generic.base import TemplateView
from django.views.generic.base import TemplateView, RedirectView
from tastypie.api import Api

from readthedocs.api.base import (ProjectResource, UserResource,
Expand Down Expand Up @@ -85,13 +86,20 @@
TemplateView.as_view(template_name='dnt-policy.txt', content_type='text/plain')),
]

debug_urls = add(
[
url('style-catalog/$',
TemplateView.as_view(template_name='style_catalog.html')),
],
static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
)
debug_urls = []
for build_format in ('epub', 'htmlzip', 'json', 'pdf'):
debug_urls += static(
settings.MEDIA_URL + build_format,
document_root=os.path.join(settings.MEDIA_ROOT, build_format),
)
debug_urls += [
url('style-catalog/$',
TemplateView.as_view(template_name='style_catalog.html')),

# This must come last after the build output files
url(r'^media/(?P<remainder>.+)$',
RedirectView.as_view(url=settings.STATIC_URL + '%(remainder)s'), name='media-redirect'),
]

# Export URLs
groups = [basic_urls, rtd_urls, project_urls, api_urls, core_urls, i18n_urls, deprecated_urls]
Expand Down

0 comments on commit ce3e4f9

Please sign in to comment.