add townstreet button cell
This commit is contained in:
parent
cb5fa09166
commit
cb16529ea0
|
@ -0,0 +1,4 @@
|
|||
*.egg-info
|
||||
__pycache__
|
||||
*.css
|
||||
*.css.map
|
|
@ -0,0 +1,8 @@
|
|||
include MANIFEST.in
|
||||
include COPYING
|
||||
include README
|
||||
include VERSION
|
||||
|
||||
recursive-include combo_plugin_imio_townstreet/locale *.po *.mo
|
||||
recursive-include combo_plugin_imio_townstreet/templates *.html
|
||||
recursive-include combo_plugin_imio_townstreet/static *.css *.scss *.js *.svg *.png *.jpg
|
|
@ -0,0 +1,26 @@
|
|||
# combo-plugin-imio-townstreet - Combo iMio town street plugin
|
||||
# Copyright (C) 2021 Entr'ouvert
|
||||
#
|
||||
# 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/>.
|
||||
|
||||
import django.apps
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
|
||||
class AppConfig(django.apps.AppConfig):
|
||||
name = __name__
|
||||
verbose_name = _('iMio Townstreet')
|
||||
|
||||
|
||||
default_app_config = __name__ + '.AppConfig'
|
|
@ -0,0 +1,45 @@
|
|||
# Generated by Django 2.2.12 on 2021-02-19 13:28
|
||||
|
||||
from django.db import migrations, models
|
||||
import django.db.models.deletion
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
initial = True
|
||||
|
||||
dependencies = [
|
||||
('data', '0045_link_list_limit'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name='TownstreetButton',
|
||||
fields=[
|
||||
(
|
||||
'id',
|
||||
models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID'),
|
||||
),
|
||||
('placeholder', models.CharField(max_length=20)),
|
||||
('order', models.PositiveIntegerField()),
|
||||
('slug', models.SlugField(blank=True, verbose_name='Slug')),
|
||||
(
|
||||
'extra_css_class',
|
||||
models.CharField(
|
||||
blank=True, max_length=100, verbose_name='Extra classes for CSS styling'
|
||||
),
|
||||
),
|
||||
('public', models.BooleanField(default=True, verbose_name='Public')),
|
||||
(
|
||||
'restricted_to_unlogged',
|
||||
models.BooleanField(default=False, verbose_name='Restrict to unlogged users'),
|
||||
),
|
||||
('last_update_timestamp', models.DateTimeField(auto_now=True)),
|
||||
('groups', models.ManyToManyField(blank=True, to='auth.Group', verbose_name='Groups')),
|
||||
('page', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='data.Page')),
|
||||
],
|
||||
options={
|
||||
'verbose_name': 'Townstreet Button',
|
||||
},
|
||||
),
|
||||
]
|
|
@ -0,0 +1,39 @@
|
|||
# combo-plugin-imio-townstreet - Combo iMio town street plugin
|
||||
# Copyright (C) 2021 Entr'ouvert
|
||||
#
|
||||
# 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/>.
|
||||
|
||||
from django.conf import settings
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
from combo.data.models import CellBase
|
||||
from combo.data.library import register_cell_class
|
||||
|
||||
|
||||
@register_cell_class
|
||||
class TownstreetButton(CellBase):
|
||||
template_name = 'imio_townstreet/button.html'
|
||||
|
||||
class Meta:
|
||||
verbose_name = _('Townstreet Button')
|
||||
|
||||
class Media:
|
||||
css = {
|
||||
'all': ('imio_townstreet/style.css',),
|
||||
}
|
||||
|
||||
def get_cell_extra_context(self, context):
|
||||
extra_context = super().get_cell_extra_context(context)
|
||||
extra_context['url'] = getattr(settings, 'TOWNSTREET_BUTTON_URL', '#')
|
||||
return extra_context
|
|
@ -0,0 +1,74 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<svg:svg
|
||||
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
||||
xmlns:cc="http://creativecommons.org/ns#"
|
||||
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||
xmlns:svg="http://www.w3.org/2000/svg"
|
||||
data-iorad-extension="firefox"
|
||||
id="svg897"
|
||||
version="1.1"
|
||||
class="feather feather-map-pin"
|
||||
stroke-linejoin="round"
|
||||
stroke-linecap="round"
|
||||
stroke-width="2"
|
||||
stroke="currentColor"
|
||||
fill="none"
|
||||
viewBox="0 0 24 24"
|
||||
height="24"
|
||||
width="24"
|
||||
color="white">
|
||||
<script />
|
||||
<svg:metadata
|
||||
id="metadata903">
|
||||
<rdf:RDF>
|
||||
<cc:Work
|
||||
rdf:about="">
|
||||
<dc:format>image/svg+xml</dc:format>
|
||||
<dc:type
|
||||
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
|
||||
<dc:title></dc:title>
|
||||
</cc:Work>
|
||||
</rdf:RDF>
|
||||
</svg:metadata>
|
||||
<svg:defs
|
||||
id="defs901" />
|
||||
<svg:g
|
||||
transform="matrix(0.88382385,0,0,0.88382385,43.653256,29.977441)"
|
||||
id="g1487">
|
||||
<svg:polygon
|
||||
transform="matrix(0.64922775,0,0,0.64922775,-42.838374,-26.753477)"
|
||||
points="8,18 16,22 23,18 23,2 16,6 8,2 1,6 1,22 "
|
||||
id="polygon879"
|
||||
style="fill:#c9e661;fill-opacity:1" />
|
||||
<svg:line
|
||||
x1="-37.644554"
|
||||
y1="-25.455023"
|
||||
x2="-37.644554"
|
||||
y2="-15.067381"
|
||||
id="line881"
|
||||
style="fill:#008080;stroke-width:1.29845548" />
|
||||
<svg:line
|
||||
x1="-32.450726"
|
||||
y1="-22.858112"
|
||||
x2="-32.450726"
|
||||
y2="-12.470467"
|
||||
id="line883"
|
||||
style="fill:#008080;stroke-width:1.29845548" />
|
||||
</svg:g>
|
||||
<svg:g
|
||||
transform="matrix(0.43097766,0,0,0.43097766,-1.4815228,2.0167839)"
|
||||
id="g1482">
|
||||
<svg:path
|
||||
d="m 29.581822,11.89091 c 0,7 -9,13 -9,13 0,0 -9,-6 -9,-13 a 9,9 0 0 1 18,0 z"
|
||||
id="path893"
|
||||
style="fill:#7b6e70;fill-opacity:1" />
|
||||
<svg:circle
|
||||
cx="20.58182"
|
||||
cy="11.89091"
|
||||
r="3"
|
||||
id="circle895"
|
||||
style="fill:#7b6e70;fill-opacity:1" />
|
||||
</svg:g>
|
||||
<script />
|
||||
<script />
|
||||
</svg:svg>
|
After Width: | Height: | Size: 2.0 KiB |
|
@ -0,0 +1,18 @@
|
|||
div.cell.townstreet-button {
|
||||
a {
|
||||
text-decoration: none;
|
||||
div {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
justify-content: flex-start;
|
||||
align-items: center;
|
||||
width: 90%;
|
||||
background: #e40105;
|
||||
padding-left: 1em;
|
||||
border-radius: 5px;
|
||||
h4 {
|
||||
color: white;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
{% load static %}
|
||||
{% spaceless %}
|
||||
<a href="{{url}}">
|
||||
<div>
|
||||
<img src="{% static 'imio_townstreet/icon.svg' %}" alt="" width="48" height="48">
|
||||
<h4>Signaler un problème sur l’espace public</h4>
|
||||
</div>
|
||||
</a>
|
||||
{% endspaceless %}
|
|
@ -0,0 +1,152 @@
|
|||
#! /usr/bin/env python3
|
||||
|
||||
import os
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
from setuptools.command.install_lib import install_lib as _install_lib
|
||||
from distutils.command.build import build as _build
|
||||
from distutils.command.sdist import sdist
|
||||
from distutils.cmd import Command
|
||||
from distutils.errors import CompileError
|
||||
from distutils.spawn import find_executable
|
||||
from setuptools import setup, find_packages
|
||||
|
||||
|
||||
class eo_sdist(sdist):
|
||||
def run(self):
|
||||
if os.path.exists('VERSION'):
|
||||
os.remove('VERSION')
|
||||
version = get_version()
|
||||
with open('VERSION', 'w') as fd:
|
||||
fd.write(version)
|
||||
sdist.run(self)
|
||||
if os.path.exists('VERSION'):
|
||||
os.remove('VERSION')
|
||||
|
||||
|
||||
def get_version():
|
||||
if os.path.exists('VERSION'):
|
||||
with open('VERSION', 'r') as v:
|
||||
return v.read()
|
||||
if os.path.exists('.git'):
|
||||
p = subprocess.Popen(
|
||||
['git', 'describe', '--dirty=.dirty', '--match=v*'],
|
||||
stdout=subprocess.PIPE,
|
||||
stderr=subprocess.PIPE,
|
||||
)
|
||||
result = p.communicate()[0]
|
||||
if p.returncode == 0:
|
||||
result = result.decode('ascii').strip()[1:] # strip spaces/newlines and initial v
|
||||
if '-' in result: # not a tagged version
|
||||
real_number, commit_count, commit_hash = result.split('-', 2)
|
||||
version = '%s.post%s+%s' % (real_number, commit_count, commit_hash)
|
||||
else:
|
||||
version = result
|
||||
return version
|
||||
else:
|
||||
return '0.0.post%s' % len(subprocess.check_output(['git', 'rev-list', 'HEAD']).splitlines())
|
||||
return '0.0'
|
||||
|
||||
|
||||
class compile_translations(Command):
|
||||
description = 'compile message catalogs to MO files via django compilemessages'
|
||||
user_options = []
|
||||
|
||||
def initialize_options(self):
|
||||
pass
|
||||
|
||||
def finalize_options(self):
|
||||
pass
|
||||
|
||||
def run(self):
|
||||
try:
|
||||
from django.core.management import call_command
|
||||
|
||||
for path, dirs, files in os.walk('combo_plugin_imio_townstreet'):
|
||||
if 'locale' not in dirs:
|
||||
continue
|
||||
curdir = os.getcwd()
|
||||
os.chdir(os.path.realpath(path))
|
||||
call_command('compilemessages')
|
||||
os.chdir(curdir)
|
||||
except ImportError:
|
||||
sys.stderr.write('!!! Please install Django >= 1.4 to build translations\n')
|
||||
|
||||
|
||||
class compile_scss(Command):
|
||||
description = 'compile scss files into css files'
|
||||
user_options = []
|
||||
|
||||
def initialize_options(self):
|
||||
pass
|
||||
|
||||
def finalize_options(self):
|
||||
pass
|
||||
|
||||
def run(self):
|
||||
sass_bin = None
|
||||
for program in ('sassc', 'sass'):
|
||||
sass_bin = find_executable(program)
|
||||
if sass_bin:
|
||||
break
|
||||
if not sass_bin:
|
||||
raise CompileError(
|
||||
'A sass compiler is required but none was found. See sass-lang.com for choices.'
|
||||
)
|
||||
|
||||
for path, dirnames, filenames in os.walk('combo_plugin_imio_townstreet'):
|
||||
for filename in filenames:
|
||||
if not filename.endswith('.scss'):
|
||||
continue
|
||||
if filename.startswith('_'):
|
||||
continue
|
||||
subprocess.check_call(
|
||||
[
|
||||
sass_bin,
|
||||
'%s/%s' % (path, filename),
|
||||
'%s/%s' % (path, filename.replace('.scss', '.css')),
|
||||
]
|
||||
)
|
||||
|
||||
|
||||
class build(_build):
|
||||
sub_commands = [('compile_translations', None), ('compile_scss', None)] + _build.sub_commands
|
||||
|
||||
|
||||
class install_lib(_install_lib):
|
||||
def run(self):
|
||||
self.run_command('compile_translations')
|
||||
_install_lib.run(self)
|
||||
|
||||
|
||||
setup(
|
||||
name='combo_plugin_imio_townstreet',
|
||||
version=get_version(),
|
||||
description='Combo iMio townstreet plugin',
|
||||
author='Frederic Peters',
|
||||
author_email='fpeters@entrouvert.com',
|
||||
packages=find_packages(),
|
||||
include_package_data=True,
|
||||
classifiers=[
|
||||
'Development Status :: 2 - Pre-Alpha',
|
||||
'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',
|
||||
'Programming Language :: Python :: 3',
|
||||
],
|
||||
install_requires=[
|
||||
'django>=1.11, <2.3',
|
||||
],
|
||||
zip_safe=False,
|
||||
cmdclass={
|
||||
'build': build,
|
||||
'compile_scss': compile_scss,
|
||||
'compile_translations': compile_translations,
|
||||
'install_lib': install_lib,
|
||||
'sdist': eo_sdist,
|
||||
},
|
||||
)
|
Loading…
Reference in New Issue