Coder Social home page Coder Social logo

spschweiz / demovox Goto Github PK

View Code? Open in Web Editor NEW
11.0 7.0 6.0 4.58 MB

demovox is a tool to collect signatures for Swiss popular initiatives by offering the visitor a personalized signature sheet.

Home Page: https://demovox.ch

License: GNU General Public License v3.0

PHP 46.42% JavaScript 51.89% Shell 0.99% SCSS 0.55% Dockerfile 0.15%

demovox's Introduction

SP Schweiz

Demovox

Demovox (dev readme)

Build Status open bugs WordPress plugin downloads WordPress plugin version WordPress tested version

Description

WordPress plugin demovox is a tool to collect signatures for Swiss popular initiatives by offering the visitor a personalized signature sheet.

This Plugin was developed by the Socialist Party of Switzerland, it was initially built for the popular initiative Prämien-Entlastungs-Initiative in 2019. It has been used for numerous others since, like umverkehR (2020) and AHVx13 (2020) by SGB, to name a few.

Requirements

  • PHP >= 7.4
  • MySQL >= 5.6.5
  • WordPress >= 4.9
  • SSL certificate for HTTPS (non-https is only allowed for development)
  • Optional feature requires the PHP modules "GMP" or "BC Math"

Productive installation

Simply install the WordPress plugin demovox from within the Plugin manager of your WordPress installation. You can find the admin manual or the prebuilt Zip-File for manual installation on demovox.ch.

If this plugin is of help for you, please consider a donation and write a review on the demovox WordPress plugin page.

Development

Please send us a pull request for any improvements on the plugin.

Installation

  1. Pull demovox from git
  2. Use the webserver wordpress container from docker-compose.yaml (for development purposes), which includes a WordPress webserver and mailhog for mail testing. Or use your own webserver (see below).
  3. Install required project packages and generate assets with grunt (see below)
  4. Activate the plugin through the 'Plugins' menu in local WordPress
  5. Place shortcodes [demovox_form] on a page or use the automatically generated page
  6. Optionally use and [demovox_count] to show the number of collected signatures and [demovox_optin] for opt-in edit form
  7. Configure the plugin in WordPress admin. Allow non-https access in the advanced settings of the plugin and disable "Redirect clients to secure HTTPS".

Own webserver

You can use your own webserver (see requirements above) and map the demovox directory to [WordPressDir]/wp-content/plugins/demovox.

While developing, you might want to work on a web server without SSL. Enable WP_DEBUG in wp-config.php and you probably want to disable WP_DEBUG_DISPLAY. Then open the Advanced settings of the plugin in the WordPress backend and disable "Redirect clients to secure HTTPS".

Building assets

Docker container

Start buildserver from docker/docker-compose.yaml. The plugin is monted in /var/demovox/

Manual installation (instead of docker container)

If you don't want to use the docker container, install the following build dependencies: Python, Ruby, node.js (use v9, as po2mo fails with higher versions; tested with v9.11.2 installed with NVM), composer, gettext for translation conversion. Install required NPM packages with npm install grunt-cli sass -g

Install required project packages

Go to demovox directory (e.g. cd /var/demovox/)

npm install
composer install --no-dev

Install required packages for tests:

composer install
chmod +x bin/install-wp-tests.sh
bin/install-wp-tests.sh wordpress_test root root demovox-db

Grunt Commands

Generate assets for development

Generate minified JS and CSS files and compile .mo translation files:

grunt buildAssets
Build for wordpress.org repo

Build plugin snapshot in demovox/buildWpOrg which can be uploaded to the WordPress.org repository:

grunt buildWpOrg
Running the tests

There are just a few PHPUnit tests available yet, feel free to contribute some and send a pull-request to increase the test coverage.

grunt test
Other commands

Build plugin snapshot as ZIP in demovox/demovox.zip, which can be uploaded to a remote WordPress installation:

grunt buildZip

Show all other available commands:

grunt availabletasks

Generate translation files

.po files are used to manage translations. They are generated from source code and converted into .mo files for runtime by the grunt task (you can also use bin/translations-po2mo.sh).

Generate frontend and admin .po files

cd bin && ./translations-generate.sh

Generate admin settings .po files

Enable WP_DEBUG and open the System info (WP backend -> demovox -> System info) to generate the .po file for the setting strings.

Changelog

See README.txt and commit log.

Authors

See also the list of contributors who participated in this project. Thanks to @dbu for code review.

License

This project is licensed under the GPLv3 License - see the LICENSE.txt file for details.

demovox's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

demovox's Issues

Pronoun

It would be very helpful if you added a data field for the signee's pronoun.

Add possibility to generate duplicate entries on signature sheets

Description

A client of mine (umverkehr.ch) requested me to adjust the demovox plugin to allow duplicate fields on a signature sheet.

Specifically I will make the following adjustments:

Implementation

Add duplication mechanism for signature sheet field positions:

  • Leverage fieldCallback($arguments) to create + and - buttons (link to code)
  • Use javascript to capture onClick events and add signature fields during runtime
  • Limit - onClick actions to avoid having no field to specify positions at all.
  • Autogenerate indexed position input / form element names to add php $_REQUEST ability

signature_sheet_fields_duplication_mechanism

Output duplicate fields to signature sheet

  • Edit $fields in step3inlineSuccessPage to accommodate duplicate fields (link to code):
		$fields = [
			'field_canton'          => strtoupper($gdeCanton),
			'field_canton_1'          => strtoupper($gdeCanton),
			'field_commune'         => $gdeName,
                        // etc
		];
  • Make sure that Config::getValueByUserLang in formatFields gets passed the correct $name (link to code)

Notes

Ideas and comments on the implementation are very welcome.
I will commit a pull request in the end containing my implementation.

E-Mail double check

Dear SP team,

maybe you'd like to consider implementing a double check for mail adresses as there are not too few people misspelling there adresses and then never get a mail with their sheet.

I.e. it could be helpfull if people are obligated to enter it twice and the form compares both entries.

Kind regards
Thomas

Mails are not sent

We have a Fatal Error, when Emails are sent:

Fatal error: Uncaught TypeError: Argument 1 passed to Demovox\Mail::config() must be an instance of PHPMailer, instance of WPMailSMTP\MailCatcherV6 given, called in /path_to_wp/wp-includes/class-wp-hook.php on line 287 and defined in /path_to_wp/wp-content/plugins/demovox/includes/helpers/Mail.php:42 Stack trace: #0 /path_to_wp/wp-includes/class-wp-hook.php(287): Demovox\Mail->config(Object(WPMailSMTP\MailCatcherV6)) #1 /path_to_wp/wp-includes/class-wp-hook.php(311): WP_Hook->apply_filters(NULL, Array) #2 /path_to_wp/wp-includes/plugin.php(544): WP_Hook->do_action(Array) #3 /path_to_wp/wp-includes/pluggable.php(494): do_action_ref_array('phpmailer_init', Array) #4 /path_to_wp/wp-content/plugins/demovox/includes/helpers/Mail.php(30): wp_mail(Array, 'Vielen Dank f\xC3\xBC...', '
<bod...', Array) #5 /path_to_wp/wp-content/plugins/demovox/admin/AdminPages.php(261): Demovox\Mail::send('onlin in /path_to_wp/wp-content/plugins/demovox/includes/helpers/Mail.php on line 42

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.