@@ -4,30 +4,11 @@ search:
44---
55
66<!-- The usermod will not be displayed if it has one of these keyword in the title. -->
7- {% set excludes = [ 'superseded', 'superseeded', 'deprecated'] %}
8-
9- <!-- Set up popularity weights -->
10- {% set first_view_weight = 1.0 %}
11- {% set first_download_weight = 3.0 %}
12- {% set repeat_view_weight = 0.1 %}
13- {% set repeat_download_weight = 0.2 %}
14-
15- <!-- Set limit for repeat views/downloads -->
16- {% set repeat_download_limit = 50 %}
17- {% set repeat_view_limit = 100 %}
18-
19- <!-- Macro to calculate popularity -->
20- {% macro get_popularity(f_views, f_downloads, r_views, r_downloads) %}
21- {% set r_views = [ r_views, repeat_view_limit] |min %}
22- {% set r_downloads = [ r_downloads, repeat_download_limit] |min %}
23-
24- {% set popularity = (f_views * first_view_weight) + (r_views * repeat_view_weight) + (f_downloads * first_download_weight) + (r_downloads * repeat_download_weight) %}
25- {{ popularity }}
26- {% endmacro %}
7+ {% set excludes = [ 'superseded', 'superseeded', 'deprecated', 'depreciated'] %}
278
289<!-- The variables that mods can be sorted by and their default orientation -->
29- {# set orders = [ ('popularity', 'descending'), ('title', 'ascending'), ('username', 'ascending'), ('created_date', 'descending')] # }
30- {% set orders = [ ('title', 'ascending'), ('username', 'ascending'), ('created_date', 'descending') ] %}
10+ {% set orders = [ ('popularity', 'descending'), ('title', 'ascending'), ('username', 'ascending'), ('created_date', 'descending')] % }
11+
3112
3213<!-- GA4 data -->
3314{% set ga4_data = {} %}
@@ -75,12 +56,16 @@ search:
7556 {% set repeat_views = ga4_mod.get('repeat_views', 0) %}
7657 {% set repeat_downloads = ga4_mod.get('repeat_downloads', 0) %}
7758
78- {% set popularity = get_popularity(first_time_views, first_time_downloads, repeat_views, repeat_downloads)|float %}
59+ {% set popularity = get_popularity(first_time_views, first_time_downloads, repeat_views, repeat_downloads, mod.created_date)|float %}
60+ {% set views_fmt = format_count(first_time_views|default(0)) %}
61+ {% set downloads_fmt = format_count(first_time_downloads|default(0)) %}
7962
8063 {% set _ = mod.update({'username': user.username}) %}
8164 {% set _ = mod.update({'repository': repo.name}) %}
8265 {% set _ = mod.update({'views': first_time_views|default(0)}) %}
8366 {% set _ = mod.update({'downloads': first_time_downloads|default(0)}) %}
67+ {% set _ = mod.update({'views_formatted': views_fmt}) %}
68+ {% set _ = mod.update({'downloads_formatted': downloads_fmt}) %}
8469 {% set _ = mod.update({'popularity': popularity}) %}
8570 {% set _ = mod.update({'tags': tags}) %}
8671
@@ -97,8 +82,7 @@ search:
9782 {% endfor %}
9883{% endfor %}
9984
100- {# set all_mods = all_mods|sort(attribute='popularity')|reverse|list #}
101- {% set all_mods = all_mods|sort(attribute='username')|reverse|list %}
85+ {% set all_mods = all_mods|sort(attribute='popularity')|reverse|list %}
10286{% set all_tags = all_tags|sort %}
10387{% set all_usernames = all_usernames|unique|sort|list %}
10488
@@ -122,8 +106,8 @@ search:
122106<script >
123107var usermods = {{ all_mods| tojson }};
124108var per_page = 20 ;
125- var defaultSort = ' {{ orders[1 ][0] }}' ;
126- var defaultSortOrder = ' {{ orders[1 ][1] }}' ;
109+ var defaultSort = ' {{ orders[0 ][0] }}' ;
110+ var defaultSortOrder = ' {{ orders[0 ][1] }}' ;
127111</script >
128112
129113<!-- Template for the modal -->
@@ -138,13 +122,13 @@ var defaultSortOrder = '{{ orders[1][1] }}';
138122 <span id="usermod-modal-author" class="usermod-modal-author"></span>
139123 <div class="usermod-modal-meta-row">
140124 <!-- Views -->
141- <span class="twemoji" style="display: none;" >
125+ <span class="twemoji">
142126 <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M12 9a3 3 0 0 0-3 3 3 3 0 0 0 3 3 3 3 0 0 0 3-3 3 3 0 0 0-3-3m0 8a5 5 0 0 1-5-5 5 5 0 0 1 5-5 5 5 0 0 1 5 5 5 5 0 0 1-5 5m0-12.5C7 4.5 2.73 7.61 1 12c1.73 4.39 6 7.5 11 7.5s9.27-3.11 11-7.5c-1.73-4.39-6-7.5-11-7.5"></path></svg>
143127 </span>
144- <span id="usermod-modal-views" style="display: none;" ></span>
128+ <span id="usermod-modal-views"></span>
145129 <!-- Downloads -->
146- <span class="twemoji" style="display: none;" ><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M5 20h14v-2H5m14-9h-4V3H9v6H5l7 7z"></path></svg></span>
147- <span id="usermod-modal-downloads" style="display: none;" ></span>
130+ <span class="twemoji"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M5 20h14v-2H5m14-9h-4V3H9v6H5l7 7z"></path></svg></span>
131+ <span id="usermod-modal-downloads"></span>
148132 <!-- Created Date -->
149133 <span class="twemoji"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M19 19H5V8h14m-3-7v2H8V1H6v2H5c-1.11 0-2 .89-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2V5a2 2 0 0 0-2-2h-1V1m-1 11h-5v5h5z"></path></svg></span>
150134 <span id="usermod-modal-created"></span>
@@ -251,7 +235,7 @@ If you would like your mods featured here, please consider [Submitting a Usermod
251235 ** {{ mod.title }}** { .custom-card-title }
252236 * {{ mod.username }}* { .custom-card-author }
253237
254- <span class =" usermod-card-stats " style = " display : none ; " >:material-eye: {{ mod.views }} :material-download: {{ mod.downloads }}</span >
238+ <span class =" usermod-card-stats " >:material-eye: {{ mod.views_formatted }} :material-download: {{ mod.downloads_formatted }}</span >
255239 <span class =" usermod-card-date " >:material-calendar: {{ mod.created_date.split('T')[ 0] }}</span >
256240
257241 <ul class =" usermod-tags " >
0 commit comments