diff --git a/files/templates/leaderboard.html b/files/templates/leaderboard.html index 81aa2a627..199006f22 100644 --- a/files/templates/leaderboard.html +++ b/files/templates/leaderboard.html @@ -1,397 +1,96 @@ {% extends "settings2.html" %} - {% block pagetitle %}Leaderboard{% endblock %} - {% block content %} +{%-set leaderboards = [ + ('coins', 'Coins', True), ('spent', 'Spent in shop', True), ('truescore', 'Truescore', True), ('followers', 'Followers', True), + ('posts', 'Posts', True), ('comments', 'Comments', True), ('awards', 'Awards', True), ('badges', 'Badges', True), + ('marseys', 'Marseys', users12) ('blocked', 'Blocked', True), ('owned-hats', 'Owned hats', True), ('designed-hats', 'Designed hats', True, False) +] -%}

 
- Coins • - Spent in shop • - Truescore • - Followers • - Posts • - Comments • - Awards • - Badges • - {% if users12 %}Marseys • {% endif %} - Blocked • - Owned hats • - Designed hats + {% for lb in leaderboards %} + {% if lbs[2] %} + {{lb[1]}}{% if not lb[3] %} •{% endif %} + {% endif %} + {% endfor %}
-
Top 25 by coins
- -
- - - - - - - -{% for user in users1 %} - - +{% macro format_user_in_table(user, style, position_no, value, user_relative_url) %} + + - - -{% endfor %} -{% if pos1 %} - - - - - -{% endif %} -
#NameCoins
{{loop.index}}
{{position_no}} {% include "user_in_table.html" %}{{"{:,}".format(user.coins)}}
{{pos1}} - {% with user=v %} - {% include "user_in_table.html" %} - {% endwith %} - {{"{:,}".format(v.coins)}}
- -
Top 25 by coins spent in shop
- -
- - - - - - - - -{% for user in users7 %} - - - - - -{% endfor %} -{% if pos7 %} - - - - - -{% endif %} -
#NameCoins
{{loop.index}}{% include "user_in_table.html" %}{{"{:,}".format(user.coins_spent)}}
{{pos7}} - {% with user=v %} - {% include "user_in_table.html" %} - {% endwith %} - {{"{:,}".format(v.coins_spent)}}
- -
Top 25 by truescore
- -
- - - - - - - - - {% for user in users10 %} - - - - - - {% endfor %} - {% if pos10 %} - - - - - - {% endif %} - -
#NameTruescore
{{loop.index}}{% include "user_in_table.html" %}{{"{:,}".format(user.truecoins)}}
{{pos10}} - {% with user=v %} - {% include "user_in_table.html" %} - {% endwith %} - {{"{:,}".format(v.truecoins)}}
- -
Top 25 by followers
- -
- - - - - - - -{% for user in users2 %} - - - - - -{% endfor %} -{% if pos2 %} - - - - - -{% endif %} -
#NameFollowers
{{loop.index}}{% include "user_in_table.html" %}{{"{:,}".format(user.stored_subscriber_count)}}
{{pos2}} - {% with user=v %} - {% include "user_in_table.html" %} - {% endwith %} - {{"{:,}".format(v.stored_subscriber_count)}}
- -
Top 25 by post count
- -
- - - - - - - -{% for user in users3 %} - - - - - -{% endfor %} -{% if pos3 %} - - - - - -{% endif %} -
#NamePosts
{{loop.index}}{% include "user_in_table.html" %}{{"{:,}".format(user.post_count)}}
{{pos3}} - {% with user=v %} - {% include "user_in_table.html" %} - {% endwith %} - {{"{:,}".format(v.post_count)}}
- -
Top 25 by comment count
- -
- - - - - - - -{% for user in users4 %} - - - - - -{% endfor %} -{% if pos4 %} - - - - - -{% endif %} -
#NameComments
{{loop.index}}{% include "user_in_table.html" %}{{"{:,}".format(user.comment_count)}}
{{pos4}} - {% with user=v %} - {% include "user_in_table.html" %} - {% endwith %} - {{"{:,}".format(v.comment_count)}}
- -
Top 25 by received awards
- -
- - - - - - - -{% for user in users5 %} - - - - - -{% endfor %} -{% if pos5 %} - - - - - -{% endif %} -
#NameAwards
{{loop.index}}{% include "user_in_table.html" %}{{"{:,}".format(user.received_award_count)}}
{{pos5}} - {% with user=v %} - {% include "user_in_table.html" %} - {% endwith %} - {{"{:,}".format(v.received_award_count)}}
- -
Top 25 by badges
- -
- - - - - - - - - {% for user, num in users11 %} - - - - - - {% endfor %} - {% if pos11 and (pos11[0] > 25 or not pos11[1]) %} - - - - - - {% endif %} - -
#NameBadges
{{loop.index}}{% include "user_in_table.html" %}{{"{:,}".format(num)}}
{{pos11[0]}} - {% with user=v %} - {% include "user_in_table.html" %} - {% endwith %} - {{"{:,}".format(pos11[1])}}
- - - -{% if users12 %} - -
Top 25 by Marseys made
- -
- - - - - - - - - {% for user, num in users12 %} - - - - - - {% endfor %} - {% if pos12 and (pos12[0] > 25 or not pos12[1]) %} - - - - - + {% if user_relative_url %} + + {% else %} + {% endif %} - + +{% endmacro %} + +{% macro leaderboard_table_header(column_name) %} + + + + + + + +{% endmacro %} + +{% macro leaderboard_table(lb, position, id, total_count, header_name, column_name, attr_name) %} +
Top {{total_count}} by {{header_name}}
+
+<# TODO: check at some point if the nesting divs are intentional #> +
#NameMarseys
{{loop.index}}{% include "user_in_table.html" %}{{"{:,}".format(num)}}
{{pos12[0]}} - {% with user=v %} - {% include "user_in_table.html" %} - {% endwith %} - {{"{:,}".format(pos12[1])}}
{{"{:,}".format(value)}}{{"{:,}".format(value)}}
#Name{{column_name}}
+ {{leaderboard_table_header(column_name)}} + + {% for user in lb %} + {% if v.id == user.id %} + {% set style="class=\"self\"" %} + {% endif %} + {{format_user_in_table(user, style, loop.index, getattr(user, attr_name))}} + {% endfor %} + {% if position %} + {{format_user_in_table(v, "style=\"border-top:2px solid var(--primary)\"", position, getattr(v, attr_name))}} + {% endif %} + +
+{% endmacro %} + +{{leaderboard_table(users1, pos1, 'coins', 25, 'coins', 'Coins', 'coins')}} +{{leaderboard_table(users7, pos7, 'spent', 25, 'coins spent in shop', 'Coins', 'coins_spent')}} +{{leaderboard_table(users10, pos10, 'truescore', 25, 'truescore', 'Truescore', 'truecoins')}} +{{leaderboard_table(users2, pos2, 'followers', 25, 'followers', 'Followers', 'stored_subscriber_count')}} +{{leaderboard_table(users3, pos3, 'posts', 25, 'post count', 'Posts', 'post_count')}} +{{leaderboard_table(users4, pos4, 'comments', 25, 'comment count', 'Comments', 'comment_count')}} +{{leaderboard_table(users5, pos5, 'awards', 25, 'received awards', 'Awards', 'awards')}} + +{% macro leaderboard_table_2(lb, position, id, total_count, header_name, column_name, user_relative_url) %} +
Top {{total_count}} by {{header_name}}
+
+ + {{leaderboard_table_header(column_name)}} + + {% for user, num in lb %} + {% if v.id == user.id %} + {% set style="class=\"self\"" %} + {% endif %} + {{format_user_in_table(user, style, loop.index, num, user_relative_url)}} + {% endfor %} + {% if position and (position[0] > total_count or not position[1]) %} + {{format_user_in_table(v, "style=\"border-top:2px solid var(--primary)\"", position, position[1], user_relative_url)}} + {% endif %} +
+{% endmacro %} + +{{leaderboard_table_2(users11, pos11, 'badges', 25, 'badges', 'Badges')}} +{% if users12 %} + {{leaderboard_table_2(users12, pos12, 'marseys', 25, 'Marseys made', 'Marseys')}} {% endif %} - -
Top 25 most blocked
- -
- - - - - - - -{% for user, num in users16 %} - - - - - -{% endfor %} -{% if pos16 and (pos16[0] > 25 or not pos16[1]) %} - - - - - -{% endif %} -
#NameBlocked By
{{loop.index}}{% include "user_in_table.html" %}{{"{:,}".format(num)}}
{{pos16[0]}} - {% with user=v %} - {% include "user_in_table.html" %} - {% endwith %} - {{"{:,}".format(pos16[1])}}
- - -
Top 25 by owned hats
- -
- - - - - - - -{% for user,num in users17 %} - - - - - -{% endfor %} -{% if pos17 and (pos17[0] > 25 or not pos17[1]) %} - - - - - -{% endif %} -
#NameOwned Hats
{{loop.index}}{% include "user_in_table.html" %}{{"{:,}".format(num)}}
{{pos17[0]}} - {% with user=v %} - {% include "user_in_table.html" %} - {% endwith %} - {{"{:,}".format(pos17[1])}}
- -
Top 25 by designed hats
- -
- - - - - - - -{% for user,num in users18 %} - - - - - -{% endfor %} -{% if pos18 and (pos18[0] > 25 or not pos18[1]) %} - - - - - -{% endif %} -
#NameDesigned Hats
{{loop.index}}{% include "user_in_table.html" %}{{"{:,}".format(num)}}
{{pos18[0]}} - {% with user=v %} - {% include "user_in_table.html" %} - {% endwith %} - {{"{:,}".format(pos18[1])}}
- +{{leaderboard_table_2(users16, pos16, 'blocked', 25, 'most blocked', 'Blocked By', 'blockers')}} +{{leaderboard_table_2(users17, pos17, 'owned-hats', 25, 'owned hats', 'Owned Hats')}} +{{leaderboard_table_2(users18, pos18, 'designed-hats', 25, 'designed hats', 'Designed Hats')}}