wmde/fundraising-banners

Name: fundraising-banners

Owner: Wikimedia Deutschland e.V.

Description: Code of all the fundraising banners

Created: 2016-11-22 11:11:09.0

Updated: 2018-05-07 14:21:51.0

Pushed: 2018-05-07 14:22:19.0

Homepage: null

Size: 919

Language: JavaScript

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

Fundraising banners, webpack edition

Build Status

This project is bundling all assets and dependencies of WMDE fundraising banners with webpack.

Installing dependencies

To install all dependencies run

docker-compose run js-build npm install
Starting the preview

The banners can be previewed using a built-in server.

docker-compose up js-serve

The preview server is at http://localhost:8084/

It will display a selection of banners to preview in their respective channel (German Wikimedia / mobile German Wikipedia / wikipedia.de).

Changes to the code base while the preview is running should be reflected via hot reload.

Check the sources

To verify the code is correct and up to our coding standards. These tests will also be run, and have to pass, in CI.

docker-compose run js-build npm run test
docker-compose run js-build npm run lint:js
docker-compose run js-build npm run lint:css
Building the assets

To build a minified version of the banner in order to use it on CentralNotice run

docker-compose run js-build npm run build
Using the compiled JavaScript on CentralNotice

After the assets are compiled, the dist directory contains .wikitext files that can be inserted 1:1 in CentralNotice.

Campaigns, Banner assets and structure

The file campaign_info.toml contains the metadata for all banners and campaigns. It'll be used to determine the unique file names of the output and the input files, the so-called entry points. Entry points are the local files (configured with the setting filename) which will be compiled by Webpack to pure JavaScript code and JavaScript code wrapped in wikitext that can be copied to CentralNotice. The CentralNotice banner names (which can also be used for the devbanner parameter in the preview) come from the pagename setting.

Each entry point includes JavaScript libraries, CSS and HTML templates through require statements in the entry point files. Webpack is configured to handle file types according to their extension: HTML templates are preprocessed as JavaScript templating functions, CSS is preprocessed and will be inserted as an inline <style> tag, etc. Most assets are shared between the banners.

The campaign_tracking and tracking parameters in campaign_info.toml are used to create the tracking information inside the banner code. The tracking information is passed to the form fields and event tracking pixels inside the banner.

Creating new campaigns
  1. Duplicate an existing folder with banner entry points, e.g. desktop.
  2. Create a new campaign and its banner configuration in campaign_info.toml.
Creating A/B tests

The changes to the code depend on which kind of test you are running.

Attention: Before creating a new A/B test, clean up the previous one by incorporating the changes into the code! Do not layer tests upon each other!

How the preview feature works
Planned Features of the dev environment
Notes on possible Banner code improvements

This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.