search_untube.html 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. {% load humanize %}
  2. <div>
  3. <div class="d-flex justify-content-center">
  4. <h1> Search all of UnTube
  5. {% if user.profile.open_search_new_tab %}
  6. <h6>Press <kbd>Esc</kbd> to close.</h6>
  7. {% endif %}
  8. </h1>
  9. </div>
  10. <input class="form-control me-lg-2" type="text"
  11. name="search" placeholder="Search UnTube"
  12. value="{{ search_query }}"
  13. hx-post="{% url 'search_UnTube' %}"
  14. hx-trigger="keyup changed delay:750ms"
  15. hx-target="#untube-searchbar-results"
  16. hx-include="[id='searchbar-radio-form']"
  17. hx-indicator=".htmx-indicator" autofocus onfocus="this.setSelectionRange(this.value.length,this.value.length);">
  18. <br>
  19. <div id="searchbar-radio-form">
  20. <div class="d-flex justify-content-center">
  21. <div class="form-check me-5">
  22. <input class="form-check-input" type="radio" name="search-settings" value="starts-with" id="starts-with-cb" {% if starts_with %} checked {% endif %}>
  23. <label class="form-check-label" for="starts-with-cb">
  24. Starts with
  25. </label>
  26. </div>
  27. <div class="form-check">
  28. <input class="form-check-input" type="radio" name="search-settings" value="contains" id="contains-cb" {% if contains %} checked {% endif %}>
  29. <label class="form-check-label" for="contains-cb">
  30. Contains
  31. </label>
  32. </div>
  33. </div>
  34. </div>
  35. </div>
  36. <div class="d-flex justify-content-between flex-wrap flex-md-nowrap align-items-center pt-3 pb-2 mb-3 border-bottom">
  37. <h1 class="h2">Playlists <span class="badge bg-primary rounded-pill">{{ playlists.count|default:"0" }}</span></h1>
  38. </div>
  39. <div>
  40. <div class="row row-cols-1 row-cols-md-3 g-4">
  41. {% if playlists %}
  42. {% for playlist in playlists %}
  43. <div class="col">
  44. <div class="card" style="background-color: #1A4464;">
  45. <a style="background-color: #1A4464;" href="{% url 'playlist' playlist.playlist_id %}" class="list-group-item list-group-item-action" aria-current="true">
  46. <div class="card-body text-white">
  47. <h5 class="card-title">
  48. {{ playlist.name|truncatewords:"15" }}
  49. {% if playlist.is_private_on_yt %}<small><span class="badge bg-light text-dark">Private</span></small> {% endif %}
  50. {% if playlist.is_from_yt %}<small><span class="badge bg-danger text-dark">YT</span></small> {% endif %}
  51. </h5>
  52. <p class="card-text">
  53. {% if playlist.description %}
  54. {{ playlist.description|truncatewords:"15" }}
  55. {% else %}
  56. No description
  57. {% endif %}
  58. </p>
  59. <small>
  60. <span class="badge bg-primary rounded-pill">{{ playlist.video_count }} views</span>
  61. <span class="badge bg-primary rounded-pill">{{ playlist.playlist_duration }} </span>
  62. </small>
  63. </div>
  64. </a>
  65. </div>
  66. </div>
  67. {% endfor %}
  68. {% else %}
  69. <h5 class="text-white align-content-center">Nothing found :(</h5>
  70. {% endif %}
  71. </div>
  72. </div>
  73. <div class="d-flex justify-content-between flex-wrap flex-md-nowrap align-items-center pt-3 pb-2 mb-3 border-bottom">
  74. <h1 class="h2">Videos <span class="badge bg-primary rounded-pill">{{ videos_count }}</span></h1>
  75. </div>
  76. <div>
  77. <div class="row row-cols-1 row-cols-md-3 g-4">
  78. {% if videos %}
  79. {% for video in videos %}
  80. <div class="col">
  81. <div class="card" style="background-color: #1A4464;">
  82. <div class="card-body">
  83. <h5 class="card-title text-light">
  84. {{ video.name|truncatewords:"15" }}<br>
  85. <small>
  86. <a class="badge bg-white text-black-50" href="{% url 'playlist' video.playlist.playlist_id %}">{{ video.playlist.name }}</a>
  87. <span class="badge bg-dark text-white-50">{{ video.duration }}</span>
  88. </small>
  89. {% if video.is_unavailable_on_yt %}<small><span class="badge bg-light text-dark">Private</span></small> {% endif %}
  90. {% if video.has_cc %}<small><span class="badge bg-danger text-dark">CC</span></small> {% endif %}
  91. </h5>
  92. <br>
  93. <span class="d-flex justify-content-center">
  94. <a href="https://www.youtube.com/watch?v={{ video.video_id }}" class="btn btn-info me-1" target="_blank" id="share_link" style=""><i class="fas fa-external-link-alt" aria-hidden="true"></i></a>
  95. <input class="form-control me-1 visually-hidden" id="video-{{ video.video_id }}" value="https://www.youtube.com/watch?v={{ video.video_id }}">
  96. <button class="copy-btn btn btn-success me-1" data-clipboard-target="#video-{{ video.video_id }}">
  97. <i class="far fa-copy" aria-hidden="true"></i>
  98. </button>
  99. <button class="btn btn-dark" type="button" hx-get="{% url 'mark_video_favorite' video.playlist.playlist_id video.video_id %}" hx-target="#video-{{ forloop.counter }}-fav">
  100. <div id="video-{{ forloop.counter }}-fav">
  101. {% if video.is_favorite %}
  102. <i class="fas fa-heart"></i>
  103. {% else %}
  104. <i class="far fa-heart"></i>
  105. {% endif %}
  106. </div>
  107. </button>
  108. </span>
  109. </div>
  110. </div>
  111. </div>
  112. {% endfor %}
  113. {% else %}
  114. <h5 class="text-white align-content-center">Nothing found :(</h5>
  115. {% endif %}
  116. </div>
  117. </div>
  118. <br>