summaryrefslogtreecommitdiffstats
path: root/askbot/skins/default
diff options
context:
space:
mode:
authorEvgeny Fadeev <evgeny.fadeev@gmail.com>2011-05-24 02:31:27 -0400
committerEvgeny Fadeev <evgeny.fadeev@gmail.com>2011-05-24 02:31:27 -0400
commit899cd7376580b9238bdb12ddc1f097bcb9912730 (patch)
tree3ba4b1a3df67756e3e5fcfe0f7666fc083869b78 /askbot/skins/default
parentc7cc2ddce4e0daec3bf6966cc7e4f6b7e794e148 (diff)
parent1243d42844613a5e04d8f40b7d3cc525f9ff8979 (diff)
downloadaskbot-899cd7376580b9238bdb12ddc1f097bcb9912730.tar.gz
askbot-899cd7376580b9238bdb12ddc1f097bcb9912730.tar.bz2
askbot-899cd7376580b9238bdb12ddc1f097bcb9912730.zip
merged follow user feature
Diffstat (limited to 'askbot/skins/default')
-rw-r--r--askbot/skins/default/media/js/user.js78
-rwxr-xr-xaskbot/skins/default/media/style/style.css23
-rw-r--r--askbot/skins/default/templates/blocks/bottom_scripts.html3
-rw-r--r--askbot/skins/default/templates/macros.html56
-rw-r--r--askbot/skins/default/templates/main_page/nothing_found.html4
-rw-r--r--askbot/skins/default/templates/main_page/tab_bar.html4
-rw-r--r--askbot/skins/default/templates/user_profile/user.html8
-rw-r--r--askbot/skins/default/templates/user_profile/user_info.html3
-rw-r--r--askbot/skins/default/templates/user_profile/user_network.html25
-rw-r--r--askbot/skins/default/templates/user_profile/user_tabs.html6
-rw-r--r--askbot/skins/default/templates/users.html23
11 files changed, 198 insertions, 35 deletions
diff --git a/askbot/skins/default/media/js/user.js b/askbot/skins/default/media/js/user.js
index 7877a828..ec169f9d 100644
--- a/askbot/skins/default/media/js/user.js
+++ b/askbot/skins/default/media/js/user.js
@@ -97,3 +97,81 @@ $(document).ready(function(){
}
);
});
+
+/**
+ * @constructor
+ * allows to follow/unfollow users
+ */
+var FollowUser = function(){
+ WrappedElement.call(this);
+ this._user_id = null;
+ this._user_name = null;
+};
+inherits(FollowUser, WrappedElement);
+
+/**
+ * @param {string} user_name
+ */
+FollowUser.prototype.setUserName = function(user_name){
+ this._user_name = user_name;
+};
+
+FollowUser.prototype.decorate = function(element){
+ this._element = element;
+ this._user_id = parseInt(element.attr('id').split('-').pop());
+ this._available_action = element.hasClass('follow') ? 'follow':'unfollow';
+ var me = this;
+ setupButtonEventHandlers(this._element, function(){ me.go() });
+};
+
+FollowUser.prototype.go = function(){
+ if (askbot['data']['userIsAuthenticated'] === false){
+ var message = gettext('Please <a href="%(signin_url)s">signin</a> to follow %(username)s');
+ var message_data = {
+ signin_url: askbot['urls']['user_signin'] + '?next=' + window.location.href,
+ username: this._user_name
+ }
+ message = interpolate(message, message_data, true);
+ showMessage(this._element, message);
+ return;
+ }
+ var user_id = this._user_id;
+ if (this._available_action === 'follow'){
+ var url = askbot['urls']['follow_user'];
+ } else {
+ var url = askbot['urls']['unfollow_user'];
+ }
+ var me = this;
+ $.ajax({
+ type: 'POST',
+ cache: false,
+ dataType: 'json',
+ url: url.replace('{{userId}}', user_id),
+ success: function(){ me.toggleState() }
+ });
+};
+
+FollowUser.prototype.toggleState = function(){
+ if (this._available_action === 'follow'){
+ this._available_action = 'unfollow';
+ this._element.removeClass('follow');
+ this._element.addClass('unfollow');
+ var fmts = gettext('unfollow %s');
+ } else {
+ this._available_action = 'follow';
+ this._element.removeClass('unfollow');
+ this._element.addClass('follow');
+ var fmts = gettext('follow %s');
+ }
+ this._element.html(interpolate(fmts, [this._user_name]));
+};
+
+(function(){
+ var fbtn = $('.follow-user');
+ if (fbtn.length === 1){
+ var follow_user = new FollowUser();
+ follow_user.decorate(fbtn);
+ follow_user.setUserName(askbot['data']['viewUserName']);
+ }
+})();
+
diff --git a/askbot/skins/default/media/style/style.css b/askbot/skins/default/media/style/style.css
index ff8b997d..24b01672 100755
--- a/askbot/skins/default/media/style/style.css
+++ b/askbot/skins/default/media/style/style.css
@@ -778,11 +778,10 @@ a:hover.medal {
height: 24px;
line-height: 26px;
margin-top: 3px;
- padding: 0px 11px 0px 11px;
}
-.tabsA a.on, tabsA a.on:hover {
- padding: 0px 6px 0px 11px;
+.tabsA a.rev.on, tabsA a.rev.on:hover {
+ padding: 0px 2px 0px 7px;
}
.tabsA a, .tabsC a{
@@ -797,7 +796,7 @@ a:hover.medal {
height: 20px;
line-height: 22px;
margin: 5px 0 0 4px;
- padding: 0 11px 0 11px;
+ padding: 0 7px;
text-decoration: none;
}
@@ -2172,3 +2171,19 @@ pre.prettyprint { padding: 3px; border: 0px solid #888; }
.atn { color: #404; }
.atv { color: #060; }
}
+
+.follow-toggle {
+ border-radius: 3px;
+ -moz-border-radius: 3px;
+ background: #fff0e0;
+ color: #777;
+ font-weight: bolder;
+ border: 1px solid #aaa;
+ cursor: pointer;
+}
+
+.follow-toggle.unfollow:hover {
+ background: #a40000;
+ color: #fff;
+ border: 1px solid #d40000;
+}
diff --git a/askbot/skins/default/templates/blocks/bottom_scripts.html b/askbot/skins/default/templates/blocks/bottom_scripts.html
index 3ba2d959..b5b88bce 100644
--- a/askbot/skins/default/templates/blocks/bottom_scripts.html
+++ b/askbot/skins/default/templates/blocks/bottom_scripts.html
@@ -20,6 +20,9 @@
askbot['urls']['mark_read_message'] = '{% url "read_message" %}';
askbot['urls']['get_tags_by_wildcard'] = '{% url "get_tags_by_wildcard" %}';
askbot['urls']['get_tag_list'] = '{% url "get_tag_list" %}';
+ askbot['urls']['follow_user'] = scriptUrl + 'followit/follow/user/{{'{{'}}userId{{'}}'}}/';
+ askbot['urls']['unfollow_user'] = scriptUrl + 'followit/unfollow/user/{{'{{'}}userId{{'}}'}}/';
+ askbot['urls']['user_signin'] = '{% url "user_signin" %}';
</script>
<script
type="text/javascript"
diff --git a/askbot/skins/default/templates/macros.html b/askbot/skins/default/templates/macros.html
index 0eb0b303..fb3e3898 100644
--- a/askbot/skins/default/templates/macros.html
+++ b/askbot/skins/default/templates/macros.html
@@ -20,6 +20,34 @@
{% endif %}
{%- endmacro -%}
+{%- macro follow_toggle(follow, name, alias, id) -%}
+ {# follow - boolean; name - object type name; alias - e.g. users name; id - object id #}
+ <div
+ class="follow-toggle follow-{{name}} {% if follow %}follow{% else %}unfollow{% endif %}"
+ id="follow-{{ name }}-{{ id }}"
+ >
+ {% if follow %}
+ {% trans %}follow {{alias}}{% endtrans %}
+ {% else %}
+ {% trans %}unfollow {{alias}}{% endtrans %}
+ {% endif %}
+ </div>
+{%- endmacro -%}
+
+{%- macro follow_user_toggle(visitor = None, subject = None) -%}
+ {% if visitor.is_anonymous() %}
+ {{ follow_toggle(True, 'user', subject.username, subject.id) }}
+ {% else %}
+ {% if visitor != subject %}
+ {% if visitor.is_following(subject) %}
+ {{ follow_toggle(False, 'user', subject.username, subject.id) }}
+ {% else %}
+ {{ follow_toggle(True, 'user', subject.username, subject.id) }}
+ {% endif %}
+ {% endif %}
+ {% endif %}
+{%- endmacro -%}
+
{%- macro user_long_score_and_badge_summary(user) -%}
<a class="user-micro-info"
href="{{user.get_absolute_url()}}?sort=reputation"
@@ -74,6 +102,30 @@
{{ user_country_name_and_flag(user) }}
{%- endmacro -%}
+{%- macro user_list(users, profile_section = None) -%}
+<div class="userList">
+ <table class="list-table">
+ <tr>
+ <td class="list-td">
+ {% for user in users %}
+ <div class="user">
+ <ul>
+ <li class="thumb">{{ gravatar(user, 32) }}</li>
+ <li><a href="{% url user_profile user.id, user.username|slugify %}{% if profile_section %}?sort={{profile_section}}{% endif %}">{{user.username}}</a>{{ user_country_flag(user) }}</li>
+ <li>{{ user_score_and_badge_summary(user) }}</li>
+ </ul>
+ </div>
+ {% if loop.index is divisibleby 7 %}
+ </td>
+ <td>
+ {% endif %}
+ {% endfor %}
+ </td>
+ </tr>
+ </table>
+</div>
+{%- endmacro -%}
+
{%- macro paginator(p, position='left') -%}{# p is paginator context dictionary #}
{% spaceless %}
{% if p.is_paginated %}
@@ -510,12 +562,12 @@ poor design of the data or methods on data objects #}
{% if sort == key_name + "-asc" %}{# "worst" first #}
<a id="by_{{key_name}}"
href="?sort={{key_name}}-desc"
- class="on"
+ class="rev on"
title="{{desc_tooltip}}"><span>{{label}} &#9650;</span></a>
{% elif sort == key_name + "-desc" %}{# "best first" #}
<a id="by_{{key_name}}"
href="?sort={{key_name}}-asc"
- class="on"
+ class="rev on"
title="{{asc_tooltip}}"><span>{{label}} &#9660;</span></a>
{% else %}{# default, when other button is active #}
<a id="by_{{key_name}}"
diff --git a/askbot/skins/default/templates/main_page/nothing_found.html b/askbot/skins/default/templates/main_page/nothing_found.html
index bc58fc27..50f2f340 100644
--- a/askbot/skins/default/templates/main_page/nothing_found.html
+++ b/askbot/skins/default/templates/main_page/nothing_found.html
@@ -4,8 +4,8 @@
{% trans %}There are no unanswered questions here{% endtrans %}
{% endif %}
{% if scope == "favorite" %}
- {% trans %}No favorite questions here. {% endtrans %}
- {% trans %}Please start (bookmark) some questions when you visit them{% endtrans %}
+ {% trans %}No questions here. {% endtrans %}
+ {% trans %}Please star (bookmark) some questions or follow some users.{% endtrans %}
{% endif %}
</p>
{% if query or search_tags or author_name %}
diff --git a/askbot/skins/default/templates/main_page/tab_bar.html b/askbot/skins/default/templates/main_page/tab_bar.html
index 12096a3b..e398be87 100644
--- a/askbot/skins/default/templates/main_page/tab_bar.html
+++ b/askbot/skins/default/templates/main_page/tab_bar.html
@@ -17,8 +17,8 @@
<a id="favorite"
class="{% if scope == 'favorite' %}on{% else %}off{% endif %}"
href="?scope=favorite"
- title="{% trans %}see your favorite questions{% endtrans %}"
- ><span>{% trans %}favorite{% endtrans %}</span></a>
+ title="{% trans %}see your followed questions{% endtrans %}"
+ ><span>{% trans %}followed{% endtrans %}</span></a>
{% endif %}
</div>
<div id="sort_tabs" class="tabsA">
diff --git a/askbot/skins/default/templates/user_profile/user.html b/askbot/skins/default/templates/user_profile/user.html
index e8abdf4b..cc1895fb 100644
--- a/askbot/skins/default/templates/user_profile/user.html
+++ b/askbot/skins/default/templates/user_profile/user.html
@@ -21,12 +21,14 @@
</div>
{% endblock %}<!-- end user.html -->
{% block endjs %}
- {% if request.user|can_moderate_user(view_user) %}
- <script type='text/javascript' src='{{"/js/jquery.form.js"|media}}'></script>
- {% endif %}
<script type="text/javascript">
var viewUserID = {{view_user.id}};
+ askbot['data']['viewUserName'] = '{{ view_user.username }}';
</script>
+ {% if request.user|can_moderate_user(view_user) %}
+ <script type='text/javascript' src='{{"/js/jquery.form.js"|media}}'></script>
+ {% endif %}
+ <script type="text/javascript" src='{{"/js/user.js"|media}}'></script>
{% block userjs %}
{% endblock %}
{% endblock %}
diff --git a/askbot/skins/default/templates/user_profile/user_info.html b/askbot/skins/default/templates/user_profile/user_info.html
index 6c6868c7..5aa5c094 100644
--- a/askbot/skins/default/templates/user_profile/user_info.html
+++ b/askbot/skins/default/templates/user_profile/user_info.html
@@ -23,6 +23,9 @@
</div>
<div class="scoreNumber">{{view_user.reputation|intcomma}}</div>
<p><b style="color:#777;">{% trans %}reputation{% endtrans %}</b></p>
+ {% if user_follow_feature_on %}
+ {{ macros.follow_user_toggle(visitor = request.user, subject = view_user) }}
+ {% endif %}
</td>
<td width="360" style="padding-left:5px;vertical-align: top;">
<table class="user-details">
diff --git a/askbot/skins/default/templates/user_profile/user_network.html b/askbot/skins/default/templates/user_profile/user_network.html
new file mode 100644
index 00000000..cc741bb1
--- /dev/null
+++ b/askbot/skins/default/templates/user_profile/user_network.html
@@ -0,0 +1,25 @@
+{% extends "user_profile/user.html" %}
+{% import "macros.html" as macros %}
+<!-- user_network.html -->
+{% block profileseciton %}
+ {% trans %}network{% endtrans %}
+{% endblock %}
+{% block usercontent %}
+ {% if followed_users or followers %}
+ {% if followers %}
+ <h2>{% trans count=followers|length %}Followed by {{count}} person{% pluralize count %}Followed by {{count}} people{% endtrans %}</h2>
+ {{ macros.user_list(followers, profile_section = 'network') }}
+ {% endif %}
+ {% if followed_users %}
+ <h2>{% trans count=followed_users|length %}Following {{count}} person{% pluralize count %}Followed by {{count}} people{% endtrans %}</h2>
+ {{ macros.user_list(followed_users, profile_section = 'network') }}
+ {% endif %}
+ {% else %}
+ {% if request.user == view_user %}
+ <p>{% trans %}Your network is empty. Would you like to follow someone? - Just visit their profiles and click "follow"{% endtrans %}</p>
+ {% else %}
+ <p>{% trans username = view_user.username %}{{user}}'s network is empty{% endtrans %}</p>
+ {% endif %}
+ {% endif %}
+{% endblock %}
+<!-- end user_network.html -->
diff --git a/askbot/skins/default/templates/user_profile/user_tabs.html b/askbot/skins/default/templates/user_profile/user_tabs.html
index 276590c9..92c42ea8 100644
--- a/askbot/skins/default/templates/user_profile/user_tabs.html
+++ b/askbot/skins/default/templates/user_profile/user_tabs.html
@@ -11,6 +11,12 @@
href="{% url user_profile view_user.id, view_user.username|slugify %}?sort=inbox"
><span>{% trans %}inbox{% endtrans %}</span></a>
{% endif %}
+ {% if user_follow_feature_on %}
+ <a id="network" {% if tab_name=="network" %}class="on"{% endif %}
+ title="{% trans %}followers and followed users{% endtrans %}"
+ href="{% url user_profile view_user.id, view_user.username|slugify %}?sort=network"
+ ><span>{% trans %}network{% endtrans %}</span></a>
+ {% endif %}
<a id="reputation" {% if tab_name=="reputation" %}class="on"{% endif %}
title="{% trans %}graph of user reputation{% endtrans %}"
href="{% url user_profile view_user.id, view_user.username|slugify %}?sort=reputation"
diff --git a/askbot/skins/default/templates/users.html b/askbot/skins/default/templates/users.html
index 74c171c8..750b3abb 100644
--- a/askbot/skins/default/templates/users.html
+++ b/askbot/skins/default/templates/users.html
@@ -40,28 +40,7 @@
<span>{% trans %}Nothing found.{% endtrans %}</span>
{% endif %}
</p>
-<div class="userList">
- <table class="list-table">
- <tr>
- <td class="list-td">
- {% for user in users.object_list %}
- <div class="user">
- <ul>
- <li class="thumb">{{ macros.gravatar(user, 32) }}</li>
- <li><a href="{% url user_profile user.id, user.username|slugify %}">{{user.username}}</a>{{ macros.user_country_flag(user) }}</li>
- <li>{{ macros.user_score_and_badge_summary(user) }}</li>
- </ul>
- </div>
-
- {% if loop.index is divisibleby 7 %}
- </td>
- <td>
- {% endif %}
- {% endfor %}
- </td>
- </tr>
- </table>
-</div>
+{{ macros.user_list(users.object_list) }}
<div class="pager">
{{ macros.paginator(paginator_context) }}
</div>