From aaeb77d9698049374a0a4ba640a27173ccd01dd8 Mon Sep 17 00:00:00 2001 From: Eloy Gomez Date: Sat, 8 Aug 2015 12:05:55 +0200 Subject: [PATCH 01/44] Add gem ahoy_matey and some dependencies --- Gemfile | 5 +- Gemfile.lock | 23 ++++++++ app/assets/javascripts/application.js | 1 + app/models/ahoy/event.rb | 8 +++ config/initializers/ahoy.rb | 3 + db/migrate/20150804144230_create_visits.rb | 56 +++++++++++++++++++ .../20150804144231_create_ahoy_events.rb | 20 +++++++ db/schema.rb | 54 ++++++++++++++++-- 8 files changed, 163 insertions(+), 7 deletions(-) create mode 100644 app/models/ahoy/event.rb create mode 100644 config/initializers/ahoy.rb create mode 100644 db/migrate/20150804144230_create_visits.rb create mode 100644 db/migrate/20150804144231_create_ahoy_events.rb diff --git a/Gemfile b/Gemfile index 4c37d5ea1..ee555ec92 100644 --- a/Gemfile +++ b/Gemfile @@ -32,6 +32,10 @@ gem 'acts_as_votable' gem "recaptcha", require: "recaptcha/rails" gem 'ckeditor' +gem 'ahoy_matey' # stats +gem "chartkick" # charts +gem 'groupdate' # group temporary data + group :development, :test do # Call 'byebug' anywhere in the code to stop execution and get a debugger console gem 'byebug' @@ -62,4 +66,3 @@ end group :test do gem 'email_spec' end - diff --git a/Gemfile.lock b/Gemfile.lock index 62be9aa71..c005c2b21 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -44,12 +44,23 @@ GEM awesome_nested_set (>= 3.0) acts_as_votable (0.10.0) addressable (2.3.8) + ahoy_matey (1.2.0) + addressable + browser (>= 0.4.0) + errbase + geocoder + rails + referer-parser (>= 0.3.0) + request_store + user_agent_parser + uuidtools arel (6.0.2) awesome_nested_set (3.0.2) activerecord (>= 4.0.0, < 5) bcrypt (3.1.10) binding_of_caller (0.7.2) debug_inspector (>= 0.0.1) + browser (0.9.1) builder (3.2.2) byebug (5.0.0) columnize (= 0.9.0) @@ -74,6 +85,7 @@ GEM rack (>= 1.0.0) rack-test (>= 0.5.4) xpath (~> 2.0) + chartkick (1.3.2) ckeditor (4.1.2) cocaine orm_adapter (~> 0.5.0) @@ -117,6 +129,7 @@ GEM email_spec (1.6.0) launchy (~> 2.1) mail (~> 2.2) + errbase (0.0.3) erubis (2.7.0) execjs (2.5.2) factory_girl (4.5.0) @@ -127,8 +140,11 @@ GEM foundation-rails (5.5.2.1) railties (>= 3.1.0) sass (>= 3.3.0, < 3.5) + geocoder (1.2.9) globalid (0.3.5) activesupport (>= 4.1.0) + groupdate (2.4.0) + activesupport (>= 3) highline (1.7.3) http-cookie (1.0.2) domain_name (~> 0.5) @@ -209,6 +225,8 @@ GEM rake (10.4.2) rdoc (4.2.0) recaptcha (0.4.0) + referer-parser (0.3.0) + request_store (1.2.0) responders (2.1.0) railties (>= 4.2.0, < 5) rest-client (1.8.0) @@ -276,6 +294,8 @@ GEM unf (0.1.4) unf_ext unf_ext (0.0.7.1) + user_agent_parser (2.2.0) + uuidtools (2.1.5) warden (1.2.3) rack (>= 1.0) web-console (2.2.1) @@ -296,6 +316,7 @@ DEPENDENCIES acts-as-taggable-on acts_as_commentable_with_threading acts_as_votable + ahoy_matey byebug capistrano (= 3.4.0) capistrano-bundler (= 1.1.4) @@ -303,6 +324,7 @@ DEPENDENCIES capistrano-rails (= 1.1.3) capistrano-rvm capybara + chartkick ckeditor coffee-rails (~> 4.1.0) coveralls @@ -311,6 +333,7 @@ DEPENDENCIES email_spec factory_girl_rails foundation-rails + groupdate i18n-tasks jbuilder (~> 2.0) jquery-rails diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js index 08153c4ec..10fad952a 100644 --- a/app/assets/javascripts/application.js +++ b/app/assets/javascripts/application.js @@ -15,6 +15,7 @@ //= require foundation //= require turbolinks //= require ckeditor/init +//= require ahoy //= require app //= require_tree . diff --git a/app/models/ahoy/event.rb b/app/models/ahoy/event.rb new file mode 100644 index 000000000..2aac3c59c --- /dev/null +++ b/app/models/ahoy/event.rb @@ -0,0 +1,8 @@ +module Ahoy + class Event < ActiveRecord::Base + self.table_name = "ahoy_events" + + belongs_to :visit + belongs_to :user + end +end diff --git a/config/initializers/ahoy.rb b/config/initializers/ahoy.rb new file mode 100644 index 000000000..22d326e53 --- /dev/null +++ b/config/initializers/ahoy.rb @@ -0,0 +1,3 @@ +class Ahoy::Store < Ahoy::Stores::ActiveRecordStore + # customize here +end diff --git a/db/migrate/20150804144230_create_visits.rb b/db/migrate/20150804144230_create_visits.rb new file mode 100644 index 000000000..6f5156c0e --- /dev/null +++ b/db/migrate/20150804144230_create_visits.rb @@ -0,0 +1,56 @@ +class CreateVisits < ActiveRecord::Migration + def change + create_table :visits, id: false do |t| + t.uuid :id, default: nil, primary_key: true + t.uuid :visitor_id, default: nil + + # the rest are recommended but optional + # simply remove the columns you don't want + + # standard + t.string :ip + t.text :user_agent + t.text :referrer + t.text :landing_page + + # user + t.integer :user_id + # add t.string :user_type if polymorphic + + # traffic source + t.string :referring_domain + t.string :search_keyword + + # technology + t.string :browser + t.string :os + t.string :device_type + t.integer :screen_height + t.integer :screen_width + + # location + t.string :country + t.string :region + t.string :city + t.string :postal_code + t.decimal :latitude + t.decimal :longitude + + # utm parameters + t.string :utm_source + t.string :utm_medium + t.string :utm_term + t.string :utm_content + t.string :utm_campaign + + # native apps + # t.string :platform + # t.string :app_version + # t.string :os_version + + t.timestamp :started_at + end + + add_index :visits, [:user_id] + end +end diff --git a/db/migrate/20150804144231_create_ahoy_events.rb b/db/migrate/20150804144231_create_ahoy_events.rb new file mode 100644 index 000000000..81fb71f37 --- /dev/null +++ b/db/migrate/20150804144231_create_ahoy_events.rb @@ -0,0 +1,20 @@ +class CreateAhoyEvents < ActiveRecord::Migration + def change + create_table :ahoy_events, id: false do |t| + t.uuid :id, default: nil, primary_key: true + t.uuid :visit_id, default: nil + + # user + t.integer :user_id + # add t.string :user_type if polymorphic + + t.string :name + t.jsonb :properties + t.timestamp :time + end + + add_index :ahoy_events, [:visit_id] + add_index :ahoy_events, [:user_id] + add_index :ahoy_events, [:time] + end +end diff --git a/db/schema.rb b/db/schema.rb index f6947e462..22b60c506 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -16,6 +16,18 @@ ActiveRecord::Schema.define(version: 20150806163142) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" + create_table "ahoy_events", id: :uuid, default: nil, force: :cascade do |t| + t.uuid "visit_id" + t.integer "user_id" + t.string "name" + t.jsonb "properties" + t.datetime "time" + end + + add_index "ahoy_events", ["time"], name: "index_ahoy_events_on_time", using: :btree + add_index "ahoy_events", ["user_id"], name: "index_ahoy_events_on_user_id", using: :btree + add_index "ahoy_events", ["visit_id"], name: "index_ahoy_events_on_visit_id", using: :btree + create_table "comments", force: :cascade do |t| t.integer "commentable_id" t.string "commentable_type" @@ -62,18 +74,18 @@ ActiveRecord::Schema.define(version: 20150806163142) do add_index "tags", ["name"], name: "index_tags_on_name", unique: true, using: :btree create_table "users", force: :cascade do |t| - t.string "email", default: "", null: false - t.string "encrypted_password", default: "", null: false + t.string "email", default: "", null: false + t.string "encrypted_password", default: "", null: false t.string "reset_password_token" t.datetime "reset_password_sent_at" t.datetime "remember_created_at" - t.integer "sign_in_count", default: 0, null: false + t.integer "sign_in_count", default: 0, null: false t.datetime "current_sign_in_at" t.datetime "last_sign_in_at" t.string "current_sign_in_ip" t.string "last_sign_in_ip" - t.datetime "created_at", null: false - t.datetime "updated_at", null: false + t.datetime "created_at", null: false + t.datetime "updated_at", null: false t.string "first_name" t.string "last_name" t.string "confirmation_token" @@ -81,7 +93,7 @@ ActiveRecord::Schema.define(version: 20150806163142) do t.datetime "confirmation_sent_at" t.string "unconfirmed_email" t.string "nickname" - t.boolean "use_nickname", default: false, null: false + t.boolean "use_nickname", default: false, null: false t.boolean "email_on_debate_comment", default: false t.boolean "email_on_comment_reply", default: false end @@ -90,6 +102,36 @@ ActiveRecord::Schema.define(version: 20150806163142) do add_index "users", ["email"], name: "index_users_on_email", unique: true, using: :btree add_index "users", ["reset_password_token"], name: "index_users_on_reset_password_token", unique: true, using: :btree + create_table "visits", id: :uuid, default: nil, force: :cascade do |t| + t.uuid "visitor_id" + t.string "ip" + t.text "user_agent" + t.text "referrer" + t.text "landing_page" + t.integer "user_id" + t.string "referring_domain" + t.string "search_keyword" + t.string "browser" + t.string "os" + t.string "device_type" + t.integer "screen_height" + t.integer "screen_width" + t.string "country" + t.string "region" + t.string "city" + t.string "postal_code" + t.decimal "latitude" + t.decimal "longitude" + t.string "utm_source" + t.string "utm_medium" + t.string "utm_term" + t.string "utm_content" + t.string "utm_campaign" + t.datetime "started_at" + end + + add_index "visits", ["user_id"], name: "index_visits_on_user_id", using: :btree + create_table "votes", force: :cascade do |t| t.integer "votable_id" t.string "votable_type" From 42d6e499157e628c846f1ebcc4a45e42dd9e6a39 Mon Sep 17 00:00:00 2001 From: Eloy Gomez Date: Sat, 8 Aug 2015 12:23:28 +0200 Subject: [PATCH 02/44] Save visitor ip --- config/initializers/ahoy.rb | 8 +++++++- db/migrate/20150808100936_add_ip_to_ahoy_event.rb | 5 +++++ db/schema.rb | 3 ++- 3 files changed, 14 insertions(+), 2 deletions(-) create mode 100644 db/migrate/20150808100936_add_ip_to_ahoy_event.rb diff --git a/config/initializers/ahoy.rb b/config/initializers/ahoy.rb index 22d326e53..9a1215c68 100644 --- a/config/initializers/ahoy.rb +++ b/config/initializers/ahoy.rb @@ -1,3 +1,9 @@ class Ahoy::Store < Ahoy::Stores::ActiveRecordStore - # customize here + + # Track user IP + def track_event(name, properties, options) + super do |event| + event.ip = request.ip + end + end end diff --git a/db/migrate/20150808100936_add_ip_to_ahoy_event.rb b/db/migrate/20150808100936_add_ip_to_ahoy_event.rb new file mode 100644 index 000000000..2c6d9d9b2 --- /dev/null +++ b/db/migrate/20150808100936_add_ip_to_ahoy_event.rb @@ -0,0 +1,5 @@ +class AddIpToAhoyEvent < ActiveRecord::Migration + def change + add_column :ahoy_events, :ip, :string + end +end diff --git a/db/schema.rb b/db/schema.rb index 22b60c506..7846bfd1e 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20150806163142) do +ActiveRecord::Schema.define(version: 20150808100936) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -22,6 +22,7 @@ ActiveRecord::Schema.define(version: 20150806163142) do t.string "name" t.jsonb "properties" t.datetime "time" + t.string "ip" end add_index "ahoy_events", ["time"], name: "index_ahoy_events_on_time", using: :btree From a83a787090e62574c8a1984223f2a5095b0aec44 Mon Sep 17 00:00:00 2001 From: Eloy Gomez Date: Sat, 8 Aug 2015 12:56:41 +0200 Subject: [PATCH 03/44] Add model visit --- app/models/visit.rb | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 app/models/visit.rb diff --git a/app/models/visit.rb b/app/models/visit.rb new file mode 100644 index 000000000..6bb47fed0 --- /dev/null +++ b/app/models/visit.rb @@ -0,0 +1,4 @@ +class Visit < ActiveRecord::Base + has_many :ahoy_events, class_name: "Ahoy::Event" + belongs_to :user +end From d16b2bef2800ee51d43a1422292c21e36ec34190 Mon Sep 17 00:00:00 2001 From: Eloy Gomez Date: Sat, 8 Aug 2015 12:58:02 +0200 Subject: [PATCH 04/44] Include devise helpers in controller specs --- spec/spec_helper.rb | 3 +++ 1 file changed, 3 insertions(+) diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 640f9e96c..a1915bc34 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,6 +1,8 @@ require 'factory_girl_rails' require 'database_cleaner' require "email_spec" +require 'devise' + Dir["./spec/support/**/*.rb"].sort.each { |f| require f} RSpec.configure do |config| @@ -8,6 +10,7 @@ RSpec.configure do |config| config.filter_run :focus config.run_all_when_everything_filtered = true + config.include Devise::TestHelpers, :type => :controller config.include FactoryGirl::Syntax::Methods config.include(EmailSpec::Helpers) config.include(EmailSpec::Matchers) From b23ca8deb1e37bebbd480672af20fbba8ca380bb Mon Sep 17 00:00:00 2001 From: Eloy Gomez Date: Sat, 8 Aug 2015 13:08:48 +0200 Subject: [PATCH 05/44] Create event on debate creation --- app/controllers/debates_controller.rb | 1 + spec/controllers/debates_controller_spec.rb | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+) create mode 100644 spec/controllers/debates_controller_spec.rb diff --git a/app/controllers/debates_controller.rb b/app/controllers/debates_controller.rb index a395f9c5e..b8ab7792c 100644 --- a/app/controllers/debates_controller.rb +++ b/app/controllers/debates_controller.rb @@ -30,6 +30,7 @@ class DebatesController < ApplicationController @debate = Debate.new(debate_params) @debate.author = current_user if verify_captcha?(@debate) and @debate.save + ahoy.track :debate_created, debate_id: @debate.id redirect_to @debate, notice: t('flash.actions.create.notice', resource_name: 'Debate') else render :new diff --git a/spec/controllers/debates_controller_spec.rb b/spec/controllers/debates_controller_spec.rb new file mode 100644 index 000000000..1a24c17d5 --- /dev/null +++ b/spec/controllers/debates_controller_spec.rb @@ -0,0 +1,18 @@ +require 'rails_helper' + +describe DebatesController do + + # create + #---------------------------------------------------------------------- + + describe 'POST create' do + let(:user) { create :user } + + it 'should create an ahoy event' do + sign_in user + post :create, debate: { title: 'foo', description: 'foo bar', terms_of_service: 1 } + expect(Ahoy::Event.where(name: :debate_created).count).to eq 1 + expect(Ahoy::Event.last.properties['debate_id']).to eq Debate.last.id + end + end +end From 02f19aa4b11bd8a03a6d49c4bd068931d38c0197 Mon Sep 17 00:00:00 2001 From: Eloy Gomez Date: Sat, 8 Aug 2015 13:09:22 +0200 Subject: [PATCH 06/44] Add visit_id to debate --- app/models/debate.rb | 6 ++++++ db/migrate/20150808102442_add_visit_id_to_debate.rb | 5 +++++ db/schema.rb | 3 ++- 3 files changed, 13 insertions(+), 1 deletion(-) create mode 100644 db/migrate/20150808102442_add_visit_id_to_debate.rb diff --git a/app/models/debate.rb b/app/models/debate.rb index 28181101a..208d10277 100644 --- a/app/models/debate.rb +++ b/app/models/debate.rb @@ -18,6 +18,12 @@ class Debate < ActiveRecord::Base before_validation :sanitize_description before_validation :sanitize_tag_list + # ahoy setup + #---------------------------------------------------------------------- + + visitable # Ahoy will automatically assign visit_id on create + + def likes get_likes.size end diff --git a/db/migrate/20150808102442_add_visit_id_to_debate.rb b/db/migrate/20150808102442_add_visit_id_to_debate.rb new file mode 100644 index 000000000..4d09f2cd0 --- /dev/null +++ b/db/migrate/20150808102442_add_visit_id_to_debate.rb @@ -0,0 +1,5 @@ +class AddVisitIdToDebate < ActiveRecord::Migration + def change + add_column :debates, :visit_id, :string + end +end diff --git a/db/schema.rb b/db/schema.rb index 7846bfd1e..b60f74eae 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20150808100936) do +ActiveRecord::Schema.define(version: 20150808102442) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -52,6 +52,7 @@ ActiveRecord::Schema.define(version: 20150808100936) do t.integer "author_id" t.datetime "created_at", null: false t.datetime "updated_at", null: false + t.string "visit_id" end create_table "taggings", force: :cascade do |t| From fe2080aff9a79bd7081ddb9051f19ceddd5ce03f Mon Sep 17 00:00:00 2001 From: Eloy Gomez Date: Sat, 8 Aug 2015 14:33:44 +0200 Subject: [PATCH 07/44] Display some stats --- app/controllers/api/api_controller.rb | 4 ++ app/controllers/api/stats_controller.rb | 10 +++++ app/controllers/stats_controller.rb | 5 +++ app/views/layouts/application.html.erb | 3 +- app/views/stats/show.html.erb | 9 ++++ config/routes.rb | 5 +++ spec/controllers/api/stats_controller_spec.rb | 44 +++++++++++++++++++ spec/factories.rb | 7 ++- 8 files changed, 85 insertions(+), 2 deletions(-) create mode 100644 app/controllers/api/api_controller.rb create mode 100644 app/controllers/api/stats_controller.rb create mode 100644 app/controllers/stats_controller.rb create mode 100644 app/views/stats/show.html.erb create mode 100644 spec/controllers/api/stats_controller_spec.rb diff --git a/app/controllers/api/api_controller.rb b/app/controllers/api/api_controller.rb new file mode 100644 index 000000000..0534444c0 --- /dev/null +++ b/app/controllers/api/api_controller.rb @@ -0,0 +1,4 @@ +class Api::ApiController < ApplicationController + before_action :authenticate_user! + protect_from_forgery with: :null_session +end diff --git a/app/controllers/api/stats_controller.rb b/app/controllers/api/stats_controller.rb new file mode 100644 index 000000000..26fb373fb --- /dev/null +++ b/app/controllers/api/stats_controller.rb @@ -0,0 +1,10 @@ +class Api::StatsController < Api::ApiController + def show + event_type = params[:event] + unless event_type.present? + return render json: {}, status: :bad_request + end + + render json: Ahoy::Event.where(name: event_type).group_by_day(:time).count + end +end diff --git a/app/controllers/stats_controller.rb b/app/controllers/stats_controller.rb new file mode 100644 index 000000000..c33f6843e --- /dev/null +++ b/app/controllers/stats_controller.rb @@ -0,0 +1,5 @@ +class StatsController < ApplicationController + def show + @event_types = Ahoy::Event.select(:name).uniq.pluck(:name) + end +end diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index 36a3c44cc..5c6324e31 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -8,6 +8,7 @@ <%= stylesheet_link_tag "application" %> <%= javascript_include_tag "vendor/modernizr" %> <%= javascript_include_tag "application", 'data-turbolinks-track' => true %> + <%= javascript_include_tag "//www.google.com/jsapi", "chartkick" %> <%= csrf_meta_tags %> @@ -27,4 +28,4 @@ <%= render 'layouts/footer' %> - \ No newline at end of file + diff --git a/app/views/stats/show.html.erb b/app/views/stats/show.html.erb new file mode 100644 index 000000000..0671b15ad --- /dev/null +++ b/app/views/stats/show.html.erb @@ -0,0 +1,9 @@ +

Stats

+ +

Visits

+<%= line_chart Visit.group_by_day(:started_at).count %> + +<% @event_types.each do |event_type| %> +

<%= event_type.titleize %>

+ <%= line_chart api_stats_path(event: event_type) %> +<% end %> diff --git a/config/routes.rb b/config/routes.rb index 73a77f60e..6cb8dcba6 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -21,6 +21,11 @@ Rails.application.routes.draw do end resource :account, controller: "account", only: [:show, :update] + resource :stats, only: [:show] + + namespace :api do + resource :stats, only: [:show] + end # Example of regular route: # get 'products/:id' => 'catalog#view' diff --git a/spec/controllers/api/stats_controller_spec.rb b/spec/controllers/api/stats_controller_spec.rb new file mode 100644 index 000000000..e2f4cd02b --- /dev/null +++ b/spec/controllers/api/stats_controller_spec.rb @@ -0,0 +1,44 @@ +require 'rails_helper' + +describe Api::StatsController do + + # GET index + #---------------------------------------------------------------------- + + describe 'GET index' do + let(:user) { create :user } + + context 'event not present' do + it 'should respond with bad_request' do + sign_in user + get :show + expect(response.status).to eq 400 + end + end + + context 'event present' do + it 'should return event counts' do + time_1 = DateTime.yesterday.to_datetime + time_2 = DateTime.now + + event_1 = create :ahoy_event, name: 'foo', time: time_1 + event_2 = create :ahoy_event, name: 'foo', time: time_1 + event_3 = create :ahoy_event, name: 'foo', time: time_2 + event_4 = create :ahoy_event, name: 'bar' + + sign_in user + get :show, event: 'foo' + + expect(response).to be_ok + + data = JSON.parse(response.body) + dates = data.keys + + expect(DateTime.parse dates.first).to eq time_1.utc.beginning_of_day + expect(DateTime.parse dates.last).to eq time_2.utc.beginning_of_day + expect(data[dates.first]).to eq 2 + expect(data[dates.last]).to eq 1 + end + end + end +end diff --git a/spec/factories.rb b/spec/factories.rb index 8e1a2ea6c..18b65b7f3 100644 --- a/spec/factories.rb +++ b/spec/factories.rb @@ -31,4 +31,9 @@ FactoryGirl.define do debate end -end \ No newline at end of file + factory :ahoy_event, :class => Ahoy::Event do + id { SecureRandom.uuid } + time DateTime.now + sequence(:name) {|n| "Event #{n} type"} + end +end From 7f8b3abace1bad7ff2fa2e2c50eb28066da19414 Mon Sep 17 00:00:00 2001 From: Eloy Gomez Date: Sat, 8 Aug 2015 15:04:47 +0200 Subject: [PATCH 08/44] Use Postgres 9.4 with travis --- .travis.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.travis.yml b/.travis.yml index c1d4bc930..cb294ec9c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,4 +1,6 @@ language: ruby +addons: + postgresql: "9.4" rvm: - "2.2.2" cache: bundler From cfd923138c4cdaa648a46d5edbe4bbaef0ddba91 Mon Sep 17 00:00:00 2001 From: Eloy Gomez Date: Mon, 10 Aug 2015 15:39:14 +0200 Subject: [PATCH 09/44] Add minimum PostgreSQL version. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 66c1853dc..0af5e03f7 100644 --- a/README.md +++ b/README.md @@ -20,7 +20,7 @@ Las herramientas utilizadas para el frontend no están cerradas aún. Los estilo ## Configuración para desarrollo y tests -Prerequisitos: tener instalado git, Ruby 2.2.2, la gema `bundler`, y una librería moderna de PostgreSQL. +Prerequisitos: tener instalado git, Ruby 2.2.2, la gema `bundler`, y PostgreSQL 9.4 o superior. ``` cd participacion From 43f8db8e3a53727349c65590bc1cc3ebb2fbbcab Mon Sep 17 00:00:00 2001 From: Alberto Garcia Cabeza Date: Mon, 17 Aug 2015 14:53:00 +0200 Subject: [PATCH 10/44] Adds styles for titles and filters --- app/assets/stylesheets/debates.scss | 5 -- app/assets/stylesheets/participacion.scss | 35 +++++++++++- app/views/debates/index.html.erb | 65 ++++++++++++++++++++++- app/views/welcome/index.html.erb | 9 +++- config/locales/en.yml | 10 ++++ config/locales/es.yml | 22 ++++---- 6 files changed, 124 insertions(+), 22 deletions(-) diff --git a/app/assets/stylesheets/debates.scss b/app/assets/stylesheets/debates.scss index f242e8757..76c4405ed 100644 --- a/app/assets/stylesheets/debates.scss +++ b/app/assets/stylesheets/debates.scss @@ -138,10 +138,6 @@ // 02. Index // - - - - - - - - - - - - - - - - - - - - - - - - - -.featured-debates { - margin-top: rem-calc(23); -} - .debate-featured { .panel { @@ -244,7 +240,6 @@ .debates-list { margin-bottom: rem-calc(48); - margin-top: rem-calc(24); } .debate { diff --git a/app/assets/stylesheets/participacion.scss b/app/assets/stylesheets/participacion.scss index 6e5ad3d7b..49ac151fe 100644 --- a/app/assets/stylesheets/participacion.scss +++ b/app/assets/stylesheets/participacion.scss @@ -10,6 +10,7 @@ // 08. Forms // 09. Alerts // 10. User account +// 11. Filters // // 01. Variables @@ -111,7 +112,6 @@ h1, h2, h3, h4, h5, h6 { } .sidebar { - margin-top: rem-calc(24); margin-bottom: rem-calc(48); } @@ -556,3 +556,36 @@ form { } } } + +// 11. Filters +// - - - - - - - - - - - - - - - - - - - - - - - - - + +.filters { + + h2 { + display: inline-block; + font-size: rem-calc(24); + margin: rem-calc(24) 0; + } + + select { + height: auto; + margin: rem-calc(24) rem-calc(6); + min-width: rem-calc(180); + outline: 0; + padding: rem-calc(12); + width: auto; + + optgroup { + font-size: rem-calc(14); + } + + option { + + &:after { + content: "a"; + font-family: "icons"; + } + } + } +} diff --git a/app/views/debates/index.html.erb b/app/views/debates/index.html.erb index 3a3881b76..6fa0db61c 100644 --- a/app/views/debates/index.html.erb +++ b/app/views/debates/index.html.erb @@ -1,6 +1,67 @@
+ + +
+
+

<%= t("debates.index.showing") %>

+ + + + +
+
+ + + +
+
+

<%= t("debates.index.showing") %>

+ + + +

<%= t("debates.index.tag") %>

+ + + +

(43)

+
+
+ +
-
+
<%= render @debates %>
@@ -10,4 +71,4 @@
-
\ No newline at end of file + diff --git a/app/views/welcome/index.html.erb b/app/views/welcome/index.html.erb index 434499859..ada595c02 100644 --- a/app/views/welcome/index.html.erb +++ b/app/views/welcome/index.html.erb @@ -1,5 +1,10 @@
-
\ No newline at end of file + diff --git a/config/locales/en.yml b/config/locales/en.yml index f1d7ba646..4ae370798 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -27,6 +27,14 @@ en: debates: index: create_debate: Create a debate + showing: You are seeing + tag: with the topic + filter_debates: debates + filter_initiatives: initiatives + filter_debates_and_initiatives: debates and initiatives + filter_news: the newest + filter_votes: the most voted + filter_rated: the best rated debate: debate: Debate comments: @@ -124,3 +132,5 @@ en: default: "You are not authorized to access this page." manage: all: "You are not authorized to %{action} %{subject}." + welcome: + featured_debates: Features debates diff --git a/config/locales/es.yml b/config/locales/es.yml index 45cfac0d5..bc5ee7df1 100644 --- a/config/locales/es.yml +++ b/config/locales/es.yml @@ -27,6 +27,14 @@ es: debates: index: create_debate: Crea un debate + showing: "Estás viendo" + tag: "con el tema" + filter_debates: debates + filter_initiatives: iniciativas + filter_debates_and_initiatives: debates e iniciativas + filter_news: "más nuevos" + filter_votes: "más votados" + filter_rated: mejor valorados debate: debate: Debate comments: @@ -122,17 +130,7 @@ es: subject: Alguien ha respondido a tu comentario unauthorized: default: "No tienes permiso para acceder a esta página." - index: - all: "No tienes permiso para listar %{subject}" - show: - all: "No tienes permiso para ver %{subject}" - edit: - all: "No tienes permiso para editar %{subject}" - update: - all: "No tienes permiso para modificar %{subject}" - create: - all: "No tienes permiso para crear %{subject}" - delete: - all: "No tienes permiso para borrar %{subject}" manage: all: "No tienes permiso para realizar la acción '%{action}' sobre %{subject}." + welcome: + featured_debates: Debates destacados From 4b59105be58f7292c55f9e349b4ff1b7801bf9d4 Mon Sep 17 00:00:00 2001 From: Alberto Garcia Cabeza Date: Mon, 17 Aug 2015 15:00:59 +0200 Subject: [PATCH 11/44] Adds filters for topics --- app/views/debates/index.html.erb | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/app/views/debates/index.html.erb b/app/views/debates/index.html.erb index 6fa0db61c..0e3e41d1d 100644 --- a/app/views/debates/index.html.erb +++ b/app/views/debates/index.html.erb @@ -49,6 +49,18 @@ + +

<%= t("debates.index.tag") %>