From 342e6c30f4dedc1c62b21a9678a9d987c7fa3f61 Mon Sep 17 00:00:00 2001 From: Lukas Winkler Date: Fri, 23 Jul 2021 17:11:42 +0200 Subject: [PATCH] first version of the Matomocamp Pretalx plugin --- .github/workflows/style.yml | 130 ++++++++++++++++++ .gitignore | 63 +++++++++ LICENSE | 13 ++ MANIFEST.in | 3 + Makefile | 8 ++ README.rst | 32 +++++ pretalx_matomocamp/__init__.py | 20 +++ .../locale/de_DE/LC_MESSAGES/.gitkeep | 0 .../locale/fr_FR/LC_MESSAGES/.gitkeep | 0 pretalx_matomocamp/signals.py | 35 +++++ .../static/pretalx_matomocamp/.gitkeep | 0 .../templates/pretalx_matomocamp/.gitkeep | 0 pylama.ini | 3 + pytest.ini | 2 + setup.cfg | 10 ++ setup.py | 42 ++++++ 16 files changed, 361 insertions(+) create mode 100644 .github/workflows/style.yml create mode 100644 .gitignore create mode 100644 LICENSE create mode 100644 MANIFEST.in create mode 100644 Makefile create mode 100644 README.rst create mode 100644 pretalx_matomocamp/__init__.py create mode 100644 pretalx_matomocamp/locale/de_DE/LC_MESSAGES/.gitkeep create mode 100644 pretalx_matomocamp/locale/fr_FR/LC_MESSAGES/.gitkeep create mode 100644 pretalx_matomocamp/signals.py create mode 100644 pretalx_matomocamp/static/pretalx_matomocamp/.gitkeep create mode 100644 pretalx_matomocamp/templates/pretalx_matomocamp/.gitkeep create mode 100644 pylama.ini create mode 100644 pytest.ini create mode 100644 setup.cfg create mode 100644 setup.py diff --git a/.github/workflows/style.yml b/.github/workflows/style.yml new file mode 100644 index 0000000..2430fbd --- /dev/null +++ b/.github/workflows/style.yml @@ -0,0 +1,130 @@ +name: Code Style + +on: + push: + branches: [ main ] + paths-ignore: + - '{{cookiecutter.module_name}}/locale/**' + - '{{cookiecutter.module_name}}/static/**' + pull_request: + branches: [ main ] + paths-ignore: + - '{{cookiecutter.module_name}}/locale/**' + - '{{cookiecutter.module_name}}/static/**' + +jobs: + isort: + name: isort + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Set up Python 3.8 + uses: actions/setup-python@v1 + with: + python-version: 3.8 + - uses: actions/cache@v1 + with: + path: ~/.cache/pip + key: ${{ runner.os }}-pip-${{ hashFiles('**/setup.py') }} + restore-keys: | + ${{ runner.os }}-pip- + - name: Install pretalx + run: pip3 install pretalx + - name: Install Dependencies + run: pip3 install isort -Ue . + - name: Run isort + run: isort -c . + flake: + name: flake8 + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Set up Python 3.8 + uses: actions/setup-python@v1 + with: + python-version: 3.8 + - uses: actions/cache@v1 + with: + path: ~/.cache/pip + key: ${{ runner.os }}-pip-${{ hashFiles('**/setup.py') }} + restore-keys: | + ${{ runner.os }}-pip- + - name: Install pretalx + run: pip3 install pretalx + - name: Install Dependencies + run: pip3 install flake8 -Ue . + - name: Run flake8 + run: flake8 . + working-directory: . + black: + name: black + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Set up Python 3.8 + uses: actions/setup-python@v1 + with: + python-version: 3.8 + - uses: actions/cache@v1 + with: + path: ~/.cache/pip + key: ${{ runner.os }}-pip-${{ hashFiles('**/setup.py') }} + restore-keys: | + ${{ runner.os }}-pip- + - name: Install pretalx + run: pip3 install pretalx + - name: Install Dependencies + run: pip3 install black -Ue . + - name: Run black + run: black --check . + working-directory: . + docformatter: + name: docformatter + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Set up Python 3.8 + uses: actions/setup-python@v1 + with: + python-version: 3.8 + - uses: actions/cache@v1 + with: + path: ~/.cache/pip + key: ${{ runner.os }}-pip-${{ hashFiles('**/setup.py') }} + restore-keys: | + ${{ runner.os }}-pip- + - name: Install pretalx + run: pip3 install pretalx + - name: Install Dependencies + run: pip3 install docformatter -Ue . + - name: Run docformatter + run: docformatter --check -r . + working-directory: . + packaging: + name: packaging + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Set up Python 3.8 + uses: actions/setup-python@v1 + with: + python-version: 3.8 + - uses: actions/cache@v1 + with: + path: ~/.cache/pip + key: ${{ runner.os }}-pip-${{ hashFiles('**/setup.py') }} + restore-keys: | + ${{ runner.os }}-pip- + - name: Install pretalx + run: pip3 install pretalx + - name: Install Dependencies + run: pip3 install twine check-manifest -Ue . + - name: Run check-manifest + run: check-manifest . + working-directory: . + - name: Build package + run: python setup.py sdist + working-directory: . + - name: Check package + run: twine check dist/* + working-directory: . diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..d95f781 --- /dev/null +++ b/.gitignore @@ -0,0 +1,63 @@ +# Byte-compiled / optimized / DLL files +__pycache__/ +*.py[cod] +*$py.class + +# C extensions +*.so + +# Distribution / packaging +.Python +env/ +build/ +develop-eggs/ +dist/ +downloads/ +eggs/ +.eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +*.egg-info/ +.installed.cfg +*.egg +.ropeproject/ + +# PyInstaller +# Usually these files are written by a python script from a template +# before PyInstaller builds the exe, so as to inject date/other infos into it. +*.manifest +*.spec + +# Installer logs +pip-log.txt +pip-delete-this-directory.txt + +# Unit test / coverage reports +htmlcov/ +.tox/ +.coverage +.coverage.* +.cache +nosetests.xml +coverage.xml +*,cover +.hypothesis/ + +# Translations +*.mo +*.pot + +# Django stuff: +*.log + +# Sphinx documentation +docs/_build/ + +# PyBuilder +target/ + +#Ipython Notebook +.ipynb_checkpoints diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..4ca81d6 --- /dev/null +++ b/LICENSE @@ -0,0 +1,13 @@ +Copyright 2021 Lukas Winkler + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. diff --git a/MANIFEST.in b/MANIFEST.in new file mode 100644 index 0000000..0e60701 --- /dev/null +++ b/MANIFEST.in @@ -0,0 +1,3 @@ +recursive-include pretalx_matomocamp/static * +recursive-include pretalx_matomocamp/templates * +recursive-include pretalx_matomocamp/locale * diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..c730ffe --- /dev/null +++ b/Makefile @@ -0,0 +1,8 @@ +all: localecompile + +localecompile: + django-admin compilemessages + +localegen: + django-admin makemessages -l de_DE -i build -i dist -i "*egg*" + diff --git a/README.rst b/README.rst new file mode 100644 index 0000000..fe88755 --- /dev/null +++ b/README.rst @@ -0,0 +1,32 @@ +Pretalx Extension for the MatomoCamp +========================== + +This is a plugin for `pretalx`_. + +Development setup +----------------- + +1. Make sure that you have a working `pretalx development setup`_. + +2. Clone this repository, eg to ``local/pretalx-matomocamp``. + +3. Activate the virtual environment you use for pretalx development. + +4. Execute ``python setup.py develop`` within this directory to register this application with pretalx's plugin registry. + +5. Execute ``make`` within this directory to compile translations. + +6. Restart your local pretalx server. You can now use the plugin from this repository for your events by enabling it in + the 'plugins' tab in the settings. + + +License +------- + +Copyright 2021 Lukas Winkler + +Released under the terms of the Apache License 2.0 + + +.. _pretalx: https://github.com/pretalx/pretalx +.. _pretalx development setup: https://docs.pretalx.org/en/latest/developer/setup.html diff --git a/pretalx_matomocamp/__init__.py b/pretalx_matomocamp/__init__.py new file mode 100644 index 0000000..026d91b --- /dev/null +++ b/pretalx_matomocamp/__init__.py @@ -0,0 +1,20 @@ +from django.apps import AppConfig +from django.utils.translation import gettext_lazy + + +class PluginApp(AppConfig): + name = "pretalx_matomocamp" + verbose_name = "Pretalx Extension for the MatomoCamp" + + class PretalxPluginMeta: + name = gettext_lazy("Pretalx Extension for the MatomoCamp") + author = "Lukas Winkler" + description = gettext_lazy("Short description") + visible = True + version = "0.0.0" + + def ready(self): + from . import signals # NOQA + + +default_app_config = "pretalx_matomocamp.PluginApp" diff --git a/pretalx_matomocamp/locale/de_DE/LC_MESSAGES/.gitkeep b/pretalx_matomocamp/locale/de_DE/LC_MESSAGES/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/pretalx_matomocamp/locale/fr_FR/LC_MESSAGES/.gitkeep b/pretalx_matomocamp/locale/fr_FR/LC_MESSAGES/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/pretalx_matomocamp/signals.py b/pretalx_matomocamp/signals.py new file mode 100644 index 0000000..aa1c470 --- /dev/null +++ b/pretalx_matomocamp/signals.py @@ -0,0 +1,35 @@ +# Register your receivers here +from django.dispatch import receiver +from pretalx.agenda.signals import register_recording_provider +from pretalx.cfp.signals import html_head +from pretalx.agenda.recording import BaseRecordingProvider + + +class MatomoVideoProvider(BaseRecordingProvider): + def get_recording(self, submission): + print(submission) + return {"iframe": '
', "csp_header": " …"} + + +# @receiver(register_recording_provider) +# def matomo_video_provider(sender, **kwargs): +# return MatomoVideoProvider(sender) + +@receiver(html_head) +def append_to_header(sender,**kwargs): + return """ + +""" diff --git a/pretalx_matomocamp/static/pretalx_matomocamp/.gitkeep b/pretalx_matomocamp/static/pretalx_matomocamp/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/pretalx_matomocamp/templates/pretalx_matomocamp/.gitkeep b/pretalx_matomocamp/templates/pretalx_matomocamp/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/pylama.ini b/pylama.ini new file mode 100644 index 0000000..316e118 --- /dev/null +++ b/pylama.ini @@ -0,0 +1,3 @@ +[pylama] +ignore = E501, +skip = */settings.py,*/celery_app.py,*.ropeproject/* diff --git a/pytest.ini b/pytest.ini new file mode 100644 index 0000000..b4b36ad --- /dev/null +++ b/pytest.ini @@ -0,0 +1,2 @@ +[pytest] +DJANGO_SETTINGS_MODULE=pretalx.common.settings.test_settings diff --git a/setup.cfg b/setup.cfg new file mode 100644 index 0000000..1805733 --- /dev/null +++ b/setup.cfg @@ -0,0 +1,10 @@ +[isort] +balanced_wrapping = True +combine_as_imports = True +default_section = THIRDPARTY +include_trailing_comma = True +known_third_party = pretalx +line_length = 80 +multi_line_output = 5 +not_skip = __init__.py +skip = migrations,setup.py diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..15336a4 --- /dev/null +++ b/setup.py @@ -0,0 +1,42 @@ +import os +from distutils.command.build import build + +from django.core import management +from setuptools import find_packages, setup + +try: + with open( + os.path.join(os.path.dirname(__file__), "README.rst"), encoding="utf-8" + ) as f: + long_description = f.read() +except FileNotFoundError: + long_description = "" + + +class CustomBuild(build): + def run(self): + management.call_command("compilemessages", verbosity=1) + build.run(self) + + +cmdclass = {"build": CustomBuild} + + +setup( + name="pretalx-matomocamp", + version="0.0.0", + description="Short description", + long_description=long_description, + url="test", + author="Lukas Winkler", + author_email="lukas@matomocamp.org", + license="Apache Software License", + install_requires=[], + packages=find_packages(exclude=["tests", "tests.*"]), + include_package_data=True, + cmdclass=cmdclass, + entry_points=""" +[pretalx.plugin] +pretalx_matomocamp=pretalx_matomocamp:PretalxPluginMeta +""", +)