Some user profile stuff.
parent
8e0cfc07e2
commit
55a973f971
|
@ -69,5 +69,21 @@ class UserProfile(models.Model):
|
||||||
else:
|
else:
|
||||||
return self.blog_domain.split(' ')[0]
|
return self.blog_domain.split(' ')[0]
|
||||||
|
|
||||||
|
def get_user_profile_url(self):
|
||||||
|
|
||||||
|
# If the user has a blog domain, use that.
|
||||||
|
if self.blog_domain:
|
||||||
|
url = 'http://{}'.format(self.get_primary_blog_domain())
|
||||||
|
|
||||||
|
# Otherwise, if they have blog posts, use their Snipt blog URL.
|
||||||
|
elif self.get_blog_posts():
|
||||||
|
url = 'https://{}.snipt.net/'.format(self.user.username)
|
||||||
|
|
||||||
|
# Otherwise, use their regular Snipt profile page.
|
||||||
|
else:
|
||||||
|
url = 'https://snipt.net/{}/'.format(self.user.username)
|
||||||
|
|
||||||
|
return url
|
||||||
|
|
||||||
|
|
||||||
User.profile = property(lambda u: UserProfile.objects.get_or_create(user=u)[0])
|
User.profile = property(lambda u: UserProfile.objects.get_or_create(user=u)[0])
|
||||||
|
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -575,17 +575,16 @@ section.main {
|
||||||
border-bottom: 1px solid #5AB6F4;
|
border-bottom: 1px solid #5AB6F4;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
div.alt-links {
|
||||||
|
margin: 0 0 30px 22px;
|
||||||
|
}
|
||||||
a.alt-link {
|
a.alt-link {
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
margin: 0 0 10px 22px;
|
|
||||||
|
|
||||||
&.active {
|
&.active {
|
||||||
color: #2B6E9B;
|
color: #2B6E9B;
|
||||||
}
|
}
|
||||||
&.favorites {
|
|
||||||
margin-bottom: 0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
nav.footer {
|
nav.footer {
|
||||||
|
@ -1460,6 +1459,18 @@ div.profile {
|
||||||
text-transform: uppercase;
|
text-transform: uppercase;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
div.urls {
|
||||||
|
border-top: 1px solid #D8D8D8;
|
||||||
|
color: #909090;
|
||||||
|
line-height: 15px;
|
||||||
|
font-size: 11px;
|
||||||
|
margin-top: 10px;
|
||||||
|
padding: 9px 0 5px 0;
|
||||||
|
|
||||||
|
a {
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
}
|
||||||
a.pro {
|
a.pro {
|
||||||
background: #DFDFDF;
|
background: #DFDFDF;
|
||||||
color: #3299B7;
|
color: #3299B7;
|
||||||
|
|
|
@ -82,19 +82,7 @@ class Snipt(models.Model):
|
||||||
user = get_object_or_None(User, username=match)
|
user = get_object_or_None(User, username=match)
|
||||||
|
|
||||||
if user:
|
if user:
|
||||||
|
url = user.profile.get_user_profile_url()
|
||||||
# If the user has a blog domain, use that.
|
|
||||||
if user.profile.get_primary_blog_domain():
|
|
||||||
url = 'http://{}'.format(user.profile.get_primary_blog_domain())
|
|
||||||
|
|
||||||
# Otherwise, if they have blog posts, use their Snipt blog URL.
|
|
||||||
elif user.profile.get_blog_posts():
|
|
||||||
url = 'https://{}.snipt.net/'.format(user.username)
|
|
||||||
|
|
||||||
# Otherwise, use their regular Snipt profile page.
|
|
||||||
else:
|
|
||||||
url = 'https://snipt.net/{}/'.format(match)
|
|
||||||
|
|
||||||
self.stylized = self.stylized.replace('@{}'.format(str(match)), '<a href="{}">@{}</a>'.format(url, match))
|
self.stylized = self.stylized.replace('@{}'.format(str(match)), '<a href="{}">@{}</a>'.format(url, match))
|
||||||
|
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -1,8 +1,12 @@
|
||||||
<section class="tags">
|
<section class="tags">
|
||||||
{% if request.user == user %}
|
<div class="alt-links">
|
||||||
<a href="/{{ user }}/favorites/" class="alt-link favorites {% if 'favorites' in request.path %}active{% endif %}"><span>View favorited snipts »</span></a>
|
{% if request.user == user %}
|
||||||
{% endif %}
|
<a href="/{{ user }}/favorites/" class="alt-link favorites {% if 'favorites' in request.path %}active{% endif %}"><span>View favorited snipts »</span></a>
|
||||||
<a href="/{{ user }}/blog-posts/" class="alt-link {% if 'blog-posts' in request.path %}active{% endif %}"><span>View blog posts »</span></a>
|
{% endif %}
|
||||||
|
{% if request.user.profile.get_blog_posts %}
|
||||||
|
<a href="/{{ user }}/blog-posts/" class="alt-link {% if 'blog-posts' in request.path %}active{% endif %}"><span>View blog posts »</span></a>
|
||||||
|
{% endif %}
|
||||||
|
</div>
|
||||||
{% if tags %}
|
{% if tags %}
|
||||||
<h1>{{ user.username }}'s tags</h1>
|
<h1>{{ user.username }}'s tags</h1>
|
||||||
<ul>
|
<ul>
|
||||||
|
|
|
@ -1,23 +1,27 @@
|
||||||
{% load snipt_tags %}
|
{% load snipt_tags %}
|
||||||
|
|
||||||
<div class="profile group">
|
<div class="profile group">
|
||||||
<img src="https://secure.gravatar.com/avatar/{{ user.email|md5 }}?s=175" alt="{{ user.username }}" title={{ user.username }}" />
|
<a href="/{{ user.username }}/">
|
||||||
|
<img src="https://secure.gravatar.com/avatar/{{ user.email|md5 }}?s=175" alt="{{ user.username }}" title="{{ user.username }}" />
|
||||||
|
</a>
|
||||||
<div class="meta">
|
<div class="meta">
|
||||||
<div class="username" title="{{ user.username }}">
|
<div class="username" title="{{ user.username }}">
|
||||||
{% if user.username == 'blog' %}
|
<a href="">
|
||||||
Blog
|
|
||||||
{% else %}
|
|
||||||
{{ user.username }}
|
{{ user.username }}
|
||||||
{% endif %}
|
</a>
|
||||||
</div>
|
</div>
|
||||||
{% if user.username == 'nick' %}
|
{% if user.username == 'nick' %}
|
||||||
<div class="member-since">Snipt Founder in {{ user.date_joined|date:"Y" }}</div>
|
<div class="member-since">Snipt Founder in {{ user.date_joined|date:"Y" }}</div>
|
||||||
{% else %}
|
{% else %}
|
||||||
{% if user.username == 'blog' %}
|
<div class="member-since">Member since {{ user.date_joined|date:"Y" }}</div>
|
||||||
<div class="member-since">Official Snipt blog</div>
|
{% endif %}
|
||||||
{% else %}
|
{% if user.profile.is_pro and user.profile.get_blog_posts %}
|
||||||
<div class="member-since">Member since {{ user.date_joined|date:"Y" }}</div>
|
<div class="urls">
|
||||||
{% endif %}
|
Snipt Blog:
|
||||||
|
<a href="{{ user.profile.get_user_profile_url }}">
|
||||||
|
{{ user.profile.get_user_profile_url }}
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
{% if user.profile.is_pro %}
|
{% if user.profile.is_pro %}
|
||||||
|
|
Loading…
Reference in New Issue