search_untube_page.html 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. {% extends 'base.html' %}
  2. {% load humanize %}
  3. {% load static %}
  4. {% block content %}
  5. <br>
  6. <script>
  7. window.onkeydown = function( event ) {
  8. if ( event.keyCode === 27 ) {
  9. window.close(); // closes current tab
  10. }
  11. };
  12. </script>
  13. <div class="d-flex justify-content-center">
  14. <h1> Search all of UnTube
  15. {% if user.profile.open_search_new_tab %}<h6>Press <kbd>Esc</kbd> to close.</h6>{% endif %}
  16. </h1>
  17. </div>
  18. <div id="search-playlist-form">
  19. <input class="form-control me-lg-2" type="text"
  20. id="untubeSearchBar"
  21. name="search" placeholder="Search UnTube"
  22. hx-post="{% url 'search_UnTube' %}"
  23. hx-trigger="keyup changed delay:700ms"
  24. hx-target="#untube-searchbar-results"
  25. hx-include="[id='search-playlist-form']"
  26. hx-indicator="#spinner" autofocus>
  27. <br>
  28. <div class="row d-flex justify-content-center">
  29. <div class="col-md-6">
  30. <select class="visually-hidden" onchange="triggerSubmit()"
  31. id="choices-multiple-remove-button" name="playlist-tags" placeholder="Add playlist tags to search within" multiple>
  32. {% for tag in user.playlist_tags.all %}
  33. <option value="{{ tag.name }}" hx-post="{% url 'search_UnTube' %}">{{ tag.name }}</option>
  34. {% endfor %}
  35. </select>
  36. </div>
  37. </div>
  38. <br>
  39. <div class="d-flex justify-content-center">
  40. <div class="form-check me-5">
  41. <input hx-post="{% url 'search_UnTube' %}"
  42. hx-trigger="click"
  43. hx-target="#untube-searchbar-results"
  44. hx-include="[id='search-playlist-form']"
  45. hx-indicator="#spinner"
  46. class="form-check-input" type="radio" name="search-settings" value="starts-with" id="starts-with-cb" checked>
  47. <label class="form-check-label" for="starts-with-cb">
  48. Starts with
  49. </label>
  50. </div>
  51. <div class="form-check">
  52. <input hx-post="{% url 'search_UnTube' %}"
  53. hx-trigger="click"
  54. hx-target="#untube-searchbar-results"
  55. hx-include="[id='search-playlist-form']"
  56. hx-indicator="#spinner"
  57. class="form-check-input" type="radio" name="search-settings" value="contains" id="contains-cb">
  58. <label class="form-check-label" for="contains-cb">
  59. Contains
  60. </label>
  61. </div>
  62. </div>
  63. </div>
  64. <div id="spinner" class="htmx-indicator d-flex justify-content-center p-3">
  65. <div class="spinner-border text-light" role="status">
  66. </div>
  67. </div>
  68. <div id="untube-searchbar-results">
  69. {% if user.profile.playlists.all %}
  70. <div class="d-flex justify-content-between flex-wrap flex-md-nowrap align-items-center pt-3 pb-2 mb-3 border-bottom">
  71. <h1 class="h2">All Playlists <span class="badge bg-primary rounded-pill">{{ user.profile.playlists.count }}</span></h1>
  72. </div>
  73. <div>
  74. <div class="row row-cols-1 row-cols-md-3 g-4">
  75. {% for playlist in user.profile.playlists.all %}
  76. <div class="col">
  77. <div class="card" style="background-color: #1A4464;">
  78. <a style="background-color: #1A4464;" href="{% url 'playlist' playlist.playlist_id %}" class="list-group-item list-group-item-action" aria-current="true">
  79. <div class="card-body text-white">
  80. <h5 class="card-title">
  81. {{ playlist.name|truncatewords:"15" }}
  82. {% if playlist.is_private_on_yt %}<small><span class="badge bg-light text-dark">Private</span></small> {% endif %}
  83. {% if playlist.is_from_yt %}<small><span class="badge bg-danger text-dark">YT</span></small> {% endif %}
  84. </h5>
  85. <p class="card-text">
  86. {% if playlist.description %}
  87. {{ playlist.description|truncatewords:"15" }}
  88. {% else %}
  89. No description
  90. {% endif %}
  91. </p>
  92. {% if playlist.tags.all %}
  93. <p class="card-text">
  94. <span class="d-flex justify-content-start flex-wrap">
  95. <small>
  96. <span style="color: #eed868;" class="me-lg-1 mb-lg-1">
  97. <i class="fas fa-tags"></i>
  98. </span>
  99. </small>
  100. {% for tag in playlist.tags.all %}
  101. <span class="badge rounded-pill bg-info mb-lg-1 me-lg-1 text-black-50">
  102. {{ tag.name }}
  103. </span>
  104. {% endfor %}
  105. </span>
  106. </p>
  107. {% endif %}
  108. <small>
  109. <span class="badge bg-primary rounded-pill">{{ playlist.video_count }} views</span>
  110. <span class="badge bg-primary rounded-pill">{{ playlist.playlist_duration }} </span>
  111. </small>
  112. </div>
  113. </a>
  114. </div>
  115. </div>
  116. {% endfor %}
  117. </div>
  118. </div>
  119. {% endif %}
  120. </div>
  121. {% endblock %}