From 58e80919df7f9b2618615496c5cd94d298840751 Mon Sep 17 00:00:00 2001 From: pixeldesu Date: Sat, 20 Jun 2015 20:38:07 +0200 Subject: [PATCH] add data page --- app/assets/stylesheets/base.css.scss | 1 + app/assets/stylesheets/scss/data.scss | 10 ++ app/controllers/user_controller.rb | 5 +- app/views/user/_settings_tabs.html.haml | 2 +- app/views/user/data.html.haml | 190 ++++++++++++++++++++++++ config/routes.rb | 2 + 6 files changed, 208 insertions(+), 2 deletions(-) create mode 100644 app/assets/stylesheets/scss/data.scss create mode 100644 app/views/user/data.html.haml diff --git a/app/assets/stylesheets/base.css.scss b/app/assets/stylesheets/base.css.scss index a9a0c63e..66320f71 100644 --- a/app/assets/stylesheets/base.css.scss +++ b/app/assets/stylesheets/base.css.scss @@ -16,6 +16,7 @@ body { @import "scss/user"; @import "scss/notifications"; @import "scss/groups"; +@import "scss/data"; @import "scss/mobile"; .j2-page { diff --git a/app/assets/stylesheets/scss/data.scss b/app/assets/stylesheets/scss/data.scss new file mode 100644 index 00000000..c4aa26c0 --- /dev/null +++ b/app/assets/stylesheets/scss/data.scss @@ -0,0 +1,10 @@ +.data-heading { + margin-bottom: 0; + font-weight: bold; + font-size: 1.1em; +} + +.data-header-preview { + height: auto; + width: 100%; +} diff --git a/app/controllers/user_controller.rb b/app/controllers/user_controller.rb index 33cad9e1..5e660905 100644 --- a/app/controllers/user_controller.rb +++ b/app/controllers/user_controller.rb @@ -1,5 +1,5 @@ class UserController < ApplicationController - before_filter :authenticate_user!, only: %w(edit update edit_privacy update_privacy) + before_filter :authenticate_user!, only: %w(edit update edit_privacy update_privacy data) def show @user = User.where('LOWER(screen_name) = ?', params[:username].downcase).first! @@ -88,4 +88,7 @@ class UserController < ApplicationController @user = User.where('LOWER(screen_name) = ?', params[:username].downcase).first! @questions = @user.questions.where(author_is_anonymous: false).reverse_order.paginate(page: params[:page]) end + + def data + end end diff --git a/app/views/user/_settings_tabs.html.haml b/app/views/user/_settings_tabs.html.haml index f2f8ea41..0f30d0fa 100644 --- a/app/views/user/_settings_tabs.html.haml +++ b/app/views/user/_settings_tabs.html.haml @@ -5,6 +5,6 @@ = list_group_item t('views.settings.tabs.profile'), edit_user_profile_path = list_group_item t('views.settings.tabs.privacy'), edit_user_privacy_path = list_group_item t('views.settings.tabs.sharing'), services_path - + = list_group_item "Your Data", user_data_path .hidden-xs= render "shared/links" diff --git a/app/views/user/data.html.haml b/app/views/user/data.html.haml new file mode 100644 index 00000000..0cc8f933 --- /dev/null +++ b/app/views/user/data.html.haml @@ -0,0 +1,190 @@ +- provide(:title, generate_title("Your Data")) +.container.j2-page + = render 'settings_tabs' + .col-md-9.col-xs-12.col-sm-9 + .panel.panel-default + .panel-body + %h2 Your Profile Data + %p Everything we have about you! Really, not that much as you might expect. + + %h3 General + .row + .col-md-6.col-sm-6.col-xs-12 + %h4 Profile + + %p.data-heading User name + %p.text-muted= current_user.screen_name + + %p.data-heading Display name + %p.text-muted + - if current_user.display_name.empty? + None set! + - else + = current_user.display_name + + %p.data-heading Bio + %p.text-muted + - if current_user.bio.empty? + None set! + - else + = current_user.bio + + %p.data-heading Location + %p.text-muted + - if current_user.location.empty? + None set! + - else + = current_user.location + + %p.data-heading Website + %p.text-muted + - if current_user.website.empty? + None set! + - else + = current_user.website + .col-md-6.col-sm-6.col-xs-12 + %h4 Pictures + %p.data-heading Profile picture + .media + .pull-left + %img.profile--img{src: current_user.profile_picture.url(:medium)} + .media-body + %ul + %li + %a{href: current_user.profile_picture.url(:small)} Small + %li + %a{href: current_user.profile_picture.url(:medium)} Medium + %li + %a{href: current_user.profile_picture.url(:medium)} Large + %li + %a{href: current_user.profile_picture.url(:original)} Original image + + %p.data-heading Header picture + %img.data-header-preview{src: current_user.profile_header.url(:mobile)} + %p + %a{href: current_user.profile_picture.url(:mobile)} Mobile + | + %a{href: current_user.profile_picture.url(:web)} Web + | + %a{href: current_user.profile_picture.url(:retina)} Retina + | + %a{href: current_user.profile_picture.url(:original)} Original image + .row + .col-md-6.col-sm-6.col-xs-12 + %h4 Statistics + + %p.data-heading Answers + %p.text-muted= current_user.answered_count + + %p.data-heading Questions + %p.text-muted= current_user.asked_count + + %p.data-heading Following + %p.text-muted= current_user.friend_count + + %p.data-heading Followers + %p.text-muted= current_user.follower_count + + %p.data-heading Smiles + %p.text-muted= current_user.smiled_count + current_user.comment_smiled_count + + %p.data-heading Comments + %p.text-muted= current_user.commented_count + .col-md-6.col-sm-6.col-xs-12 + %h4 Badges + + %p.data-heading Admin + %p + - if current_user.admin? + %span.label.label-success + %i.fa.fa-fw.fa-check + - else + %span.label.label-danger + %i.fa.fa-fw.fa-close + + %p.data-heading Moderator + %p + - if current_user.mod? + %span.label.label-success + %i.fa.fa-fw.fa-check + - else + %span.label.label-danger + %i.fa.fa-fw.fa-close + + %p.data-heading Supporter + %p + - if current_user.supporter? + %span.label.label-success + %i.fa.fa-fw.fa-check + - else + %span.label.label-danger + %i.fa.fa-fw.fa-close + + %p.data-heading Contributor + %p + - if current_user.contributor? + %span.label.label-success + %i.fa.fa-fw.fa-check + - else + %span.label.label-danger + %i.fa.fa-fw.fa-close + + %p.data-heading Blogger + %p + - if current_user.blogger? + %span.label.label-success + %i.fa.fa-fw.fa-check + - else + %span.label.label-danger + %i.fa.fa-fw.fa-close + + %p.data-heading Translator + %p + - if current_user.translator? + %span.label.label-success + %i.fa.fa-fw.fa-check + - else + %span.label.label-danger + %i.fa.fa-fw.fa-close + .row + .col-md-6.col-sm-6.col-xs-12 + %h3 IP + %p.data-heading Current Sign In + %p.text-muted= current_user.current_sign_in_ip + + %p.data-heading Last Sign In + %p.text-muted= current_user.last_sign_in_ip + .col-md-6.col-sm-6.col-xs-12 + %h3 Miscellaneous + + %p.data-heading Locale + %p.text-muted + - if current_user.locale.empty? + None set! + - else + = current_user.locale + %h3 Dates + .row + .col-md-6.col-sm-6.col-xs-12 + %h4 Sign In + + %p.data-heading Current Sign In + %p.text-muted= localize(current_user.current_sign_in_at) + + %p.data-heading Last Sign In + %p.text-muted= localize(current_user.last_sign_in_at) + + %p.data-heading Remember me set at + %p.text-muted= localize(current_user.remember_created_at) + .col-md-6.col-sm-6.col-xs-12 + %h4 Create/Update + + %p.data-heading Account created + %p.text-muted + = localize(current_user.created_at) + = " (#{time_ago_in_words(current_user.created_at)} ago)" + + %p.data-heading Account last updated + %p.text-muted + = localize(current_user.updated_at) + = " (#{time_ago_in_words(current_user.updated_at)} ago)" diff --git a/config/routes.rb b/config/routes.rb index 8cb2a9ca..af4b4d6b 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -65,6 +65,8 @@ Rails.application.routes.draw do match '/settings/privacy', to: 'user#edit_privacy', via: :get, as: :edit_user_privacy match '/settings/privacy', to: 'user#update_privacy', via: :patch, as: :update_user_privacy + match '/settings/data', to: 'user#data', via: :get, as: :user_data + namespace :ajax do match '/ask', to: 'question#create', via: :post, as: :ask match '/destroy_question', to: 'question#destroy', via: :post, as: :destroy_question