Mercurial > public > sg101
changeset 1014:a34daec7f936
Converting to ManifestStaticFilesStorage.
Got rid of all occurrences of STATIC_URL from Python code.
line wrap: on
line diff
--- a/bio/templatetags/bio_tags.py Sat Nov 28 22:16:29 2015 -0600 +++ b/bio/templatetags/bio_tags.py Tue Dec 01 20:58:31 2015 -0600 @@ -3,7 +3,6 @@ """ from django import template from django.conf import settings -from django.core.cache import cache from django.db.models import Count import bio.flags @@ -92,14 +91,14 @@ try: name = bio.flags.FLAG_DATA[code] except KeyError: - code = 'zz' - name = '' + src = None + else: + n = '24' if size == 'small' else '64' + src = "flags/{n}/{code}.png".format(n=n, code=code) return { - 'code': code, + 'src': src, 'name': name, - 'size': size, - 'STATIC_URL': settings.STATIC_URL, } @@ -111,9 +110,10 @@ annotate(count=Count('country')).order_by('country') for rec in flag_data: - rec['name'] = bio.flags.FLAG_DATA[rec['country']] + country = rec['country'] + rec['name'] = bio.flags.FLAG_DATA[country] + rec['src'] = "flags/24/{}.png".format(country) return { 'flag_data': flag_data, - 'STATIC_URL': settings.STATIC_URL, }
--- a/bio/templatetags/elsewhere_tags.py Sat Nov 28 22:16:29 2015 -0600 +++ b/bio/templatetags/elsewhere_tags.py Tue Dec 01 20:58:31 2015 -0600 @@ -2,7 +2,6 @@ Template tags for the elsewhere application. """ from django import template -from django.conf import settings register = template.Library() @@ -13,5 +12,4 @@ 'social_nets': user.social_network_profiles.all(), 'ims': user.instant_messenger_profiles.all(), 'websites': user.website_profiles.all(), - 'STATIC_URL': settings.STATIC_URL, }
--- a/comments/templatetags/comment_tags.py Sat Nov 28 22:16:29 2015 -0600 +++ b/comments/templatetags/comment_tags.py Tue Dec 01 20:58:31 2015 -0600 @@ -8,7 +8,6 @@ {% render_comment_list [object] %} """ from django import template -from django.conf import settings from django.template.loader import render_to_string from comments.models import Comment @@ -163,6 +162,5 @@ qs = Comment.objects.for_object(object).select_related('user', 'user__profile') return { 'comments': qs, - 'STATIC_URL': settings.STATIC_URL, }
--- a/core/templatetags/core_tags.py Sat Nov 28 22:16:29 2015 -0600 +++ b/core/templatetags/core_tags.py Tue Dec 01 20:58:31 2015 -0600 @@ -21,21 +21,15 @@ register = template.Library() -ICON_PARAMS = { - True: (settings.STATIC_URL + 'icons/accept.png', 'Yes'), - False: (settings.STATIC_URL + 'icons/delete.png', 'No'), -} -@register.simple_tag +@register.inclusion_tag('core/bool_icon.html') def bool_icon(flag): - params = ICON_PARAMS[bool(flag)] - return u"""<img src="%s" alt="%s" title="%s" />""" % ( - params[0], params[1], params[1]) + return {'flag': flag} @register.inclusion_tag('core/comment_dialogs.html') def comment_dialogs(): - return {'STATIC_URL': settings.STATIC_URL} + return {} @register.inclusion_tag('core/max_users_tag.html') @@ -79,7 +73,6 @@ return { 'title': title, 'url': url, - 'STATIC_URL': settings.STATIC_URL, } @@ -182,7 +175,6 @@ birthdays.sort(key=lambda b: b.day) return { - 'STATIC_URL': settings.STATIC_URL, 'birthdays': birthdays, 'today': today, }
--- a/core/templatetags/script_tags.py Sat Nov 28 22:16:29 2015 -0600 +++ b/core/templatetags/script_tags.py Tue Dec 01 20:58:31 2015 -0600 @@ -6,22 +6,22 @@ register = template.Library() -@register.simple_tag +@register.inclusion_tag('core/script_tags.html') def script_tags(libraries): - s = '' + css = [] + js = [] for library in libraries.split(): if library in settings.GPP_THIRD_PARTY_CSS: for path in settings.GPP_THIRD_PARTY_CSS[library]: - prefix = '' - if not path.startswith('http'): - prefix = settings.STATIC_URL - s += '<link rel="stylesheet" href="%s%s" />' % (prefix, path) + local = not path.startswith('http') + css.append((local, path)) if library in settings.GPP_THIRD_PARTY_JS: for path in settings.GPP_THIRD_PARTY_JS[library]: - prefix = '' - if not path.startswith('http'): - prefix = settings.STATIC_URL - s += '<script src="%s%s"></script>' % (prefix, path) + local = not path.startswith('http') + js.append((local, path)) - return s + return { + 'css_sources': css, + 'js_sources': js, + }
--- a/forums/templatetags/forum_tags.py Sat Nov 28 22:16:29 2015 -0600 +++ b/forums/templatetags/forum_tags.py Tue Dec 01 20:58:31 2015 -0600 @@ -37,7 +37,6 @@ def last_post_info(context, post): return { 'post': post, - 'STATIC_URL': context['STATIC_URL'], 'user': context['user'], } @@ -53,7 +52,6 @@ return { 'post': post, 'show_button': show_button, - 'STATIC_URL': settings.STATIC_URL, } @@ -122,7 +120,6 @@ 'form': form, 'submit_value': submit_value, 'is_ajax': is_ajax, - 'STATIC_URL': settings.STATIC_URL, } @@ -155,7 +152,6 @@ """Displays the "unread", "sticky", and "locked" icons for a given topic.""" return { 'topic': topic, - 'STATIC_URL': settings.STATIC_URL, } @@ -194,4 +190,4 @@ if subtitle: nav_list.append(dict(name=subtitle, url=None)) - return dict(nav_list=nav_list, STATIC_URL=settings.STATIC_URL) + return dict(nav_list=nav_list)
--- a/news/templatetags/news_tags.py Sat Nov 28 22:16:29 2015 -0600 +++ b/news/templatetags/news_tags.py Tue Dec 01 20:58:31 2015 -0600 @@ -4,7 +4,6 @@ import datetime from django import template -from django.conf import settings from news.models import Story from news.utils import attach_extra_attrs @@ -26,6 +25,5 @@ return { 'stories': stories, - 'STATIC_URL': settings.STATIC_URL, 'on_home': True, }
--- a/sg101/templates/bio/elsewhere_links.html Sat Nov 28 22:16:29 2015 -0600 +++ b/sg101/templates/bio/elsewhere_links.html Tue Dec 01 20:58:31 2015 -0600 @@ -1,15 +1,20 @@ +{% load static from staticfiles %} {% if social_nets or ims or websites %} <ul class="icon-list"> {% for net in social_nets %} - <li><img src="{{ STATIC_URL }}elsewhere/{{ net.icon_name }}" alt="{{ net.name }}" /> + {% with 'elsewhere/'|add:net.icon_name as src %} + <li><img src="{% static src %}" alt="{{ net.name }}" /> <a href="{{ net.url }}">{{ net.name }}</a></li> + {% endwith %} {% endfor %} {% for im in ims %} - <li><img src="{{ STATIC_URL }}elsewhere/{{ im.icon_name }}" alt="{{ im.name }}" /> + {% with 'elsewhere/'|add:im.icon_name as src %} + <li><img src="{% static src %}" alt="{{ im.name }}" /> <a href="{{ im.url }}">{{ im.name }}</a></li> + {% endwith %} {% endfor %} {% for site in websites %} - <li><img src="{{ STATIC_URL }}icons/world.png" alt="{{ site.name }}" /> + <li><img src="{% static 'icons/world.png' %}" alt="{{ site.name }}" /> <a href="{{ site.url }}">{{ site.name }}</a></li> {% endfor %} </ul>
--- a/sg101/templates/bio/flag_icon.html Sat Nov 28 22:16:29 2015 -0600 +++ b/sg101/templates/bio/flag_icon.html Tue Dec 01 20:58:31 2015 -0600 @@ -1,10 +1,6 @@ -{% if code != 'zz' %} - {% if size == 'large' %} - <div class="flag"> - <img src="{{ STATIC_URL }}flags/64/{{ code }}.png" alt="{{ name }}" title="{{ name }}" /> - {{ name }} - </div> - {% else %} - <img src="{{ STATIC_URL }}flags/24/{{ code }}.png" alt="{{ name }}" title="{{ name }}" /> - {% endif %} +{% load static from staticfiles %} +{% if src %} + <div class="flag"> + <img src="{% static src %}" alt="{{ name }}" title="{{ name }}" /> {{ name }} + </div> {% endif %}
--- a/sg101/templates/bio/member_flags_tag.html Sat Nov 28 22:16:29 2015 -0600 +++ b/sg101/templates/bio/member_flags_tag.html Tue Dec 01 20:58:31 2015 -0600 @@ -1,7 +1,8 @@ +{% load static from staticfiles %} {% if flag_data %} <div> {% for rec in flag_data %} - <img src="{{ STATIC_URL }}flags/24/{{ rec.country }}.png" + <img src="{% static rec.src %}" alt="{{ rec.name }}" title="{{ rec.count }} {{ rec.name }}" /> {% endfor %} </div>
--- a/sg101/templates/comments/comment.html Sat Nov 28 22:16:29 2015 -0600 +++ b/sg101/templates/comments/comment.html Tue Dec 01 20:58:31 2015 -0600 @@ -1,3 +1,4 @@ +{% load static from staticfiles %} {% load bio_tags %} <div class="comment" id="c{{ comment.id }}"> <div class="comment-list">{{ forloop.counter }}.</div> @@ -15,7 +16,7 @@ {% if not comment.is_removed %} | <a href="#" class="comment-flag" id="fc-{{ comment.id }}" title="Flag this comment as spam, abuse, or a violation of site rules."> - <img src="{{ STATIC_URL }}icons/flag_red.png" alt="Flag" /></a> + <img src="{% static "icons/flag_red.png" %}" alt="Flag" /></a> {% endif %} </div> </div>
--- a/sg101/templates/core/birthday_block.html Sat Nov 28 22:16:29 2015 -0600 +++ b/sg101/templates/core/birthday_block.html Tue Dec 01 20:58:31 2015 -0600 @@ -1,7 +1,8 @@ {% extends 'side_block.html' %} {% load bio_tags %} {% load humanize %} -{% block block_title %}<img src="{{ STATIC_URL }}icons/cake.png" alt="Cake" class="middle" /> {{ today|date:"F" }} Birthdays <img src="{{ STATIC_URL }}icons/cake.png" alt="Cake" class="middle" /> {% endblock %} +{% load static from staticfiles %} +{% block block_title %}<img src="{% static "icons/cake.png" %}" alt="Cake" class="middle" /> {{ today|date:"F" }} Birthdays <img src="{% static "icons/cake.png" %}" alt="Cake" class="middle" />{% endblock %} {% block block_content %} {% if birthdays %} <ul class="no-bullet">
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sg101/templates/core/bool_icon.html Tue Dec 01 20:58:31 2015 -0600 @@ -0,0 +1,6 @@ +{% load static from staticfiles %} +{% if flag %} +<img src="{% static "icons/accept.png" %}" alt="Yes" title="Yes" /> +{% else %} +<img src="{% static "icons/delete.png" %}" alt="No" title="No" /> +{% endif %}
--- a/sg101/templates/core/comment_dialogs.html Sat Nov 28 22:16:29 2015 -0600 +++ b/sg101/templates/core/comment_dialogs.html Tue Dec 01 20:58:31 2015 -0600 @@ -1,10 +1,11 @@ +{% load static from staticfiles %} <a href="#" id="more_smileys_link"> -<img src="{{ STATIC_URL }}icons/emoticon_smile.png" alt="More smileys" title="More smileys" /></a> +<img src="{% static "icons/emoticon_smile.png" %}" alt="More smileys" title="More smileys" /></a> <a href="#" id="markdown_help_link"> -<img src="{{ STATIC_URL }}icons/help.png" alt="Help" title="Help" /></a> +<img src="{% static "icons/help.png" %}" alt="Help" title="Help" /></a> <div id="smileys_dialog_popup" title="More Smileys"> -<img src="{{ STATIC_URL }}icons/ajax_busy.gif" alt="Loading" id="smiley_busy" /> +<img src="{% static "icons/ajax_busy.gif" %}" alt="Loading" id="smiley_busy" /> </div> <div id="markdown_help_dialog_popup" title="Markdown Help"> -<img src="{{ STATIC_URL }}icons/ajax_busy.gif" alt="Loading" id="markdown_busy" /> +<img src="{% static "icons/ajax_busy.gif" %}" alt="Loading" id="markdown_busy" /> </div>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sg101/templates/core/script_tags.html Tue Dec 01 20:58:31 2015 -0600 @@ -0,0 +1,17 @@ +{% load static from staticfiles %} +<!-- begin script tags --> +{% for local, src in css_sources %} +{% if local %} +<link rel="stylesheet" href="{% static src %}" /> +{% else %} +<link rel="stylesheet" href="{{ src }}" /> +{% endif %} +{% endfor %} +{% for local, src in js_sources %} +{% if local %} +<script src="{% static src %}"></script> +{% else %} +<script src="{{ src }}"></script> +{% endif %} +{% endfor %} +<!-- end script tags -->
--- a/sg101/templates/core/social_sharing_tag.html Sat Nov 28 22:16:29 2015 -0600 +++ b/sg101/templates/core/social_sharing_tag.html Tue Dec 01 20:58:31 2015 -0600 @@ -1,13 +1,14 @@ +{% load static from staticfiles %} <div class="social-sharing"> <ul class="no-bullet-inline-block"> <li style="vertical-align:top; margin-right:1.5em"> -<a href="https://twitter.com/intent/tweet?text={{ title|urlencode }}&url={{ url|urlencode }}&via=SurfGuitar101"><img src="{{ STATIC_URL }}icons/button-twitter.png" alt="Tweet"/></a> +<a href="https://twitter.com/intent/tweet?text={{ title|urlencode }}&url={{ url|urlencode }}&via=SurfGuitar101"><img src="{% static "icons/button-twitter.png" %}" alt="Tweet"/></a> </li> <li style="vertical-align:top; margin-right:1.5em"> -<a href="https://plus.google.com/share?url={{ url|urlencode }}"><img src="{{ STATIC_URL }}icons/button-googleplus.png" alt="Share on Google Plus"/></a> +<a href="https://plus.google.com/share?url={{ url|urlencode }}"><img src="{% static "icons/button-googleplus.png" %}" alt="Share on Google Plus"/></a> </li> <li style="vertical-align:top"> -<a href="https://www.facebook.com/sharer/sharer.php?u={{ url|urlencode }}"><img src="{{ STATIC_URL }}icons/button-facebook.png" alt="Share on Facebook"/></a> +<a href="https://www.facebook.com/sharer/sharer.php?u={{ url|urlencode }}"><img src="{% static "icons/button-facebook.png" %}" alt="Share on Facebook"/></a> </li> </ul> </div>
--- a/sg101/templates/forums/last_post_info.html Sat Nov 28 22:16:29 2015 -0600 +++ b/sg101/templates/forums/last_post_info.html Tue Dec 01 20:58:31 2015 -0600 @@ -1,7 +1,8 @@ {% load bio_tags %} {% load forum_tags %} +{% load static from staticfiles %} {% if post %} -<a href="{{ post.get_absolute_url }}" title="Goto last post"><img src="{{ STATIC_URL }}icons/note_go.png" alt="Goto last post" /></a> +<a href="{{ post.get_absolute_url }}" title="Goto last post"><img src="{% static "icons/note_go.png" %}" alt="Goto last post" /></a> <a href="{{ post.get_absolute_url }}" title="Goto last post">{% forum_date post.creation_date user %}</a><br /> {% profile_link post.user.username %} {% else %}
--- a/sg101/templates/forums/navigation_tag.html Sat Nov 28 22:16:29 2015 -0600 +++ b/sg101/templates/forums/navigation_tag.html Tue Dec 01 20:58:31 2015 -0600 @@ -1,10 +1,11 @@ +{% load static from staticfiles %} <a class="intra" name="top"></a> <h2 class="forum-nav"><a href="{% url 'forums-index' %}">SurfGuitar101 Forums</a> » {% for nav_item in nav_list %} {% if not forloop.last %} <a href="{{ nav_item.url }}">{{ nav_item.name }}</a> » {% else %} - </h2><h3 class="forum-nav">{% if nav_item.url %}<a href="{{ nav_item.url }}" title="Permalink"><img src="{{ STATIC_URL }}icons/link.png" alt="Permalink" /></a>{% endif %} {{ nav_item.name }}</h3> +</h2><h3 class="forum-nav">{% if nav_item.url %}<a href="{{ nav_item.url }}" title="Permalink"><img src="{% static "icons/link.png" %}" alt="Permalink" /></a>{% endif %} {{ nav_item.name }}</h3> {% endif %} {% empty %} </h2>
--- a/sg101/templates/forums/post_edit_button.html Sat Nov 28 22:16:29 2015 -0600 +++ b/sg101/templates/forums/post_edit_button.html Tue Dec 01 20:58:31 2015 -0600 @@ -1,3 +1,4 @@ +{% load static from staticfiles %} {% if show_button %} -<a href="{% url 'forums-edit_post' id=post.id %}"><img src="{{ STATIC_URL }}icons/page_edit.png" alt="Edit post" title="Edit post" /></a> +<a href="{% url 'forums-edit_post' id=post.id %}"><img src="{% static "icons/page_edit.png" %}" alt="Edit post" title="Edit post" /></a> {% endif %}
--- a/sg101/templates/forums/show_form.html Sat Nov 28 22:16:29 2015 -0600 +++ b/sg101/templates/forums/show_form.html Tue Dec 01 20:58:31 2015 -0600 @@ -1,3 +1,4 @@ +{% load static from staticfiles %} {% load core_tags %} <form action="." method="post" id="forums_post_form">{% csrf_token %} <fieldset> @@ -10,7 +11,7 @@ <div id="topic_search_results"> </div> <div id="topic-search-results"> -<img id="search-busy-icon" src="{{ STATIC_URL }}icons/ajax_busy.gif" alt="Please wait" style="display:none;"/> +<img id="search-busy-icon" src="{% static "icons/ajax_busy.gif" %}" alt="Please wait" style="display:none;"/> </div> </p> <p>{{ form.body.errors }}{{ form.body }}</p>
--- a/sg101/templates/forums/topic_icons_tag.html Sat Nov 28 22:16:29 2015 -0600 +++ b/sg101/templates/forums/topic_icons_tag.html Tue Dec 01 20:58:31 2015 -0600 @@ -1,4 +1,5 @@ -{% if topic.has_unread %}<a href="{% url 'forums-topic_unread' id=topic.id %}"><img src="{{ STATIC_URL }}icons/new.png" alt="New Posts" title="New Posts" class="forums-topic-icon" /></a>{% endif %} -{% if topic.sticky %}<img src="{{ STATIC_URL }}icons/asterisk_orange.png" alt="Sticky" title="Sticky" class="forums-topic-icon" />{% endif %} -{% if topic.locked %}<img src="{{ STATIC_URL }}icons/lock.png" alt="Locked" title="Locked" +{% load static from staticfiles %} +{% if topic.has_unread %}<a href="{% url 'forums-topic_unread' id=topic.id %}"><img src="{% static "icons/new.png" %}" alt="New Posts" title="New Posts" class="forums-topic-icon" /></a>{% endif %} +{% if topic.sticky %}<img src="{% static "icons/asterisk_orange.png" %}" alt="Sticky" title="Sticky" class="forums-topic-icon" />{% endif %} +{% if topic.locked %}<img src="{% static "icons/lock.png" %}" alt="Locked" title="Locked" class="forums-topic-icon" />{% endif %}
--- a/sg101/templates/news/story_summary.html Sat Nov 28 22:16:29 2015 -0600 +++ b/sg101/templates/news/story_summary.html Tue Dec 01 20:58:31 2015 -0600 @@ -1,3 +1,4 @@ +{% load static from staticfiles %} {% load tagging_tags %} {% load bio_tags %} {% load comment_tags %} @@ -22,14 +23,14 @@ {% endif %} {% if story.long_text %} <p> -<img src="{{ STATIC_URL }}icons/bullet_go.png" alt="Read More" /> +<img src="{% static "icons/bullet_go.png" %}" alt="Read More" /> <a href="{{ story.get_absolute_url }}">There is more to this story, continue reading ...</a> </p> {% endif %} <hr /> <p> Category: <a href="{% url 'news-category' slug=story.category.slug %}">{{ story.category.title }}</a> -<img src="{{ STATIC_URL }}icons/comments.png" alt="Comments" title="Comments" /> +<img src="{% static "icons/comments.png" %}" alt="Comments" title="Comments" /> {% if story.version == 0 %} <a href="{{ story.get_absolute_url }}">{{ story.comment_count }} comment{{ story.comment_count|pluralize }}</a> {% else %} @@ -39,15 +40,15 @@ <em>Comments are disabled</em> {% endif %} {% endif %} -<a href="{{ story.get_absolute_url }}"><img src="{{ STATIC_URL }}icons/link.png" alt="Permalink" title="Permalink" /></a> +<a href="{{ story.get_absolute_url }}"><img src="{% static "icons/link.png" %}" alt="Permalink" title="Permalink" /></a> {% if user.is_authenticated %} -<a href="{% url 'news.views.email_story' story.id %}"><img src="{{ STATIC_URL }}icons/email_go.png" +<a href="{% url 'news.views.email_story' story.id %}"><img src="{% static "icons/email_go.png" %}" alt="Send this story to a friend" title="Send this story to a friend" /></a> {% endif %} </p> {% if story.tag_list %} <div class="news-tags"> - <img src="{{ STATIC_URL }}icons/tag_blue.png" alt="Tags" title="Tags" /> Tags: + <img src="{% static "icons/tag_blue.png" %}" alt="Tags" title="Tags" /> Tags: <ul> {% for tag in story.tag_list %} <li><a href="{% url 'news-tag_page' tag_name=tag %}">{{ tag }}</a></li>
--- a/sg101/templates/shoutbox/shoutbox.html Sat Nov 28 22:16:29 2015 -0600 +++ b/sg101/templates/shoutbox/shoutbox.html Tue Dec 01 20:58:31 2015 -0600 @@ -1,5 +1,6 @@ {% extends 'side_block.html' %} {% load core_tags %} +{% load static from staticfiles %} {% block block_title %}Shoutbox{% endblock %} {% block block_content %} <div id="shoutbox-shout-container"> @@ -26,7 +27,7 @@ <input id="shoutbox-smilies" type="button" value="Smilies" /> </form> <div id="shoutbox-smiley-frame" style="display:none;"> -<img id="shoutbox-busy-icon" src="{{ STATIC_URL }}icons/ajax_busy.gif" alt="Please wait" /> +<img id="shoutbox-busy-icon" src="{% static "icons/ajax_busy.gif" %}" alt="Please wait" /> </div> </div> {% else %}