mirror of
https://github.com/DarrenOfficial/dpaste.git
synced 2024-11-23 03:46:37 +11:00
Removed inline tag in favor of a separate app.
This commit is contained in:
parent
296c778bbd
commit
c685f6a5ac
5 changed files with 7 additions and 59 deletions
|
@ -117,6 +117,7 @@ TEMPLATES = [
|
|||
]
|
||||
|
||||
INSTALLED_APPS = (
|
||||
'staticinline',
|
||||
'django.contrib.staticfiles',
|
||||
'django.contrib.sessions',
|
||||
'dpaste.apps.dpasteAppConfig',
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{% load i18n %}
|
||||
{% load staticfiles %}
|
||||
{% load dpaste_tags %}
|
||||
{% load staticinline %}
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
|
@ -8,7 +8,7 @@
|
|||
<title>{% block title %}{% endblock %}</title>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
|
||||
{% block meta %}<meta name="robots" content="noindex, nofollow"/>{% endblock %}
|
||||
<style type="text/css">{% inlinestatic "dpaste.css" %}</style>
|
||||
<style type="text/css">{% staticinline "dpaste.css" %}</style>
|
||||
</head>
|
||||
<body {% block body_type %}{%endblock %}>
|
||||
|
||||
|
@ -25,6 +25,6 @@
|
|||
|
||||
<main>{% block page %}{% endblock %}</main>
|
||||
|
||||
<script>{% inlinestatic "dpaste.js" %}</script>
|
||||
<script>{% staticinline "dpaste.js" %}</script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -1,54 +0,0 @@
|
|||
import os
|
||||
from logging import getLogger
|
||||
|
||||
from django.conf import settings
|
||||
from django.contrib.staticfiles.finders import find
|
||||
from django.template.defaulttags import register
|
||||
from django.utils.safestring import mark_safe
|
||||
from django.contrib.staticfiles.storage import staticfiles_storage
|
||||
|
||||
logger = getLogger(__file__)
|
||||
|
||||
|
||||
@register.simple_tag()
|
||||
def inlinestatic(path):
|
||||
"""
|
||||
Similiar to Django's native `static` templatetag, but this includes
|
||||
the file directly in the template, rather than a link to it.
|
||||
|
||||
Example:
|
||||
|
||||
<style type="text/css">{% inlinestatic "dpaste.css" %}</style>
|
||||
<script>{% inlinestatic "dpaste.js" %}</script>
|
||||
|
||||
Becomes:
|
||||
|
||||
<style type="text/css">body{ color: red; }</style>
|
||||
<script>alert("Hello World");</script>
|
||||
|
||||
Raises a ValueError if the the file does not exist, and
|
||||
DEBUG is enabled.
|
||||
|
||||
:param path: (string) Filename of the file to include.
|
||||
:return: (string) The included File or an empty string `''` if the
|
||||
file was not found, and DEBUG is disabled.
|
||||
"""
|
||||
# Filename in build/ directory (when in Watch mode)
|
||||
filename = find(path)
|
||||
|
||||
# File in collectstatic target directory (regular deployment)
|
||||
if not filename:
|
||||
if staticfiles_storage.exists(path):
|
||||
filename = staticfiles_storage.path(path)
|
||||
|
||||
# If it wasn't found, raise an error if in DEBUG mode.
|
||||
if not filename or not os.path.exists(filename):
|
||||
logger.error('Unable to include inline static file "%s", '
|
||||
'file not found.', filename)
|
||||
if settings.DEBUG:
|
||||
raise ValueError('Unable to include inline static file "{0}", '
|
||||
'file not found.'.format(filename))
|
||||
return ''
|
||||
|
||||
return mark_safe(open(filename).read())
|
||||
|
5
setup.py
5
setup.py
|
@ -4,12 +4,12 @@ from setuptools import find_packages, setup
|
|||
|
||||
long_description = '\n\n'.join((
|
||||
open('README.rst').read(),
|
||||
open('CHANGELOG').read()
|
||||
open('CHANGELOG.rst').read()
|
||||
))
|
||||
|
||||
setup(
|
||||
name='dpaste',
|
||||
version='3.0a3',
|
||||
version='3.0a4',
|
||||
description='dpaste is a Django based pastebin. It\'s intended to run '
|
||||
'separately but its also possible to be installed into an '
|
||||
'existing Django project like a regular app.',
|
||||
|
@ -36,6 +36,7 @@ setup(
|
|||
# Essential packages
|
||||
'django>=1.11',
|
||||
'pygments>=1.6',
|
||||
'django-staticinline>=1.0',
|
||||
|
||||
# Additional Code Lexer
|
||||
'pygments-lexer-solidity>=0.1.0',
|
||||
|
|
Loading…
Reference in a new issue