From 3b2ed08b54061de324e57b05674d124040b8849a Mon Sep 17 00:00:00 2001 From: Alessandro Cuoghi Date: Fri, 21 Jul 2017 16:36:42 +0200 Subject: [PATCH 01/41] Add recommended partials. --- app/views/welcome/_recommended.html.erb | 138 ++++++++++++++++++ .../welcome/_recommended_no_image.html.erb | 129 ++++++++++++++++ 2 files changed, 267 insertions(+) create mode 100644 app/views/welcome/_recommended.html.erb create mode 100644 app/views/welcome/_recommended_no_image.html.erb diff --git a/app/views/welcome/_recommended.html.erb b/app/views/welcome/_recommended.html.erb new file mode 100644 index 000000000..3c6e17294 --- /dev/null +++ b/app/views/welcome/_recommended.html.erb @@ -0,0 +1,138 @@ +
+

Recomendaciones que te pueden interesar

+
+
+

Debates recomendados

+
+
+
    +
  • +
    + +
    +
    Titulo debate 1
    +

    Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua

    +
    +
    +
  • + + + + +
+
+
+ + +
+
+
+
+ +
+ +
+

Propuestas recomendadas

+
+
+
    +
  • +
    + +
    +
    Titulo propuesta 1
    +

    Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua

    +
    +
    +
  • + + + +
+
+
+ + +
+
+
+
+ +
+ +
+

Presupuestos recomendados

+
+
+
    +
  • +
    + +
    +
    Titulo presupuesto 1
    +

    Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua

    +
    +
    +
  • + + + +
+
+
+ + +
+
+
+
+ +
diff --git a/app/views/welcome/_recommended_no_image.html.erb b/app/views/welcome/_recommended_no_image.html.erb new file mode 100644 index 000000000..8fc04488c --- /dev/null +++ b/app/views/welcome/_recommended_no_image.html.erb @@ -0,0 +1,129 @@ +
+

Recomendaciones que te pueden interesar

+
+
+

Debates recomendados

+
+
+
    +
  • +
    +
    +
    Titulo debate 1
    +

    Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua

    +
    +
    +
  • + + + + +
+
+
+ + +
+
+
+
+ +
+ +
+

Propuestas recomendadas

+
+
+
    +
  • +
    +
    +
    Titulo propuesta 1
    +

    Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua

    +
    +
    +
  • + + + +
+
+
+ + +
+
+
+
+ +
+ +
+

Presupuestos recomendados

+
+
+
    +
  • +
    +
    +
    Titulo presupuesto 1
    +

    Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua

    +
    +
    +
  • + + + +
+
+
+ + +
+
+
+
+ +
From ff6471982c1a8f58cb301bc8f48871a6017a024f Mon Sep 17 00:00:00 2001 From: taitus Date: Fri, 21 Jul 2017 20:06:33 +0200 Subject: [PATCH 02/41] Add recommended debates, proposals and investement to Home page. --- app/controllers/welcome_controller.rb | 3 - app/helpers/welcome_helper.rb | 11 ++ app/models/user.rb | 18 ++ app/views/proposals/index.html.erb | 14 +- .../welcome/_recommended_no_image.html.erb | 157 ++++++++---------- app/views/welcome/index.html.erb | 2 + config/locales/en/general.yml | 8 + config/locales/es/general.yml | 8 + 8 files changed, 122 insertions(+), 99 deletions(-) create mode 100644 app/helpers/welcome_helper.rb diff --git a/app/controllers/welcome_controller.rb b/app/controllers/welcome_controller.rb index d0c650fa3..5aec4a456 100644 --- a/app/controllers/welcome_controller.rb +++ b/app/controllers/welcome_controller.rb @@ -4,9 +4,6 @@ class WelcomeController < ApplicationController layout "devise", only: [:welcome, :verification] def index - if current_user - redirect_to :proposals - end end def welcome diff --git a/app/helpers/welcome_helper.rb b/app/helpers/welcome_helper.rb new file mode 100644 index 000000000..78c01b141 --- /dev/null +++ b/app/helpers/welcome_helper.rb @@ -0,0 +1,11 @@ +module WelcomeHelper + + def active_class(index) + "is-active is-in" if index == 0 + end + + def slide_display(index) + "display: none;" if index > 0 + end + +end diff --git a/app/models/user.rb b/app/models/user.rb index 60536195b..1a26030ea 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -313,6 +313,24 @@ class User < ActiveRecord::Base follows.map{|follow| follow.followable.tags.map(&:name)}.flatten.compact.uniq end + def recommended_debates + Debate.tagged_with(interests, any: true). + where("author_id != ?", self). + order("cached_votes_total DESC").limit(3) + end + + def recommended_proposals + Proposal.tagged_with(interests, any: true). + where("author_id != ?", self). + order("cached_votes_up DESC").limit(3) + end + + def recommended_budget_investments + Budget::Investment.tagged_with(interests, any: true). + where("author_id != ?", self). + order("cached_votes_up DESC").limit(3) + end + private def clean_document_number diff --git a/app/views/proposals/index.html.erb b/app/views/proposals/index.html.erb index e1c04c607..5d51ad279 100644 --- a/app/views/proposals/index.html.erb +++ b/app/views/proposals/index.html.erb @@ -16,13 +16,13 @@
<% if @search_terms || @advanced_search_terms %> -

<%= t("shared.search_results") %>

-

- <%= page_entries_info @proposals %> - <% if !@advanced_search_terms %> - <%= t("proposals.index.search_results_html", count: @proposals.size, search_term: @search_terms) %> - <% end %> -

+

<%= t("shared.search_results") %>

+

+ <%= page_entries_info @proposals %> + <% if !@advanced_search_terms %> + <%= t("proposals.index.search_results_html", count: @proposals.size, search_term: @search_terms) %> + <% end %> +

<% elsif @tag_filter %>

<%= t("shared.search_results") %>

diff --git a/app/views/welcome/_recommended_no_image.html.erb b/app/views/welcome/_recommended_no_image.html.erb index 8fc04488c..495bccc5c 100644 --- a/app/views/welcome/_recommended_no_image.html.erb +++ b/app/views/welcome/_recommended_no_image.html.erb @@ -1,128 +1,107 @@

-

Recomendaciones que te pueden interesar

-
+

<%= t("welcome.recommended.title") %>

+ +
-

Debates recomendados

+ +

<%= t("welcome.recommended.debates.title") %>

+
+
    -
  • -
    -
    -
    Titulo debate 1
    -

    Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua

    -
    -
    -
  • + <% current_user.recommended_debates.each_with_index do |debate, index| %> -
  • +
    +
    +
    <%= debate.title %>
    +

    <%= debate.description %>

    + +
    -
- + - + <% end %> + +
+ +
+ +
-
- - -
-
- +
-

Propuestas recomendadas

+ +

<%= t("welcome.recommended.proposals.title") %>

+
-
    -
  • -
    -
    -
    Titulo propuesta 1
    -

    Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua

    -
    -
    -
  • - - + + + <% end %>
+
-
+ +
-
+
+
-
+
+
+ +

<%= t("welcome.recommended.budget_investments.title") %>

-
-

Presupuestos recomendados

-
    -
  • -
    -
    -
    Titulo presupuesto 1
    -

    Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua

    -
    -
    -
  • - - + + + <% end %>
+
-
+ +
-
-
+
+ +
diff --git a/app/views/welcome/index.html.erb b/app/views/welcome/index.html.erb index 727ec67b7..a9b2d455c 100644 --- a/app/views/welcome/index.html.erb +++ b/app/views/welcome/index.html.erb @@ -45,3 +45,5 @@
<% end %> + +<%= render "recommended_no_image" %> diff --git a/config/locales/en/general.yml b/config/locales/en/general.yml index aea5c65c8..28e294c03 100644 --- a/config/locales/en/general.yml +++ b/config/locales/en/general.yml @@ -713,6 +713,14 @@ en: proposal: description: Open space for citizen proposals about the kind of city we want to live in. title: You propose + recommended: + title: Recommendations that may interest you + debates: + title: Recommended debates + proposals: + title: Recommended proposals + budget_investments: + title: Recommended investments verification: i_dont_have_an_account: I don't have an account i_have_an_account: I already have an account diff --git a/config/locales/es/general.yml b/config/locales/es/general.yml index 3f21ed55f..47aae4544 100644 --- a/config/locales/es/general.yml +++ b/config/locales/es/general.yml @@ -713,6 +713,14 @@ es: proposal: description: Espacio abierto para propuestas ciudadanas sobre el tipo de ciudad en el que queremos vivir. title: Propones + recommended: + title: Recomendaciones que te pueden interesar + debates: + title: Debates recomendados + proposals: + title: Propuestas recomendados + budget_investments: + title: Presupuestos recomendados verification: i_dont_have_an_account: No tengo cuenta, quiero crear una y verificarla i_have_an_account: Ya tengo una cuenta que quiero verificar From a4e12ea8018c1d286e176d99187cb2a77be41674 Mon Sep 17 00:00:00 2001 From: Alessandro Cuoghi Date: Sat, 22 Jul 2017 00:31:10 +0200 Subject: [PATCH 03/41] Added style to recommended section. Added orbit bullet. For each title of the recommended added truncate horizontal with css. Added link for each recommended. Adjusted for responsive. Passed scss-lint. --- app/assets/stylesheets/layout.scss | 101 +++++++++++ app/assets/stylesheets/mixins.scss | 28 +++ .../welcome/_recommended_no_image.html.erb | 170 +++++++++--------- db/schema.rb | 2 +- 4 files changed, 215 insertions(+), 86 deletions(-) diff --git a/app/assets/stylesheets/layout.scss b/app/assets/stylesheets/layout.scss index 7a5705f60..5c4dcb567 100644 --- a/app/assets/stylesheets/layout.scss +++ b/app/assets/stylesheets/layout.scss @@ -18,6 +18,7 @@ // 16. Flags // 17. Activity // 18. Banners +// 19. Recommended Section Home // // 01. Global styles @@ -319,6 +320,14 @@ a { background: $brand; } +.truncate-horizontal-text { + white-space: nowrap; + overflow: hidden; + text-overflow: ellipsis; + -o-text-overflow: ellipsis; + -ms-text-overflow: ellipsis; +} + // 02. Header // ---------- @@ -2128,3 +2137,95 @@ table { text-decoration: none; } } + +// 19. Recommended Section Home +// ----------- +.section-recommended { + padding-top: $line-height * 2; + + h2 { + margin-bottom: $line-height * 2; + } + + .debates, + .proposals, + .budget-investments { + + @include breakpoint(medium) { + margin-bottom: 0; + } + + @include breakpoint(small) { + margin-bottom: $line-height; + } + } + + .card { + + .card-section { + padding: $line-height; + + p { + font-size: rem-calc(15); + } + } + + .orbit { + height: 300px; + + .orbit-wrapper { + max-height: 250px; + overflow: hidden; + position: relative; + } + + .orbit-bullets { + @include orbit-bullets; + width: 100%; + } + } + } + + .card .orbit .orbit-wrapper .truncate { + background: image-url('truncate.png'); + background-repeat: repeat-x; + bottom: 0; + height: 20px; + position: absolute; + width: 100%; + } + + .debates-inner { + border-top: 4px solid $debates; + } + + .proposals-inner { + border-top: 4px solid $proposals; + } + + .budget-investments-inner { + border-top: 4px solid $budget; + } + + .debates-inner, + .proposals-inner, + .budget-investments-inner { + background: #fff; + max-height: 350px; + + @include breakpoint(small) { + max-height: 400px; + } + + h4 { + margin-top: $line-height; + margin-bottom: 0; + font-size: rem-calc(18); + min-height: 50px; + } + + h5 { + font-size: rem-calc(14); + } + } +} diff --git a/app/assets/stylesheets/mixins.scss b/app/assets/stylesheets/mixins.scss index 401a2ec81..70f4c179d 100644 --- a/app/assets/stylesheets/mixins.scss +++ b/app/assets/stylesheets/mixins.scss @@ -1,6 +1,7 @@ // Table of Contents // // 01. Logo +// 02. Orbit bullets // // 01. Logo @@ -30,3 +31,30 @@ } } } + + +//02. Orbit bullet +@mixin orbit-bullets { + @include disable-mouse-outline; + position: relative; + margin-top: $orbit-bullet-margin-top; + margin-bottom: $orbit-bullet-margin-bottom; + text-align: center; + + button { + width: $orbit-bullet-diameter; + height: $orbit-bullet-diameter; + margin: $orbit-bullet-margin; + + border-radius: 50%; + background-color: $orbit-bullet-background; + + &:hover { + background-color: $orbit-bullet-background-active; + } + + &.is-active { + background-color: $orbit-bullet-background-active; + } + } +} diff --git a/app/views/welcome/_recommended_no_image.html.erb b/app/views/welcome/_recommended_no_image.html.erb index 495bccc5c..e151c06c0 100644 --- a/app/views/welcome/_recommended_no_image.html.erb +++ b/app/views/welcome/_recommended_no_image.html.erb @@ -1,108 +1,108 @@ -
-

<%= t("welcome.recommended.title") %>

+