diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..1d0d227
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,4 @@
+*.egg-info
+__pycache__
+*.css
+*.css.map
diff --git a/MANIFEST.in b/MANIFEST.in
new file mode 100644
index 0000000..da1900e
--- /dev/null
+++ b/MANIFEST.in
@@ -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
diff --git a/combo_plugin_imio_townstreet/__init__.py b/combo_plugin_imio_townstreet/__init__.py
new file mode 100644
index 0000000..c786915
--- /dev/null
+++ b/combo_plugin_imio_townstreet/__init__.py
@@ -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 .
+
+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'
diff --git a/combo_plugin_imio_townstreet/migrations/0001_initial.py b/combo_plugin_imio_townstreet/migrations/0001_initial.py
new file mode 100644
index 0000000..9b954ce
--- /dev/null
+++ b/combo_plugin_imio_townstreet/migrations/0001_initial.py
@@ -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',
+ },
+ ),
+ ]
diff --git a/combo_plugin_imio_townstreet/migrations/__init__.py b/combo_plugin_imio_townstreet/migrations/__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/combo_plugin_imio_townstreet/models.py b/combo_plugin_imio_townstreet/models.py
new file mode 100644
index 0000000..19ab9ff
--- /dev/null
+++ b/combo_plugin_imio_townstreet/models.py
@@ -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 .
+
+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
diff --git a/combo_plugin_imio_townstreet/static/imio_townstreet/icon.svg b/combo_plugin_imio_townstreet/static/imio_townstreet/icon.svg
new file mode 100644
index 0000000..4f6197a
--- /dev/null
+++ b/combo_plugin_imio_townstreet/static/imio_townstreet/icon.svg
@@ -0,0 +1,74 @@
+
+
+
+
+
+
+ image/svg+xml
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/combo_plugin_imio_townstreet/static/imio_townstreet/style.scss b/combo_plugin_imio_townstreet/static/imio_townstreet/style.scss
new file mode 100644
index 0000000..a80d0b8
--- /dev/null
+++ b/combo_plugin_imio_townstreet/static/imio_townstreet/style.scss
@@ -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;
+ }
+ }
+ }
+}
diff --git a/combo_plugin_imio_townstreet/templates/imio_townstreet/button.html b/combo_plugin_imio_townstreet/templates/imio_townstreet/button.html
new file mode 100644
index 0000000..390db60
--- /dev/null
+++ b/combo_plugin_imio_townstreet/templates/imio_townstreet/button.html
@@ -0,0 +1,9 @@
+{% load static %}
+{% spaceless %}
+
+
+
+
Signaler un problème sur l’espace public
+
+
+{% endspaceless %}
diff --git a/setup.py b/setup.py
new file mode 100644
index 0000000..9540507
--- /dev/null
+++ b/setup.py
@@ -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,
+ },
+)