Commit 6629c87a authored by Dylann Cordel's avatar Dylann Cordel

wip

parents
*.pyc
*.egg-info
.sass-cache
Current or previous core committers:
* Dylann Cordel <d.cordel@webu.coop>
django-cms-graphviz
Copyright (C) 2017 Webu
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
include AUTHORS
include LICENSE
include README.rst
recursive-include cms_graphviz/templates *
###########################
django CMS Graphviz Plugin
###########################
This package provides graphivz plugins for django CMS
(content management system based on the django framework).
********
Features
********
Plugins allow you to add a SVG/PNG or DOT graph format in your page.
*************
Documentation
*************
In settings.py add ``cms_graphviz`` to ``INSTALLED_APPS``.
Then, configure your CMS placeholders to allow wanted plugins.
*******
Credits
*******
* Uses pygraphviz <http://pygraphviz.github.io>
# -*- coding: utf-8 -*-
__version__ = '0.0.0'
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.utils.translation import ugettext_lazy as _
from cms.plugin_pool import plugin_pool
from cms.plugin_base import CMSPluginBase
from django.conf import settings
from cms_graphviz.forms import GraphvizForm
from cms_graphviz.models import GraphvizPlugin as GraphvizPluginModel
class GraphvizPluginPlugin(CMSPluginBase):
form = GraphvizForm
model = GraphvizPluginModel
text_enabled = False
name = _('Graph')
render_template = 'cms_graphviz/plugin.html'
def render(self, context, instance, placeholder):
graph = ''
context['graph'] = graph
return context
plugin_pool.register_plugin(GraphvizPluginPlugin)
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django import forms
from django.conf import settings
from cms_graphviz.models import GraphvizPlugin
class GraphvizForm(forms.ModelForm):
class Meta:
model = GraphvizPlugin
exclude = []
def __init__(self, *args, **kwargs):
super(GraphvizPlugin, self).__init__(*args, **kwargs)
choices = settings.CMS_GRAPHVIZ_STYLES
if choices:
self.fields['style'].widget = forms.Select(choices=choices)
else:
self.fields['style'].widget = forms.HiddenInput()
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import models
from cms.models.pluginmodel import CMSPlugin
from django.utils.translation import ugettext_lazy as _
class GraphvizPlugin(CMSPlugin):
DISPLAY_TYPE_SVG = 'svg'
DISPLAY_TYPE_PNG = 'png'
DISPLAY_TYPE_IMG_URL = 'url'
DISPLAY_TYPE_CHOICES = (
(DISPLAY_TYPE_SVG, _('Image SVG')),
(DISPLAY_TYPE_PNG, _('Image PNG en base 64')),
(DISPLAY_TYPE_IMG_URL, _('Image PNG stockée sur le serveur')),
)
class Meta:
verbose_name = _('graph')
verbose_name_plural = _('graphics')
name = models.CharField(
verbose_name=_('name'),
max_length=100,
null=False, blank=True,)
graph_dot = models.TextField(
verbose_name=_('DOT graph'),
null=False, blank=False,)
display_type = models.CharField(
verbose_name=_('display type'),
max_length=3,
default=DISPLAY_TYPE_SVG,
choices=DISPLAY_TYPE_CHOICES,
null=False, blank=False,)
style = models.CharField(
verbose_name=_('style'),
max_length=100,
null=True, blank=True,)
<div class="graphviz">
{% if instance.display_type == instance.DISPLAY_TYPE_SVG %}
{{ graph|safe }}
{% elif instance.display_type == instance.DISPLAY_TYPE_IMG_URL %}
<img src="{{ graph }}" alt="{{ instance.name }}" />
{% elif instance.display_type == instance.DISPLAY_TYPE_PNG %}
<img src="data:image/png;base64,{{ graph }}" alt="{{ instance.name }}" />
{% else %}
<pre class="dot">{{ graph }}</pre>
{% endif %}
</div>
from setuptools import setup, find_packages
import os
import cms_graphviz
CLASSIFIERS = [
'Development Status :: 5 - Production/Stable',
'Environment :: Web Environment',
'Framework :: Django',
'Intended Audience :: Developers',
'License :: OSI Approved :: GNU Affero General Public License v3 or later (AGPLv3+)',
'Operating System :: OS Independent',
'Programming Language :: Python',
'Topic :: Internet :: WWW/HTTP :: Dynamic Content',
'Topic :: Software Development',
'Topic :: Software Development :: Libraries :: Application Frameworks',
"Programming Language :: Python :: 2.6",
"Programming Language :: Python :: 2.7",
"Programming Language :: Python :: 3.3",
]
setup(
author="Webu",
author_email="d.cordel@webu.coop",
name='django-cms-graphviz',
version=cms_graphviz.__version__,
description='A Django CMS plugin providing graphviz support',
long_description=open(os.path.join(os.path.dirname(__file__), 'README.rst')).read(),
url='https://dev.webu.coop/shared/django-cms-graphviz',
license='AGPLv3+',
platforms=['OS Independent'],
classifiers=CLASSIFIERS,
install_requires=[
'Django>=1.8,<1.10',
'django-cms>=3.2,<4.0',
'pygraphviz'
],
packages=find_packages(exclude=["project", "project.*"]),
include_package_data=True,
)
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