Browse Source

Profile nav

Rafał Pitoń 11 years ago
parent
commit
e20df31a90

+ 4 - 4
misago/static/misago/css/misago/navs.less

@@ -5,7 +5,7 @@
 
 /* Tabs */
 .nav-tabs {
-  border-bottom-width: 2px;
+  border-bottom-width:3px;
 
   &>li {
     &>a {
@@ -20,7 +20,7 @@
 
       &:hover {
         border: none;
-        border-bottom: 2px solid @nav-tabs-link-hover-border-color;
+        border-bottom: 3px solid @nav-tabs-link-hover-border-color;
         margin-bottom: -2px;
         padding: @nav-tabs-padding;
 
@@ -28,7 +28,7 @@
       }
 
       &:active {
-        border-bottom-color: @nav-tabs-link-active-border-color
+        border-bottom-color: @nav-tabs-link-active-border-color;
       }
     }
   }
@@ -38,7 +38,7 @@
       &:link, &:active, a:hover, &:visited {
         border: none;
         border-radius: 0px;
-        border-bottom: 2px solid @nav-tabs-active-link-hover-border-color;
+        border-bottom: 3px solid @nav-tabs-active-link-hover-border-color;
         margin-bottom: -2px;
         padding: @nav-link-padding;
 

+ 41 - 0
misago/static/misago/css/misago/profile.less

@@ -3,6 +3,46 @@
 // --------------------------------------------------
 
 
+// Profile header
+//
+//==
+.user-profile-header {
+  padding: 0px;
+  padding-top: @line-height-computed;
+  border-bottom-width: 3px;
+
+  .nav-tabs {
+    border-bottom: none;
+
+    font-size: @font-size-large;
+
+    &>li{
+      &>a {
+        .label {
+          background-color: darken(@body-bg, 5%);
+          padding-left: 5px;
+          padding-right: 5px;
+          position: relative;
+          top: -2px;
+
+          color: fadeOut(@text-color, 60%);
+          font-size: @font-size-small;
+        }
+      }
+
+      &.active {
+        &>a {
+          .label {
+            background-color: fadeOut(@text-color, 40%);
+            color: @body-bg;
+          }
+        }
+      }
+    }
+  }
+}
+
+
 // Side avatar
 //
 //==
@@ -13,6 +53,7 @@
       border-radius: @border-radius-large;
       .box-shadow(0px 0px 0px 2px darken(@body-bg, 5%));
       padding: 4px;
+      margin-top: (@line-height-computed * 3.5) * -1;
     }
   }
 }

+ 31 - 8
misago/templates/misago/profile/base.html

@@ -8,6 +8,29 @@
 
 
 {% block content %}
+<div class="page-header user-profile-header">
+  <div class="container">
+    <div class="row">
+      <div class="col-md-9 col-md-offset-3">
+
+        <ul class="nav nav-tabs">
+          {% for page in pages %}
+          <li{% if page.is_active %} class="active"{% endif %}>
+            <a href="{% url page.link user_slug=profile.slug user_id=profile.pk %}">
+              {{ page.name }}
+              {% if page.badge != None %}
+              <span class="label label-default">{{ page.badge }}</span>
+              {% endif %}
+            </a>
+          </li>
+          {% endfor %}
+        </ul>
+
+      </div>
+    </div>
+  </div>
+</div>
+
 <div class="container user-profile {% if profile.rank.css_class %}profile-{{ profile.rank.css_class }}{% endif %}">
   <div class="row">
     <div class="col-md-3 profile-side">
@@ -30,14 +53,6 @@
 
       <div class="user-details">
         <ul class="list-unstyled">
-          {% if show_email %}
-          <li class="user-email">
-            <a href="mailto:{{ profile.email }}" class="tooltip-top"title="{% trans "E-mail address" %}">
-              <span class="fa fa-envelope-o fa-fw"></span>
-              {{ profile.email }}
-            </a>
-          </li>
-          {% endif %}
           <li class="user-active">
             {% include "misago/profile/state.html" %}
           </li>
@@ -47,6 +62,14 @@
               {{ profile.joined_on|date }}
             </span>
           </li>
+          {% if show_email %}
+          <li class="user-email">
+            <a href="mailto:{{ profile.email }}" class="tooltip-top"title="{% trans "E-mail address" %}">
+              <span class="fa fa-envelope-o fa-fw"></span>
+              {{ profile.email }}
+            </a>
+          </li>
+          {% endif %}
         </ul>
       </div>
 

+ 6 - 1
misago/templates/misago/profile/posts.html

@@ -1,6 +1,11 @@
 {% extends "misago/profile/base.html" %}
+{% load i18n %}
 
 
 {% block page %}
-Hello, I am WIP posts list.
+<p class="lead">
+  {% blocktrans trimmed with user=profile.username %}
+  {{ user }} posted no messages, or you can't see them.
+  {% endblocktrans %}
+</p>
 {% endblock page %}

+ 6 - 1
misago/templates/misago/profile/threads.html

@@ -1,6 +1,11 @@
 {% extends "misago/profile/base.html" %}
+{% load i18n %}
 
 
 {% block page %}
-Hello, I am WIP threads list.
+<p class="lead">
+  {% blocktrans trimmed with user=profile.username %}
+  {{ user }} started no threads, or you can't see them.
+  {% endblocktrans %}
+</p>
 {% endblock page %}

+ 9 - 2
misago/users/apps.py

@@ -40,7 +40,14 @@ class MisagoUsersConfig(AppConfig):
                             icon='fa fa-check')
 
     def register_default_user_profile_pages(self):
+        def posts_badge(request, profile):
+            return profile.posts
+        def threads_badge(request, profile):
+            return profile.threads
+
         user_profile.add_page(link='misago:user_posts',
-                              name=_("Posts"))
+                              name=_("Posts"),
+                              badge=posts_badge)
         user_profile.add_page(link='misago:user_threads',
-                              name=_("Threads"))
+                              name=_("Threads"),
+                              badge=threads_badge)

+ 7 - 2
misago/users/sites.py

@@ -64,7 +64,7 @@ class Site(object):
             return True
 
     def add_page(self, link, name, icon=None, after=None, before=None,
-                 visibility_condition=None):
+                 visibility_condition=None, badge=None):
         if self._finalized:
             message = ("%s site was initialized already and no longer "
                        "accepts new pages")
@@ -79,6 +79,7 @@ class Site(object):
             'icon': icon,
             'after': after,
             'before': before,
+            'badge': badge,
             'visibility_condition': visibility_condition,
             })
 
@@ -102,12 +103,16 @@ class Site(object):
         else:
             test_args = (request,)
 
-        for page in self._sorted_list:
+        for _page in self._sorted_list:
+            page = _page.copy()
+
             is_visible = True
             if page['visibility_condition']:
                 is_visible = page['visibility_condition'](*test_args)
 
             if is_visible:
+                if page['badge']:
+                    page['badge'] = page['badge'](*test_args)
                 page['is_active'] = active_link.startswith(page['link'])
                 visible_pages.append(page)
         return visible_pages

+ 7 - 2
misago/users/views/profile.py

@@ -4,6 +4,7 @@ from django.shortcuts import redirect, render as django_render
 from misago.core.shortcuts import get_object_or_404, validate_slug
 
 from misago.users import online
+from misago.users.sites import user_profile
 
 
 def profile_view(f):
@@ -19,8 +20,12 @@ def profile_view(f):
     return decorator
 
 
-def render(request, template, context=None):
-    context = context or {}
+def render(request, template, context):
+    context['pages'] = user_profile.get_pages(request, context['profile'])
+    for page in context['pages']:
+        if page['is_active']:
+            context['active_page'] = page
+            break
 
     if request.user.is_authenticated():
         authenticateds_profile = context['profile'].pk == request.user.pk