From cb7b79a58f0337ab28b41ed5105215de302d3f73 Mon Sep 17 00:00:00 2001 From: Andy Allan Date: Wed, 28 Jul 2021 17:54:57 +0100 Subject: [PATCH] Split the non-public information off of the profile page This opens up many possibilities for more interesting things to be shown on the dashboard, as well as making it easier to find if you have lots of content in your profile. --- app/abilities/ability.rb | 1 + app/assets/stylesheets/common.scss | 6 +- app/controllers/dashboards_controller.rb | 14 +++++ .../{users => dashboards}/_contact.html.erb | 4 +- .../{users => dashboards}/_popup.html.erb | 0 app/views/dashboards/show.html.erb | 61 +++++++++++++++++++ app/views/layouts/_header.html.erb | 1 + app/views/users/show.html.erb | 58 ------------------ config/locales/en.yml | 37 ++++++----- config/routes.rb | 1 + .../controllers/dashboards_controller_test.rb | 34 +++++++++++ test/controllers/users_controller_test.rb | 10 +-- 12 files changed, 137 insertions(+), 90 deletions(-) create mode 100644 app/controllers/dashboards_controller.rb rename app/views/{users => dashboards}/_contact.html.erb (93%) rename app/views/{users => dashboards}/_popup.html.erb (100%) create mode 100644 app/views/dashboards/show.html.erb create mode 100644 test/controllers/dashboards_controller_test.rb diff --git a/app/abilities/ability.rb b/app/abilities/ability.rb index 018ce0096..769fbca47 100644 --- a/app/abilities/ability.rb +++ b/app/abilities/ability.rb @@ -42,6 +42,7 @@ class Ability can [:index, :new, :create, :show, :edit, :update, :destroy], :oauth2_application can [:index, :destroy], :oauth2_authorized_application can [:new, :show, :create, :destroy], :oauth2_authorization + can [:show], :dashboard can [:new, :create, :edit, :update, :comment, :subscribe, :unsubscribe], DiaryEntry can [:make_friend, :remove_friend], Friendship can [:new, :create, :reply, :show, :inbox, :outbox, :mark, :destroy], Message diff --git a/app/assets/stylesheets/common.scss b/app/assets/stylesheets/common.scss index 0023286bf..42090e733 100644 --- a/app/assets/stylesheets/common.scss +++ b/app/assets/stylesheets/common.scss @@ -1123,11 +1123,7 @@ tr.turn:hover { margin-bottom: 0; } -.users-show { - // Silly exception; remove when user page is redesigned. - .content-inner { - max-width: none; - } +.dashboards-show { p#no_home_location { margin: $lineheight; } diff --git a/app/controllers/dashboards_controller.rb b/app/controllers/dashboards_controller.rb new file mode 100644 index 000000000..540683d25 --- /dev/null +++ b/app/controllers/dashboards_controller.rb @@ -0,0 +1,14 @@ +class DashboardsController < ApplicationController + layout "site" + + before_action :authorize_web + before_action :set_locale + + authorize_resource :class => false + + before_action :check_database_readable + + def show + @user = current_user + end +end diff --git a/app/views/users/_contact.html.erb b/app/views/dashboards/_contact.html.erb similarity index 93% rename from app/views/users/_contact.html.erb rename to app/views/dashboards/_contact.html.erb index c7e10c060..3b46a3b45 100644 --- a/app/views/users/_contact.html.erb +++ b/app/views/dashboards/_contact.html.erb @@ -12,9 +12,9 @@ <% if @user.home_lon and @user.home_lat and contact.home_lon and contact.home_lat %> <% distance = @user.distance(contact) %> <% if distance < 1 %> - (<%= t "users.show.m away", :count => (distance * 1000).round %>) + (<%= t ".m away", :count => (distance * 1000).round %>) <% else %> - (<%= t "users.show.km away", :count => distance.round %>) + (<%= t ".km away", :count => distance.round %>) <% end %> <% end %>

diff --git a/app/views/users/_popup.html.erb b/app/views/dashboards/_popup.html.erb similarity index 100% rename from app/views/users/_popup.html.erb rename to app/views/dashboards/_popup.html.erb diff --git a/app/views/dashboards/show.html.erb b/app/views/dashboards/show.html.erb new file mode 100644 index 000000000..3fe27b779 --- /dev/null +++ b/app/views/dashboards/show.html.erb @@ -0,0 +1,61 @@ +<% content_for :heading do %> +

<%= t ".title" %>

+<% end %> + +
+ <% if current_user and @user.id == current_user.id %> +
+ <% if @user.home_lat.nil? or @user.home_lon.nil? %> +
+

<%= t(".no_home_location_html", :edit_profile_link => link_to(t(".edit_your_profile"), edit_profile_path)) %>

+
+ <% else %> + <% content_for :head do %> + <%= javascript_include_tag "user" %> + <% end %> + <% user_data = { + :lon => current_user.home_lon, + :lat => current_user.home_lat, + :icon => image_path("marker-red.png"), + :description => render(:partial => "popup", :object => current_user, :locals => { :type => "your location" }) + } %> + <%= tag.div "", :id => "map", :class => "content_map", :data => { :user => user_data } %> + <% end %> + + <% friends = @user.friends %> + <% nearby = @user.nearby - friends %> +
+ +
+

<%= t ".my friends" %>

+ + <% if friends.empty? %> + <%= t ".no friends" %> + <% else %> +
    +
  • <%= link_to t(".friends_changesets"), friend_changesets_path %>
  • +
  • <%= link_to t(".friends_diaries"), friends_diary_entries_path %>
  • +
+
+ <%= render :partial => "contact", :collection => friends, :locals => { :type => "friend" } %> +
+ <% end %> + +
+ +

<%= t ".nearby users" %>

+ + <% if nearby.empty? %> + <%= t ".no nearby users" %> + <% else %> +
    +
  • <%= link_to t(".nearby_changesets"), nearby_changesets_path %>
  • +
  • <%= link_to t(".nearby_diaries"), nearby_diary_entries_path %>
  • +
+
+ <%= render :partial => "contact", :collection => nearby, :locals => { :type => "nearby mapper" } %> +
+ <% end %> +
+ <% end %> +
diff --git a/app/views/layouts/_header.html.erb b/app/views/layouts/_header.html.erb index a20474b57..192b07614 100644 --- a/app/views/layouts/_header.html.erb +++ b/app/views/layouts/_header.html.erb @@ -90,6 +90,7 @@