├── .gitignore ├── .ruby-version ├── .travis.yml ├── LICENSE.txt ├── NOTICE.txt ├── README.md ├── api ├── .env.sample ├── API_DOC.md ├── app │ ├── controllers │ │ ├── Application.scala │ │ ├── Management.scala │ │ └── Swarms.scala │ └── lib │ │ ├── Elasticsearch.scala │ │ └── GeoJsonFormatter.scala ├── conf │ ├── application.conf │ └── routes ├── eb_name.txt └── package.sh ├── bombard ├── Gemfile ├── Gemfile.lock ├── README.md ├── bombard.rb └── postcodes.csv ├── case_studies ├── broadband_survey.md ├── broadband_survey │ ├── add-fields.gif │ ├── clone.gif │ ├── create.gif │ ├── csv.png │ ├── embed-code.gif │ ├── graphs.gif │ ├── login.gif │ ├── move-delete.gif │ ├── open.gif │ ├── permissions.gif │ ├── preview.png │ ├── table.png │ ├── thumb.png │ └── view-form.png ├── indyref.md ├── indyref │ ├── indyref-graph1.png │ ├── indyref-graph2.png │ ├── indyref-graph3.png │ ├── indyref1.gif │ └── thumb.png ├── realtime_clicker.md └── realtime_clicker │ ├── aggregate-field.gif │ ├── api-keys.gif │ ├── get-code.gif │ ├── map-demo.png │ ├── preview-form.png │ ├── results-over-time.png │ └── thumb.jpg ├── cloudformation ├── README.md ├── __example.template ├── all.template ├── base.template ├── bashlib │ └── shared.sh ├── cfn.conf ├── collector.template ├── create_all.sh ├── delete_all.sh ├── dist │ └── elasticsearch.yml ├── elasticsearch.template ├── processor.template ├── update_all.sh └── validate_all.sh ├── collector ├── README.md ├── app │ ├── Global.scala │ ├── controllers │ │ ├── Application.scala │ │ ├── Management.scala │ │ └── Swarms.scala │ └── views │ │ ├── index.scala.html │ │ └── main.scala.html ├── conf │ ├── application.conf │ └── routes ├── eb_name.txt ├── example_curl_live_form.sh ├── example_curl_live_json.sh ├── example_curl_local_form.sh ├── example_curl_local_json.sh ├── package.sh └── public │ ├── images │ └── favicon.png │ └── stylesheets │ └── main.css ├── copy_static_markdown.sh ├── deploy.sh ├── deploy ├── Gemfile ├── Gemfile.lock ├── README.md └── deploy.rb ├── examples ├── README.md ├── generic-backend │ ├── .gitignore │ ├── README.md │ ├── backend.js │ ├── package.json │ └── public │ │ └── index.html ├── livedebate-scotland │ ├── README.md │ ├── ad.jpg │ ├── as.jpg │ ├── cookies.js │ ├── debate.css │ ├── debate.js │ ├── index.html │ └── jquery.min.js ├── livedebate │ ├── .gitignore │ ├── Gemfile │ ├── Gemfile.lock │ ├── README.md │ ├── app.rb │ ├── config.rb │ ├── config.ru │ ├── lib │ │ └── swarm_api.rb │ ├── public │ │ ├── images │ │ │ ├── .gitkeep │ │ │ ├── dc.jpg │ │ │ ├── em.jpg │ │ │ └── nc.jpg │ │ ├── javascripts │ │ │ ├── application.js │ │ │ └── jquery.min.js │ │ └── stylesheets │ │ │ └── application.css │ ├── stylesheets │ │ └── application.scss │ └── views │ │ ├── index.haml │ │ └── layout.haml ├── mapdemo-backend │ ├── .gitignore │ ├── README.md │ ├── backend.js │ ├── package.json │ └── public │ │ └── index.html └── mapdemo-standalone │ ├── README.md │ └── index.html ├── geocoder ├── .gitignore ├── README.md ├── eb_name.txt ├── geocoder.js ├── package.json └── package.sh ├── processor ├── app │ ├── Global.scala │ ├── controllers │ │ ├── Application.scala │ │ ├── Management.scala │ │ └── Swarms.scala │ └── lib │ │ ├── Activities.scala │ │ ├── ActivityDispatcher.scala │ │ ├── Decider.scala │ │ ├── Elasticsearch.scala │ │ ├── ExternalActivity.scala │ │ └── StoreInElasticsearchActivity.scala ├── conf │ ├── application-logger.xml │ ├── application.conf │ └── routes ├── eb_name.txt ├── external_processors.md ├── logs │ └── processor.log ├── package.sh ├── start_prod_processor.sh ├── stop_prod_processor.sh └── test │ ├── ActivityRunOnce.scala │ ├── DeciderRunOnce.scala │ └── resources │ └── logback-test.xml ├── project ├── SwarmizeBuild.scala ├── build.properties └── plugins.sbt ├── sentiment-endpoint ├── .gitignore ├── Procfile ├── package.json └── sentiment-endpoint.js ├── shared-lib └── src │ ├── main │ ├── resources │ │ └── field_types.json │ └── scala │ │ └── swarmize │ │ ├── ClassLogger.scala │ │ ├── FieldTypes.scala │ │ ├── Swarm.scala │ │ ├── SwarmApiKeys.scala │ │ ├── SwarmField.scala │ │ ├── SwarmSubmissionValidator.scala │ │ ├── SwarmTable.scala │ │ ├── UniqueId.scala │ │ ├── aws │ │ ├── AWS.scala │ │ ├── SimpleWorkflowConfig.scala │ │ └── swf │ │ │ ├── SwfAsyncHelpers.scala │ │ │ ├── SwfDecision.scala │ │ │ └── SwfHistoryEvent.scala │ │ └── json │ │ ├── FieldTypeJson.scala │ │ ├── PlayJsonIsoDateFormat.scala │ │ ├── SubmittedData.scala │ │ └── SwarmDefinition.scala │ └── test │ └── scala │ └── swarmize │ ├── SwarmFieldTypesTest.scala │ ├── SwarmSubmissionValidatorTest.scala │ ├── SwarmTest.scala │ ├── TestSwarms.scala │ ├── aws │ └── swf │ │ └── SwfHistoryEventTest.scala │ └── json │ ├── SubmittedDataTest.scala │ └── SwarmDefinitionJsonTest.scala └── swarmize-dot-com ├── .ebextensions └── packages.config ├── .env.example ├── .gitignore ├── .rspec ├── Gemfile ├── Gemfile.lock ├── Guardfile ├── README.md ├── Rakefile ├── app ├── assets │ ├── fonts │ │ ├── glyphicons-halflings-regular.eot │ │ ├── glyphicons-halflings-regular.svg │ │ ├── glyphicons-halflings-regular.ttf │ │ └── glyphicons-halflings-regular.woff │ ├── images │ │ ├── .keep │ │ └── favicon.ico │ ├── javascripts │ │ ├── application.js │ │ ├── backbone-min.js │ │ ├── bootstrap.min.js │ │ ├── c3.min.js │ │ ├── d3.min.js │ │ ├── embed.js │ │ ├── field_workspace.js │ │ ├── form_element.js │ │ ├── jquery.iecors.js │ │ ├── models │ │ │ ├── graph_data.js │ │ │ └── results_data.js │ │ ├── moment.min.js │ │ ├── palette_field.js │ │ ├── parsley-config.js │ │ ├── parsley.min.js │ │ ├── rickshaw.min.js │ │ ├── swarmize-embed.js │ │ ├── underscore-min.js │ │ └── views │ │ │ ├── pie_graph.js │ │ │ ├── results_table.js │ │ │ └── timeseries_graph.js │ └── stylesheets │ │ ├── application.scss │ │ ├── bootstrap-theme.min.css │ │ ├── bootstrap.min.css │ │ ├── c3.css │ │ └── rickshaw.min.css ├── controllers │ ├── admin_controller.rb │ ├── api_keys_controller.rb │ ├── application_controller.rb │ ├── case_studies_controller.rb │ ├── concerns │ │ └── .keep │ ├── csv_controller.rb │ ├── documentation_controller.rb │ ├── graphs_controller.rb │ ├── home_controller.rb │ ├── oembed_controller.rb │ ├── permissions_controller.rb │ ├── search_controller.rb │ ├── sessions_controller.rb │ ├── swarm_import_controller.rb │ ├── swarms_controller.rb │ ├── users_controller.rb │ └── utils_controller.rb ├── helpers │ ├── application_helper.rb │ └── fields_helper.rb ├── mailers │ ├── .keep │ └── permission_mailer.rb ├── models │ ├── .keep │ ├── access_permission.rb │ ├── api_key.rb │ ├── concerns │ │ └── .keep │ ├── field_description.rb │ ├── graph.rb │ ├── swarm.rb │ ├── swarm_field.rb │ └── user.rb └── views │ ├── admin │ └── show.html.haml │ ├── api_keys │ └── index.html.haml │ ├── case_studies │ ├── _list.html.haml │ ├── index.html.haml │ └── show.html.haml │ ├── documentation │ ├── index.html.haml │ └── show.html.haml │ ├── form_partials │ ├── _bigtext_display_field_partial.html.haml │ ├── _check_box_display_field_partial.html.haml │ ├── _display_field_partial.html.haml │ ├── _edit_field_partial.html.haml │ ├── _element_controls.html.haml │ ├── _pick_one_display_field_partial.html.haml │ ├── _pick_several_display_field_partial.html.haml │ ├── _rating_display_field_partial.html.haml │ └── _yesno_display_field_partial.html.haml │ ├── graphs │ ├── _pie.html.haml │ ├── _timeseries.html.haml │ ├── delete.html.haml │ ├── edit.html.haml │ ├── index.html.haml │ └── new.html.haml │ ├── home │ ├── _logged_in.html.haml │ ├── _logged_out.html.haml │ ├── _project_status.html.haml │ └── show.html.haml │ ├── layouts │ ├── _flashes.html.haml │ ├── _nav.html.haml │ ├── application.html.haml │ └── embed.html.haml │ ├── permission_mailer │ └── permission_email.text.erb │ ├── permissions │ ├── _logged_out_permissions_page.html.haml │ ├── _owner_permissions_page.html.haml │ └── index.html.haml │ ├── search │ └── results.html.haml │ ├── sessions │ └── logout.html.haml │ ├── swarm_import │ └── new.html.haml │ ├── swarms │ ├── _close_swarm_modal.html.haml │ ├── _embed_closed.html.haml │ ├── _embed_live.html.haml │ ├── _field_code_update_js.html.haml │ ├── _open_swarm_modal.html.haml │ ├── _swarm_description_open_close.html.haml │ ├── _swarm_description_open_close_logged_in.html.haml │ ├── _swarm_dropdown_menu.html.haml │ ├── _swarm_graphs.html.haml │ ├── _swarm_header.html.haml │ ├── _swarm_page_js.html.haml │ ├── _swarm_results.html.haml │ ├── _swarm_table.html.haml │ ├── closed.html.haml │ ├── code.html.haml │ ├── delete.html.haml │ ├── draft.html.haml │ ├── edit.html.haml │ ├── embed.html.haml │ ├── fields.html.haml │ ├── index.html.haml │ ├── live.html.haml │ ├── new.html.haml │ ├── preview.html.haml │ └── show.html.haml │ └── users │ ├── _user_header.html.haml │ ├── closed.html.haml │ ├── delete.html.haml │ ├── draft.html.haml │ ├── index.html.haml │ ├── live.html.haml │ └── show.html.haml ├── bin ├── bundle ├── rails └── rake ├── config.ru ├── config ├── application.rb ├── boot.rb ├── database.yml ├── environment.rb ├── environments │ ├── development.rb │ ├── production.rb │ └── test.rb ├── initializers │ ├── amazon_ses.rb │ ├── aws.rb │ ├── backtrace_silencers.rb │ ├── filter_parameter_logging.rb │ ├── inflections.rb │ ├── mime_types.rb │ ├── non_digest_assets.rb │ ├── omniauth.rb │ ├── secret_token.rb │ ├── session_store.rb │ ├── will_paginate.rb │ └── wrap_parameters.rb ├── locales │ └── en.yml └── routes.rb ├── db ├── migrate │ ├── 20140712134916_create_swarms.rb │ ├── 20140716162431_add_fields_to_swarm.rb │ ├── 20140722135555_add_open_close_to_swarm.rb │ ├── 20140729093242_create_users.rb │ ├── 20140729123430_add_user_id_to_swarms.rb │ ├── 20140729133308_add_parent_swarm_id_to_swarms.rb │ ├── 20140801101148_add_is_fake_to_users.rb │ ├── 20140801134513_add_spiked_field_to_swarms.rb │ ├── 20140812130235_add_tokens_to_swarms.rb │ ├── 20140814134610_create_graph_configurations.rb │ ├── 20140814135824_rename_graph_configurations.rb │ ├── 20140814173018_create_swarm_fields.rb │ ├── 20140815095709_remove_serialized_fields.rb │ ├── 20140826092139_create_access_permissions.rb │ ├── 20140827092647_add_owner_field_to_permissions.rb │ ├── 20140827103714_add_creators_to_access_permissions.rb │ ├── 20140827162410_remove_creator_field_from_swarm.rb │ ├── 20140828114635_add_is_admin_to_users.rb │ ├── 20140912101553_add_deleted_at_to_swarms.rb │ ├── 20141010094402_remove_viz_type.rb │ ├── 20141017093840_add_other_to_swarmfield.rb │ ├── 20141017131200_add_toggles_to_swarm.rb │ ├── 20141017150238_change_other_to_allow_other.rb │ ├── 20141021114539_change_desscription_to_text_field.rb │ └── 20141204145601_allow_pick_one_to_be_select.rb ├── schema.rb └── seeds.rb ├── deploy-sample.json ├── deploy.rb ├── eb_name.txt ├── field_types.json ├── lib ├── assets │ └── .keep ├── dummy.rb ├── dynamo_sync.rb ├── email_validator.rb ├── json_importer.rb ├── swarm_csv_tool.rb ├── swarmize_oembed.rb ├── swarmize_search.rb ├── swarmize_search │ └── queries.rb └── tasks │ ├── .keep │ └── swarmize.rake ├── log └── .keep ├── package.sh ├── public ├── 404.html ├── 422.html ├── 500.html ├── case_studies │ ├── broadband_survey.md │ ├── broadband_survey │ │ ├── add-fields.gif │ │ ├── clone.gif │ │ ├── create.gif │ │ ├── csv.png │ │ ├── embed-code.gif │ │ ├── graphs.gif │ │ ├── login.gif │ │ ├── move-delete.gif │ │ ├── open.gif │ │ ├── permissions.gif │ │ ├── preview.png │ │ ├── table.png │ │ ├── thumb.png │ │ └── view-form.png │ ├── indyref.md │ ├── indyref │ │ ├── indyref-graph1.png │ │ ├── indyref-graph2.png │ │ ├── indyref-graph3.png │ │ ├── indyref1.gif │ │ └── thumb.png │ ├── realtime_clicker.md │ └── realtime_clicker │ │ ├── aggregate-field.gif │ │ ├── api-keys.gif │ │ ├── get-code.gif │ │ ├── map-demo.png │ │ ├── preview-form.png │ │ ├── results-over-time.png │ │ └── thumb.jpg ├── documentation │ └── api.md ├── favicon.ico ├── fonts │ ├── glyphicons-halflings-regular.eot │ ├── glyphicons-halflings-regular.svg │ ├── glyphicons-halflings-regular.ttf │ └── glyphicons-halflings-regular.woff ├── js │ └── swarmize-embed.js └── robots.txt ├── spec ├── controllers │ ├── admin_controller_spec.rb │ ├── api_tokens_controller_spec.rb │ ├── case_studies_controller_spec.rb │ ├── csv_controller_spec.rb │ ├── graphs_controller_spec.rb │ ├── home_controller_spec.rb │ ├── oembed_controller_spec.rb │ ├── permissions_controller_spec.rb │ ├── search_controller_spec.rb │ ├── sessions_controller_spec.rb │ ├── shared_examples_for_controllers.rb │ ├── swarm_import_controller_spec.rb │ ├── swarms_controller_spec.rb │ ├── users_controller_spec.rb │ └── utils_controller_spec.rb ├── factories │ ├── access_permissions.rb │ ├── graphs.rb │ ├── swarm_fields.rb │ ├── swarms.rb │ └── users.rb ├── helpers │ ├── admin_helper_spec.rb │ ├── graphs_helper_spec.rb │ ├── home_helper_spec.rb │ ├── permissions_helper_spec.rb │ ├── search_helper_spec.rb │ ├── sessions_helper_spec.rb │ ├── swarms_helper_spec.rb │ └── users_helper_spec.rb ├── lib │ ├── json_importer_spec.rb │ ├── sample.json │ ├── sample_field.json │ └── sample_field_possible_values.json ├── mailers │ └── permission_mailer_spec.rb ├── models │ ├── access_permission_spec.rb │ ├── email_validator_spec.rb │ ├── graph_spec.rb │ ├── swarm_field_spec.rb │ ├── swarm_spec.rb │ └── user_spec.rb ├── spec_helper.rb └── support │ └── factory_girl.rb └── vendor └── assets ├── javascripts └── .keep └── stylesheets └── .keep /.gitignore: -------------------------------------------------------------------------------- 1 | target/ 2 | .idea*/ 3 | 4 | collector/logs 5 | stasher/logs 6 | logs 7 | *.zip 8 | credentials.csv 9 | .rakeTasks 10 | .generators 11 | -------------------------------------------------------------------------------- /.ruby-version: -------------------------------------------------------------------------------- 1 | 1.9.3-p547 2 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: scala 2 | scala: 3 | - 2.11.2 4 | -------------------------------------------------------------------------------- /NOTICE.txt: -------------------------------------------------------------------------------- 1 | Swarmize 2 | Copyright 2014 Guardian Media Group 3 | 4 | Swarmize was created by Tom Armitage, Graham Tackley, Sean Clarke and Matt McAlister. 5 | 6 | Swarmize was initially funded by a grant from the Knight News Challenge with support from Guardian Media Group. 7 | 8 | http://www.swarmize.com/ 9 | 10 | 11 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | THIS PROJECT IS NOW DEPRECATED 2 | 3 | 4 | # Swarmize 5 | 6 | Swarmize is a stack of tools to make crowd-powered number-gathering a lot easier. 7 | 8 | ## The Stack 9 | 10 | Swarmize is built out of a number of components, written in either Ruby or Scala, and currently built around an AWS stack including RDS (hosting Postgres), Simple Workflow, DynamoDB, and deployed against Elastic Beanstalk. We use Elasticsearch as a data store. 11 | 12 | ## Contents 13 | 14 | Currently in this repository: 15 | 16 | * `api`: The Scala-based API [scala] 17 | * `bombard`: A small script for filling a Swarm with fake data [ruby] 18 | * `case_studies`: the case studies for the project, which are then copied into the Rails app for deployment (but will work fine on Github as they are) [markdown] 19 | * `cloudformation`: AWS CloudFormation config 20 | * `collector`: Receive data from an endpoint and forward it to the stream. [scala] 21 | * `deploy`: The deploy tools/scripts [ruby/bash] 22 | * `examples`: Examples of Collector and Retrieval API usage 23 | * `geocoder`: Simple Node geocoder endpoint [node] 24 | * `livedebate`: Sample app: click on the face you're liking most at any point during a prime ministerial debate; the data - along with some demographic information - will be pushed into Swarm. [ruby] 25 | * `processor`: Processes submitted data [scala] 26 | * `sentiment-endpoint`: Simple Node sentiment analysis endpoint [node] 27 | * `swarmize-dot-com`: the Swarmize alpha website. [ruby] 28 | 29 | [](https://travis-ci.org/guardian/swarmize) 30 | -------------------------------------------------------------------------------- /api/.env.sample: -------------------------------------------------------------------------------- 1 | ELASTICSEARCH_HOST=localhost 2 | AWS_ACCESS_KEY_ID=xx 3 | AWS_SECRET_ACCESS_KEY=xx 4 | 5 | -------------------------------------------------------------------------------- /api/app/controllers/Application.scala: -------------------------------------------------------------------------------- 1 | package controllers 2 | 3 | import play.api._ 4 | import play.api.mvc._ 5 | 6 | object Application extends Controller { 7 | 8 | def index = Action { 9 | Ok("swarmize-api") 10 | } 11 | 12 | } -------------------------------------------------------------------------------- /api/app/controllers/Management.scala: -------------------------------------------------------------------------------- 1 | package controllers 2 | 3 | import play.api.mvc.{Controller, Action} 4 | 5 | object Management extends Controller { 6 | def healthCheck() = Action { 7 | Ok("All good") 8 | } 9 | } -------------------------------------------------------------------------------- /api/app/lib/GeoJsonFormatter.scala: -------------------------------------------------------------------------------- 1 | package lib 2 | 3 | import play.api.libs.json._ 4 | 5 | object GeoJsonFormatter { 6 | 7 | def format(src: List[JsValue], key: String): JsObject = { 8 | 9 | val features = src map { objvalue => 10 | val obj = objvalue.as[JsObject] 11 | val geoPoint = makeGeoPointDoubles(obj \ key) 12 | val props = obj - key 13 | 14 | Json.obj( 15 | "type" -> "Feature", 16 | "geometry" -> Json.obj( 17 | "type" -> "Point", 18 | "coordinates" -> geoPoint 19 | ), 20 | "properties" -> props 21 | ) 22 | 23 | } 24 | 25 | Json.obj( 26 | "type" -> "FeatureCollection", 27 | "features" -> features 28 | ) 29 | } 30 | 31 | private def makeGeoPointDoubles(pt: JsValue): JsValue = { 32 | val arrValues = pt.as[JsArray].value 33 | 34 | val doubleValues = arrValues.map { 35 | case JsString(s) => JsNumber(BigDecimal(s)) 36 | case other => other 37 | } 38 | 39 | JsArray(doubleValues) 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /api/conf/routes: -------------------------------------------------------------------------------- 1 | # Routes 2 | # This file defines all application routes (Higher priority routes first) 3 | # ~~~~ 4 | 5 | # Home page 6 | GET / controllers.Application.index 7 | 8 | GET /swarms/:token controllers.Swarms.show(token) 9 | GET /swarms/:token/results controllers.Swarms.results(token, page: Int ?= 1, per_page: Int ?= 10, format: Option[String], geo_json_point_key: Option[String], order_by ?= "oldest") 10 | GET /swarms/:token/latest controllers.Swarms.latest(token) 11 | GET /swarms/:token/counts controllers.Swarms.counts(token) 12 | 13 | 14 | GET /health-check controllers.Management.healthCheck 15 | -------------------------------------------------------------------------------- /api/eb_name.txt: -------------------------------------------------------------------------------- 1 | Swarmize API 2 | -------------------------------------------------------------------------------- /api/package.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | PACKAGE_FILENAME=$1 4 | DIRECTORY=$2 5 | 6 | APP_NAME=api 7 | 8 | # clear up stuff left behind from previous builds 9 | [ -d target/docker ] && rm -rf target/docker 10 | 11 | # build the zip 12 | cd .. 13 | 14 | sbt ${APP_NAME}/docker:stage && \ 15 | cd ${DIRECTORY}/target/docker && \ 16 | zip -r ../../${PACKAGE_FILENAME} * 17 | 18 | 19 | -------------------------------------------------------------------------------- /bombard/Gemfile: -------------------------------------------------------------------------------- 1 | source 'https://rubygems.org' 2 | 3 | gem 'httparty' 4 | -------------------------------------------------------------------------------- /bombard/Gemfile.lock: -------------------------------------------------------------------------------- 1 | GEM 2 | remote: https://rubygems.org/ 3 | specs: 4 | httparty (0.13.1) 5 | json (~> 1.8) 6 | multi_xml (>= 0.5.2) 7 | json (1.8.1) 8 | multi_xml (0.5.5) 9 | 10 | PLATFORMS 11 | ruby 12 | 13 | DEPENDENCIES 14 | httparty 15 | -------------------------------------------------------------------------------- /bombard/README.md: -------------------------------------------------------------------------------- 1 | # bombard 2 | 3 | Bombard is a very simple/dumb ruby script for hammering a swarm (FSVO 'hammering') with hits. It was designed around a specific swarm, and contains code specific to those fields, but it should be straightforward enough to adapt it for other swarms, especially if you'd like to fill them with not-entirely-random data. 4 | 5 | (For instance: in this swarm, an imaginary user will always specify the same plans to vote in the next election, even though who they agree with will change moment-to-moment). -------------------------------------------------------------------------------- /case_studies/broadband_survey/add-fields.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/guardian/swarmize/d3b23b7e093c7d35f9ba68e7174bc026ed16b03f/case_studies/broadband_survey/add-fields.gif -------------------------------------------------------------------------------- /case_studies/broadband_survey/clone.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/guardian/swarmize/d3b23b7e093c7d35f9ba68e7174bc026ed16b03f/case_studies/broadband_survey/clone.gif -------------------------------------------------------------------------------- /case_studies/broadband_survey/create.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/guardian/swarmize/d3b23b7e093c7d35f9ba68e7174bc026ed16b03f/case_studies/broadband_survey/create.gif -------------------------------------------------------------------------------- /case_studies/broadband_survey/csv.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/guardian/swarmize/d3b23b7e093c7d35f9ba68e7174bc026ed16b03f/case_studies/broadband_survey/csv.png -------------------------------------------------------------------------------- /case_studies/broadband_survey/embed-code.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/guardian/swarmize/d3b23b7e093c7d35f9ba68e7174bc026ed16b03f/case_studies/broadband_survey/embed-code.gif -------------------------------------------------------------------------------- /case_studies/broadband_survey/graphs.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/guardian/swarmize/d3b23b7e093c7d35f9ba68e7174bc026ed16b03f/case_studies/broadband_survey/graphs.gif -------------------------------------------------------------------------------- /case_studies/broadband_survey/login.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/guardian/swarmize/d3b23b7e093c7d35f9ba68e7174bc026ed16b03f/case_studies/broadband_survey/login.gif -------------------------------------------------------------------------------- /case_studies/broadband_survey/move-delete.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/guardian/swarmize/d3b23b7e093c7d35f9ba68e7174bc026ed16b03f/case_studies/broadband_survey/move-delete.gif -------------------------------------------------------------------------------- /case_studies/broadband_survey/open.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/guardian/swarmize/d3b23b7e093c7d35f9ba68e7174bc026ed16b03f/case_studies/broadband_survey/open.gif -------------------------------------------------------------------------------- /case_studies/broadband_survey/permissions.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/guardian/swarmize/d3b23b7e093c7d35f9ba68e7174bc026ed16b03f/case_studies/broadband_survey/permissions.gif -------------------------------------------------------------------------------- /case_studies/broadband_survey/preview.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/guardian/swarmize/d3b23b7e093c7d35f9ba68e7174bc026ed16b03f/case_studies/broadband_survey/preview.png -------------------------------------------------------------------------------- /case_studies/broadband_survey/table.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/guardian/swarmize/d3b23b7e093c7d35f9ba68e7174bc026ed16b03f/case_studies/broadband_survey/table.png -------------------------------------------------------------------------------- /case_studies/broadband_survey/thumb.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/guardian/swarmize/d3b23b7e093c7d35f9ba68e7174bc026ed16b03f/case_studies/broadband_survey/thumb.png -------------------------------------------------------------------------------- /case_studies/broadband_survey/view-form.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/guardian/swarmize/d3b23b7e093c7d35f9ba68e7174bc026ed16b03f/case_studies/broadband_survey/view-form.png -------------------------------------------------------------------------------- /case_studies/indyref/indyref-graph1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/guardian/swarmize/d3b23b7e093c7d35f9ba68e7174bc026ed16b03f/case_studies/indyref/indyref-graph1.png -------------------------------------------------------------------------------- /case_studies/indyref/indyref-graph2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/guardian/swarmize/d3b23b7e093c7d35f9ba68e7174bc026ed16b03f/case_studies/indyref/indyref-graph2.png -------------------------------------------------------------------------------- /case_studies/indyref/indyref-graph3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/guardian/swarmize/d3b23b7e093c7d35f9ba68e7174bc026ed16b03f/case_studies/indyref/indyref-graph3.png -------------------------------------------------------------------------------- /case_studies/indyref/indyref1.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/guardian/swarmize/d3b23b7e093c7d35f9ba68e7174bc026ed16b03f/case_studies/indyref/indyref1.gif -------------------------------------------------------------------------------- /case_studies/indyref/thumb.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/guardian/swarmize/d3b23b7e093c7d35f9ba68e7174bc026ed16b03f/case_studies/indyref/thumb.png -------------------------------------------------------------------------------- /case_studies/realtime_clicker/aggregate-field.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/guardian/swarmize/d3b23b7e093c7d35f9ba68e7174bc026ed16b03f/case_studies/realtime_clicker/aggregate-field.gif -------------------------------------------------------------------------------- /case_studies/realtime_clicker/api-keys.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/guardian/swarmize/d3b23b7e093c7d35f9ba68e7174bc026ed16b03f/case_studies/realtime_clicker/api-keys.gif -------------------------------------------------------------------------------- /case_studies/realtime_clicker/get-code.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/guardian/swarmize/d3b23b7e093c7d35f9ba68e7174bc026ed16b03f/case_studies/realtime_clicker/get-code.gif -------------------------------------------------------------------------------- /case_studies/realtime_clicker/map-demo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/guardian/swarmize/d3b23b7e093c7d35f9ba68e7174bc026ed16b03f/case_studies/realtime_clicker/map-demo.png -------------------------------------------------------------------------------- /case_studies/realtime_clicker/preview-form.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/guardian/swarmize/d3b23b7e093c7d35f9ba68e7174bc026ed16b03f/case_studies/realtime_clicker/preview-form.png -------------------------------------------------------------------------------- /case_studies/realtime_clicker/results-over-time.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/guardian/swarmize/d3b23b7e093c7d35f9ba68e7174bc026ed16b03f/case_studies/realtime_clicker/results-over-time.png -------------------------------------------------------------------------------- /case_studies/realtime_clicker/thumb.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/guardian/swarmize/d3b23b7e093c7d35f9ba68e7174bc026ed16b03f/case_studies/realtime_clicker/thumb.jpg -------------------------------------------------------------------------------- /cloudformation/README.md: -------------------------------------------------------------------------------- 1 | # Cloudformation Scripts 2 | 3 | These scripts are used to deploy swarmize on an amazon account. 4 | 5 | Before using, you need to manually create an S3 bucket to store these, and the distibution artifacts, on. 6 | Update settings.sh to define the name of that bucket. 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /cloudformation/base.template: -------------------------------------------------------------------------------- 1 | { 2 | "AWSTemplateFormatVersion" : "2010-09-09", 3 | 4 | "Description" : "swamize: basic infrastructure", 5 | 6 | "Resources" : { 7 | 8 | } 9 | 10 | } 11 | -------------------------------------------------------------------------------- /cloudformation/bashlib/shared.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | S3_CFN_PATH="s3://$BUCKET_NAME/cfn/" 4 | S3_CFN_URL="https://s3-$REGION.amazonaws.com/$BUCKET_NAME/cfn" 5 | S3_DIST_PATH="s3://$BUCKET_NAME/" 6 | S3_DIST_URL="https://s3-$REGION.amazonaws.com/$BUCKET_NAME" 7 | AWS_CMD="aws --region $REGION --profile $PROFILE" 8 | 9 | echo "Region: $REGION Profile: $PROFILE" 10 | 11 | 12 | uploadTemplates() 13 | { 14 | echo "Uploading templates to $S3_CFN_PATH..." 15 | 16 | ${AWS_CMD} s3 sync . ${S3_CFN_PATH} --exclude "*" --include "*.template" --acl public-read 17 | 18 | echo "Uploading distribution files to $S3_DIST_URL..." 19 | 20 | ${AWS_CMD} s3 sync dist ${S3_DIST_PATH} --acl public-read 21 | 22 | } -------------------------------------------------------------------------------- /cloudformation/cfn.conf: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | PROFILE=swarmize 4 | REGION=eu-west-1 5 | BUCKET_NAME=swarmize-bin 6 | STACK_NAME="Swarmize" -------------------------------------------------------------------------------- /cloudformation/create_all.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | . cfn.conf 4 | 5 | . bashlib/shared.sh 6 | 7 | uploadTemplates 8 | 9 | echo "Applying cloudformation script..." 10 | 11 | ${AWS_CMD} cloudformation create-stack \ 12 | --stack-name "$STACK_NAME" \ 13 | --template-url "$S3_CFN_URL/all.template" \ 14 | --capabilities CAPABILITY_IAM \ 15 | --parameters ParameterKey=TemplateBucketPath,ParameterValue=${S3_CFN_URL} \ 16 | ParameterKey=DistBucketPath,ParameterValue=${S3_DIST_URL} 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /cloudformation/delete_all.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | . cfn.conf 4 | 5 | . bashlib/shared.sh 6 | 7 | echo "Deleting cloudformation stack $STACK_NAME..." 8 | 9 | ${AWS_CMD} cloudformation delete-stack \ 10 | --stack-name "$STACK_NAME" \ 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /cloudformation/dist/elasticsearch.yml: -------------------------------------------------------------------------------- 1 | cluster.name: swarmize 2 | 3 | plugin.mandatory: cloud-aws 4 | 5 | cloud.aws.region: eu-west-1 6 | cloud.node.auto_attributes: true 7 | 8 | gateway.recover_after_nodes: 2 9 | gateway.recover_after_time: 2m 10 | gateway.expected_nodes: 2 11 | 12 | discovery.zen.ping.multicast.enabled: false 13 | discovery.zen.minimum_master_nodes: 1 14 | 15 | discovery.type: ec2 16 | discovery.ec2.tag.Name: swarmize-elasticsearch 17 | 18 | index.number_of_shards: 3 19 | index.number_of_replicas: 0 20 | 21 | -------------------------------------------------------------------------------- /cloudformation/update_all.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | . cfn.conf 4 | 5 | . bashlib/shared.sh 6 | 7 | uploadTemplates 8 | 9 | echo "Updating cloudformation for $STACK_NAME..." 10 | 11 | ${AWS_CMD} cloudformation update-stack \ 12 | --stack-name "$STACK_NAME" \ 13 | --template-url "$S3_CFN_URL/all.template" \ 14 | --capabilities CAPABILITY_IAM \ 15 | --parameters ParameterKey=TemplateBucketPath,ParameterValue=${S3_CFN_URL} \ 16 | ParameterKey=DistBucketPath,ParameterValue=${S3_DIST_URL} 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /cloudformation/validate_all.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | . cfn.conf 4 | 5 | . bashlib/shared.sh 6 | 7 | uploadTemplates 8 | 9 | echo "Validating cloudformation script..." 10 | 11 | ${AWS_CMD} cloudformation validate-template \ 12 | --template-url "$S3_CFN_URL/all.template" 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /collector/README.md: -------------------------------------------------------------------------------- 1 | Collector 2 | ========= 3 | 4 | This is a scala app, built with scala's [simple build tool](http://www.scala-sbt.org/). 5 | 6 | To build, first install any version of sbt as described [here](http://www.scala-sbt.org/download.html). 7 | Summary: on a mac, just `brew install sbt`. 8 | 9 | Then in this directory: 10 | 11 | ``` 12 | $ sbt 13 | > test:run 14 | ``` 15 | 16 | The first time you run, the internet will download. It shouldn't happen again. 17 | -------------------------------------------------------------------------------- /collector/app/Global.scala: -------------------------------------------------------------------------------- 1 | import play.api.http.HeaderNames 2 | import play.api.mvc.{Filter, RequestHeader, Result, WithFilters} 3 | 4 | import scala.concurrent.Future 5 | 6 | import scala.concurrent.ExecutionContext.Implicits.global 7 | 8 | object Global extends WithFilters(AddCorsHeaderFilter) { 9 | } 10 | 11 | 12 | object AddCorsHeaderFilter extends Filter { 13 | override def apply(nextFilter: (RequestHeader) => Future[Result])(req: RequestHeader): Future[Result] = { 14 | nextFilter(req) map ( 15 | _.withHeaders(HeaderNames.ACCESS_CONTROL_ALLOW_ORIGIN -> "*") 16 | ) 17 | } 18 | } -------------------------------------------------------------------------------- /collector/app/controllers/Application.scala: -------------------------------------------------------------------------------- 1 | package controllers 2 | 3 | import play.api.mvc._ 4 | 5 | object Application extends Controller { 6 | 7 | def index = Action { 8 | Ok("swarmize: collector") 9 | } 10 | 11 | } -------------------------------------------------------------------------------- /collector/app/controllers/Management.scala: -------------------------------------------------------------------------------- 1 | package controllers 2 | 3 | import play.api.mvc.{Controller, Action} 4 | 5 | object Management extends Controller { 6 | def healthCheck() = Action { 7 | Ok("All good") 8 | } 9 | } -------------------------------------------------------------------------------- /collector/app/views/index.scala.html: -------------------------------------------------------------------------------- 1 | @(message: String) 2 | 3 | @main("Welcome to Play") { 4 | 5 | @play20.welcome(message) 6 | 7 | } 8 | -------------------------------------------------------------------------------- /collector/app/views/main.scala.html: -------------------------------------------------------------------------------- 1 | @(title: String)(content: Html) 2 | 3 | 4 | 5 | 6 |
7 |The below data is retrieved via JSON - but you won't expose a token in the front-end if you do so.
22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /examples/livedebate-scotland/README.md: -------------------------------------------------------------------------------- 1 | # Swarmize app demo: single page example. 2 | 3 | This demonstration is of a "live clicker" for real-time feedback during a TV debate: the user enters their name and postcode, and then taps a face every time they agree with something said on TV. 4 | 5 | This demo differs from the original `livedebate` version by not requiring a backend: it posts data directly to the collector via Javascript. 6 | 7 | ## Running 8 | 9 | Serve "index.html" from a webserver of your choice. For instance, in the project directory: 10 | 11 | python -m SimpleHTTPServer 12 | 13 | or using node's `http-server` 14 | 15 | http-server 16 | 17 | From the application directory: 18 | 19 | npm start 20 | 21 | And then you'll be able to view the clicker at: 22 | 23 | http://localhost:8000/ 24 | 25 | (or whatever port the server is running on). 26 | 27 | 28 | ## Notes 29 | 30 | You'll note you don't need an API token to send data to the Collector API: all valid requests to swarms that aren't closed are accepted; you just need to know the field names, swarm token, and ensure your data submitted is valid. 31 | 32 | So as to be able to filter all results by individual users, each user gets a unique token which is set as a cookie, and injected into a hidden field within the form. 33 | 34 | The app is presented as a single form for conceptual purposes - one form posting to Swarmize - but could, obviously, be made more complex to make the interactions more compelling. 35 | 36 | As you can see, unlike the retrieval API examples, submitting to the Collector is most straightforwardly done without a backend, and there are few downsides to this approach. -------------------------------------------------------------------------------- /examples/livedebate-scotland/ad.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/guardian/swarmize/d3b23b7e093c7d35f9ba68e7174bc026ed16b03f/examples/livedebate-scotland/ad.jpg -------------------------------------------------------------------------------- /examples/livedebate-scotland/as.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/guardian/swarmize/d3b23b7e093c7d35f9ba68e7174bc026ed16b03f/examples/livedebate-scotland/as.jpg -------------------------------------------------------------------------------- /examples/livedebate-scotland/debate.js: -------------------------------------------------------------------------------- 1 | $(document).ready(function() { 2 | if(!docCookies.hasItem('scotlandUserId')) { 3 | docCookies.setItem('scotlandUserId',Date.now(),Infinity); 4 | } 5 | 6 | // set hidden field. 7 | $("#userkey").val(docCookies.getItem('scotlandUserId')); 8 | 9 | // Open external links in a new window 10 | $(".feedback-buttons").hide(); 11 | 12 | $(".next-button").click(function(e) { 13 | $(".setup").hide(); 14 | $("h1").hide(); 15 | $(".feedback-buttons").show(); 16 | e.preventDefault(); 17 | }); 18 | 19 | $(".feedback-button").click(function(e) { 20 | if(!$(this).hasClass('disabled')) { 21 | clickVisuals(this); 22 | $("input#feedback").val(this.id); 23 | $.post( $("form#debate").attr('action'), 24 | $("form#debate").serialize()); 25 | } 26 | e.preventDefault(); 27 | }); 28 | 29 | }); 30 | 31 | function clickVisuals(el) { 32 | $(".feedback-button").animate({'opacity': 0.5},200); 33 | 34 | var top = $(el).offset().top + 20 35 | //var left = ($(el).width() / 2) - 20; 36 | var left = 0; 37 | 38 | $("body").append("http://www.swarmize.com/swarms/rycadjgp
12 |
13 | = submit_tag "Import Swarm", :class => "btn btn-default"
14 |
--------------------------------------------------------------------------------
/swarmize-dot-com/app/views/swarms/_embed_closed.html.haml:
--------------------------------------------------------------------------------
1 | .embeddable-swarm
2 | - if @swarm.display_title
3 | %h2= @swarm.name
4 | - if @swarm.display_description
5 | .explanation= simple_format @swarm.description
6 | .closed
7 | This swarm is now closed, and is no longer accepting responses.
8 |
9 | .small
10 | Powered by
11 | %b Swarmize.
12 |
13 |
--------------------------------------------------------------------------------
/swarmize-dot-com/app/views/swarms/_embed_live.html.haml:
--------------------------------------------------------------------------------
1 | .embeddable-swarm
2 | - if @swarm.display_title
3 | %h2= @swarm.name
4 | - if @swarm.display_description
5 | .explanation= simple_format @swarm.description
6 | = form_tag @swarm.collector_url, 'data-parsley-validate' => 'true' do
7 | - if @swarm.swarm_fields
8 | - @swarm.swarm_fields.each do |swarm_field|
9 | - if swarm_field.has_custom_display?
10 | = render "form_partials/#{swarm_field.field_type}_display_field_partial", field: swarm_field, field_description: swarm_field.description
11 | - else
12 | = render "form_partials/display_field_partial", field: swarm_field, field_description: swarm_field.description
13 | %p.submit
14 | = submit_tag "Submit", :class => "btn btn-default"
15 |
16 | .feedback
17 | .small
18 | Powered by
19 | %b Swarmize.
20 |
21 |
--------------------------------------------------------------------------------
/swarmize-dot-com/app/views/swarms/_field_code_update_js.html.haml:
--------------------------------------------------------------------------------
1 | :javascript
2 | $(document).ready(function() {
3 | $(".code-text-block a.alter").click(function(e) {
4 | $(this).parents('.form-group').find('.field-code-block').show();
5 | $(this).parents('.code-text-block').hide();
6 | e.preventDefault();
7 | });
8 |
9 | $("input.field-name").unbind('change').on('change', function(e) {
10 | if(!('hasCustomFieldCode' in $(this).parents('.form-element').data())) {
11 | var fieldCode = $(this).val();
12 | var codeField = $(this).parents('.form-element').find('.field-code');
13 | var codeText = $(this).parents('.form-element').find('.code-text');
14 | $.get("/utils/name_to_code", {name: fieldCode}, function(data) {
15 | $(codeField).val(data);
16 | $(codeText).text(data);
17 | });
18 | }
19 | });
20 |
21 | $("input.field-code").unbind('focus').on('focus', function(e) {
22 | console.log('focus');
23 | $(this).data('code-pre-alter', $(this).val());
24 | console.log($(this).data());
25 | });
26 |
27 | $("input.field-code").unbind('change').on('change', function(e) {
28 | if('codePreAlter' in $(this).data()) {
29 | if($(this).val() != $(this).data('codePreAlter')) {
30 | console.log("changed by hand, noting this is a custom field code");
31 | $(this).parents('.form-element').data('hasCustomFieldCode', true);
32 | }
33 | }
34 | });
35 | });
36 |
--------------------------------------------------------------------------------
/swarmize-dot-com/app/views/swarms/_swarm_description_open_close.html.haml:
--------------------------------------------------------------------------------
1 | .row
2 | .col-sm-6
3 | .desc= simple_format @swarm.description
4 | .col-sm-6
5 | .row
6 | .col-sm-6
7 | - if @swarm.has_opened?
8 | %h3 Opened at
9 | %h4
10 | = format_swarm_date(@swarm.opens_at)
11 | %br
12 | = format_swarm_time(@swarm.opens_at)
13 | .col-sm-6
14 | - if @swarm.closed?
15 | %h3 Closed at
16 | %h4
17 | = format_swarm_date(@swarm.closes_at)
18 | %br
19 | = format_swarm_time(@swarm.closes_at)
20 |
--------------------------------------------------------------------------------
/swarmize-dot-com/app/views/swarms/_swarm_dropdown_menu.html.haml:
--------------------------------------------------------------------------------
1 | .dropdown.actions-dropdown
2 | %button.btn.btn-default.dropdown-toggle{"data-toggle" => "dropdown"}
3 | Actions
4 | %span.caret
5 | %ul.dropdown-menu.dropdown-menu-right
6 | %li
7 | = link_to " Clone".html_safe, clone_swarm_path(@swarm), :method => :post
8 | %li.divider
9 | - if AccessPermission.can_alter?(@swarm, @current_user) && !@swarm.closed?
10 | %li
11 | %a{:href => edit_swarm_path(@swarm)}
12 | = glyphicon('pencil')
13 | Edit
14 |
15 | - if AccessPermission.can_alter?(@swarm, @current_user)
16 | %li
17 | %a{:href => code_swarm_path(@swarm)}
18 | = glyphicon('th-list')
19 | Get Code
20 | %li
21 | %a{:href => swarm_api_keys_path(@swarm)}
22 | = glyphicon('tag')
23 | API Keys
24 | %li
25 | %a{:href => swarm_permissions_path(@swarm)}
26 | = glyphicon('user')
27 | Permissions
28 | - if AccessPermission.can_destroy?(@swarm, @current_user)
29 | %li.divider
30 | %li
31 | %a{:href => delete_swarm_path(@swarm)}
32 | = glyphicon('remove')
33 | Delete
34 |
35 |
--------------------------------------------------------------------------------
/swarmize-dot-com/app/views/swarms/_swarm_graphs.html.haml:
--------------------------------------------------------------------------------
1 | %h2 Graphs
2 |
3 | - @swarm.graphs.each_with_index do |graph, i|
4 | = render :partial => "graphs/#{graph.graph_type}", :locals => {:graph => graph, :count => i}
5 |
6 | #graphs
7 |
8 | .clearfix
9 |
10 |
--------------------------------------------------------------------------------
/swarmize-dot-com/app/views/swarms/_swarm_header.html.haml:
--------------------------------------------------------------------------------
1 | .row
2 | .page-header.swarmize-header
3 | .col-sm-9
4 | %h1
5 | = @swarm.name
6 | - if @swarm.live?
7 | %span.label.label-success.swarmlive Live!
8 | .subheader
9 | = @swarm.owners.map { |creator| link_to @swarm.creator.name, user_path(@swarm.creator) }.to_sentence
10 | - if @current_user
11 | |
12 | = link_to "View Form", embed_swarm_path(@swarm)
13 | - if @swarm.parent_swarm
14 | %small
15 | [Cloned from #{link_to @swarm.parent_swarm.name, swarm_path(@swarm.parent_swarm)}]
16 |
17 | .col-sm-3.swarm-controls
18 | = render :partial => 'swarms/swarm_dropdown_menu'
19 |
20 | .clearfix
21 |
--------------------------------------------------------------------------------
/swarmize-dot-com/app/views/swarms/_swarm_page_js.html.haml:
--------------------------------------------------------------------------------
1 | :javascript
2 | $(document).ready(function() {
3 | $("#set-open-date-to-now").click(function(e) {
4 | var d = new Date();
5 |
6 | var year = d.getFullYear();
7 | var month = d.getMonth() + 1;
8 | var day = d.getDate();
9 | var hours = d.getHours();
10 | var mins = d.getMinutes();
11 |
12 | $('select[name=open_year]').val(year);
13 | $('select[name=open_month]').val(month);
14 | $('select[name=open_day]').val(day);
15 | $('select[name=open_hour]').val(hours);
16 | $('select[name=open_minute]').val(mins);
17 |
18 | e.preventDefault();
19 | });
20 |
21 | $("#open-submit").click(function(e) {
22 | $("#open-date-form").submit();
23 | e.preventDefault();
24 | });
25 |
26 | $("#set-close-date-to-now").click(function(e) {
27 | var d = new Date();
28 |
29 | var year = d.getFullYear();
30 | var month = d.getMonth() + 1;
31 | var day = d.getDate();
32 | var hours = d.getHours();
33 | var mins = d.getMinutes();
34 |
35 | $('select[name=close_year]').val(year);
36 | $('select[name=close_month]').val(month);
37 | $('select[name=close_day]').val(day);
38 | $('select[name=close_hour]').val(hours);
39 | $('select[name=close_minute]').val(mins);
40 |
41 | e.preventDefault();
42 | });
43 |
44 | $("#close-submit").click(function(e) {
45 | $("#close-date-form").submit();
46 | e.preventDefault();
47 | });
48 | });
49 |
--------------------------------------------------------------------------------
/swarmize-dot-com/app/views/swarms/_swarm_table.html.haml:
--------------------------------------------------------------------------------
1 | %table.table
2 | %thead
3 | %tr
4 | %th Name
5 | %th Description
6 | %th Created by
7 | %th Opens At
8 | %th Closes At
9 |
10 | %tbody
11 | - if swarms && swarms.any?
12 | - for swarm in swarms
13 | %tr
14 | %td= link_to swarm.name, swarm
15 | %td= swarm.description
16 | %td= link_to swarm.creator.name, user_path(swarm.creator) if swarm.creator
17 | %td= swarm.opens_at
18 | %td= swarm.closes_at
19 |
--------------------------------------------------------------------------------
/swarmize-dot-com/app/views/swarms/closed.html.haml:
--------------------------------------------------------------------------------
1 | - content_for :pagetitle do
2 | Closed Swarms : Swarms :
3 |
4 | %h1 Explore Swarms
5 |
6 | %ul.nav.nav-tabs
7 | %li
8 | %a{:href => swarms_path}
9 | All Swarms
10 | %span.badge= @all_swarms_count
11 | - if @current_user
12 | %li
13 | %a{:href => draft_swarms_path}
14 | Draft
15 | %span.badge= @open_swarms_count
16 | %li
17 | %a{:href => live_swarms_path}
18 | In Progress
19 | %span.badge= @live_swarms_count
20 | %li.active
21 | %a{:href => closed_swarms_path}
22 | Closed
23 | %span.badge= @closed_swarms_count
24 |
25 | = render :partial => "swarms/swarm_table", :locals => {:swarms => @swarms}
26 |
27 | = will_paginate @swarms
28 |
29 | - if @current_user
30 | %p= link_to "New swarm", new_swarm_path
31 |
--------------------------------------------------------------------------------
/swarmize-dot-com/app/views/swarms/code.html.haml:
--------------------------------------------------------------------------------
1 | - content_for :pagetitle do
2 | Code for #{@swarm.name} : Swarms :
3 |
4 | .page-header.swarmize-header
5 | %h1
6 | Code for '#{@swarm.name}'
7 | %p
8 | %a{:href => swarm_path(@swarm)}
9 | = glyphicon('circle-arrow-left')
10 | Back to swarm
11 | %dl
12 | %dt Embed code
13 | %dd
14 | %textarea{style: 'width: 400px; height: 150px;'}
15 | #{""}
16 |
17 | %dt Token
18 | %dd
19 | %code= @swarm.token
20 |
21 | %dt Collector URL
22 | %dd
23 | %code= @swarm.collector_url
24 |
25 | %table.table
26 | %thead
27 | %tr
28 | %th Field name
29 | %th Field code
30 | %th Field type
31 | %th Possible values
32 | %tbody
33 | - @swarm.swarm_fields.each do |f|
34 | %tr
35 | %td= f.field_name
36 | %td
37 | %code= f.field_code
38 | %td
39 | %code= f.field_type
40 | %td
41 | - case f.field_type
42 | - when 'yesno'
43 | %code yes
44 | %br
45 | %code no
46 | - when 'rating'
47 | %code #{f.minimum}...#{f.maximum}
48 | - when 'pick_one', 'pick_several'
49 | - if f.possible_values
50 | - f.possible_values.each do |v|
51 | %code= v.parameterize.underscore
52 | %br
53 |
54 | %p= link_to "API Documentation", doc_path('api')
55 |
--------------------------------------------------------------------------------
/swarmize-dot-com/app/views/swarms/delete.html.haml:
--------------------------------------------------------------------------------
1 | - content_for :pagetitle do
2 | Delete Swarm '#{@swarm.name}'? : Swarms :
3 |
4 | .page-header.swarmize-header
5 | %h1
6 | Delete swarm '#{@swarm.name}'?
7 | %p
8 | %a{:href => swarm_path(@swarm)}
9 | = glyphicon('circle-arrow-left')
10 | Back to swarm
11 |
12 | %p Are you sure you want to delete this swarm?
13 |
14 | %p
15 | = button_to "Delete", swarm_path(@swarm), :method => :delete, :class => "btn btn-default"
16 | or
17 | = link_to "Return to all swarms", swarms_path
18 |
--------------------------------------------------------------------------------
/swarmize-dot-com/app/views/swarms/draft.html.haml:
--------------------------------------------------------------------------------
1 | - content_for :pagetitle do
2 | Yet To Open : Swarms :
3 |
4 | %h1 Explore Swarms
5 |
6 | %ul.nav.nav-tabs
7 | %li
8 | %a{:href => swarms_path}
9 | All Swarms
10 | %span.badge= @all_swarms_count
11 | %li.active
12 | %a{:href => draft_swarms_path}
13 | Draft
14 | %span.badge= @open_swarms_count
15 | %li
16 | %a{:href => live_swarms_path}
17 | In Progress
18 | %span.badge= @live_swarms_count
19 | %li
20 | %a{:href => closed_swarms_path}
21 | Closed
22 | %span.badge= @closed_swarms_count
23 |
24 | = render :partial => "swarms/swarm_table", :locals => {:swarms => @swarms}
25 |
26 | = will_paginate @swarms
27 |
28 | - if @current_user
29 | %p= link_to "New swarm", new_swarm_path
30 |
--------------------------------------------------------------------------------
/swarmize-dot-com/app/views/swarms/embed.html.haml:
--------------------------------------------------------------------------------
1 | - if @swarm.closed?
2 | = render :partial => 'swarms/embed_closed'
3 | - else
4 | = render :partial => 'swarms/embed_live'
5 |
--------------------------------------------------------------------------------
/swarmize-dot-com/app/views/swarms/index.html.haml:
--------------------------------------------------------------------------------
1 | - content_for :pagetitle do
2 | Swarms :
3 |
4 | %h1 Explore Swarms
5 |
6 | %ul.nav.nav-tabs
7 | %li.active
8 | %a{:href => swarms_path}
9 | All Swarms
10 | %span.badge= @all_swarms_count
11 | - if @current_user
12 | %li
13 | %a{:href => draft_swarms_path}
14 | Draft
15 | %span.badge= @open_swarms_count
16 | %li
17 | %a{:href => live_swarms_path}
18 | In Progress
19 | %span.badge= @live_swarms_count
20 | %li
21 | %a{:href => closed_swarms_path}
22 | Closed
23 | %span.badge= @closed_swarms_count
24 |
25 | = render :partial => "swarms/swarm_table", :locals => {:swarms => @swarms}
26 |
27 | = will_paginate @swarms
28 |
29 | - if @current_user
30 | %p= link_to "New swarm", new_swarm_path
31 |
--------------------------------------------------------------------------------
/swarmize-dot-com/app/views/swarms/live.html.haml:
--------------------------------------------------------------------------------
1 | - content_for :pagetitle do
2 | Live Swarms : Swarms :
3 |
4 | %h1 Explore Swarms
5 |
6 | %ul.nav.nav-tabs
7 | %li
8 | %a{:href => swarms_path}
9 | All Swarms
10 | %span.badge= @all_swarms_count
11 | - if @current_user
12 | %li
13 | %a{:href => draft_swarms_path}
14 | Draft
15 | %span.badge= @open_swarms_count
16 | %li.active
17 | %a{:href => live_swarms_path}
18 | In Progress
19 | %span.badge= @live_swarms_count
20 | %li
21 | %a{:href => closed_swarms_path}
22 | Closed
23 | %span.badge= @closed_swarms_count
24 |
25 | = render :partial => "swarms/swarm_table", :locals => {:swarms => @swarms}
26 |
27 | = will_paginate @swarms
28 |
29 | - if @current_user
30 | %p= link_to "New swarm", new_swarm_path
31 |
--------------------------------------------------------------------------------
/swarmize-dot-com/app/views/swarms/preview.html.haml:
--------------------------------------------------------------------------------
1 | - content_for :pagetitle do
2 | Preview '#{@swarm.name}' : Swarms :
3 |
4 | .page-header.swarmize-header
5 | %h1 Preview '#{@swarm.name}'
6 | %p= link_to "Back to swarm", @swarm
7 |
8 | %ul.nav.nav-tabs.swarmbuilder-nav.nav-justified
9 | %li
10 | %a{:href => edit_swarm_path(@swarm)}
11 | = glyphicon('pencil')
12 | Swarm Details
13 | %li
14 | %a{:href => fields_swarm_path(@swarm)}
15 | = glyphicon('list')
16 | Swarm Fields
17 | %li.active
18 | %a{:href => preview_swarm_path(@swarm)}
19 | = glyphicon('list-alt')
20 | Preview Swarm
21 |
22 | %script{type: 'text/javascript', src: '/js/swarmize-embed.js'}
23 | #swarmize-embedded-form{"data-swarmize-token" => @swarm.token}
24 | = link_to "Fill out your answers on swarmize.com", embed_swarm_path(@swarm)
25 |
26 | %p
27 | = link_to "← Alter fields".html_safe, fields_swarm_path(@swarm), :class => "btn btn-default"
28 | = link_to "Done!", @swarm, :class => "btn btn-default"
29 |
30 | %p= link_to "Back to swarm", @swarm
31 |
--------------------------------------------------------------------------------
/swarmize-dot-com/app/views/users/_user_header.html.haml:
--------------------------------------------------------------------------------
1 | .page-header.swarmize-header
2 | %h1
3 | Swarms for #{@user.name}
4 | - if @user == @current_user
5 | %span.label.label-success.swarmlive You!
6 |
7 |
--------------------------------------------------------------------------------
/swarmize-dot-com/app/views/users/closed.html.haml:
--------------------------------------------------------------------------------
1 | - content_for :pagetitle do
2 | Closed Swarms for #{@user.name} : Users :
3 |
4 | = render :partial => 'users/user_header'
5 |
6 | %ul.nav.nav-tabs
7 | %li
8 | %a{:href => user_path(@user)}
9 | All Swarms
10 | %span.badge= @all_swarms_count
11 | - if AccessPermission.can_see_user_drafts?(@current_user, @user)
12 | %li
13 | %a{:href => draft_user_path(@user)}
14 | Draft
15 | %span.badge= @open_swarms_count
16 | %li
17 | %a{:href => live_user_path(@user)}
18 | In Progress
19 | %span.badge= @live_swarms_count
20 | %li.active
21 | %a{:href => closed_user_path(@user)}
22 | Closed
23 | %span.badge= @closed_swarms_count
24 |
25 | = render :partial => "swarms/swarm_table", :locals => {:swarms => @swarms}
26 | = will_paginate @swarms
27 |
--------------------------------------------------------------------------------
/swarmize-dot-com/app/views/users/delete.html.haml:
--------------------------------------------------------------------------------
1 | - content_for :pagetitle do
2 | Delete #{@user.name}? : Users :
3 |
4 | .page-header.swarmize-header
5 | %h1 Delete User '#{@user.name}'?
6 |
7 | %p Are you sure you want to delete this user?
8 |
9 | %p
10 | = button_to "Delete", user_path(@user), :method => :delete, :class => "btn btn-default"
11 | or
12 | = link_to "Return to all users", users_path
13 |
--------------------------------------------------------------------------------
/swarmize-dot-com/app/views/users/draft.html.haml:
--------------------------------------------------------------------------------
1 | - content_for :pagetitle do
2 | Swarms yet to open for #{@user.name} : Users :
3 |
4 | = render :partial => 'users/user_header'
5 |
6 | %ul.nav.nav-tabs
7 | %li
8 | %a{:href => user_path(@user)}
9 | All Swarms
10 | %span.badge= @all_swarms_count
11 | - if AccessPermission.can_see_user_drafts?(@current_user, @user)
12 | %li.active
13 | %a{:href => draft_user_path(@user)}
14 | Draft
15 | %span.badge= @open_swarms_count
16 | %li
17 | %a{:href => live_user_path(@user)}
18 | In Progress
19 | %span.badge= @live_swarms_count
20 | %li
21 | %a{:href => closed_user_path(@user)}
22 | Closed
23 | %span.badge= @closed_swarms_count
24 |
25 | = render :partial => "swarms/swarm_table", :locals => {:swarms => @swarms}
26 | = will_paginate @swarms
27 |
--------------------------------------------------------------------------------
/swarmize-dot-com/app/views/users/index.html.haml:
--------------------------------------------------------------------------------
1 | - content_for :pagetitle do
2 | Users :
3 |
4 | .page-header.swarmize-header
5 | %h1 Users
6 |
7 | %p This page is intended for development purposes only: to enumerate who's in the system.
8 |
9 | %table.table
10 | %thead
11 | %tr
12 | %th Name
13 | %th Email
14 | %th Image
15 | %th Is Fake?
16 | %th Actions
17 | %tbody
18 | - for user in @users
19 | %tr
20 | %td= user.name
21 | %td= user.email
22 | %td= image_tag(user.image_url)
23 | %td
24 | - if user.is_fake?
25 | √
26 | %td
27 | = link_to "View", user_path(user)
28 | |
29 | = link_to "Edit", edit_user_path(user)
30 | |
31 | = link_to "Delete", delete_user_path(user)
32 |
33 | = will_paginate @users
34 |
35 |
--------------------------------------------------------------------------------
/swarmize-dot-com/app/views/users/live.html.haml:
--------------------------------------------------------------------------------
1 | - content_for :pagetitle do
2 | Live Swarms for #{@user.name} : Users :
3 |
4 | = render :partial => 'users/user_header'
5 |
6 | %ul.nav.nav-tabs
7 | %li
8 | %a{:href => user_path(@user)}
9 | All Swarms
10 | %span.badge= @all_swarms_count
11 | - if AccessPermission.can_see_user_drafts?(@current_user, @user)
12 | %li
13 | %a{:href => draft_user_path(@user)}
14 | Draft
15 | %span.badge= @open_swarms_count
16 | %li.active
17 | %a{:href => live_user_path(@user)}
18 | In Progress
19 | %span.badge= @live_swarms_count
20 | %li
21 | %a{:href => closed_user_path(@user)}
22 | Closed
23 | %span.badge= @closed_swarms_count
24 |
25 | = render :partial => "swarms/swarm_table", :locals => {:swarms => @swarms}
26 | = will_paginate @swarms
27 |
--------------------------------------------------------------------------------
/swarmize-dot-com/app/views/users/show.html.haml:
--------------------------------------------------------------------------------
1 | - content_for :pagetitle do
2 | #{@user.name} : Users :
3 |
4 | = render :partial => 'users/user_header'
5 |
6 | %ul.nav.nav-tabs
7 | %li.active
8 | %a{:href => user_path(@user)}
9 | All Swarms
10 | %span.badge= @all_swarms_count
11 | - if AccessPermission.can_see_user_drafts?(@current_user, @user)
12 | %li
13 | %a{:href => draft_user_path(@user)}
14 | Draft
15 | %span.badge= @open_swarms_count
16 | %li
17 | %a{:href => live_user_path(@user)}
18 | In Progress
19 | %span.badge= @live_swarms_count
20 | %li
21 | %a{:href => closed_user_path(@user)}
22 | Closed
23 | %span.badge= @closed_swarms_count
24 |
25 | = render :partial => "swarms/swarm_table", :locals => {:swarms => @swarms}
26 | = will_paginate @swarms
27 |
--------------------------------------------------------------------------------
/swarmize-dot-com/bin/bundle:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env ruby
2 | ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
3 | load Gem.bin_path('bundler', 'bundle')
4 |
--------------------------------------------------------------------------------
/swarmize-dot-com/bin/rails:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env ruby
2 | APP_PATH = File.expand_path('../../config/application', __FILE__)
3 | require_relative '../config/boot'
4 | require 'rails/commands'
5 |
--------------------------------------------------------------------------------
/swarmize-dot-com/bin/rake:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env ruby
2 | require_relative '../config/boot'
3 | require 'rake'
4 | Rake.application.run
5 |
--------------------------------------------------------------------------------
/swarmize-dot-com/config.ru:
--------------------------------------------------------------------------------
1 | # This file is used by Rack-based servers to start the application.
2 |
3 | require ::File.expand_path('../config/environment', __FILE__)
4 | run Rails.application
5 |
--------------------------------------------------------------------------------
/swarmize-dot-com/config/boot.rb:
--------------------------------------------------------------------------------
1 | # Set up gems listed in the Gemfile.
2 | ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
3 |
4 | require 'bundler/setup' if File.exists?(ENV['BUNDLE_GEMFILE'])
5 |
--------------------------------------------------------------------------------
/swarmize-dot-com/config/environment.rb:
--------------------------------------------------------------------------------
1 | # Load the Rails application.
2 | require File.expand_path('../application', __FILE__)
3 |
4 | # Initialize the Rails application.
5 | Swarmize::Application.initialize!
6 |
--------------------------------------------------------------------------------
/swarmize-dot-com/config/environments/development.rb:
--------------------------------------------------------------------------------
1 | Swarmize::Application.configure do
2 | # Settings specified here will take precedence over those in config/application.rb.
3 |
4 | # In the development environment your application's code is reloaded on
5 | # every request. This slows down response time but is perfect for development
6 | # since you don't have to restart the web server when you make code changes.
7 | config.cache_classes = false
8 |
9 | # Do not eager load code on boot.
10 | config.eager_load = false
11 |
12 | # Show full error reports and disable caching.
13 | config.consider_all_requests_local = true
14 | config.action_controller.perform_caching = false
15 |
16 | # Don't care if the mailer can't send.
17 | config.action_mailer.raise_delivery_errors = false
18 |
19 | # Print deprecation notices to the Rails logger.
20 | config.active_support.deprecation = :log
21 |
22 | # Raise an error on page load if there are pending migrations
23 | config.active_record.migration_error = :page_load
24 |
25 | # Debug mode disables concatenation and preprocessing of assets.
26 | # This option may cause significant delays in view rendering with a large
27 | # number of complex assets.
28 | config.assets.debug = true
29 | end
30 |
--------------------------------------------------------------------------------
/swarmize-dot-com/config/initializers/amazon_ses.rb:
--------------------------------------------------------------------------------
1 | ActionMailer::Base.add_delivery_method :ses, AWS::SES::Base,
2 | access_key_id: ENV['AWS_ACCESS_KEY_ID'],
3 | secret_access_key: ENV['AWS_SECRET_KEY'],
4 | server: 'email.eu-west-1.amazonaws.com'
5 |
--------------------------------------------------------------------------------
/swarmize-dot-com/config/initializers/aws.rb:
--------------------------------------------------------------------------------
1 | AWS.config(region: 'eu-west-1')
2 |
--------------------------------------------------------------------------------
/swarmize-dot-com/config/initializers/backtrace_silencers.rb:
--------------------------------------------------------------------------------
1 | # Be sure to restart your server when you modify this file.
2 |
3 | # You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces.
4 | # Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ }
5 |
6 | # You can also remove all the silencers if you're trying to debug a problem that might stem from framework code.
7 | # Rails.backtrace_cleaner.remove_silencers!
8 |
--------------------------------------------------------------------------------
/swarmize-dot-com/config/initializers/filter_parameter_logging.rb:
--------------------------------------------------------------------------------
1 | # Be sure to restart your server when you modify this file.
2 |
3 | # Configure sensitive parameters which will be filtered from the log file.
4 | Rails.application.config.filter_parameters += [:password]
5 |
--------------------------------------------------------------------------------
/swarmize-dot-com/config/initializers/inflections.rb:
--------------------------------------------------------------------------------
1 | # Be sure to restart your server when you modify this file.
2 |
3 | # Add new inflection rules using the following format. Inflections
4 | # are locale specific, and you may define rules for as many different
5 | # locales as you wish. All of these examples are active by default:
6 | # ActiveSupport::Inflector.inflections(:en) do |inflect|
7 | # inflect.plural /^(ox)$/i, '\1en'
8 | # inflect.singular /^(ox)en/i, '\1'
9 | # inflect.irregular 'person', 'people'
10 | # inflect.uncountable %w( fish sheep )
11 | # end
12 |
13 | # These inflection rules are supported but not enabled by default:
14 | # ActiveSupport::Inflector.inflections(:en) do |inflect|
15 | # inflect.acronym 'RESTful'
16 | # end
17 |
--------------------------------------------------------------------------------
/swarmize-dot-com/config/initializers/mime_types.rb:
--------------------------------------------------------------------------------
1 | # Be sure to restart your server when you modify this file.
2 |
3 | # Add new mime types for use in respond_to blocks:
4 | # Mime::Type.register "text/richtext", :rtf
5 | # Mime::Type.register_alias "text/html", :iphone
6 |
--------------------------------------------------------------------------------
/swarmize-dot-com/config/initializers/non_digest_assets.rb:
--------------------------------------------------------------------------------
1 | # this is now just in public/js
2 | # NonStupidDigestAssets.whitelist = ['swarmize-embed.js']
3 |
--------------------------------------------------------------------------------
/swarmize-dot-com/config/initializers/omniauth.rb:
--------------------------------------------------------------------------------
1 | Rails.application.config.middleware.use OmniAuth::Builder do
2 | provider :google_oauth2, ENV["GOOGLE_CLIENT_ID"], ENV["GOOGLE_CLIENT_SECRET"], {
3 | :prompt => 'select_account'
4 | }
5 | end
6 |
--------------------------------------------------------------------------------
/swarmize-dot-com/config/initializers/secret_token.rb:
--------------------------------------------------------------------------------
1 | # Be sure to restart your server when you modify this file.
2 |
3 | # Your secret key is used for verifying the integrity of signed cookies.
4 | # If you change this key, all old signed cookies will become invalid!
5 |
6 | # Make sure the secret is at least 30 characters and all random,
7 | # no regular words or you'll be exposed to dictionary attacks.
8 | # You can use `rake secret` to generate a secure secret key.
9 |
10 | # Make sure your secret_key_base is kept private
11 | # if you're sharing your code publicly.
12 | Swarmize::Application.config.secret_key_base = 'dbe967e6beee21a22e385dac263b7636e6f6069a144d4993a0641f66183fa4507322439902e4a3530db95d2acd70a853a315d6347981f16fc1902a5bb5940d47'
13 |
--------------------------------------------------------------------------------
/swarmize-dot-com/config/initializers/session_store.rb:
--------------------------------------------------------------------------------
1 | # Be sure to restart your server when you modify this file.
2 |
3 | Swarmize::Application.config.session_store :cookie_store, key: '_swarmize_session'
4 |
--------------------------------------------------------------------------------
/swarmize-dot-com/config/initializers/will_paginate.rb:
--------------------------------------------------------------------------------
1 | WillPaginate.per_page = 10
2 |
--------------------------------------------------------------------------------
/swarmize-dot-com/config/initializers/wrap_parameters.rb:
--------------------------------------------------------------------------------
1 | # Be sure to restart your server when you modify this file.
2 |
3 | # This file contains settings for ActionController::ParamsWrapper which
4 | # is enabled by default.
5 |
6 | # Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array.
7 | ActiveSupport.on_load(:action_controller) do
8 | wrap_parameters format: [:json] if respond_to?(:wrap_parameters)
9 | end
10 |
11 | # To enable root element in JSON for ActiveRecord objects.
12 | # ActiveSupport.on_load(:active_record) do
13 | # self.include_root_in_json = true
14 | # end
15 |
--------------------------------------------------------------------------------
/swarmize-dot-com/config/locales/en.yml:
--------------------------------------------------------------------------------
1 | # Files in the config/locales directory are used for internationalization
2 | # and are automatically loaded by Rails. If you want to use locales other
3 | # than English, add the necessary files in this directory.
4 | #
5 | # To use the locales, use `I18n.t`:
6 | #
7 | # I18n.t 'hello'
8 | #
9 | # In views, this is aliased to just `t`:
10 | #
11 | # <%= t('hello') %>
12 | #
13 | # To use a different locale, set it with `I18n.locale`:
14 | #
15 | # I18n.locale = :es
16 | #
17 | # This would use the information in config/locales/es.yml.
18 | #
19 | # To learn more, please read the Rails Internationalization guide
20 | # available at http://guides.rubyonrails.org/i18n.html.
21 |
22 | en:
23 | hello: "Hello world"
24 |
--------------------------------------------------------------------------------
/swarmize-dot-com/db/migrate/20140712134916_create_swarms.rb:
--------------------------------------------------------------------------------
1 | class CreateSwarms < ActiveRecord::Migration
2 | def change
3 | create_table :swarms do |t|
4 | t.string :name
5 | t.string :description
6 | t.timestamps
7 | end
8 | end
9 | end
10 |
--------------------------------------------------------------------------------
/swarmize-dot-com/db/migrate/20140716162431_add_fields_to_swarm.rb:
--------------------------------------------------------------------------------
1 | class AddFieldsToSwarm < ActiveRecord::Migration
2 | def change
3 | add_column :swarms, :fields, :text
4 | end
5 | end
6 |
--------------------------------------------------------------------------------
/swarmize-dot-com/db/migrate/20140722135555_add_open_close_to_swarm.rb:
--------------------------------------------------------------------------------
1 | class AddOpenCloseToSwarm < ActiveRecord::Migration
2 | def change
3 | add_column :swarms, :opens_at, :datetime
4 | add_column :swarms, :closes_at, :datetime
5 | end
6 | end
7 |
--------------------------------------------------------------------------------
/swarmize-dot-com/db/migrate/20140729093242_create_users.rb:
--------------------------------------------------------------------------------
1 | class CreateUsers < ActiveRecord::Migration
2 | def change
3 | create_table :users do |t|
4 | t.string :email
5 | t.string :name
6 | t.string :image_url
7 | t.timestamps
8 | end
9 | end
10 | end
11 |
--------------------------------------------------------------------------------
/swarmize-dot-com/db/migrate/20140729123430_add_user_id_to_swarms.rb:
--------------------------------------------------------------------------------
1 | class AddUserIdToSwarms < ActiveRecord::Migration
2 | def change
3 | add_column :swarms, :user_id, :integer
4 | add_index :swarms, :user_id
5 | end
6 | end
7 |
--------------------------------------------------------------------------------
/swarmize-dot-com/db/migrate/20140729133308_add_parent_swarm_id_to_swarms.rb:
--------------------------------------------------------------------------------
1 | class AddParentSwarmIdToSwarms < ActiveRecord::Migration
2 | def change
3 | add_column :swarms, :cloned_from, :integer, :default => nil
4 | end
5 | end
6 |
--------------------------------------------------------------------------------
/swarmize-dot-com/db/migrate/20140801101148_add_is_fake_to_users.rb:
--------------------------------------------------------------------------------
1 | class AddIsFakeToUsers < ActiveRecord::Migration
2 | def change
3 | add_column :users, :is_fake, :boolean, :default => false
4 | end
5 | end
6 |
--------------------------------------------------------------------------------
/swarmize-dot-com/db/migrate/20140801134513_add_spiked_field_to_swarms.rb:
--------------------------------------------------------------------------------
1 | class AddSpikedFieldToSwarms < ActiveRecord::Migration
2 | def change
3 | add_column :swarms, :is_spiked, :boolean, :default => false
4 | end
5 | end
6 |
--------------------------------------------------------------------------------
/swarmize-dot-com/db/migrate/20140812130235_add_tokens_to_swarms.rb:
--------------------------------------------------------------------------------
1 | class AddTokensToSwarms < ActiveRecord::Migration
2 | def change
3 | add_column :swarms, :token, :string, :limit => 8
4 | end
5 | end
6 |
--------------------------------------------------------------------------------
/swarmize-dot-com/db/migrate/20140814134610_create_graph_configurations.rb:
--------------------------------------------------------------------------------
1 | class CreateGraphConfigurations < ActiveRecord::Migration
2 | def change
3 | create_table :graph_configurations do |t|
4 | t.string :title
5 | t.string :graph_type
6 | t.string :field
7 | t.string :viz_type
8 | t.text :options
9 | t.references :swarm
10 | t.timestamps
11 | end
12 | end
13 | end
14 |
--------------------------------------------------------------------------------
/swarmize-dot-com/db/migrate/20140814135824_rename_graph_configurations.rb:
--------------------------------------------------------------------------------
1 | class RenameGraphConfigurations < ActiveRecord::Migration
2 | def change
3 | rename_table :graph_configurations, :graphs
4 | end
5 | end
6 |
--------------------------------------------------------------------------------
/swarmize-dot-com/db/migrate/20140814173018_create_swarm_fields.rb:
--------------------------------------------------------------------------------
1 | class CreateSwarmFields < ActiveRecord::Migration
2 | def change
3 | create_table :swarm_fields do |t|
4 | t.integer :field_index
5 | t.string :field_type
6 | t.string :field_name
7 | t.string :field_code
8 | t.text :hint
9 | t.string :sample_value
10 | t.boolean :compulsory, :default => false
11 | t.text :possible_values
12 | t.integer :minimum, :default => nil
13 | t.integer :maximum, :default => nil
14 | t.references :swarm
15 | t.timestamps
16 | end
17 | end
18 | end
19 |
--------------------------------------------------------------------------------
/swarmize-dot-com/db/migrate/20140815095709_remove_serialized_fields.rb:
--------------------------------------------------------------------------------
1 | class RemoveSerializedFields < ActiveRecord::Migration
2 | def change
3 | remove_column :swarms, :fields, :text
4 | end
5 | end
6 |
--------------------------------------------------------------------------------
/swarmize-dot-com/db/migrate/20140826092139_create_access_permissions.rb:
--------------------------------------------------------------------------------
1 | class CreateAccessPermissions < ActiveRecord::Migration
2 | def change
3 | create_table :access_permissions do |t|
4 | t.references :swarm
5 | t.references :user
6 | t.string :email
7 | t.timestamps
8 | end
9 |
10 | add_index :access_permissions, :email
11 | end
12 | end
13 |
--------------------------------------------------------------------------------
/swarmize-dot-com/db/migrate/20140827092647_add_owner_field_to_permissions.rb:
--------------------------------------------------------------------------------
1 | class AddOwnerFieldToPermissions < ActiveRecord::Migration
2 | def change
3 | add_column :access_permissions, :is_owner, :boolean, :default => false
4 | end
5 | end
6 |
--------------------------------------------------------------------------------
/swarmize-dot-com/db/migrate/20140827103714_add_creators_to_access_permissions.rb:
--------------------------------------------------------------------------------
1 | class AddCreatorsToAccessPermissions < ActiveRecord::Migration
2 | def change
3 | add_column :access_permissions, :creator_id, :integer, :default => nil
4 | end
5 | end
6 |
--------------------------------------------------------------------------------
/swarmize-dot-com/db/migrate/20140827162410_remove_creator_field_from_swarm.rb:
--------------------------------------------------------------------------------
1 | class RemoveCreatorFieldFromSwarm < ActiveRecord::Migration
2 | def change
3 | remove_column :swarms, :user_id, :integer
4 | end
5 | end
6 |
--------------------------------------------------------------------------------
/swarmize-dot-com/db/migrate/20140828114635_add_is_admin_to_users.rb:
--------------------------------------------------------------------------------
1 | class AddIsAdminToUsers < ActiveRecord::Migration
2 | def change
3 | add_column :users, :is_admin, :boolean, :default => false
4 | end
5 | end
6 |
--------------------------------------------------------------------------------
/swarmize-dot-com/db/migrate/20140912101553_add_deleted_at_to_swarms.rb:
--------------------------------------------------------------------------------
1 | class AddDeletedAtToSwarms < ActiveRecord::Migration
2 | def up
3 | add_column :swarms, :deleted_at, :datetime
4 | add_index :swarms, :deleted_at
5 | Swarm.where(is_spiked: true).each do |swarm|
6 | swarm.update(deleted_at: Time.now)
7 | end
8 | remove_column :swarms, :is_spiked
9 | end
10 |
11 | def down
12 | add_column :swarms, :is_spiked, :boolean
13 | Swarm.only_deleted.each do |swarm|
14 | swarm.update(is_spiked: true)
15 | end
16 | remove_index :swarms, :deleted_at
17 | remove_column :swarms, :deleted_at
18 | end
19 | end
20 |
--------------------------------------------------------------------------------
/swarmize-dot-com/db/migrate/20141010094402_remove_viz_type.rb:
--------------------------------------------------------------------------------
1 | class RemoveVizType < ActiveRecord::Migration
2 | def up
3 | Graph.all.each do |graph|
4 | graph.graph_type = graph.viz_type
5 | graph.save
6 | end
7 | remove_column :graphs, :viz_type
8 | end
9 |
10 | def down
11 | add_column :graphs, :viz_type, :string
12 | end
13 | end
14 |
--------------------------------------------------------------------------------
/swarmize-dot-com/db/migrate/20141017093840_add_other_to_swarmfield.rb:
--------------------------------------------------------------------------------
1 | class AddOtherToSwarmfield < ActiveRecord::Migration
2 | def change
3 | add_column :swarm_fields, :other, :boolean, :default => false
4 | end
5 | end
6 |
--------------------------------------------------------------------------------
/swarmize-dot-com/db/migrate/20141017131200_add_toggles_to_swarm.rb:
--------------------------------------------------------------------------------
1 | class AddTogglesToSwarm < ActiveRecord::Migration
2 | def change
3 | add_column :swarms, :display_title, :boolean, :default => true
4 | add_column :swarms, :display_description, :boolean, :default => true
5 | end
6 | end
7 |
--------------------------------------------------------------------------------
/swarmize-dot-com/db/migrate/20141017150238_change_other_to_allow_other.rb:
--------------------------------------------------------------------------------
1 | class ChangeOtherToAllowOther < ActiveRecord::Migration
2 | def change
3 | rename_column :swarm_fields, :other, :allow_other
4 | end
5 | end
6 |
--------------------------------------------------------------------------------
/swarmize-dot-com/db/migrate/20141021114539_change_desscription_to_text_field.rb:
--------------------------------------------------------------------------------
1 | class ChangeDesscriptionToTextField < ActiveRecord::Migration
2 | def up
3 | change_column :swarms, :description, :text
4 | end
5 | def down
6 | change_column :swarms, :description, :string
7 | end
8 | end
9 |
--------------------------------------------------------------------------------
/swarmize-dot-com/db/migrate/20141204145601_allow_pick_one_to_be_select.rb:
--------------------------------------------------------------------------------
1 | class AllowPickOneToBeSelect < ActiveRecord::Migration
2 | def change
3 | add_column :swarm_fields, :display_as_select, :boolean, default: false
4 | end
5 | end
6 |
--------------------------------------------------------------------------------
/swarmize-dot-com/db/seeds.rb:
--------------------------------------------------------------------------------
1 | # This file should contain all the record creation needed to seed the database with its default values.
2 | # The data can then be loaded with the rake db:seed (or created alongside the db with db:setup).
3 | #
4 | # Examples:
5 | #
6 | # cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }])
7 | # Mayor.create(name: 'Emanuel', city: cities.first)
8 |
--------------------------------------------------------------------------------
/swarmize-dot-com/deploy-sample.json:
--------------------------------------------------------------------------------
1 | {
2 | "appname": "Application Name",
3 | "live_env": "Live Environment Name",
4 | "aws_region": "eu-west-1",
5 | "s3_bucket": "bucketname",
6 | "app_dir": "subdir_of_repo",
7 | "slack_key": "slack_key_here"
8 | }
9 |
--------------------------------------------------------------------------------
/swarmize-dot-com/eb_name.txt:
--------------------------------------------------------------------------------
1 | Swarmize
2 |
--------------------------------------------------------------------------------
/swarmize-dot-com/lib/assets/.keep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/guardian/swarmize/d3b23b7e093c7d35f9ba68e7174bc026ed16b03f/swarmize-dot-com/lib/assets/.keep
--------------------------------------------------------------------------------
/swarmize-dot-com/lib/dummy.rb:
--------------------------------------------------------------------------------
1 | class Dummy
2 | def self.create_fake_user
3 | u = User.new
4 | first_name = Faker::Name.first_name
5 | last_name = Faker::Name.last_name
6 |
7 | u.name = [first_name,last_name].join(" ")
8 | u.email = Faker::Internet.email(first_name)
9 |
10 | u.is_fake = true
11 |
12 | u.save
13 | u
14 | end
15 |
16 | def self.create_dummy_preopen_swarm(user, n=1)
17 | s = Dummy.create_dummy_swarm(user, (Time.now+n.days), nil)
18 | s
19 | end
20 |
21 | def self.create_dummy_live_swarm(user, n=1)
22 | s = Dummy.create_dummy_swarm(user, (Time.now-n.days), (Time.now+n.days))
23 | s
24 | end
25 |
26 | def self.create_dummy_closed_swarm(user, n=1)
27 | s = Dummy.create_dummy_swarm(user, (Time.now-(2*n).days), (Time.now-n.days))
28 | s
29 | end
30 |
31 | def self.create_dummy_swarm(user,opens,closes)
32 | s = Swarm.new
33 | s.user = user
34 | s.opens_at = opens
35 | s.closes_at = closes
36 | s.name = Faker::Lorem.sentence(2)
37 | s.description = Faker::Lorem.sentences(3).join(" ")
38 | s.save
39 | s
40 | end
41 |
42 | def self.destroy_fake_data
43 | fake_users = User.where(:is_fake => true)
44 | fake_users.each do |u|
45 | u.swarms.destroy_all
46 | end
47 |
48 | fake_users.destroy_all
49 | end
50 |
51 | end
52 |
--------------------------------------------------------------------------------
/swarmize-dot-com/lib/dynamo_sync.rb:
--------------------------------------------------------------------------------
1 | class DynamoSync
2 | def self.sync(swarm)
3 | if Rails.env.production?
4 | @@dynamo ||= AWS::DynamoDB.new
5 | swarms_table = @@dynamo.tables['swarms'].load_schema
6 |
7 | if swarm.deleted_at
8 | delete(swarm)
9 | else
10 | swarms_table.items.create(token: swarm.token,
11 | definition: swarm.to_json)
12 | end
13 | end
14 | end
15 |
16 | def self.delete(swarm)
17 | if Rails.env.production?
18 | @@dynamo ||= AWS::DynamoDB.new
19 | swarms_table = @@dynamo.tables['swarms'].load_schema
20 |
21 | swarms_table.items[swarm.token].delete
22 | end
23 | end
24 | end
25 |
--------------------------------------------------------------------------------
/swarmize-dot-com/lib/email_validator.rb:
--------------------------------------------------------------------------------
1 | class EmailValidator
2 | def self.is_valid_email?(email)
3 | email = email.downcase
4 | (email == 'tom@infovore.org') || (email =~ /@theguardian\.com$/) || (email =~ /@guardian\.co\.uk$/)
5 | end
6 |
7 | def self.normalize_email(email)
8 | email.downcase.gsub('theguardian.com', 'guardian.co.uk')
9 | end
10 | end
11 |
--------------------------------------------------------------------------------
/swarmize-dot-com/lib/swarm_csv_tool.rb:
--------------------------------------------------------------------------------
1 | require 'csv'
2 | include ApplicationHelper
3 |
4 | class SwarmCSVTool
5 | attr_reader :swarm
6 |
7 | def initialize(swarm)
8 | @swarm = swarm
9 |
10 | @header_hash = {timestamp: 'Timestamp'}
11 | @swarm.swarm_fields.each do |f|
12 | @header_hash[f.field_code.to_sym] = f.field_name
13 | if f.derived_field_suffixes.any?
14 | f.derived_field_suffixes.each do |df|
15 | @header_hash["#{f.field_code}#{df}"] = "#{f.field_name} [#{df}]"
16 | end
17 | end
18 | end
19 |
20 | @public_header_keys = @header_hash.keys.select do |key|
21 | @swarm.public_field_codes.include?(key.to_s)
22 | end
23 |
24 | @public_header_values = @public_header_keys.map do |key|
25 | @header_hash[key]
26 | end
27 | end
28 |
29 | def headers
30 | # true indicates it's a header
31 | CSV::Row.new(@header_hash.keys, @header_hash.values, true)
32 | end
33 |
34 | def public_headers
35 | # true indicates it's a header
36 | CSV::Row.new(@public_header_keys, @public_header_values, true)
37 | end
38 |
39 | def result_to_row(result)
40 | cols = @header_hash.keys.map do |key|
41 | result.send(key)
42 | end
43 | CSV::Row.new(@header_hash.keys, cols, false)
44 | end
45 |
46 | def result_to_public_row(result)
47 | cols = @public_header_keys.map do |key|
48 | result.send(key)
49 | end
50 | CSV::Row.new(@header_hash.keys, cols, false)
51 | end
52 | end
53 |
54 |
--------------------------------------------------------------------------------
/swarmize-dot-com/lib/swarmize_oembed.rb:
--------------------------------------------------------------------------------
1 | require 'open-uri'
2 |
3 | class SwarmizeOembed
4 | class << self
5 | include Rails.application.routes.url_helpers
6 | include ActionView::Helpers::AssetUrlHelper
7 | end
8 |
9 | def self.matches_scheme(url)
10 | url =~ /http:\/\/www\.swarmize\.com\/swarms\/(\w{8})\/?/
11 | end
12 |
13 | def self.extract_token(url)
14 | url.gsub("http://www.swarmize.com/swarms/", "").split("/").first
15 | end
16 |
17 | def self.for(swarm, options={})
18 | if options[:maxwidth]
19 | width = options[:maxwidth].to_i
20 | else
21 | width = 460
22 | end
23 |
24 | if options[:maxheight]
25 | height = options[:maxheight].to_i
26 | else
27 | height = swarm.estimate_form_height
28 | end
29 |
30 | html = ""
31 |
32 | {
33 | type: "rich",
34 | version: "1.0",
35 | title: swarm.name,
36 | provider_name: "Swarmize",
37 | provider_url: "http://www.swarmize.com",
38 | width: width,
39 | height: height,
40 | html: html
41 | }.to_json
42 | end
43 | end
44 |
--------------------------------------------------------------------------------
/swarmize-dot-com/lib/tasks/.keep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/guardian/swarmize/d3b23b7e093c7d35f9ba68e7174bc026ed16b03f/swarmize-dot-com/lib/tasks/.keep
--------------------------------------------------------------------------------
/swarmize-dot-com/log/.keep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/guardian/swarmize/d3b23b7e093c7d35f9ba68e7174bc026ed16b03f/swarmize-dot-com/log/.keep
--------------------------------------------------------------------------------
/swarmize-dot-com/package.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | PACKAGE_FILENAME=$1
4 | DIRECTORY=$2
5 |
6 | cd ..
7 |
8 | git archive -o ${DIRECTORY}/${PACKAGE_FILENAME} master:${DIRECTORY}
9 |
--------------------------------------------------------------------------------
/swarmize-dot-com/public/404.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | You may have mistyped the address or the page may have moved.
55 |If you are the application owner check the logs for more information.
57 | 58 | 59 | -------------------------------------------------------------------------------- /swarmize-dot-com/public/422.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 |Maybe you tried to change something you didn't have access to.
55 |If you are the application owner check the logs for more information.
57 | 58 | 59 | -------------------------------------------------------------------------------- /swarmize-dot-com/public/500.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 |If you are the application owner check the logs for more information.
56 | 57 | 58 | -------------------------------------------------------------------------------- /swarmize-dot-com/public/case_studies/broadband_survey/add-fields.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/guardian/swarmize/d3b23b7e093c7d35f9ba68e7174bc026ed16b03f/swarmize-dot-com/public/case_studies/broadband_survey/add-fields.gif -------------------------------------------------------------------------------- /swarmize-dot-com/public/case_studies/broadband_survey/clone.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/guardian/swarmize/d3b23b7e093c7d35f9ba68e7174bc026ed16b03f/swarmize-dot-com/public/case_studies/broadband_survey/clone.gif -------------------------------------------------------------------------------- /swarmize-dot-com/public/case_studies/broadband_survey/create.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/guardian/swarmize/d3b23b7e093c7d35f9ba68e7174bc026ed16b03f/swarmize-dot-com/public/case_studies/broadband_survey/create.gif -------------------------------------------------------------------------------- /swarmize-dot-com/public/case_studies/broadband_survey/csv.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/guardian/swarmize/d3b23b7e093c7d35f9ba68e7174bc026ed16b03f/swarmize-dot-com/public/case_studies/broadband_survey/csv.png -------------------------------------------------------------------------------- /swarmize-dot-com/public/case_studies/broadband_survey/embed-code.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/guardian/swarmize/d3b23b7e093c7d35f9ba68e7174bc026ed16b03f/swarmize-dot-com/public/case_studies/broadband_survey/embed-code.gif -------------------------------------------------------------------------------- /swarmize-dot-com/public/case_studies/broadband_survey/graphs.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/guardian/swarmize/d3b23b7e093c7d35f9ba68e7174bc026ed16b03f/swarmize-dot-com/public/case_studies/broadband_survey/graphs.gif -------------------------------------------------------------------------------- /swarmize-dot-com/public/case_studies/broadband_survey/login.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/guardian/swarmize/d3b23b7e093c7d35f9ba68e7174bc026ed16b03f/swarmize-dot-com/public/case_studies/broadband_survey/login.gif -------------------------------------------------------------------------------- /swarmize-dot-com/public/case_studies/broadband_survey/move-delete.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/guardian/swarmize/d3b23b7e093c7d35f9ba68e7174bc026ed16b03f/swarmize-dot-com/public/case_studies/broadband_survey/move-delete.gif -------------------------------------------------------------------------------- /swarmize-dot-com/public/case_studies/broadband_survey/open.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/guardian/swarmize/d3b23b7e093c7d35f9ba68e7174bc026ed16b03f/swarmize-dot-com/public/case_studies/broadband_survey/open.gif -------------------------------------------------------------------------------- /swarmize-dot-com/public/case_studies/broadband_survey/permissions.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/guardian/swarmize/d3b23b7e093c7d35f9ba68e7174bc026ed16b03f/swarmize-dot-com/public/case_studies/broadband_survey/permissions.gif -------------------------------------------------------------------------------- /swarmize-dot-com/public/case_studies/broadband_survey/preview.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/guardian/swarmize/d3b23b7e093c7d35f9ba68e7174bc026ed16b03f/swarmize-dot-com/public/case_studies/broadband_survey/preview.png -------------------------------------------------------------------------------- /swarmize-dot-com/public/case_studies/broadband_survey/table.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/guardian/swarmize/d3b23b7e093c7d35f9ba68e7174bc026ed16b03f/swarmize-dot-com/public/case_studies/broadband_survey/table.png -------------------------------------------------------------------------------- /swarmize-dot-com/public/case_studies/broadband_survey/thumb.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/guardian/swarmize/d3b23b7e093c7d35f9ba68e7174bc026ed16b03f/swarmize-dot-com/public/case_studies/broadband_survey/thumb.png -------------------------------------------------------------------------------- /swarmize-dot-com/public/case_studies/broadband_survey/view-form.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/guardian/swarmize/d3b23b7e093c7d35f9ba68e7174bc026ed16b03f/swarmize-dot-com/public/case_studies/broadband_survey/view-form.png -------------------------------------------------------------------------------- /swarmize-dot-com/public/case_studies/indyref/indyref-graph1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/guardian/swarmize/d3b23b7e093c7d35f9ba68e7174bc026ed16b03f/swarmize-dot-com/public/case_studies/indyref/indyref-graph1.png -------------------------------------------------------------------------------- /swarmize-dot-com/public/case_studies/indyref/indyref-graph2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/guardian/swarmize/d3b23b7e093c7d35f9ba68e7174bc026ed16b03f/swarmize-dot-com/public/case_studies/indyref/indyref-graph2.png -------------------------------------------------------------------------------- /swarmize-dot-com/public/case_studies/indyref/indyref-graph3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/guardian/swarmize/d3b23b7e093c7d35f9ba68e7174bc026ed16b03f/swarmize-dot-com/public/case_studies/indyref/indyref-graph3.png -------------------------------------------------------------------------------- /swarmize-dot-com/public/case_studies/indyref/indyref1.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/guardian/swarmize/d3b23b7e093c7d35f9ba68e7174bc026ed16b03f/swarmize-dot-com/public/case_studies/indyref/indyref1.gif -------------------------------------------------------------------------------- /swarmize-dot-com/public/case_studies/indyref/thumb.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/guardian/swarmize/d3b23b7e093c7d35f9ba68e7174bc026ed16b03f/swarmize-dot-com/public/case_studies/indyref/thumb.png -------------------------------------------------------------------------------- /swarmize-dot-com/public/case_studies/realtime_clicker/aggregate-field.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/guardian/swarmize/d3b23b7e093c7d35f9ba68e7174bc026ed16b03f/swarmize-dot-com/public/case_studies/realtime_clicker/aggregate-field.gif -------------------------------------------------------------------------------- /swarmize-dot-com/public/case_studies/realtime_clicker/api-keys.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/guardian/swarmize/d3b23b7e093c7d35f9ba68e7174bc026ed16b03f/swarmize-dot-com/public/case_studies/realtime_clicker/api-keys.gif -------------------------------------------------------------------------------- /swarmize-dot-com/public/case_studies/realtime_clicker/get-code.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/guardian/swarmize/d3b23b7e093c7d35f9ba68e7174bc026ed16b03f/swarmize-dot-com/public/case_studies/realtime_clicker/get-code.gif -------------------------------------------------------------------------------- /swarmize-dot-com/public/case_studies/realtime_clicker/map-demo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/guardian/swarmize/d3b23b7e093c7d35f9ba68e7174bc026ed16b03f/swarmize-dot-com/public/case_studies/realtime_clicker/map-demo.png -------------------------------------------------------------------------------- /swarmize-dot-com/public/case_studies/realtime_clicker/preview-form.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/guardian/swarmize/d3b23b7e093c7d35f9ba68e7174bc026ed16b03f/swarmize-dot-com/public/case_studies/realtime_clicker/preview-form.png -------------------------------------------------------------------------------- /swarmize-dot-com/public/case_studies/realtime_clicker/results-over-time.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/guardian/swarmize/d3b23b7e093c7d35f9ba68e7174bc026ed16b03f/swarmize-dot-com/public/case_studies/realtime_clicker/results-over-time.png -------------------------------------------------------------------------------- /swarmize-dot-com/public/case_studies/realtime_clicker/thumb.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/guardian/swarmize/d3b23b7e093c7d35f9ba68e7174bc026ed16b03f/swarmize-dot-com/public/case_studies/realtime_clicker/thumb.jpg -------------------------------------------------------------------------------- /swarmize-dot-com/public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/guardian/swarmize/d3b23b7e093c7d35f9ba68e7174bc026ed16b03f/swarmize-dot-com/public/favicon.ico -------------------------------------------------------------------------------- /swarmize-dot-com/public/fonts/glyphicons-halflings-regular.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/guardian/swarmize/d3b23b7e093c7d35f9ba68e7174bc026ed16b03f/swarmize-dot-com/public/fonts/glyphicons-halflings-regular.eot -------------------------------------------------------------------------------- /swarmize-dot-com/public/fonts/glyphicons-halflings-regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/guardian/swarmize/d3b23b7e093c7d35f9ba68e7174bc026ed16b03f/swarmize-dot-com/public/fonts/glyphicons-halflings-regular.ttf -------------------------------------------------------------------------------- /swarmize-dot-com/public/fonts/glyphicons-halflings-regular.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/guardian/swarmize/d3b23b7e093c7d35f9ba68e7174bc026ed16b03f/swarmize-dot-com/public/fonts/glyphicons-halflings-regular.woff -------------------------------------------------------------------------------- /swarmize-dot-com/public/robots.txt: -------------------------------------------------------------------------------- 1 | # See http://www.robotstxt.org/wc/norobots.html for documentation on how to use the robots.txt file 2 | # 3 | # To ban all spiders from the entire site uncomment the next two lines: 4 | # User-agent: * 5 | # Disallow: / 6 | -------------------------------------------------------------------------------- /swarmize-dot-com/spec/controllers/admin_controller_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper' 2 | require 'controllers/shared_examples_for_controllers' 3 | 4 | describe AdminController do 5 | describe "GET #show" do 6 | it_should_behave_like "it needs an admin user", :get, :show 7 | end 8 | 9 | end 10 | -------------------------------------------------------------------------------- /swarmize-dot-com/spec/controllers/api_tokens_controller_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper' 2 | 3 | -------------------------------------------------------------------------------- /swarmize-dot-com/spec/controllers/case_studies_controller_spec.rb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/guardian/swarmize/d3b23b7e093c7d35f9ba68e7174bc026ed16b03f/swarmize-dot-com/spec/controllers/case_studies_controller_spec.rb -------------------------------------------------------------------------------- /swarmize-dot-com/spec/controllers/csv_controller_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper' 2 | 3 | describe CsvController do 4 | describe "GET #show" do 5 | describe 'for a user who is not logged in' do 6 | it "should redirect to login" do 7 | get :show, :swarm_id => 1 8 | expect(response).to redirect_to(login_path) 9 | end 10 | end 11 | end 12 | end 13 | -------------------------------------------------------------------------------- /swarmize-dot-com/spec/controllers/home_controller_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper' 2 | 3 | describe HomeController do 4 | render_views 5 | 6 | describe "GET #show" do 7 | describe "when logged out" do 8 | it "renders the show page" do 9 | get :show 10 | expect(response).to render_template :show 11 | end 12 | 13 | it "renders the logged out partial" do 14 | get :show 15 | expect(response).to render_template(:partial => "home/_logged_out") 16 | end 17 | 18 | end 19 | 20 | describe "when logged in" do 21 | before do 22 | user = FactoryGirl.create(:user) 23 | session[:user_id] = user.id 24 | end 25 | 26 | it "renders the logged in partial" do 27 | get :show 28 | expect(response).to render_template(:partial => "home/_logged_in") 29 | end 30 | end 31 | 32 | end 33 | 34 | end 35 | -------------------------------------------------------------------------------- /swarmize-dot-com/spec/controllers/oembed_controller_spec.rb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/guardian/swarmize/d3b23b7e093c7d35f9ba68e7174bc026ed16b03f/swarmize-dot-com/spec/controllers/oembed_controller_spec.rb -------------------------------------------------------------------------------- /swarmize-dot-com/spec/controllers/permissions_controller_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper' 2 | 3 | describe PermissionsController do 4 | 5 | end 6 | -------------------------------------------------------------------------------- /swarmize-dot-com/spec/controllers/search_controller_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper' 2 | require 'controllers/shared_examples_for_controllers' 3 | 4 | describe SearchController do 5 | describe "GET #results" do 6 | it_should_behave_like "it needs login", :get, :results, :query => 'swarm' 7 | end 8 | 9 | end 10 | -------------------------------------------------------------------------------- /swarmize-dot-com/spec/controllers/sessions_controller_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper' 2 | 3 | describe SessionsController do 4 | 5 | end 6 | -------------------------------------------------------------------------------- /swarmize-dot-com/spec/controllers/swarm_import_controller_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper' 2 | 3 | describe SwarmImportController do 4 | 5 | end 6 | -------------------------------------------------------------------------------- /swarmize-dot-com/spec/controllers/utils_controller_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper' 2 | 3 | describe UtilsController do 4 | 5 | end 6 | -------------------------------------------------------------------------------- /swarmize-dot-com/spec/factories/access_permissions.rb: -------------------------------------------------------------------------------- 1 | FactoryGirl.define do 2 | factory :access_permission do 3 | user 4 | swarm 5 | email { user.email } 6 | is_owner false 7 | creator_id nil 8 | end 9 | end 10 | -------------------------------------------------------------------------------- /swarmize-dot-com/spec/factories/graphs.rb: -------------------------------------------------------------------------------- 1 | FactoryGirl.define do 2 | factory :graph do 3 | title "Graph Title" 4 | graph_type "pie" 5 | field "postcode" 6 | swarm 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /swarmize-dot-com/spec/factories/swarm_fields.rb: -------------------------------------------------------------------------------- 1 | FactoryGirl.define do 2 | factory :swarm_field do 3 | field_index 0 4 | field_type 'text' 5 | field_name 'Enter some text' 6 | hint 'Anything will do' 7 | sample_value 'foo' 8 | swarm 9 | end 10 | end 11 | -------------------------------------------------------------------------------- /swarmize-dot-com/spec/factories/swarms.rb: -------------------------------------------------------------------------------- 1 | FactoryGirl.define do 2 | factory :swarm do |s| 3 | s.name "A test swarm" 4 | s.description "Test swarm description" 5 | s.token "abcdefgh" 6 | 7 | factory :swarm_opens_in_the_future do 8 | opens_at Time.zone.now + 1.day 9 | end 10 | 11 | factory :swarm_already_opened do 12 | opens_at Time.zone.now - 1.day 13 | end 14 | end 15 | end 16 | -------------------------------------------------------------------------------- /swarmize-dot-com/spec/factories/users.rb: -------------------------------------------------------------------------------- 1 | require 'faker' 2 | 3 | FactoryGirl.define do 4 | factory :user do |f| 5 | f.name Faker::Name.name 6 | f.email Faker::Internet.email 7 | f.image_url "" 8 | f.is_fake false 9 | 10 | factory :admin do 11 | is_admin true 12 | end 13 | end 14 | end 15 | -------------------------------------------------------------------------------- /swarmize-dot-com/spec/helpers/admin_helper_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper' 2 | 3 | # Specs in this file have access to a helper object that includes 4 | # the AdminHelper. For example: 5 | # 6 | # describe AdminHelper do 7 | # describe "string concat" do 8 | # it "concats two strings with spaces" do 9 | # expect(helper.concat_strings("this","that")).to eq("this that") 10 | # end 11 | # end 12 | # end 13 | describe AdminHelper do 14 | end 15 | -------------------------------------------------------------------------------- /swarmize-dot-com/spec/helpers/graphs_helper_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper' 2 | 3 | # Specs in this file have access to a helper object that includes 4 | # the GraphsHelper. For example: 5 | # 6 | # describe GraphsHelper do 7 | # describe "string concat" do 8 | # it "concats two strings with spaces" do 9 | # expect(helper.concat_strings("this","that")).to eq("this that") 10 | # end 11 | # end 12 | # end 13 | describe GraphsHelper do 14 | end 15 | -------------------------------------------------------------------------------- /swarmize-dot-com/spec/helpers/home_helper_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper' 2 | 3 | # Specs in this file have access to a helper object that includes 4 | # the HomeHelper. For example: 5 | # 6 | # describe HomeHelper do 7 | # describe "string concat" do 8 | # it "concats two strings with spaces" do 9 | # expect(helper.concat_strings("this","that")).to eq("this that") 10 | # end 11 | # end 12 | # end 13 | describe HomeHelper do 14 | end 15 | -------------------------------------------------------------------------------- /swarmize-dot-com/spec/helpers/permissions_helper_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper' 2 | describe PermissionsHelper do 3 | end 4 | -------------------------------------------------------------------------------- /swarmize-dot-com/spec/helpers/search_helper_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper' 2 | 3 | # Specs in this file have access to a helper object that includes 4 | # the SearchHelper. For example: 5 | # 6 | # describe SearchHelper do 7 | # describe "string concat" do 8 | # it "concats two strings with spaces" do 9 | # expect(helper.concat_strings("this","that")).to eq("this that") 10 | # end 11 | # end 12 | # end 13 | describe SearchHelper do 14 | end 15 | -------------------------------------------------------------------------------- /swarmize-dot-com/spec/helpers/sessions_helper_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper' 2 | 3 | # Specs in this file have access to a helper object that includes 4 | # the SessionsHelper. For example: 5 | # 6 | # describe SessionsHelper do 7 | # describe "string concat" do 8 | # it "concats two strings with spaces" do 9 | # expect(helper.concat_strings("this","that")).to eq("this that") 10 | # end 11 | # end 12 | # end 13 | describe SessionsHelper do 14 | end 15 | -------------------------------------------------------------------------------- /swarmize-dot-com/spec/helpers/swarms_helper_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper' 2 | 3 | # Specs in this file have access to a helper object that includes 4 | # the SwarmsHelper. For example: 5 | # 6 | # describe SwarmsHelper do 7 | # describe "string concat" do 8 | # it "concats two strings with spaces" do 9 | # expect(helper.concat_strings("this","that")).to eq("this that") 10 | # end 11 | # end 12 | # end 13 | describe SwarmsHelper do 14 | end 15 | -------------------------------------------------------------------------------- /swarmize-dot-com/spec/helpers/users_helper_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper' 2 | 3 | # Specs in this file have access to a helper object that includes 4 | # the UsersHelper. For example: 5 | # 6 | # describe UsersHelper do 7 | # describe "string concat" do 8 | # it "concats two strings with spaces" do 9 | # expect(helper.concat_strings("this","that")).to eq("this that") 10 | # end 11 | # end 12 | # end 13 | describe UsersHelper do 14 | end 15 | -------------------------------------------------------------------------------- /swarmize-dot-com/spec/lib/sample.json: -------------------------------------------------------------------------------- 1 | 2 | {"name":"#indyref survey","description":"Extracting data from the #indyref hashtag on Twitter, capturing numbers of #no, #voteno and #yes, #voteyes votes.","fields":[{"field_type":"yesno","field_name":"Are you for an independent Scotland?","field_name_code":"are_you_for_an_independent_scotland","compulsory":true},{"field_type":"text","field_name":"What is your twitter screen name?","field_name_code":"screen_name","compulsory":true},{"field_type":"text","field_name":"Full text of tweet","field_name_code":"full_text_of_tweet","compulsory":true},{"field_type":"geolocation","field_name":"Where was your tweet from?","field_name_code":"where_was_your_tweet_from","compulsory":false}],"opens_at":"2014-09-13T19:46:04.575Z","closes_at":null,"token":"jtjsvwdc"} 3 | -------------------------------------------------------------------------------- /swarmize-dot-com/spec/lib/sample_field.json: -------------------------------------------------------------------------------- 1 | 2 | {"name":"#indyref survey","description":"Extracting data from the #indyref hashtag on Twitter, capturing numbers of #no, #voteno and #yes, #voteyes votes.","fields":[{"field_type":"yesno","field_name":"Are you for an independent Scotland?","field_name_code":"are_you_for_an_independent_scotland","compulsory":true}],"opens_at":"2014-09-13T19:46:04.575Z","closes_at":null} 3 | -------------------------------------------------------------------------------- /swarmize-dot-com/spec/lib/sample_field_possible_values.json: -------------------------------------------------------------------------------- 1 | {"name":"Prime Ministerial Debate (cloned)","description":"","fields":[{"field_type":"pick_one","field_name":"Who did you just agree with?","field_name_code":"who_did_you_just_agree_with","compulsory":true,"possible_values":{"david_cameron":"David Cameron","ed_miliband":"Ed Miliband","nick_clegg":"Nick Clegg"}}],"opens_at":"2014-09-08T12:03:54.305Z","closes_at":"2014-09-08T16:24:34.414Z"} 2 | -------------------------------------------------------------------------------- /swarmize-dot-com/spec/mailers/permission_mailer_spec.rb: -------------------------------------------------------------------------------- 1 | require "spec_helper" 2 | 3 | describe PermissionMailer do 4 | end 5 | -------------------------------------------------------------------------------- /swarmize-dot-com/spec/models/email_validator_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper' 2 | 3 | describe EmailValidator do 4 | describe "testing an email address for validity" do 5 | it "should be valid if it is Tom" do 6 | expect(EmailValidator.is_valid_email?('tom@infovore.org')).to be_truthy 7 | end 8 | 9 | it "should be valid if it is Graham's guardian.com email" do 10 | expect(EmailValidator.is_valid_email?('graham.tackley@theguardian.com')).to be_truthy 11 | end 12 | 13 | it "should be valid if it is Matt's guardian.co.uk email" do 14 | expect(EmailValidator.is_valid_email?('matt.mcalister@guardian.co.uk')).to be_truthy 15 | end 16 | 17 | it "shouldn't be valid if it is Bob" do 18 | expect(EmailValidator.is_valid_email?('bob@example.org')).to be_falsey 19 | end 20 | end 21 | 22 | describe "normalising an email address" do 23 | it "should normalize guardian.com emails to guardian.co.uk emails" do 24 | expect(EmailValidator.normalize_email('SAMPLE@THEGUARDIAN.COM')).to eq('sample@guardian.co.uk') 25 | end 26 | it "should lowercase a non-lowercase email" do 27 | expect(EmailValidator.normalize_email('SAMPLE@GUARDIAN.CO.UK')).to eq('sample@guardian.co.uk') 28 | end 29 | it "should not alter tom's email" do 30 | expect(EmailValidator.normalize_email('tom@infovore.org')).to eq('tom@infovore.org') 31 | 32 | end 33 | end 34 | end 35 | -------------------------------------------------------------------------------- /swarmize-dot-com/spec/models/graph_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper' 2 | 3 | describe Graph do 4 | end 5 | -------------------------------------------------------------------------------- /swarmize-dot-com/spec/models/swarm_field_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper' 2 | 3 | describe SwarmField do 4 | describe 'being created' do 5 | it 'should set its field_code correctly' do 6 | s = FactoryGirl.create(:swarm_field, :field_name => 'What is your postcode?') 7 | expect(s.field_code).to eq('what_is_your_postcode') 8 | end 9 | end 10 | end 11 | -------------------------------------------------------------------------------- /swarmize-dot-com/spec/support/factory_girl.rb: -------------------------------------------------------------------------------- 1 | RSpec.configure do |config| 2 | config.include FactoryGirl::Syntax::Methods 3 | end -------------------------------------------------------------------------------- /swarmize-dot-com/vendor/assets/javascripts/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/guardian/swarmize/d3b23b7e093c7d35f9ba68e7174bc026ed16b03f/swarmize-dot-com/vendor/assets/javascripts/.keep -------------------------------------------------------------------------------- /swarmize-dot-com/vendor/assets/stylesheets/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/guardian/swarmize/d3b23b7e093c7d35f9ba68e7174bc026ed16b03f/swarmize-dot-com/vendor/assets/stylesheets/.keep --------------------------------------------------------------------------------