Skip to content
Snippets Groups Projects
Unverified Commit e49d4a59 authored by Nik | Klampfradler's avatar Nik | Klampfradler
Browse files

Initial commit.

parents
No related branches found
No related tags found
No related merge requests found
root = true
[*]
charset = utf-8
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true
[*.py]
indent_style = space
indent_size = 4
[*.html]
file_type_emacs = jinja2
indent_style = space
indent_size = 2
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class
# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
*.egg-info/
.installed.cfg
*.egg
# Installer logs
pip-log.txt
pip-delete-this-directory.txt
# Translations
*.mo
*.pot
# Django stuff:
*.log
local_settings.py
# pyenv
.python-version
# Environments
.env
.venv
env/
venv/
ENV/
# Editors
*~
DEADJOE
\#*#
# Database
db.sqlite3
LICENCE 0 → 100644
Copyright (c) 2019 Dominik George <nik@naturalnet.de>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
include LICENCE
recursive-include django_any_js/templates *
Django Any-JS
=============
Description
-----------
Django-Any-JS helps you at including any combination of JavaScript/CSS
URLs in your site, with readable settings and template tags.
Usage
-----
In your settings:
::
ANY_JS = {
'DataTables': {
'js_url': '/javascript/jquery-datatables/dataTables.bootstrap4.min.js',
'css_url': '/javascript/jquery-datatables/css/dataTables.bootstrap4.min.css'
}
}
In your template:
::
{% include_js "DataTables" %}
{% include_css "DataTables" %}
from django.apps import AppConfig
class DjangoAnyJSConfig(AppConfig):
name = 'django_any_js'
<link rel="stylesheet" type="text/css" href="{{ css_url }}" />
<script type="text/javascript" src="{{ js_url }}"></script>
from django import template
from django.conf import settings
from django.template import loader, Context
register = template.Library()
@register.simple_tag
def include_js(name):
js_url = settings.ANY_JS['name']['js_url']
template = loader.get_template('django_any_js/js.html')
context = Context({'js_url': js_url})
return template.render(context)
@register.simple_tag
def include_css(name):
css_url = settings.ANY_JS['name']['css_url']
template = loader.get_template('django_any_js/css.html')
context = Context({'css_url': css_url})
return template.render(context)
setup.py 0 → 100644
import os
from setuptools import setup
MYDIR = os.path.dirname(__file__)
setup(
name='django-any-js',
version='1.0',
keywords=['django', 'javascript'],
description='Include JavaScript libraries with readable template tags',
long_description=open(os.path.join(MYDIR, "README.rst"),
"r", encoding="utf-8").read(),
url='https://edugit.org/nik/django-any-js',
author='Dominik George',
author_email='nik@naturalnet.de',
packages=['django_any_js'],
include_package_data=True,
install_requires=['Django>=1.11'],
classifiers=[
'Environment :: Web Environment',
'Framework :: Django',
'Framework :: Django :: 1.11',
'Framework :: Django :: 2.0',
'Framework :: Django :: 2.1',
'Framework :: Django :: 2.2',
'License :: OSI Approved :: MIT License',
'Operating System :: OS Independent',
'Programming Language :: Python',
'Programming Language :: Python :: 3',
'Topic :: Internet :: WWW/HTTP',
'Topic :: Internet :: WWW/HTTP :: Dynamic Content',
],
)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment