Espelho para https://github.com/piratas/action-center-platform

Vivian Brown 0552141317 Merge pull request #433 from EFForg/rm18595-rate_limit_subscriptions 5 years ago
.ebextensions 9b210830a7 Initial commit: open sourcing 8 years ago
app fddd59e845 Be lenient with space at end of action url 5 years ago
bin 9b210830a7 Initial commit: open sourcing 8 years ago
config d70fd1c7f9 Rate limit /subscriptions to 10 per day 5 years ago
db 8e8f9f5514 GDPR Compliance: Users must opt-in to subscriptions and tracking 5 years ago
docker ca472a5d93 Revert "Use cookie_store for sessions" 6 years ago
features c40d3f0838 Fix 'I should be signed in' feature step 5 years ago
lib 24a100c62e Merge pull request #405 from EFForg/404-contact-preferences-form 5 years ago
public 7b28e462fd Update favicon.ico 5 years ago
script 5615278f6b Rubocop compliance 6 years ago
spec cd72919b46 Change logout from a GET to a DELETE request 5 years ago
vendor 00f22ead6f Move congress-forms.js from vendor to app 6 years ago
.csslintrc a2a46ee324 sprinkling on travis-ci, codeclimate and codecoverage 8 years ago
.dockerignore 88e1c832fc Building out Dockerfile, creating docker-compose.yml.example 8 years ago
.env.example f7658a02c5 Remove example ESI config 6 years ago
.eslintignore a2a46ee324 sprinkling on travis-ci, codeclimate and codecoverage 8 years ago
.eslintrc a2a46ee324 sprinkling on travis-ci, codeclimate and codecoverage 8 years ago
.gitignore 065627daa8 Lint stylesheets with sass-lint 6 years ago
.rubocop.yml 17e9b665fb Add automatic support for Rubocop 6 years ago
.ruby-gemset 9b210830a7 Initial commit: open sourcing 8 years ago
.ruby-version 75642cf478 Update ruby version in .ruby-version 7 years ago
.sass-lint.yml 065627daa8 Lint stylesheets with sass-lint 6 years ago
.travis.yml 1ef6dfa507 Add Sass Lint to README, Rake task, and Travis 6 years ago
Dockerfile 9f777bbdad Add gnupg to Dockerfile 5 years ago
Gemfile 8cffeaa670 Upgrade aws-sdk gem from v1 to v2 6 years ago
Gemfile.lock 9c53f9d31e Update rubyzip to 1.2.2 from 1.2.1 5 years ago
LICENSE 9b210830a7 Initial commit: open sourcing 8 years ago
README.md 1ef6dfa507 Add Sass Lint to README, Rake task, and Travis 6 years ago
Rakefile 1ef6dfa507 Add Sass Lint to README, Rake task, and Travis 6 years ago
config.ru 120e3795f8 Lint whitespace 6 years ago
docker-compose.yml.example c1380957e9 Add helpful setup to README and docker-compose.yml.example 6 years ago
package.json 065627daa8 Lint stylesheets with sass-lint 6 years ago
varnish.vcl 21a4c4e96c Set cookie on password/edit to avoid csrf error 5 years ago
yarn.lock 065627daa8 Lint stylesheets with sass-lint 6 years ago

README.md

Build Status

Action Center Platform

The Action Center Platform is an online organizing tool maintained by EFF. Administrators can create targeted campaigns where users sign petitions, contact legislators, and engage on social media.

Setup

Follow these instructions to run the Action Center using Docker (recommended). To run the Action Center without Docker, see setup without Docker.

  1. Install Docker (instructions) and Docker Compose (instructions).
  2. git clone https://github.com/EFForg/action-center-platform.git
  3. Copy docker-compose.yml.example to docker-compose.yml, and .env.example to .env. Fill in the variables in .env according to the instructions in that file. See notable dependencies for hints.
  4. Build the docker image: sudo docker-compose build
  5. Run the application: sudo docker-compose up
  6. In a new tab, get a bash shell with access to your app: sudo docker-compose exec app bash.
    1. If you aren't running migrations automatically, run rake db:migrate to migrate the database.
    2. Run rake congress:update to populate CongressMember table.

Notable Dependencies

  • Amazon S3 secret key and key id
    • Allows admins to upload images for the ActionPages
  • SmartyStreets API key and id
    • Allows Congress members to be looked up for users
  • Phantom of the Capitol whitelisting on server side?
    • Allows users to submit e-messages to congress
  • Call Congress url and API key
    • Connects calls between citizens and their congress person using the Twilio API

Generating the icon font

The EFF icon font is generated using fontello.com and via the fontello-rails-converter.

To add a new icon to the fontset, read the Update your existing fontello font section of the fontello_rails_converter readme.

Using the Action Center

Action Center administrators can create four types of actions:

  • Call Action
    • A user is connected to a political leader by phone, leaving a message or sometimes speaking to an aid.
  • Petition Action
    • A user signs a petition, leaving an email address and sometimes location data.
    • Optionally, users can petition local institutions (like universities) and see signatures by institution.
  • Tweet Action
    • A user is invited to join a tweet action using their twitter account.
  • Email Action

Administering Users

To get started using the Action Center, create a user and grant them admin privileges. Administrators can create, track, and manage campaigns.

To create an admin user:

  1. If the user doesn't exist yet, create them through the web interface by following the register link in the top nav.
  2. Run the rake task to grant them admin access (including square brackets): rake users:add_admin[youremail@example.org] New users will need to complete an e-mail confirmation in order to log in. Administrators can access admin features by clicking admin in the nav.

To remove an admin user:

rake users:remove_admin[youremail@example.org]

To list all admin users:

rake users:list_admins

Delayed Jobs and Cron

Action Center uses DelayedJob to perform certain tasks outside of a web request context. See that repository for information regarding how to run a delayed job worker. If you are deploying with Docker, our docker-compose.yml.example shows how to create a service which processes the job queue indefinitely.

You may also want to automate certain other tasks (such as rake signatures:deduplicate and rake congress:update) to run occasionally. For those deploying with Docker, docker-compose.yml.example illustrates how to create a service which runs these commands periodically using cron.

Embedding Actions

Embedding actions is simple. Just include the following HTML on the page you want the action to be embedded:

<script type="text/javascript" src="https://act.eff.org/action/embed"></script>
<a class="action-center-widget" href="https://act.eff.org/action/shut-the-nsa-s-backdoor-to-the-internet">Take part in the action!</a>

The link href should point to the action page you wish to embed. You may add ?nosignup=1 to the URL to get newsletter signup fields omitted from the action.

If you want to get fancy, you can modify the embed code to include some of the following parameters, all of which are optional:

<script type="text/javascript">
    var ac_embed = {};
    ac_embed.css = "https://example.com/hello.css"; // specify a css file url
    ac_embed.width = 500; // specify a width manually
    ac_embed.no_css = true; // remove all default styles
    ac_embed.css_content = "#some_elem"; // specify an element which itself contains some styles
    ac_embed.bioguide_ids = ["ID1", "ID2"...] // bioguide IDs of congress members to target
</script>
<script id="some_div" type="text/x-css-content">
    body{
        background-color: blue;
    }
</script>
<script type="text/javascript" src="https://act.eff.org/action/embed"></script>
<a id="action-center-widget" href="https://act.eff.org/action/shut-the-nsa-s-backdoor-to-the-internet">Take part in the action!</a>

Testing

To run the full test suite, simply run rake with no arguments.

Rspec tests are used for unit testing the app, and some integration testing. Cucumber tests are used for testing API keys, javascript tests, and feature tests.

We use WebMock to stub backend requests to third party services and Puffing Billy to stub frontend (Ajax) requests. Puffing Billy will cache unrecognized requests and play them back during future test runs. To prevent Puffing Billy from making any new requests, set DISABLE_PUFFING_BILLY_REQUESTS=true.

Linting

rake will also run our linting:

Rubocop

Rubocop checks for consistent style across the Ruby areas of the codebase. We use a modified version of Rubocop-Github to stay consistent with SEC.

Sass Lint

Sass-lint checks for consistent style across the stylesheets. Our .sass-lint file is derived from SEC.

Deployment

For notes related to deploying Action Center in production, see the project wiki.

Acknowledgements

This project was created by Lilia Kai, Thomas Davis, and Sina Khanifar. Large portions of the codebase are directly attributable to them, while under the employ or contractorship of the Electronic Frontier Foundation in 2014. Thank you Lilia, Thomas, and Sina! The Action Center is currently maintained by the EFF Engineering and Design team.

Licensing

See the LICENSE file for licensing information. This is applicable to the entire project, sans any 3rd party libraries that may be included.