Skip to content

Commit

Permalink
Merge pull request #37 from abilian/forum_refactor_update
Browse files Browse the repository at this point in the history
Forum refactor update
  • Loading branch information
sfermigier committed May 17, 2017
2 parents 941d581 + 761007c commit 6e72f7d
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 16 deletions.
26 changes: 14 additions & 12 deletions abilian/sbe/apps/forum/templates/forum/index.html
Expand Up @@ -19,7 +19,7 @@
{% if threads %}
<table class="thread-table" border="0">
<tr>
<th colspan="2">
<th>
{{ _("Topic") }}
</th>
<th>
Expand Down Expand Up @@ -60,12 +60,7 @@
{%- set thread_href = url_for(thread) %}
{%- set thread_length = thread.posts|length %}
<tr>
<td class="thread-user">
{% call m_user_link(thread.creator) %}
{{ m_user_photo(thread.creator, size=40) }}
{%- endcall %}
</td>
<td style="width: 41%;">
<td>
<div class="entry">
<h4 class="thread-list-title"><a href="{{ thread_href }}" title="{{ thread.created_at | age(date_threshold='day') }}"
class="thread-title"> {{ thread.title }} </a></h4>
Expand All @@ -75,13 +70,19 @@ <h4 class="thread-list-title"><a href="{{ thread_href }}" title="{{ thread.creat
</div>
</td>
<td class="thread-frequent-posters">
{% call m_user_link(thread.creator) %}
{{ m_user_photo(thread.creator, size=40) }}
{%- endcall %}

{% for p in thread.get_frequent_posters(5) %}
{% call m_user_link(p) %}
<span class="thread-participants-logo">
{{ m_user_photo(p, size=30) }}
</span>
{%- endcall %}
{% endfor %}
</td>
<td style="width: 6.9%;">
<td>
<center>
<div class="comments" style="position: relative;">
<a class="thread-replies" href="{{ thread_href }}">{{ thread_length-1 }}</a>
Expand All @@ -90,26 +91,27 @@ <h4 class="thread-list-title"><a href="{{ thread_href }}" title="{{ thread.creat
<span class="thread-hilightview"
title="not viewed"><span class="badge thread-unread-posts">+{{ nb_viewed_posts[thread] }}</span></span>
{% endif %}
</div>
</center>
</td>
<td>
<td style="width:10%;">
<center>
<span class="thread-viewers">
<i class="fa fa-user" aria-hidden="true"></i>
{{ nb_viewers[thread] }}
</span>
</center>
</td>
<td>
<td style="width:0%;">
<center>
<span class="thread-viewed-times"> {% if nb_viewed_times[thread] %}{{ nb_viewed_times[thread] }}{% else %}0{% endif %}</span>
</center>
</td>
<td style="width: 17%;">
<td>
<center>
<span class="hidden-xs">
<span class="divider"
style="color:silver;"> {{ thread.last_post_at | age(date_threshold='day') }}</span>
style="color:silver;"> {{ activity_time_format(thread.last_post_at) }}</span>
</span>
</center>
</td>
Expand Down
5 changes: 3 additions & 2 deletions abilian/sbe/apps/forum/templates/forum/thread_viewers.html
Expand Up @@ -10,8 +10,9 @@
{% call m_box_content() %}
{# TODO #}
<p>
<a href="{{ url_for('.index', community_id=g.community.slug) }}">
<i class="fa fa-arrow-left"></i> {{ _("Back to conversation list") }}</a>
{%- set thread_href = url_for(thread) %}
<a href="{{ thread_href }}">
<i class="fa fa-arrow-left"></i> {{ _("Back to the topic") }}</a>
</p>

<article class="thread">
Expand Down
26 changes: 25 additions & 1 deletion abilian/sbe/apps/forum/views.py
Expand Up @@ -95,6 +95,29 @@ def get_viewed_posts(entities):
return nb_viewed_posts


def activity_time_format(time):
current_date = datetime.utcnow()
time_diffrence = current_date - time
month_abbreviation = time.strftime('%B')[:3]
days, hours, minutes, seconds = time_diffrence.days, time_diffrence.seconds // 3600, time_diffrence.seconds // 60, time_diffrence.seconds

if time.year == current_date.year:
if time.month == current_date.month:
if time.day == current_date.day:
if minutes < 1:
return "{}s".format(seconds)
elif minutes > 60:
return "{}h".format(hours)
else:
return "{}m".format(minutes % 60)
else:
return "{}d".format(days)
else:
return "{} {}".format(month_abbreviation, time.day)
else:
return "{} {}".format(month_abbreviation, str(time.year))


def get_viewed_times(entities):
if entities:
views = viewtracker.get_views(entities=entities)
Expand Down Expand Up @@ -133,7 +156,8 @@ def index():
has_more=has_more,
nb_viewers=nb_viewers,
nb_viewed_posts=nb_viewed_posts,
nb_viewed_times=nb_viewed_times)
nb_viewed_times=nb_viewed_times,
activity_time_format=activity_time_format)


def group_monthly(entities_list):
Expand Down
10 changes: 9 additions & 1 deletion abilian/sbe/static/less/modules/forum.less
Expand Up @@ -183,7 +183,7 @@ ul.threads {
// hilight not viewed number
.thread-hilightview {
position: relative;
top: -0.5px;
top: -0.4pt;
color: lightcoral;
font-weight: bold;
}
Expand All @@ -193,6 +193,13 @@ ul.threads {
color: #858585;
}

.thread-participants-logo {
margin-right: -13px;
> .avatar {
border: 2px solid white;
}
}

.thread-list-title {
text-align: justify;
margin-right: 23px;
Expand Down Expand Up @@ -311,6 +318,7 @@ element.style {

// the table of threads
.thread-table {
width: 100%;

> tbody > tr {
border-bottom: 1px solid #e9e9e9;
Expand Down

0 comments on commit 6e72f7d

Please sign in to comment.