Skip to content

Commit

Permalink
Move random sound of the day to sidebar
Browse files Browse the repository at this point in the history
  • Loading branch information
ffont committed Mar 22, 2023
1 parent 1d919de commit 171e9cc
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 97 deletions.
4 changes: 2 additions & 2 deletions sounds/templatetags/display_sound.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,8 @@ def sound_object_retrieved_using_bulk_query_id(sound):
'is_explicit': sound_obj.is_explicit and
(not request.user.is_authenticated or not request.user.profile.is_adult),
'is_authenticated': request.user.is_authenticated,
'show_bookmark_button': show_bookmark if show_bookmark is not None else (player_size == 'small' or player_size == 'small_no_info'), # Only BW
'show_similar_sounds_button': show_similar_sounds if show_similar_sounds is not None else (player_size == 'small' or player_size == 'small_no_info'), # Only BW
'show_bookmark_button': show_bookmark if show_bookmark is not None else (player_size == 'small' or player_size == 'small_no_info' or player_size == 'big_no_info'), # Only BW
'show_similar_sounds_button': show_similar_sounds if show_similar_sounds is not None else (player_size == 'small' or player_size == 'small_no_info' or player_size == 'big_no_info'), # Only BW
'request_user_is_author': request.user.is_authenticated and sound_obj.user_id == request.user.id,
'player_size': player_size,
'show_milliseconds': 'true' if (player_size == 'big_no_info' or sound_obj.duration < 10) else 'false', # Only BW
Expand Down
137 changes: 43 additions & 94 deletions templates_bw/front.html
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,12 @@ <h3 class="v-spacing-4">Latest additions</h3>
<div class="col-6 col-md-4">
{% display_sound_small sound_id %}
</div>
<div class="col-6 col-md-4">
{% display_sound_small sound_id %}
</div>
<div class="col-6 col-md-4">
{% display_sound_small sound_id %}
</div>
{% endfor %}
</div>
</div>
Expand All @@ -63,7 +69,7 @@ <h3 class="v-spacing-4">Latest additions</h3>
{% if trending_sound_ids %}
{% cache 300 bw_front_page_trending_sounds %}
<section class="v-spacing-3">
<h3 class="v-spacing-4 v-spacing-top-4" title="Most downloaded sounds during the last week">Trending sounds</h3>
<h3 class="v-spacing-4 v-spacing-top-3" title="Most downloaded sounds during the last week">Trending sounds</h3>
<div class="bw-carousel-container" data-carousel-type="adaptive">
<div class="bw-carousel-wrapper" style="margin-left: -15px">
<div class="bw-carousel with-dots dots-distance-1">
Expand All @@ -85,7 +91,7 @@ <h3 class="v-spacing-4 v-spacing-top-4" title="Most downloaded sounds during the
{% if trending_new_sound_ids %}
{% cache 300 bw_front_page_trending_new_sounds %}
<section class="v-spacing-3">
<h3 class="v-spacing-4 v-spacing-top-4" title="Most downloaded sounds created in the last week">Trending new sounds</h3>
<h3 class="v-spacing-4 v-spacing-top-3" title="Most downloaded sounds created in the last week">Trending new sounds</h3>
<div class="bw-carousel-container" data-carousel-type="adaptive">
<div class="bw-carousel-wrapper" style="margin-left: -15px">
<div class="bw-carousel with-dots dots-distance-1">
Expand All @@ -107,7 +113,7 @@ <h3 class="v-spacing-4 v-spacing-top-4" title="Most downloaded sounds created in
{% if trending_new_pack_ids %}
{% cache 300 bw_front_page_trending_new_packs %}
<section class="v-spacing-3">
<h3 class="v-spacing-4 v-spacing-top-4" title="Most downloaded pack created in the last week">Trending new packs</h3>
<h3 class="v-spacing-4 v-spacing-top-3" title="Most downloaded pack created in the last week">Trending new packs</h3>
<div class="bw-carousel-container" data-carousel-type="adaptive">
<div class="bw-carousel-wrapper" style="margin-left: -15px">
<div class="bw-carousel with-dots dots-distance-1">
Expand All @@ -122,13 +128,13 @@ <h3 class="v-spacing-4 v-spacing-top-4" title="Most downloaded pack created in t
</div>
</div>
</section>
<hr />
{% endcache %}
{% endif %}

{% if popular_searches and enable_popular_searches %}
<hr />
<section class="v-spacing-3">
<h3 class="v-spacing-4 v-spacing-top-4">Popular searches</h3>
<h3 class="v-spacing-4 v-spacing-top-3">Popular searches</h3>
<div class="bw-carousel-container">
<div class="bw-carousel-wrapper" style="margin-left: -15px">
<div class="bw-carousel with-dots">
Expand All @@ -149,96 +155,39 @@ <h3 class="v-spacing-4 v-spacing-top-4">Popular searches</h3>
</section>
<hr />
{% endif %}

</main>
<aside class="col-lg-3">
<hr class="d-lg-none v-spacing-3"/>
{% cache 300 bw_front_page_random_sound %}
{% if random_sound %}
<section class="v-spacing-3">
<h3 class="v-spacing-4 v-spacing-top-4">Guess the random sound of the day</h3>
{% with random_sound as sound %}
{% display_sound_big_no_info random_sound %}
<div id="collapsable-random-sound" class="collapsable-block bw-sound-page__information v-spacing-top-2">
<div class="row middle">
<div class="col-10 overflow-hidden">
<h4 class="padding-bottom-1"><a class="bw-link--black" href="{% url 'sound' sound.username sound.id %}">{{sound.original_filename}}</a></h4>
</div>
<div class="col-2 text-right">
<div class="text-grey">
{% if sound.similarity_state == 'OK' %}
<button title="Find similar sounds" class="btn-neutral" data-toggle="similar-sounds-modal" data-modal-activation-param="similar" data-modal-content-url="{% url 'sound-similar' sound.user.username sound.id %}?ajax=1">
{% bw_icon 'similar' %}
</button>
{% endif %}
<span class="h-spacing-left-2"></span>
<button title="Save as favorite" class="btn-neutral" data-toggle="bookmark-modal" data-modal-url="{% url 'bookmarks-add-form-for-sound' sound.id %}" data-add-bookmark-url="{% url 'add-bookmark' sound.id %}">
{% bw_icon 'bookmark' %}
</button>
</div>
</div>
</div>
<div class="middle v-spacing-top-1">{% bw_sound_stars sound False False %}<span class="text-grey h-spacing-left-1">{% if sound.num_ratings >= min_num_ratings %}Overall rating ({{ sound.num_ratings }}){% else %}Not enough ratings{% endif %}</span></div>
<div class="middle bw-sound-page__user v-spacing-top-2">
<div class="h-spacing-1">
{% bw_user_avatar sound.user.profile.locations.avatar.M.url sound.username 40 %}
</div>
<div class="h-spacing-left-1">
<a href="{% url 'account' sound.username %}">{{ sound.username | truncate_string:15 }}</a>
<p class="text-grey">{{ sound.created|date:"F jS, Y" }}</p>
</div>
{% if sound.user != request.user %}
<div class="h-spacing-left-3">
<a class="no-hover btn-inverse" href="{% url 'follow-user' sound.username %}?next={{ next_path }}">Follow</a>
</div>
{% endif %}
</div>
<div class="middle v-spacing-top-3">
{% if sound.geotag_id %}
<div>
<a href="{% url 'sound-geotag' sound.username sound.id %}">
{% bw_icon 'pin' %} {{ sound.geotag.lat|floatformat:3 }}, {{ sound.geotag.lon|floatformat:3 }}
</a>
</div>
{% if sound.pack_id or sound.remix_group.all.count %}
<div class="text-grey h-spacing-left-2 h-spacing-2">·</div>
{% endif %}
{% endif %}
{% if sound.pack_id %}
<div class="text-grey">
This sound is part of the pack <a href="{% url 'pack' sound.username sound.pack.id %}">{{ sound.pack.name}}</a>
</div>
{% if sound.remix_group.all.count %}
<div class="text-grey h-spacing-left-2 h-spacing-2">·</div>
{% endif %}
{% endif %}
{% if sound.remix_group.all.count %}
<div class="text-grey">
This sound has <a href="{% url 'sound-remixes' sound.username sound.id %}">remixes or has been remixed</a>
</div>
{% endif %}
</div>
<div class="v-spacing-top-1">
<div class="text-17 line-height-30">
{{ sound.description|replace_img|safe|linebreaks|truncatewords_html:30 }}
</div>
<div class="v-spacing-top-3">
{% for tag in sound.tag_array %}
{% bw_tag tag 1 "h-spacing-1" %}
{% endfor %}
</div>
</div>
{% if random_sound %}
<section class="v-spacing-4">
<h4 class="v-spacing-1 display-none d-lg-block">Sound of the day</h4>
<h4 class="v-spacing-1 d-lg-none">Random sound of the day</h4>
<p class="text-grey v-spacing-2">Can you guess the random sound of the day?</p>
{% with random_sound as sound %}
<div class="display-none d-lg-block">{% display_sound_small_no_info random_sound %}</div>
<div class="d-lg-none">{% display_sound_big_no_info random_sound %}</div>
<div id="collapsable-random-sound" class="collapsable-block bw-sound-page__information v-spacing-top-1 overflow-hidden">
<h5 class="ellipsis line-height-percentage-150 v-spacing-top-1">
<a class="bw-link--black" href="{% url 'sound' sound.username sound.id %}">{{ sound.original_filename }}</a>
</h5>
<div>
<a href="{% url 'account' sound.username %}">{{ sound.username|truncate_string:15 }}</a>
<br><span class="text-grey">{{ sound.created|timesince }} ago</span>
</div>
<div class="text-center v-spacing-top-2">
<span data-target="collapsable-random-sound" data-show-text="Reveal sound details" data-hide-text="Hide sound details" data-hide-on-load class="collapsable-toggle text-16"></span>
<div class="v-spacing-top-1 text-grey overflow-hidden" style="height:52px;">
{{ sound.description|striptags|safe|truncatechars_html:55 }}
</div>
{% endwith %}
</section>
</div>
<div class="text-center v-spacing-top-2">
<span data-target="collapsable-random-sound" data-show-text="Reveal sound details" data-hide-text="Hide sound details" data-hide-on-load class="collapsable-toggle"></span>
</div>
{% endwith %}
</section>
<hr class="v-spacing-3" />
{% endif %}
{% endcache %}
</main>
<aside class="col-lg-3">
<div class="v-spacing-4 d-lg-none">
<hr />
</div>
<section class="v-spacing-4">
<section class="v-spacing-3">
<h4 class="v-spacing-1">Enjoying Freesound?</h4>
<p class="text-grey v-spacing-2">Please consider donating some money. It doesn't take a large donation to help us!</p>
<div class="no-paddings offset-3 col-6 offset-lg-2 col-lg-8 offset-xl-0 col-xl-12">
Expand All @@ -258,9 +207,9 @@ <h4 class="v-spacing-1">Enjoying Freesound?</h4>
{% endcache %}
{% endif %}
</section>
<hr />
<hr class="v-spacing-3" />
{% cache 300 bw_forum_threads %}
<section class="v-padding-4">
<section class="v-spacing-top-2 v-spacing-4">
<h4 class="v-spacing-1">Hot forum threads</h4>
{% for forum in current_forum_threads %}
<article class="v-padding-2">
Expand All @@ -278,9 +227,9 @@ <h4 class="v-spacing-1">Hot forum threads</h4>
<a class="no-hover" href="{% url 'forums-hot-threads' %}"><button class="btn-inverse">More threads here</button></a>
</div>
</section>
<hr />
<hr class="v-spacing-3" />
{% endcache %}
<section class="v-padding-4">
<section class="v-spacing-top-2">
<div class="bw-front__freesound_labs_logo v-spacing-3"></div>
<p class="text-grey v-spacing-2">Freesound Labs is a directory of apps, hacks, projects, and research using Freesound. <a class="bw-link--grey" href="https://labs.freesound.org" target="_blank">Click here to learn more!</a></p>
</section>
Expand Down
2 changes: 1 addition & 1 deletion templates_bw/sounds/sound.html
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ <h4>Content warning</h4>
{% endif %}
<div class="row no-gutters {% if is_explicit %}blur{% endif %}">
<div class="col-md-8">
{% display_sound_big_no_info sound %}
{% display_sound_big_no_info_no_bookmark sound %}
<div class="bw-sound-page__information v-spacing-top-5">
{% cache 3600 bw_sound_page sound.id %}
<div class="row middle">
Expand Down

0 comments on commit 171e9cc

Please sign in to comment.