infractores 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (123) hide show
  1. checksums.yaml +7 -0
  2. data/.env.sample +8 -0
  3. data/.gitignore +22 -0
  4. data/.travis.yml +14 -0
  5. data/CODE_OF_CONDUCT.md +49 -0
  6. data/Gemfile +67 -0
  7. data/Gemfile.lock +417 -0
  8. data/Guardfile +8 -0
  9. data/LICENSE +21 -0
  10. data/Procfile +2 -0
  11. data/README.md +48 -0
  12. data/Rakefile +6 -0
  13. data/app/assets/images/.keep +0 -0
  14. data/app/assets/images/gallery-buttons.png +0 -0
  15. data/app/assets/images/logo-infractores.svg +10 -0
  16. data/app/assets/javascripts/application.js +18 -0
  17. data/app/assets/javascripts/bootstrap.js +4 -0
  18. data/app/assets/javascripts/index.js +82 -0
  19. data/app/assets/javascripts/twitter.js +18 -0
  20. data/app/assets/stylesheets/1-utilities/_variables.scss +12 -0
  21. data/app/assets/stylesheets/2-quarks/_typography.scss +32 -0
  22. data/app/assets/stylesheets/3-atoms/_buttons.scss +3 -0
  23. data/app/assets/stylesheets/4-molecules/_footer.scss +32 -0
  24. data/app/assets/stylesheets/4-molecules/_infraction-gallery.scss +101 -0
  25. data/app/assets/stylesheets/4-molecules/_navbar.scss +71 -0
  26. data/app/assets/stylesheets/5-pages/index.scss +165 -0
  27. data/app/assets/stylesheets/5-pages/show.scss +29 -0
  28. data/app/assets/stylesheets/application.css +18 -0
  29. data/app/assets/stylesheets/bootstrap_and_overrides.css +7 -0
  30. data/app/controllers/application_controller.rb +5 -0
  31. data/app/controllers/concerns/.keep +0 -0
  32. data/app/controllers/infractions_controller.rb +23 -0
  33. data/app/controllers/users_controller.rb +7 -0
  34. data/app/helpers/application_helper.rb +19 -0
  35. data/app/helpers/infractions_helper.rb +6 -0
  36. data/app/mailers/.keep +0 -0
  37. data/app/models/.keep +0 -0
  38. data/app/models/concerns/.keep +0 -0
  39. data/app/models/evidence.rb +23 -0
  40. data/app/models/infraction.rb +43 -0
  41. data/app/models/tweet.rb +54 -0
  42. data/app/models/user.rb +34 -0
  43. data/app/services/twitter_service.rb +51 -0
  44. data/app/uploaders/evidence_uploader.rb +62 -0
  45. data/app/views/infractions/_map.html.erb +17 -0
  46. data/app/views/infractions/_reported_by.html.erb +4 -0
  47. data/app/views/infractions/_summary.html.erb +23 -0
  48. data/app/views/infractions/index.html.erb +18 -0
  49. data/app/views/infractions/show.html.erb +24 -0
  50. data/app/views/layouts/application.html.erb +90 -0
  51. data/app/views/shared/_google_analytics.html.erb +12 -0
  52. data/app/views/users/index.html.erb +21 -0
  53. data/app/workers/tweet_inspector.rb +18 -0
  54. data/bin/bundle +3 -0
  55. data/bin/rails +8 -0
  56. data/bin/rake +8 -0
  57. data/bin/setup +29 -0
  58. data/bin/spring +15 -0
  59. data/config.ru +4 -0
  60. data/config/application.rb +27 -0
  61. data/config/boot.rb +3 -0
  62. data/config/database.yml.sample +85 -0
  63. data/config/environment.rb +5 -0
  64. data/config/environments/development.rb +50 -0
  65. data/config/environments/production.rb +79 -0
  66. data/config/environments/test.rb +42 -0
  67. data/config/initializers/assets.rb +15 -0
  68. data/config/initializers/backtrace_silencers.rb +7 -0
  69. data/config/initializers/carrierwave.rb +17 -0
  70. data/config/initializers/cookies_serializer.rb +3 -0
  71. data/config/initializers/filter_parameter_logging.rb +4 -0
  72. data/config/initializers/inflections.rb +16 -0
  73. data/config/initializers/mime_types.rb +4 -0
  74. data/config/initializers/session_store.rb +3 -0
  75. data/config/initializers/twitter.rb +1 -0
  76. data/config/initializers/wrap_parameters.rb +14 -0
  77. data/config/locales/en.bootstrap.yml +23 -0
  78. data/config/locales/en.yml +23 -0
  79. data/config/locales/es.yml +263 -0
  80. data/config/routes.rb +6 -0
  81. data/config/secrets.yml +22 -0
  82. data/db/migrate/20150824210535_add_tweets_table.rb +8 -0
  83. data/db/migrate/20150829133406_create_infractions.rb +11 -0
  84. data/db/migrate/20150829134520_create_users.rb +12 -0
  85. data/db/migrate/20150829141909_add_user_id_to_tweets.rb +5 -0
  86. data/db/migrate/20150829154430_create_locations.rb +10 -0
  87. data/db/migrate/20150830224603_create_evidences_table.rb +8 -0
  88. data/db/migrate/20150911020838_add_valid_column_to_infractions.rb +6 -0
  89. data/db/migrate/20150911025204_add_index_to_users_username.rb +5 -0
  90. data/db/migrate/20151102220702_add_lat_lon_to_infractions.rb +6 -0
  91. data/db/migrate/20151102221811_remove_locations.rb +5 -0
  92. data/db/migrate/20151117194703_add_reported_at_to_infractions.rb +5 -0
  93. data/db/migrate/20160229023500_change_lat_lon_precision.rb +6 -0
  94. data/db/seeds.rb +7 -0
  95. data/infractores.gemspec +25 -0
  96. data/lib/assets/.keep +0 -0
  97. data/lib/infractores.rb +1 -0
  98. data/lib/infractores/version.rb +3 -0
  99. data/lib/tasks/.keep +0 -0
  100. data/lib/tasks/twitter.rake +16 -0
  101. data/lib/tasks/users.rake +9 -0
  102. data/log/.keep +0 -0
  103. data/public/404.html +67 -0
  104. data/public/422.html +67 -0
  105. data/public/500.html +66 -0
  106. data/public/favicon.ico +0 -0
  107. data/public/robots.txt +5 -0
  108. data/vendor/assets/images/blank.gif +0 -0
  109. data/vendor/assets/images/fancybox_loading.gif +0 -0
  110. data/vendor/assets/images/fancybox_loading@2x.gif +0 -0
  111. data/vendor/assets/images/fancybox_overlay.png +0 -0
  112. data/vendor/assets/images/fancybox_sprite.png +0 -0
  113. data/vendor/assets/images/fancybox_sprite@2x.png +0 -0
  114. data/vendor/assets/images/glyphicons-halflings-white.png +0 -0
  115. data/vendor/assets/images/glyphicons-halflings.png +0 -0
  116. data/vendor/assets/javascripts/.keep +0 -0
  117. data/vendor/assets/javascripts/jquery.fancybox-buttons.js +122 -0
  118. data/vendor/assets/javascripts/jquery.fancybox.pack.js +46 -0
  119. data/vendor/assets/javascripts/livereload.js +1183 -0
  120. data/vendor/assets/stylesheets/.keep +0 -0
  121. data/vendor/assets/stylesheets/jquery.fancybox-buttons.css +97 -0
  122. data/vendor/assets/stylesheets/jquery.fancybox.css +274 -0
  123. metadata +215 -0
@@ -0,0 +1,6 @@
1
+ Rails.application.routes.draw do
2
+ root 'infractions#index'
3
+ resources :infractions, only: [:index, :show]
4
+ get 'leaderboard' => 'users#index'
5
+ get ':username' => 'infractions#index'
6
+ end
@@ -0,0 +1,22 @@
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 the secrets in this file are kept private
11
+ # if you're sharing your code publicly.
12
+
13
+ development:
14
+ secret_key_base: 6ee34b13e168333e2cd22082b393408b30aefab7b1cc3cdcf6fdff482b83ca9418489daf3e08e26173d03663fc9f77576ab8552290f866c4e5f939f26118c24a
15
+
16
+ test:
17
+ secret_key_base: 2755c0b82794687463d85f0acade5b3fb6bee317b780230f66ba33ee72ae40c55e428bbe16f20e19bc7608696a53606bddfb06c15e8f57ff701ff9815cf1fb46
18
+
19
+ # Do not keep production secrets in the repository,
20
+ # instead read values from the environment.
21
+ production:
22
+ secret_key_base: <%= ENV["SECRET_KEY_BASE"] %>
@@ -0,0 +1,8 @@
1
+ class AddTweetsTable < ActiveRecord::Migration
2
+ def change
3
+ create_table :tweets, id: false do |t|
4
+ t.string :id, unique: true, null: false
5
+ t.text :json, null: false
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,11 @@
1
+ class CreateInfractions < ActiveRecord::Migration
2
+ def change
3
+ create_table :infractions do |t|
4
+ t.string :tweet_id
5
+ t.text :description
6
+ t.belongs_to :location
7
+
8
+ t.timestamps null: false
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,12 @@
1
+ class CreateUsers < ActiveRecord::Migration
2
+ def change
3
+ create_table :users do |t|
4
+ t.string :twitter_user_id
5
+ t.string :username
6
+ t.string :profile_image_url
7
+ t.string :name
8
+
9
+ t.timestamps null: false
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,5 @@
1
+ class AddUserIdToTweets < ActiveRecord::Migration
2
+ def change
3
+ add_column :tweets, :user_id, :integer, references: "users"
4
+ end
5
+ end
@@ -0,0 +1,10 @@
1
+ class CreateLocations < ActiveRecord::Migration
2
+ def change
3
+ create_table :locations do |t|
4
+ t.references :infraction
5
+ t.decimal :lon, precision: 10, scale: 6, null: false
6
+ t.decimal :lat, precision: 10, scale: 6, null: false
7
+ t.timestamps null: false
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,8 @@
1
+ class CreateEvidencesTable < ActiveRecord::Migration
2
+ def change
3
+ create_table :evidences do |t|
4
+ t.integer :infraction_id
5
+ t.string :media
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,6 @@
1
+ class AddValidColumnToInfractions < ActiveRecord::Migration
2
+ def change
3
+ add_column :infractions, :legitimate, :boolean, default: true
4
+ add_column :users, :infractions_count, :integer, default: 0
5
+ end
6
+ end
@@ -0,0 +1,5 @@
1
+ class AddIndexToUsersUsername < ActiveRecord::Migration
2
+ def change
3
+ add_index :users, :username
4
+ end
5
+ end
@@ -0,0 +1,6 @@
1
+ class AddLatLonToInfractions < ActiveRecord::Migration
2
+ def change
3
+ add_column :infractions, :lat, :decimal, precision: 10, scale: 6, null: false
4
+ add_column :infractions, :lon, :decimal, precision: 10, scale: 6, null: false
5
+ end
6
+ end
@@ -0,0 +1,5 @@
1
+ class RemoveLocations < ActiveRecord::Migration
2
+ def change
3
+ drop_table :locations
4
+ end
5
+ end
@@ -0,0 +1,5 @@
1
+ class AddReportedAtToInfractions < ActiveRecord::Migration
2
+ def change
3
+ add_column :infractions, :reported_at, :datetime
4
+ end
5
+ end
@@ -0,0 +1,6 @@
1
+ class ChangeLatLonPrecision < ActiveRecord::Migration
2
+ def change
3
+ change_column :infractions, :lat, :decimal, precision: 12, scale: 10, null: false
4
+ change_column :infractions, :lon, :decimal, precision: 12, scale: 10, null: false
5
+ end
6
+ end
@@ -0,0 +1,7 @@
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)
@@ -0,0 +1,25 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'infractores/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "infractores"
8
+ spec.version = Infractores::VERSION
9
+ spec.authors = ["Ernesto Tagwerker", "Mauro Otonelli"]
10
+ spec.email = ["ernesto+github@ombulabs.com", "mauro.otonelli@gmail.com"]
11
+
12
+ spec.summary = %q{Track parking violations reported via Twitter}
13
+ spec.description = %q{Track any kind of violations via Twitter with a geolocated tweet}
14
+ spec.homepage = "https://github.com/ombulabs/infractores"
15
+ spec.license = "MIT"
16
+
17
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
18
+ spec.bindir = "bin"
19
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
20
+ spec.require_paths = ["lib"]
21
+
22
+ spec.add_development_dependency "bundler", "~> 1.12"
23
+ spec.add_development_dependency "rake", "~> 10.0"
24
+ spec.add_development_dependency "rspec", "~> 3.0"
25
+ end
File without changes
@@ -0,0 +1 @@
1
+ require "infractores/version"
@@ -0,0 +1,3 @@
1
+ module Infractores
2
+ VERSION = "1.0.0"
3
+ end
File without changes
@@ -0,0 +1,16 @@
1
+ namespace :twitter do
2
+ task download_tweets: :environment do
3
+ puts "Downloading mentions"
4
+ TwitterService.instance.download_tweets
5
+ puts "Downloaded mentions"
6
+ end
7
+
8
+ task populate_reported_at: :environment do
9
+ puts "Populating reported_at"
10
+ Infraction.all.find_each do |infraction|
11
+ infraction.reported_at = infraction.tweet.source["created_at"]
12
+ infraction.save!
13
+ end
14
+ puts "Populated reported_at"
15
+ end
16
+ end
@@ -0,0 +1,9 @@
1
+ namespace :users do
2
+ task update_infractions_counter: :environment do
3
+ puts "Updating leaderboard"
4
+ User.find_each do |usr|
5
+ usr.update_infractions_counter!
6
+ end
7
+ puts "Updated leaderboard"
8
+ end
9
+ end
File without changes
@@ -0,0 +1,67 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>The page you were looking for doesn't exist (404)</title>
5
+ <meta name="viewport" content="width=device-width,initial-scale=1">
6
+ <style>
7
+ body {
8
+ background-color: #EFEFEF;
9
+ color: #2E2F30;
10
+ text-align: center;
11
+ font-family: arial, sans-serif;
12
+ margin: 0;
13
+ }
14
+
15
+ div.dialog {
16
+ width: 95%;
17
+ max-width: 33em;
18
+ margin: 4em auto 0;
19
+ }
20
+
21
+ div.dialog > div {
22
+ border: 1px solid #CCC;
23
+ border-right-color: #999;
24
+ border-left-color: #999;
25
+ border-bottom-color: #BBB;
26
+ border-top: #B00100 solid 4px;
27
+ border-top-left-radius: 9px;
28
+ border-top-right-radius: 9px;
29
+ background-color: white;
30
+ padding: 7px 12% 0;
31
+ box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
32
+ }
33
+
34
+ h1 {
35
+ font-size: 100%;
36
+ color: #730E15;
37
+ line-height: 1.5em;
38
+ }
39
+
40
+ div.dialog > p {
41
+ margin: 0 0 1em;
42
+ padding: 1em;
43
+ background-color: #F7F7F7;
44
+ border: 1px solid #CCC;
45
+ border-right-color: #999;
46
+ border-left-color: #999;
47
+ border-bottom-color: #999;
48
+ border-bottom-left-radius: 4px;
49
+ border-bottom-right-radius: 4px;
50
+ border-top-color: #DADADA;
51
+ color: #666;
52
+ box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
53
+ }
54
+ </style>
55
+ </head>
56
+
57
+ <body>
58
+ <!-- This file lives in public/404.html -->
59
+ <div class="dialog">
60
+ <div>
61
+ <h1>The page you were looking for doesn't exist.</h1>
62
+ <p>You may have mistyped the address or the page may have moved.</p>
63
+ </div>
64
+ <p>If you are the application owner check the logs for more information.</p>
65
+ </div>
66
+ </body>
67
+ </html>
@@ -0,0 +1,67 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>The change you wanted was rejected (422)</title>
5
+ <meta name="viewport" content="width=device-width,initial-scale=1">
6
+ <style>
7
+ body {
8
+ background-color: #EFEFEF;
9
+ color: #2E2F30;
10
+ text-align: center;
11
+ font-family: arial, sans-serif;
12
+ margin: 0;
13
+ }
14
+
15
+ div.dialog {
16
+ width: 95%;
17
+ max-width: 33em;
18
+ margin: 4em auto 0;
19
+ }
20
+
21
+ div.dialog > div {
22
+ border: 1px solid #CCC;
23
+ border-right-color: #999;
24
+ border-left-color: #999;
25
+ border-bottom-color: #BBB;
26
+ border-top: #B00100 solid 4px;
27
+ border-top-left-radius: 9px;
28
+ border-top-right-radius: 9px;
29
+ background-color: white;
30
+ padding: 7px 12% 0;
31
+ box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
32
+ }
33
+
34
+ h1 {
35
+ font-size: 100%;
36
+ color: #730E15;
37
+ line-height: 1.5em;
38
+ }
39
+
40
+ div.dialog > p {
41
+ margin: 0 0 1em;
42
+ padding: 1em;
43
+ background-color: #F7F7F7;
44
+ border: 1px solid #CCC;
45
+ border-right-color: #999;
46
+ border-left-color: #999;
47
+ border-bottom-color: #999;
48
+ border-bottom-left-radius: 4px;
49
+ border-bottom-right-radius: 4px;
50
+ border-top-color: #DADADA;
51
+ color: #666;
52
+ box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
53
+ }
54
+ </style>
55
+ </head>
56
+
57
+ <body>
58
+ <!-- This file lives in public/422.html -->
59
+ <div class="dialog">
60
+ <div>
61
+ <h1>The change you wanted was rejected.</h1>
62
+ <p>Maybe you tried to change something you didn't have access to.</p>
63
+ </div>
64
+ <p>If you are the application owner check the logs for more information.</p>
65
+ </div>
66
+ </body>
67
+ </html>
@@ -0,0 +1,66 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>We're sorry, but something went wrong (500)</title>
5
+ <meta name="viewport" content="width=device-width,initial-scale=1">
6
+ <style>
7
+ body {
8
+ background-color: #EFEFEF;
9
+ color: #2E2F30;
10
+ text-align: center;
11
+ font-family: arial, sans-serif;
12
+ margin: 0;
13
+ }
14
+
15
+ div.dialog {
16
+ width: 95%;
17
+ max-width: 33em;
18
+ margin: 4em auto 0;
19
+ }
20
+
21
+ div.dialog > div {
22
+ border: 1px solid #CCC;
23
+ border-right-color: #999;
24
+ border-left-color: #999;
25
+ border-bottom-color: #BBB;
26
+ border-top: #B00100 solid 4px;
27
+ border-top-left-radius: 9px;
28
+ border-top-right-radius: 9px;
29
+ background-color: white;
30
+ padding: 7px 12% 0;
31
+ box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
32
+ }
33
+
34
+ h1 {
35
+ font-size: 100%;
36
+ color: #730E15;
37
+ line-height: 1.5em;
38
+ }
39
+
40
+ div.dialog > p {
41
+ margin: 0 0 1em;
42
+ padding: 1em;
43
+ background-color: #F7F7F7;
44
+ border: 1px solid #CCC;
45
+ border-right-color: #999;
46
+ border-left-color: #999;
47
+ border-bottom-color: #999;
48
+ border-bottom-left-radius: 4px;
49
+ border-bottom-right-radius: 4px;
50
+ border-top-color: #DADADA;
51
+ color: #666;
52
+ box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
53
+ }
54
+ </style>
55
+ </head>
56
+
57
+ <body>
58
+ <!-- This file lives in public/500.html -->
59
+ <div class="dialog">
60
+ <div>
61
+ <h1>We're sorry, but something went wrong.</h1>
62
+ </div>
63
+ <p>If you are the application owner check the logs for more information.</p>
64
+ </div>
65
+ </body>
66
+ </html>
File without changes
@@ -0,0 +1,5 @@
1
+ # See http://www.robotstxt.org/robotstxt.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: /