feat: add leaderboard with demo data
This commit is contained in:
1 parent
16ebdc1098
commit
475aa1caf2
1 file changed
+98
@@ -0,0 +1,98 @@
|
|||||||
|
{% comment %} --- Static Demo Data --- {% endcomment %}
|
||||||
|
{% assign demo_users = "" | split: "," %}
|
||||||
|
{% assign user1 = '{"username": "chair_enthusiast2025", "merits": 152, "posts": 15, "comments": 45, "joined": "2024-11-01"}' | parse_json %}
|
||||||
|
{% assign user2 = '{"username": "desk_ninja", "merits": 121, "posts": 8, "comments": 72, "joined": "2025-01-15"}' | parse_json %}
|
||||||
|
{% assign user3 = '{"username": "cable_conqueror", "merits": 98, "posts": 25, "comments": 30, "joined": "2024-12-20"}' | parse_json %}
|
||||||
|
{% assign user4 = '{"username": "ergonomic_explorer", "merits": 85, "posts": 12, "comments": 55, "joined": "2025-03-10"}' | parse_json %}
|
||||||
|
{% assign user5 = '{"username": "monitor_maven", "merits": 77, "posts": 5, "comments": 60, "joined": "2025-04-22"}' | parse_json %}
|
||||||
|
{% assign user6 = '{"username": "keyboard_king", "merits": 65, "posts": 18, "comments": 28, "joined": "2025-02-05"}' | parse_json %}
|
||||||
|
{% assign user7 = '{"username": "plant_parent_pro", "merits": 50, "posts": 3, "comments": 40, "joined": "2025-05-01"}' | parse_json %}
|
||||||
|
{% assign user8 = '{"username": "snack_strategist", "merits": 42, "posts": 22, "comments": 15, "joined": "2025-04-18"}' | parse_json %}
|
||||||
|
{% assign user9 = '{"username": "focus_finder", "merits": 30, "posts": 10, "comments": 20, "joined": "2025-03-28"}' | parse_json %}
|
||||||
|
{% assign user10 = '{"username": "newbie_navigator", "merits": 15, "posts": 2, "comments": 8, "joined": "2025-05-04"}' | parse_json %}
|
||||||
|
|
||||||
|
{% assign demo_users = demo_users | push: user1 | push: user2 | push: user3 | push: user4 | push: user5 | push: user6 | push: user7 | push: user8 | push: user9 | push: user10 %}
|
||||||
|
|
||||||
|
{% comment %} Sort Users for Leaderboards {% endcomment %}
|
||||||
|
{% assign top_merits_users = demo_users | sort: "merits" | reverse %}
|
||||||
|
{% assign top_posters = demo_users | sort: "posts" | reverse %}
|
||||||
|
{% assign top_commenters = demo_users | sort: "comments" | reverse %}
|
||||||
|
{% assign new_users = demo_users | sort: "joined" | reverse %}
|
||||||
|
|
||||||
|
|
||||||
|
{% comment %} --- Leaderboard Display --- {% endcomment %}
|
||||||
|
<div class="leaderboard space-y-10">
|
||||||
|
|
||||||
|
<!-- Top Merits -->
|
||||||
|
<section>
|
||||||
|
<h2 class="text-2xl font-bold text-primary mb-4 font-action flex items-center">
|
||||||
|
<i class="fas fa-trophy text-yellow-500 mr-3 fa-fw"></i> Top Merits (All-Time)
|
||||||
|
</h2>
|
||||||
|
<ol class="list-none space-y-3">
|
||||||
|
{% for user in top_merits_users limit:10 %}
|
||||||
|
<li class="flex items-center justify-between p-3 bg-bg-footer rounded-md shadow-sm border border-gray-200">
|
||||||
|
<div class="flex items-center">
|
||||||
|
<span class="text-lg font-bold text-text-muted w-8 text-right mr-4">{{ forloop.index }}</span>
|
||||||
|
<a href="/user/{{ user.username }}/" class="text-primary font-action hover:underline font-medium">{{ user.username }}</a>
|
||||||
|
</div>
|
||||||
|
<span class="text-primary font-bold font-action">{{ user.merits }} Merits</span>
|
||||||
|
</li>
|
||||||
|
{% endfor %}
|
||||||
|
</ol>
|
||||||
|
</section>
|
||||||
|
|
||||||
|
<!-- Most Posts -->
|
||||||
|
<section>
|
||||||
|
<h2 class="text-2xl font-bold text-primary mb-4 font-action flex items-center">
|
||||||
|
<i class="fas fa-file-alt text-purple-500 mr-3 fa-fw"></i> Most Posts Submitted
|
||||||
|
</h2>
|
||||||
|
<ol class="list-none space-y-3">
|
||||||
|
{% for user in top_posters limit:10 %}
|
||||||
|
<li class="flex items-center justify-between p-3 bg-bg-footer rounded-md shadow-sm border border-gray-200">
|
||||||
|
<div class="flex items-center">
|
||||||
|
<span class="text-lg font-bold text-text-muted w-8 text-right mr-4">{{ forloop.index }}</span>
|
||||||
|
<a href="/user/{{ user.username }}/" class="text-primary font-action hover:underline font-medium">{{ user.username }}</a>
|
||||||
|
</div>
|
||||||
|
<span class="text-primary font-bold font-action">{{ user.posts }} Posts</span>
|
||||||
|
</li>
|
||||||
|
{% endfor %}
|
||||||
|
</ol>
|
||||||
|
</section>
|
||||||
|
|
||||||
|
<!-- Most Comments -->
|
||||||
|
<section>
|
||||||
|
<h2 class="text-2xl font-bold text-primary mb-4 font-action flex items-center">
|
||||||
|
<i class="fas fa-comments text-blue-500 mr-3 fa-fw"></i> Most Comments Submitted
|
||||||
|
</h2>
|
||||||
|
<ol class="list-none space-y-3">
|
||||||
|
{% for user in top_commenters limit:10 %}
|
||||||
|
<li class="flex items-center justify-between p-3 bg-bg-footer rounded-md shadow-sm border border-gray-200">
|
||||||
|
<div class="flex items-center">
|
||||||
|
<span class="text-lg font-bold text-text-muted w-8 text-right mr-4">{{ forloop.index }}</span>
|
||||||
|
<a href="/user/{{ user.username }}/" class="text-primary font-action hover:underline font-medium">{{ user.username }}</a>
|
||||||
|
</div>
|
||||||
|
<span class="text-primary font-bold font-action">{{ user.comments }} Comments</span>
|
||||||
|
</li>
|
||||||
|
{% endfor %}
|
||||||
|
</ol>
|
||||||
|
</section>
|
||||||
|
|
||||||
|
<!-- New Users -->
|
||||||
|
<section>
|
||||||
|
<h2 class="text-2xl font-bold text-primary mb-4 font-action flex items-center">
|
||||||
|
<i class="fas fa-user-plus text-green-500 mr-3 fa-fw"></i> Newest Members
|
||||||
|
</h2>
|
||||||
|
<ol class="list-none space-y-3">
|
||||||
|
{% for user in new_users limit:10 %}
|
||||||
|
<li class="flex items-center justify-between p-3 bg-bg-footer rounded-md shadow-sm border border-gray-200">
|
||||||
|
<div class="flex items-center">
|
||||||
|
<span class="text-lg font-bold text-text-muted w-8 text-right mr-4">{{ forloop.index }}</span>
|
||||||
|
<a href="/user/{{ user.username }}/" class="text-primary font-action hover:underline font-medium">{{ user.username }}</a>
|
||||||
|
</div>
|
||||||
|
<span class="text-sm text-text-muted font-action">Joined {{ user.joined | date: "%b %d, %Y" }}</span>
|
||||||
|
</li>
|
||||||
|
{% endfor %}
|
||||||
|
</ol>
|
||||||
|
</section>
|
||||||
|
|
||||||
|
</div>
|
||||||
Reference in new issue
Block a user