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
/* Rules for the user profile page */
-#userinformation {
- min-height: 100px;
- .userinformation-inner {
- float: left;
- }
- .user-description {
- width: 100%;
- clear: both;
- }
-}
-
-.admin-user-info small {
- margin-bottom: $lineheight/2;
- display: inline;
- margin-right: $lineheight;
-}
-
.contact-activity {
margin-top: $lineheight;
width: 100%;
}
-.activity-details p {
- margin-left: 70px;
- margin-bottom: 0;
-}
-
-.users-show {
- // Silly exception; remove when user page is redesigned.
- .content-inner {
- max-width: none;
- }
- p#no_home_location {
- margin: $lineheight;
- }
- .user_thumbnail {
- margin-top: $lineheight/4;
- float: left;
- }
-}
-
/* Rules for the user map */
.content_map .leaflet-popup-content {
margin-right: $lineheight;
}
+img.user_image_no_margins {
+ max-width: 100px;
+ max-height: 100px;
+ border: 1px solid $grey;
+}
+
img.user_thumbnail {
max-width: 50px;
max-height: 50px;
margin-right: $lineheight;
}
+img.user_thumbnail_no_margins {
+ max-width: 50px;
+ max-height: 50px;
+ border: 1px solid $grey;
+}
+
img.user_thumbnail_tiny {
width: auto;
height: auto;
/* General styles for action lists / subnavs / pager navs */
-ul.secondary-actions {
- font-style: normal;
- margin-bottom: 0;
- margin-left: 0;
- padding: 0;
- &.pager {
- display: inline-block;
- margin-right: 60px;
- }
- > li {
- display: block;
- float: left;
- list-style: none;
- border-left: 1px solid $grey;
- padding-left: $lineheight/2;
- margin-right: $lineheight/2;
- &:first-child {
- border-left: 0;
- padding-left: 0;
+
+nav.secondary-actions {
+ margin-left: -11px;
+ overflow: hidden;
+ > ul {
+ display: flex;
+ flex-direction: row;
+ flex-wrap: wrap;
+ margin-bottom: 0;
+ margin-left: -1px;
+ padding: 0;
+ &.pager {
+ display: inline-block;
+ margin-right: 60px;
}
- &:last-child {
- margin-right: 0px;
+ > li {
+ flex-basis: auto;
+ list-style: none;
+ border-left: 1px solid $grey;
+ padding-left: $lineheight/2;
+ margin-right: $lineheight/2;
+ margin-bottom: $lineheight/8;
}
}
}
}
}
+/* Create a single-line dl */
+
+dl.dl-inline {
+ dt, dd {
+ display: inline-block;
+ }
+ dd {
+ margin-right: 1em;
+ }
+}
+
/* Customise the background colour of striped tables */
.table-striped > tbody > tr:nth-child(2n+1) > td,
--- /dev/null
+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
:icon => image_path(type == "friend" ? "marker-blue.png" : "marker-green.png"),
:description => render(:partial => "popup", :object => contact, :locals => { :type => type })
} %>
-<%= tag.div :class => "contact-activity clearfix", :data => { :user => user_data } do %>
- <%= user_thumbnail contact %>
- <div class='activity-details'>
- <p class='text-muted'>
+<%= tag.div :class => "contact-activity clearfix row", :data => { :user => user_data } do %>
+ <div class="col-auto">
+ <%= user_thumbnail contact, :class => "user_thumbnail_no_margins" %>
+ </div>
+ <div class="col">
+ <p class='text-muted mb-0'>
<%= link_to contact.display_name, user_path(contact) %>
<% 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 %>
</p>
- <p>
+ <p class="mb-0">
<% changeset = contact.changesets.first %>
<% if changeset %>
<%= t("users.show.latest edit", :ago => time_ago_in_words(changeset.created_at, :scope => :"datetime.distance_in_words_ago")) %>
<% end %>
</p>
- <ul class='secondary-actions clearfix text-muted'>
- <li><%= link_to t("users.show.send message"), new_message_path(contact) %></li>
- <li>
- <% if current_user.is_friends_with?(contact) %>
- <%= link_to t("users.show.remove as friend"), remove_friend_path(:display_name => contact.display_name, :referer => request.fullpath), :method => :post %>
- <% else %>
- <%= link_to t("users.show.add as friend"), make_friend_path(:display_name => contact.display_name, :referer => request.fullpath), :method => :post %>
- <% end %>
- </li>
- </ul>
+ <nav class='secondary-actions'>
+ <ul class='clearfix text-muted'>
+ <li><%= link_to t("users.show.send message"), new_message_path(contact) %></li>
+ <li>
+ <% if current_user.is_friends_with?(contact) %>
+ <%= link_to t("users.show.remove as friend"), remove_friend_path(:display_name => contact.display_name, :referer => request.fullpath), :method => :post %>
+ <% else %>
+ <%= link_to t("users.show.add as friend"), make_friend_path(:display_name => contact.display_name, :referer => request.fullpath), :method => :post %>
+ <% end %>
+ </li>
+ </ul>
+ </nav>
</div>
<% end %>
--- /dev/null
+<% content_for :heading do %>
+ <h1><%= t ".title" %></h1>
+<% end %>
+
+<div class="row">
+ <% if current_user and @user.id == current_user.id %>
+ <div class="col-md order-md-last">
+ <% if @user.home_lat.nil? or @user.home_lon.nil? %>
+ <div id="map" class="content_map">
+ <p class="m-3"><%= t(".no_home_location_html", :edit_profile_link => link_to(t(".edit_your_profile"), edit_profile_path)) %></p>
+ </div>
+ <% 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 %>
+ </div>
+
+ <div class="col-md">
+ <h3><%= t ".my friends" %></h3>
+
+ <% if friends.empty? %>
+ <%= t ".no friends" %>
+ <% else %>
+ <nav class='secondary-actions'>
+ <ul class='clearfix'>
+ <li><%= link_to t(".friends_changesets"), friend_changesets_path %></li>
+ <li><%= link_to t(".friends_diaries"), friends_diary_entries_path %></li>
+ </ul>
+ </nav>
+ <div id="friends-container">
+ <%= render :partial => "contact", :collection => friends, :locals => { :type => "friend" } %>
+ </div>
+ <% end %>
+
+ <hr>
+
+ <h3><%= t ".nearby users" %></h3>
+
+ <% if nearby.empty? %>
+ <%= t ".no nearby users" %>
+ <% else %>
+ <nav class='secondary-actions'>
+ <ul class='clearfix'>
+ <li><%= link_to t(".nearby_changesets"), nearby_changesets_path %></li>
+ <li><%= link_to t(".nearby_diaries"), nearby_diary_entries_path %></li>
+ </ul>
+ </nav>
+ <div id="nearbyusers">
+ <%= render :partial => "contact", :collection => nearby, :locals => { :type => "nearby mapper" } %>
+ </div>
+ <% end %>
+ </div>
+ <% end %>
+</div>
<%= render :partial => "location", :object => diary_entry %>
<% end %>
- <ul class='secondary-actions clearfix'>
- <% if params[:action] == 'index' %>
- <li><%= link_to t(".comment_link"), diary_entry_path(diary_entry.user, diary_entry, :anchor => "newcomment") %></li>
- <li><%= link_to t(".reply_link"), new_message_path(diary_entry.user, :message => { :title => "Re: #{diary_entry.title}" }) %></li>
- <li><%= link_to t(".comment_count", :count => diary_entry.visible_comments.count), diary_entry_path(diary_entry.user, diary_entry, :anchor => "comments") %></li>
- <% end %>
+ <nav class='secondary-actions'>
+ <ul class='clearfix'>
+ <% if params[:action] == 'index' %>
+ <li><%= link_to t(".comment_link"), diary_entry_path(diary_entry.user, diary_entry, :anchor => "newcomment") %></li>
+ <li><%= link_to t(".reply_link"), new_message_path(diary_entry.user, :message => { :title => "Re: #{diary_entry.title}" }) %></li>
+ <li><%= link_to t(".comment_count", :count => diary_entry.visible_comments.count), diary_entry_path(diary_entry.user, diary_entry, :anchor => "comments") %></li>
+ <% end %>
- <% if current_user && current_user == diary_entry.user %>
- <li><%= link_to t(".edit_link"), :action => "edit", :display_name => diary_entry.user.display_name, :id => diary_entry.id %></li>
- <% end %>
+ <% if current_user && current_user == diary_entry.user %>
+ <li><%= link_to t(".edit_link"), :action => "edit", :display_name => diary_entry.user.display_name, :id => diary_entry.id %></li>
+ <% end %>
- <% if current_user and diary_entry.user != current_user %>
- <li>
- <%= report_link(t(".report"), diary_entry) %>
- </li>
- <% end %>
+ <% if current_user and diary_entry.user != current_user %>
+ <li>
+ <%= report_link(t(".report"), diary_entry) %>
+ </li>
+ <% end %>
- <% if can? :hide, DiaryEntry %>
- <li>
- <% if diary_entry.visible %>
- <%= link_to t(".hide_link"), hide_diary_entry_path(:display_name => diary_entry.user.display_name, :id => diary_entry.id), :method => :post, :data => { :confirm => t(".confirm") } %>
- <% else %>
- <%= link_to t(".unhide_link"), unhide_diary_entry_path(:display_name => diary_entry.user.display_name, :id => diary_entry.id), :method => :post, :data => { :confirm => t(".confirm") } %>
- <% end %>
- </li>
- <% end %>
- </ul>
+ <% if can? :hide, DiaryEntry %>
+ <li>
+ <% if diary_entry.visible %>
+ <%= link_to t(".hide_link"), hide_diary_entry_path(:display_name => diary_entry.user.display_name, :id => diary_entry.id), :method => :post, :data => { :confirm => t(".confirm") } %>
+ <% else %>
+ <%= link_to t(".unhide_link"), unhide_diary_entry_path(:display_name => diary_entry.user.display_name, :id => diary_entry.id), :method => :post, :data => { :confirm => t(".confirm") } %>
+ <% end %>
+ </li>
+ <% end %>
+ </ul>
+ </nav>
</div>
<% end %>
<h1><%= @title %></h1>
- <ul class="secondary-actions clearfix">
- <% unless params[:friends] or params[:nearby] -%>
- <li><%= rss_link_to :action => "rss", :language => params[:language] %></li>
- <% end -%>
-
- <% if @user && @user == current_user || !@user && current_user %>
- <li><%= link_to image_tag("new.png", :class => "small_icon") + t(".new"), new_diary_entry_path, :title => t(".new_title") %></li>
- <% end %>
-
- <% if !@user && current_user %>
- <li><%= link_to t(".my_diary"), :controller => "diary_entries", :action => "index", :display_name => current_user.display_name %></li>
- <% end %>
- </ul>
+ <nav class="secondary-actions">
+ <ul class="clearfix">
+ <% unless params[:friends] or params[:nearby] -%>
+ <li><%= rss_link_to :action => "rss", :language => params[:language] %></li>
+ <% end -%>
+
+ <% if @user && @user == current_user || !@user && current_user %>
+ <li><%= link_to image_tag("new.png", :class => "small_icon") + t(".new"), new_diary_entry_path, :title => t(".new_title") %></li>
+ <% end %>
+
+ <% if !@user && current_user %>
+ <li><%= link_to t(".my_diary"), :controller => "diary_entries", :action => "index", :display_name => current_user.display_name %></li>
+ <% end %>
+ </ul>
+ </nav>
</div>
<% end %>
</span>
</a>
<div class='dropdown-menu dropdown-menu-right'>
+ <%= link_to t("users.show.my_dashboard"), dashboard_path, :class => "dropdown-item" %>
<%= link_to inbox_messages_path, :class => "dropdown-item" do %>
<%= t("users.show.my messages") %>
<span class='count-number'><%= number_with_delimiter(current_user.new_messages.size) %></span>
</td>
<td>
<% if trace.inserted? %>
- <ul class="secondary-actions">
- <li>
- <%= link_to t(".view_map"), { :controller => "site", :action => "index", :mlat => trace.latitude, :mlon => trace.longitude, :anchor => "map=14/#{trace.latitude}/#{trace.longitude}" } %>
- </li>
- <li>
- <%= link_to t(".edit_map"), { :controller => "site", :action => "edit", :gpx => trace.id } %>
- </li>
- </ul>
+ <nav class="secondary-actions">
+ <ul>
+ <li>
+ <%= link_to t(".view_map"), { :controller => "site", :action => "index", :mlat => trace.latitude, :mlon => trace.longitude, :anchor => "map=14/#{trace.latitude}/#{trace.longitude}" } %>
+ </li>
+ <li>
+ <%= link_to t(".edit_map"), { :controller => "site", :action => "edit", :gpx => trace.id } %>
+ </li>
+ </ul>
+ </nav>
<% end %>
</td>
</tr>
<%= render :partial => "block", :locals => { :show_revoke_link => show_revoke_link, :show_user_name => show_user_name, :show_creator_name => show_creator_name }, :collection => @user_blocks %>
</table>
-<ul class='secondary-actions'>
- <% if @user_blocks_pages.current_page.number > 1 -%>
- <li><%= link_to t(".previous"), @params.merge(:page => @user_blocks_pages.current_page.number - 1) %></li>
- <% else -%>
- <li><%= t(".previous") %></li>
- <% end -%>
+<nav class='secondary-actions'>
+ <ul>
+ <% if @user_blocks_pages.current_page.number > 1 -%>
+ <li><%= link_to t(".previous"), @params.merge(:page => @user_blocks_pages.current_page.number - 1) %></li>
+ <% else -%>
+ <li><%= t(".previous") %></li>
+ <% end -%>
- <li><%= t(".showing_page", :page => @user_blocks_pages.current_page.number) %></li>
+ <li><%= t(".showing_page", :page => @user_blocks_pages.current_page.number) %></li>
- <% if @user_blocks_pages.current_page.number < @user_blocks_pages.page_count -%>
- <li><%= link_to t(".next"), @params.merge(:page => @user_blocks_pages.current_page.number + 1) %></li>
- <% else -%>
- <li><%= t(".next") %></li>
- <% end -%>
-</ul>
+ <% if @user_blocks_pages.current_page.number < @user_blocks_pages.page_count -%>
+ <li><%= link_to t(".next"), @params.merge(:page => @user_blocks_pages.current_page.number + 1) %></li>
+ <% else -%>
+ <li><%= t(".next") %></li>
+ <% end -%>
+ </ul>
+</nav>
<h1><%= t(".heading_html",
:name => link_to(@user_block.user.display_name,
user_path(@user_block.user))) %></h1>
- <ul class='secondary-actions clearfix'>
- <li><%= link_to t(".show"), @user_block %></li>
- <li><%= link_to t(".back"), user_blocks_path %></li>
- </ul>
+ <nav class='secondary-actions'>
+ <ul class='clearfix'>
+ <li><%= link_to t(".show"), @user_block %></li>
+ <li><%= link_to t(".back"), user_blocks_path %></li>
+ </ul>
+ </nav>
<% end %>
<%= bootstrap_form_for(@user_block) do |f| %>
user_path(@user_block.user)),
:block_by => link_to(@user_block.creator.display_name,
user_path(@user_block.creator))) %></h1>
-<ul class='secondary-actions clearfix'>
- <% if @user_block.ends_at > Time.now.getutc %>
- <% if current_user and current_user.id == @user_block.creator_id %>
- <li><%= link_to t(".edit"), edit_user_block_path(@user_block) %></li>
- <% end %>
- <% if can?(:revoke, UserBlock) %>
- <li><%= link_to t(".revoke"), revoke_user_block_path(@user_block) %></li>
- <% end %>
- <% end %>
- <li><%= link_to t(".back"), user_blocks_path %></li>
-</ul>
+ <nav class='secondary-actions'>
+ <ul class='clearfix'>
+ <% if @user_block.ends_at > Time.now.getutc %>
+ <% if current_user and current_user.id == @user_block.creator_id %>
+ <li><%= link_to t(".edit"), edit_user_block_path(@user_block) %></li>
+ <% end %>
+ <% if can?(:revoke, UserBlock) %>
+ <li><%= link_to t(".revoke"), revoke_user_block_path(@user_block) %></li>
+ <% end %>
+ <% end %>
+ <li><%= link_to t(".back"), user_blocks_path %></li>
+ </ul>
+ </nav>
<% end %>
<dl class="row">
<% content_for :heading do %>
- <div id='userinformation'>
- <%= user_image @user %>
- <div class='userinformation-inner'>
+ <div id="userinformation" class="row">
+ <div class="col-sm-auto">
+ <%= user_image @user, :class => "user_image_no_margins" %>
+ </div>
+ <div class="col">
<h1><%= @user.display_name %> <%= role_icons(@user) %></h1>
<% if current_user and @user.id == current_user.id %>
<!-- Displaying user's own profile page -->
- <ul class='secondary-actions clearfix'>
- <li>
- <%= link_to t(".my edits"), :controller => "changesets", :action => "index", :display_name => current_user.display_name %>
- <span class='count-number'><%= number_with_delimiter(current_user.changesets.size) %></span>
- </li>
- <li>
- <%= link_to t(".my notes"), user_notes_path(@user) %>
- </li>
- <li>
- <%= link_to t(".my traces"), :controller => "traces", :action => "mine" %>
- <span class='count-number'><%= number_with_delimiter(current_user.traces.size) %></span>
- </li>
- <li>
- <%= link_to t(".my diary"), :controller => "diary_entries", :action => "index", :display_name => current_user.display_name %>
- <span class='count-number'><%= number_with_delimiter(current_user.diary_entries.size) %></span>
- </li>
- <li>
- <%= link_to t(".my comments"), diary_comments_path(current_user) %>
- </li>
- <li>
- <%= link_to t(".my settings"), user_account_path(current_user) %>
- </li>
-
- <% if current_user.blocks.exists? %>
+ <nav class='secondary-actions'>
+ <ul class='clearfix'>
<li>
- <%= link_to t(".blocks on me"), user_blocks_on_path(current_user) %>
- <span class='count-number'><%= number_with_delimiter(current_user.blocks.active.size) %></span>
+ <%= link_to t(".my edits"), :controller => "changesets", :action => "index", :display_name => current_user.display_name %>
+ <span class='count-number'><%= number_with_delimiter(current_user.changesets.size) %></span>
+ </li>
+ <li>
+ <%= link_to t(".my notes"), user_notes_path(@user) %>
+ </li>
+ <li>
+ <%= link_to t(".my traces"), :controller => "traces", :action => "mine" %>
+ <span class='count-number'><%= number_with_delimiter(current_user.traces.size) %></span>
+ </li>
+ <li>
+ <%= link_to t(".my diary"), :controller => "diary_entries", :action => "index", :display_name => current_user.display_name %>
+ <span class='count-number'><%= number_with_delimiter(current_user.diary_entries.size) %></span>
+ </li>
+ <li>
+ <%= link_to t(".my comments"), diary_comments_path(current_user) %>
</li>
- <% end %>
-
- <% if can?(:create, UserBlock) and current_user.blocks_created.exists? %>
<li>
- <%= link_to t(".blocks by me"), user_blocks_by_path(current_user) %>
- <span class='count-number'><%= number_with_delimiter(current_user.blocks_created.active.size) %></span>
+ <%= link_to t(".my settings"), user_account_path(current_user) %>
</li>
- <% end %>
- </ul>
+ <% if current_user.blocks.exists? %>
+ <li>
+ <%= link_to t(".blocks on me"), user_blocks_on_path(current_user) %>
+ <span class='count-number'><%= number_with_delimiter(current_user.blocks.active.size) %></span>
+ </li>
+ <% end %>
+
+ <% if can?(:create, UserBlock) and current_user.blocks_created.exists? %>
+ <li>
+ <%= link_to t(".blocks by me"), user_blocks_by_path(current_user) %>
+ <span class='count-number'><%= number_with_delimiter(current_user.blocks_created.active.size) %></span>
+ </li>
+ <% end %>
+
+ </ul>
+ </nav>
<% else %>
<!-- Displaying user profile page to the public -->
- <ul class='secondary-actions clearfix'>
-
- <li>
- <%= link_to t(".edits"), :controller => "changesets", :action => "index", :display_name => @user.display_name %>
- <span class='count-number'><%= number_with_delimiter(@user.changesets.size) %></span>
- </li>
- <li>
- <%= link_to t(".notes"), user_notes_path(@user) %>
- </li>
- <li>
- <%= link_to t(".traces"), :controller => "traces", :action => "index", :display_name => @user.display_name %>
- <span class='count-number'><%= number_with_delimiter(@user.traces.size) %></span>
- </li>
-
- <!-- Displaying another user's profile page -->
-
- <li>
- <%= link_to t(".send message"), new_message_path(@user) %>
- </li>
- <li>
- <%= link_to t(".diary"), :controller => "diary_entries", :action => "index", :display_name => @user.display_name %>
- <span class='count-number'><%= number_with_delimiter(@user.diary_entries.size) %></span>
- </li>
- <li>
- <%= link_to t(".comments"), diary_comments_path(@user) %>
- </li>
- <li>
- <% if current_user and current_user.is_friends_with?(@user) %>
- <%= link_to t(".remove as friend"), remove_friend_path(:display_name => @user.display_name), :method => :post %>
- <% elsif current_user %>
- <%= link_to t(".add as friend"), make_friend_path(:display_name => @user.display_name), :method => :post %>
- <% else %>
- <%= link_to t(".add as friend"), make_friend_path(:display_name => @user.display_name) %>
- <% end %>
- </li>
+ <nav class='secondary-actions'>
+ <ul class='clearfix'>
- <% if @user.blocks.exists? %>
<li>
- <%= link_to t(".block_history"), user_blocks_on_path(@user) %>
- <span class='count-number'><%= number_with_delimiter(@user.blocks.active.size) %></span>
+ <%= link_to t(".edits"), :controller => "changesets", :action => "index", :display_name => @user.display_name %>
+ <span class='count-number'><%= number_with_delimiter(@user.changesets.size) %></span>
</li>
- <% end %>
-
- <% if @user.moderator? and @user.blocks_created.exists? %>
<li>
- <%= link_to t(".moderator_history"), user_blocks_by_path(@user) %>
- <span class='count-number'><%= number_with_delimiter(@user.blocks_created.active.size) %></span>
+ <%= link_to t(".notes"), user_notes_path(@user) %>
</li>
- <% end %>
-
- <% if can?(:create, UserBlock) %>
<li>
- <%= link_to t(".create_block"), new_user_block_path(@user) %>
+ <%= link_to t(".traces"), :controller => "traces", :action => "index", :display_name => @user.display_name %>
+ <span class='count-number'><%= number_with_delimiter(@user.traces.size) %></span>
</li>
- <% end %>
- <% if current_user and @user.id != current_user.id %>
+ <!-- Displaying another user's profile page -->
+
<li>
- <%= report_link(t(".report"), @user) %>
+ <%= link_to t(".send message"), new_message_path(@user) %>
+ </li>
+ <li>
+ <%= link_to t(".diary"), :controller => "diary_entries", :action => "index", :display_name => @user.display_name %>
+ <span class='count-number'><%= number_with_delimiter(@user.diary_entries.size) %></span>
+ </li>
+ <li>
+ <%= link_to t(".comments"), diary_comments_path(@user) %>
+ </li>
+ <li>
+ <% if current_user and current_user.is_friends_with?(@user) %>
+ <%= link_to t(".remove as friend"), remove_friend_path(:display_name => @user.display_name), :method => :post %>
+ <% elsif current_user %>
+ <%= link_to t(".add as friend"), make_friend_path(:display_name => @user.display_name), :method => :post %>
+ <% else %>
+ <%= link_to t(".add as friend"), make_friend_path(:display_name => @user.display_name) %>
+ <% end %>
</li>
- <% end %>
- </ul>
-
- <% end %>
-
- <% if can?(:set_status, User) || can?(:destroy, User) %>
- <ul class='secondary-actions clearfix'>
- <% if can? :set_status, User %>
- <% if ["active", "confirmed"].include? @user.status %>
+ <% if @user.blocks.exists? %>
<li>
- <%= link_to t(".deactivate_user"), set_status_user_path(:status => "pending", :display_name => @user.display_name), :method => :post, :data => { :confirm => t(".confirm") } %>
+ <%= link_to t(".block_history"), user_blocks_on_path(@user) %>
+ <span class='count-number'><%= number_with_delimiter(@user.blocks.active.size) %></span>
</li>
- <% elsif ["pending"].include? @user.status %>
+ <% end %>
+
+ <% if @user.moderator? and @user.blocks_created.exists? %>
<li>
- <%= link_to t(".activate_user"), set_status_user_path(:status => "active", :display_name => @user.display_name), :method => :post, :data => { :confirm => t(".confirm") } %>
+ <%= link_to t(".moderator_history"), user_blocks_by_path(@user) %>
+ <span class='count-number'><%= number_with_delimiter(@user.blocks_created.active.size) %></span>
</li>
<% end %>
- <% if ["active", "suspended"].include? @user.status %>
+ <% if can?(:create, UserBlock) %>
<li>
- <%= link_to t(".confirm_user"), set_status_user_path(:status => "confirmed", :display_name => @user.display_name), :method => :post, :data => { :confirm => t(".confirm") } %>
+ <%= link_to t(".create_block"), new_user_block_path(@user) %>
</li>
<% end %>
+
+ <% if current_user and @user.id != current_user.id %>
<li>
- <% if ["pending", "active", "confirmed", "suspended"].include? @user.status %>
- <%= link_to t(".hide_user"), set_status_user_path(:status => "deleted", :display_name => @user.display_name), :method => :post, :data => { :confirm => t(".confirm") } %>
- <% else %>
- <%= link_to t(".unhide_user"), set_status_user_path(:status => "active", :display_name => @user.display_name), :method => :post, :data => { :confirm => t(".confirm") } %>
+ <%= report_link(t(".report"), @user) %>
</li>
<% end %>
- <% end %>
- <% if can? :destroy, User %>
- <li>
- <%= link_to t(".delete_user"), user_path(:display_name => @user.display_name), :method => :delete, :data => { :confirm => t(".confirm") } %>
- </li>
- <% end %>
- </ul>
-
- <% end %>
+ </ul>
+ </nav>
+ <% end %>
- <p class='text-muted'>
+ <div class='text-muted'>
<small>
- <%= t ".mapper since" %> <%= l @user.creation_time.to_date, :format => :long %>
- <% unless @user.terms_agreed %>
- |
- <%= t ".ct status" %>
- <% if @user.terms_seen? -%>
- <%= t ".ct declined" %>
- <% else -%>
- <%= t ".ct undecided" %>
+ <dl class="dl-inline">
+ <dt><%= t ".mapper since" %></dt>
+ <dd><%= l @user.creation_time.to_date, :format => :long %></dd>
+ <% unless @user.terms_agreed %>
+ <dt><%= t ".ct status" %></dt>
+ <dd>
+ <% if @user.terms_seen? -%>
+ <%= t ".ct declined" %>
+ <% else -%>
+ <%= t ".ct undecided" %>
+ <% end -%>
+ </dd>
<% end -%>
- <% end -%>
+ </dl>
</small>
- </p>
- </div>
-
- <div class="user-description richtext text-break"><%= @user.description.to_html %></div>
-
- <% if current_user and @user.id == current_user.id %>
- <div class="my-3">
- <%= link_to t(".edit_profile"), edit_profile_path, :class => "btn btn-outline-primary" %>
</div>
- <% end %>
- </div>
+ <% if can?(:set_status, User) || can?(:destroy, User) %>
+ <nav class='secondary-actions'>
+ <ul class='clearfix'>
+ <% if can? :set_status, User %>
+ <% if ["active", "confirmed"].include? @user.status %>
+ <li>
+ <%= link_to t(".deactivate_user"), set_status_user_path(:status => "pending", :display_name => @user.display_name), :method => :post, :data => { :confirm => t(".confirm") } %>
+ </li>
+ <% elsif ["pending"].include? @user.status %>
+ <li>
+ <%= link_to t(".activate_user"), set_status_user_path(:status => "active", :display_name => @user.display_name), :method => :post, :data => { :confirm => t(".confirm") } %>
+ </li>
+ <% end %>
+
+ <% if ["active", "suspended"].include? @user.status %>
+ <li>
+ <%= link_to t(".confirm_user"), set_status_user_path(:status => "confirmed", :display_name => @user.display_name), :method => :post, :data => { :confirm => t(".confirm") } %>
+ </li>
+ <% end %>
+ <li>
+ <% if ["pending", "active", "confirmed", "suspended"].include? @user.status %>
+ <%= link_to t(".hide_user"), set_status_user_path(:status => "deleted", :display_name => @user.display_name), :method => :post, :data => { :confirm => t(".confirm") } %>
+ <% else %>
+ <%= link_to t(".unhide_user"), set_status_user_path(:status => "active", :display_name => @user.display_name), :method => :post, :data => { :confirm => t(".confirm") } %>
+ <% end %>
+ </li>
+ <% end %>
+ <% if can? :destroy, User %>
+ <li>
+ <%= link_to t(".delete_user"), user_path(:display_name => @user.display_name), :method => :delete, :data => { :confirm => t(".confirm") } %>
+ </li>
+ <% end %>
+ </ul>
+ </nav>
+ <% end %>
- <% if current_user and current_user.administrator? -%>
- <div class='admin-user-info text-muted'>
- <small><b><%= t ".email address" %></b> <%= @user.email %></small>
- <% unless @user.creation_ip.nil? -%>
- <small><b><%= t ".created from" %></b> <%= @user.creation_ip %></small>
+ <% if current_user and current_user.administrator? -%>
+ <div class='text-muted'>
+ <small>
+ <dl class='dl-inline'>
+ <dt><%= t ".email address" %></dt>
+ <dd><%= @user.email %></dd>
+ <% unless @user.creation_ip.nil? -%>
+ <dt><%= t ".created from" %></dt>
+ <dd><%= @user.creation_ip %></dd>
+ <% end -%>
+ <dt><%= t ".status" %></dt>
+ <dd><%= @user.status.capitalize %></dd>
+ <dt><%= t ".spam score" %></dt>
+ <dd><%= @user.spam_score %></dd>
+ </dl>
+ </small>
+ </div>
<% end -%>
- <small><b><%= t ".status" %></b> <%= @user.status.capitalize %></small>
- <small><b><%= t ".spam score" %></b> <%= @user.spam_score %></small>
</div>
- <% end -%>
-
+ </div>
<% end %>
-<div class="row">
- <% if current_user and @user.id == current_user.id %>
- <div class="col-md order-md-last">
- <% if @user.home_lat.nil? or @user.home_lon.nil? %>
- <div id="map" class="content_map">
- <p id="no_home_location"><%= t(".no_home_location_html", :edit_profile_link => link_to(t(".edit_your_profile"), edit_profile_path)) %></p>
- </div>
- <% 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 %>
- </div>
-
- <div class="col-md">
- <h3><%= t ".my friends" %></h3>
-
- <% if friends.empty? %>
- <%= t ".no friends" %>
- <% else %>
- <ul class='secondary-actions clearfix'>
- <li><%= link_to t(".friends_changesets"), friend_changesets_path %></li>
- <li><%= link_to t(".friends_diaries"), friends_diary_entries_path %></li>
- </ul>
- <div id="friends-container">
- <%= render :partial => "contact", :collection => friends, :locals => { :type => "friend" } %>
- </div>
- <% end %>
-
- <hr>
+<div class="richtext text-break clearfix"><%= @user.description.to_html %></div>
- <h3><%= t ".nearby users" %></h3>
-
- <% if nearby.empty? %>
- <%= t ".no nearby users" %>
- <% else %>
- <ul class='secondary-actions clearfix'>
- <li><%= link_to t(".nearby_changesets"), nearby_changesets_path %></li>
- <li><%= link_to t(".nearby_diaries"), nearby_diary_entries_path %></li>
- </ul>
- <div id="nearbyusers">
- <%= render :partial => "contact", :collection => nearby, :locals => { :type => "nearby mapper" } %>
- </div>
- <% end %>
- </div>
- <% end %>
-</div>
+<% if current_user and @user.id == current_user.id %>
+ <div class="my-3">
+ <%= link_to t(".edit_profile"), edit_profile_path, :class => "btn btn-outline-primary" %>
+ </div>
+<% end %>
title_particular: "OpenStreetMap changeset #%{changeset_id} discussion"
timeout:
sorry: "Sorry, the list of changeset comments you requested took too long to retrieve."
+ dashboards:
+ contact:
+ km away: "%{count}km away"
+ m away: "%{count}m away"
+ popup:
+ your location: "Your location"
+ nearby mapper: "Nearby mapper"
+ friend: "Friend"
+ show:
+ title: My Dashboard
+ no_home_location_html: "%{edit_profile_link} and set your home location to see nearby users."
+ edit_your_profile: Edit your profile
+ my friends: My friends
+ no friends: You have not added any friends yet.
+ nearby users: "Other nearby users"
+ no nearby users: "There are no other users who admit to mapping nearby yet."
+ friends_changesets: "friends' changesets"
+ friends_diaries: "friends' diary entries"
+ nearby_changesets: "nearby user changesets"
+ nearby_diaries: "nearby user diary entries"
diary_entries:
new:
title: New Diary Entry
my settings: My Settings
my comments: My Comments
my_preferences: My Preferences
+ my_dashboard: My Dashboard
blocks on me: Blocks on Me
blocks by me: Blocks by Me
edit_profile: Edit Profile
spam score: "Spam Score:"
description: Description
user location: User location
- no_home_location_html: "%{edit_profile_link} and set your home location to see nearby users."
- edit_your_profile: Edit your profile
- my friends: My friends
- no friends: You have not added any friends yet.
- km away: "%{count}km away"
- m away: "%{count}m away"
- nearby users: "Other nearby users"
- no nearby users: "There are no other users who admit to mapping nearby yet."
role:
administrator: "This user is an administrator"
moderator: "This user is a moderator"
unhide_user: "Unhide this User"
delete_user: "Delete this User"
confirm: "Confirm"
- friends_changesets: "friends' changesets"
- friends_diaries: "friends' diary entries"
- nearby_changesets: "nearby user changesets"
- nearby_diaries: "nearby user diary entries"
report: Report this User
- popup:
- your location: "Your location"
- nearby mapper: "Nearby mapper"
- friend: "Friend"
account:
title: "Edit account"
my settings: My Settings
match "/user/:display_name/account" => "users#account", :via => [:get, :post], :as => "user_account"
post "/user/:display_name/set_status" => "users#set_status", :as => :set_status_user
+ resource :dashboard, :only => [:show]
resource :preferences, :only => [:show, :edit, :update]
resource :profile, :only => [:edit, :update]
--- /dev/null
+require "test_helper"
+
+class DashboardsControllerTest < ActionDispatch::IntegrationTest
+ ##
+ # test all routes which lead to this controller
+ def test_routes
+ assert_routing(
+ { :path => "/dashboard", :method => :get },
+ { :controller => "dashboards", :action => "show" }
+ )
+ end
+
+ def test_show_no_friends
+ user = create(:user)
+ session_for(user)
+
+ get dashboard_path
+ end
+
+ def test_show_with_friends
+ user = create(:user, :home_lon => 1.1, :home_lat => 1.1)
+ friend_user = create(:user, :home_lon => 1.2, :home_lat => 1.2)
+ create(:friendship, :befriender => user, :befriendee => friend_user)
+ create(:changeset, :user => friend_user)
+ session_for(user)
+
+ get dashboard_path
+
+ # Friends should be visible as we're now logged in
+ assert_select "div#friends-container" do
+ assert_select "div.contact-activity", :count => 1
+ end
+ end
+end
assert_response :not_found
# Test a normal user
- user = create(:user, :home_lon => 1.1, :home_lat => 1.1)
- friend_user = create(:user, :home_lon => 1.2, :home_lat => 1.2)
- create(:friendship, :befriender => user, :befriendee => friend_user)
- create(:changeset, :user => friend_user)
+ user = create(:user)
get user_path(user)
assert_response :success
assert_select "a[href='/blocks/new/#{ERB::Util.u(user.display_name)}']", 0
end
- # Friends should be visible as we're now logged in
- assert_select "div#friends-container" do
- assert_select "div.contact-activity", :count => 1
- end
-
# Login as a moderator
session_for(create(:moderator_user))
get user_path(agreed_user)
assert_response :success
assert_select "div#userinformation" do
- assert_select "p", :count => 0, :text => /Contributor terms/
+ assert_select "dt", :count => 0, :text => /Contributor terms/
end
get user_path(seen_user)
assert_response :success
# put @response.body
assert_select "div#userinformation" do
- assert_select "p", :count => 1, :text => /Contributor terms/
- assert_select "p", /Declined/
+ assert_select "dt", :count => 1, :text => /Contributor terms/
+ assert_select "dd", /Declined/
end
get user_path(not_seen_user)
assert_response :success
assert_select "div#userinformation" do
- assert_select "p", :count => 1, :text => /Contributor terms/
- assert_select "p", /Undecided/
+ assert_select "dt", :count => 1, :text => /Contributor terms/
+ assert_select "dd", /Undecided/
end
end