base.html 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412
  1. {% load static %}
  2. <!doctype html>
  3. <html lang="en">
  4. <head>
  5. <meta charset="utf-8">
  6. <meta name="viewport" content="width=device-width, initial-scale=1">
  7. <meta name="description" content="">
  8. <meta name="author" content="Mark Otto, Jacob Thornton, and Bootstrap contributors">
  9. <meta name="generator" content="Hugo 0.83.1">
  10. <title>UnTube</title>
  11. <style type="text/css">
  12. #btn-back-to-top {
  13. position: fixed;
  14. bottom: 20px;
  15. right: 20px;
  16. display: none;
  17. z-index: 4;
  18. }
  19. .big-checkbox {width: 30px; height: 30px;}
  20. </style>
  21. <script src="https://unpkg.com/htmx.org@1.4.1"></script>
  22. <script src="https://unpkg.com/htmx.org/dist/ext/class-tools.js"></script>
  23. <script src="https://cdn.jsdelivr.net/npm/clipboard@2.0.8/dist/clipboard.min.js"></script>
  24. <link href="https://fonts.googleapis.com/css2?family=Fredoka+One&family=Open+Sans&display=swap" rel="stylesheet">
  25. <script src="https://kit.fontawesome.com/5baac7e9b7.js" crossorigin="anonymous"></script>
  26. <!-- Bootstrap core CSS
  27. <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.1/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-+0n0xVW2eSR5OomGNYDnhzAbDsOXxcvSN1TPprVMTNDbiYZCxYbOOl7+AMvyTG2x" crossorigin="anonymous">
  28. -->
  29. <link href="{% static 'bootstrap5.0.1/css/bootstrap.min.css' %}" rel="stylesheet">
  30. </head>
  31. <body class="bg-dark text-white" style="font-family: 'Fredoka One'">
  32. <nav class="navbar navbar-expand-lg navbar-dark bg-dark sticky-top">
  33. <div class="container-fluid">
  34. <a class="navbar-brand" href="{% url 'home' %}"><h3>UnTube</h3></a>
  35. <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
  36. <span class="navbar-toggler-icon"></span>
  37. </button>
  38. <div class="collapse navbar-collapse" id="navbarSupportedContent">
  39. <ul class="navbar-nav me-auto mb-2 mb-lg-0">
  40. <li class="nav-item">
  41. <a class="nav-link" aria-current="page" href="{% url 'home' %}">Dashboard</a>
  42. </li>
  43. <li class="nav-item">
  44. <a class="nav-link" href="{% url 'all_playlists' 'home' %}">Library</a>
  45. </li>
  46. <li class="nav-item dropdown">
  47. <a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" data-bs-toggle="dropdown" aria-expanded="false">
  48. Quick View
  49. </a>
  50. <ul class="dropdown-menu" aria-labelledby="navbarDropdown">
  51. <li><a class="dropdown-item" href="{% url 'all_playlists' 'favorites' %}">Favorites</a></li>
  52. <li><a class="dropdown-item" href="{% url 'all_playlists' 'watching' %}">Watching</a></li>
  53. <li><a class="dropdown-item" href="{% url 'all_playlists' 'watching' %}">On Hold</a></li>
  54. <li><a class="dropdown-item" href="{% url 'all_playlists' 'watching' %}">YouTube</a></li>
  55. <li><a class="dropdown-item" href="{% url 'all_playlists' 'watching' %}">UnTube</a></li>
  56. <li><hr class="dropdown-divider"></li>
  57. <li><a class="dropdown-item" href="{% url 'all_playlists' 'all' %}">View all</a></li>
  58. </ul>
  59. </li>
  60. <li class="nav-item">
  61. <a class="nav-link" href="{% url 'all_playlists' 'home' %}">Manage</a>
  62. </li>
  63. <li class="nav-item">
  64. <a class="nav-link" data-bs-toggle="offcanvas" href="#offcanvasExample" role="button" aria-controls="offcanvasExample">
  65. Settings </a>
  66. </li>
  67. </ul>
  68. <div class="navbar-nav justify-content-end">
  69. <input class="form-control me-lg-2 bg-dark mb-1" id="unTubeSearchBar" type="text" placeholder="Search UnTube">
  70. <button type="button" class="btn btn-primary visually-hidden" id="unTubeSearchBtn" data-bs-toggle="modal" data-bs-target="#unTubeSearchBarResultsModal">
  71. Launches search model
  72. </button>
  73. </div>
  74. <a class="btn btn-outline-danger mb-1" href="{% url 'log_out' %}">
  75. Log out
  76. </a>
  77. </div>
  78. </div>
  79. </nav>
  80. <div class="container-fluid">
  81. <div class="row">
  82. <!--
  83. <nav class="col-md-3 ms-sm-auto col-lg-2 px-md-4">
  84. <div class="position-sticky pt-3">
  85. <ul class="nav flex-column">
  86. <li class="nav-item">
  87. <a class="nav-link" href="{% url 'all_playlists' 'home' %}">
  88. Library
  89. </a>
  90. </li>
  91. <li class="nav-item">
  92. <a class="nav-link active" aria-current="page" href="#">
  93. Add a playlist
  94. </a>
  95. </li>
  96. <li class="nav-item">
  97. <a class="nav-link" href="#">
  98. Create a playlist
  99. </a>
  100. </li>
  101. </ul>
  102. <h6 class="sidebar-heading d-flex justify-content-between align-items-center px-3 mt-4 mb-1">
  103. <span>Top 3 Playlists</span>
  104. <a class="link-secondary" href="#collapseExample" aria-label="Add a new report" data-bs-toggle="collapse" role="button" aria-expanded="false" aria-controls="collapseExample">
  105. </a>
  106. </h6>
  107. <ul class="nav flex-column mb-2">
  108. <li class="nav-item">
  109. {% for pl in user_playlists|slice:"0:3" %}
  110. <a class="nav-link" href="{% url 'playlist' pl.playlist_id %}">
  111. {{ pl.name }}
  112. </a>
  113. {% if forloop.last %}
  114. {% endif %}
  115. {% empty %}
  116. <span class="nav-link link-secondary">
  117. None
  118. </span>
  119. {% endfor %}
  120. </li>
  121. </ul>
  122. <h6 class="sidebar-heading d-flex justify-content-between align-items-center px-3 mt-4 mb-1">
  123. <span>Watching</span>
  124. </h6>
  125. <ul class="nav flex-column mb-2">
  126. <li class="nav-item">
  127. {% for pl in playlist_watching|slice:"0:3" %}
  128. <a class="nav-link" href="{% url 'playlist' pl.playlist_id %}">
  129. <span data-feather="file-text"></span>
  130. {{ pl.name }}
  131. </a>
  132. {% empty %}
  133. <span class="nav-link link-secondary">
  134. None. Add some!
  135. </span>
  136. {% endfor %}
  137. </li>
  138. </ul>
  139. <h6 class="sidebar-heading d-flex justify-content-between align-items-center px-3 mt-4 mb-1">
  140. <span>Logged in as <b>{{ user.username }}</b></span>
  141. </h6>
  142. </div>
  143. </nav>
  144. -->
  145. <!-- <main class="col-md-9 ms-sm-auto col-lg-10 px-md-4">-->
  146. <main class="ms-lg-auto px-lg-5">
  147. {% block content %}
  148. {% endblock %}
  149. <!-- Button trigger modal -->
  150. <!-- Modal -->
  151. <div class="modal fade bg-dark" id="unTubeSearchBarResultsModal" tabindex="-1" aria-labelledby="unTubeSearchBarResultsModalLabel" aria-hidden="true">
  152. <div class="modal-dialog modal-xl modal-dialog-scrollable bg-dark">
  153. <div class="modal-content bg-dark">
  154. <div class="modal-body bg-dark">
  155. <div id="untube-searchbar-results">
  156. <input class="form-control me-lg-2 bg-dark text-white" id="unTubeSearchBar" type="text"
  157. name="search" placeholder="Search UnTube"
  158. hx-post="{% url 'search_UnTube' %}"
  159. hx-trigger="keyup changed delay:500ms"
  160. hx-target="#untube-searchbar-results"
  161. hx-include="[id='searchbar-radio-form']"
  162. hx-indicator=".htmx-indicator" autofocus>
  163. <br>
  164. <div id="searchbar-radio-form">
  165. <div class="d-flex justify-content-center">
  166. <div class="form-check me-5">
  167. <input class="form-check-input" type="radio" name="search-settings" value="starts-with" id="starts-with-cb" checked>
  168. <label class="form-check-label" for="starts-with-cb">
  169. Starts with
  170. </label>
  171. </div>
  172. <div class="form-check">
  173. <input class="form-check-input" type="radio" name="search-settings" value="contains" id="contains-cb">
  174. <label class="form-check-label" for="contains-cb">
  175. Contains
  176. </label>
  177. </div>
  178. </div>
  179. </div>
  180. </div>
  181. </div>
  182. </div>
  183. </div>
  184. </div>
  185. </main>
  186. </div>
  187. </div>
  188. <div class="offcanvas offcanvas-end text-white-50" style="background-color: #181A1B" tabindex="-1" id="offcanvasExample" aria-labelledby="offcanvasExampleLabel">
  189. <div class="offcanvas-header text-white">
  190. <h2 class="offcanvas-title" id="offcanvasExampleLabel">Settings</h2>
  191. <button type="button" class="btn-close text-reset" data-bs-dismiss="offcanvas" aria-label="Close"></button>
  192. </div>
  193. <div class="offcanvas-body">
  194. <div id="settings-status-div" class="text-dark">
  195. </div>
  196. <div id="settings-form">
  197. <div class="mb-3">
  198. <label for="username" class="form-label">Username</label>
  199. <input type="text" class="form-control" name="username" id="username" value="{{ user.username }}">
  200. </div>
  201. <fieldset disabled>
  202. <div class="mb-3">
  203. <label for="email" class="form-label">Email Address</label>
  204. <input type="email" class="form-control" id="email" aria-describedby="emailHelp" value="{{ user.email }}">
  205. <div id="emailHelp" class="form-text">This is the google account you logged in with.</div>
  206. </div>
  207. <div class="mb-3">
  208. <label for="fullname" class="form-label">Full Name</label>
  209. <input type="text" class="form-control" id="fullname" value="{{ user.get_full_name }}">
  210. </div>
  211. <div class="mb-3">
  212. <label for="ytchannelid" class="form-label">YouTube Channel ID</label>
  213. <input type="text" class="form-control" id="ytchannelid" aria-describedby="emailHelp" value="{{ user.profile.yt_channel_id }}">
  214. </div>
  215. <div class="mb-3">
  216. <label for="accesstoken" class="form-label">Access Token</label>
  217. <input type="text" class="form-control" id="accesstoken" value="{{ user.profile.access_token }}">
  218. </div>
  219. <div class="mb-3">
  220. <label for="refreshtoken" class="form-label">Refresh Token</label>
  221. <input type="text" class="form-control" id="refreshtoken" value="{{ user.profile.refresh_token }}">
  222. </div>
  223. <div class="mb-3">
  224. <label for="expiresat" class="form-label">Expires At</label>
  225. <input type="datetime-local" class="form-control" id="expiresat" value="{{ user.profile.expires_at }}">
  226. </div>
  227. </fieldset>
  228. <div class="mb-3 form-check form-switch">
  229. <input class="form-check-input" name="auto refresh playlists" type="checkbox" id="flexSwitchCheckDefault">
  230. <label class="form-check-label" for="flexSwitchCheckDefault">Automatically refresh playlists on visit</label>
  231. </div>
  232. <div class="mb-3 form-check form-switch">
  233. <input class="form-check-input" name="hide videos" type="checkbox" id="flexSwitchCheckChecked" checked>
  234. <label class="form-check-label" for="flexSwitchCheckChecked">Hide deleted/private videos</label>
  235. </div>
  236. <div class="mb-3 form-check form-switch">
  237. <input class="form-check-input" name="confirm before deleting" type="checkbox" id="flexSwitchCheckChecked" checked>
  238. <label class="form-check-label" for="flexSwitchCheckChecked">Confirm before deleting</label>
  239. </div>
  240. </div>
  241. <button type="button" hx-post="{% url 'update_settings' %}" hx-include="[id='settings-form']" hx-target="#settings-status-div" class="btn btn-success">Save</button>
  242. <a class="btn btn-outline-danger" href="{% url 'delete_account' %}">Delete account</a>
  243. <br>
  244. </div>
  245. </div>
  246. <div class="offcanvas offcanvas-start" style="background-color: #181A1B" tabindex="-1" id="offcanvasForVideoNotes" aria-labelledby="offcanvasForVideoNotes">
  247. <div id="video-notes">
  248. </div>
  249. </div>
  250. <button
  251. type="button"
  252. class="btn btn-danger btn-floating btn-lg"
  253. id="btn-back-to-top"
  254. >
  255. </button>
  256. <br>
  257. <script>
  258. <!-- for htmx to send csrf_token with every post request -->
  259. document.body.addEventListener('htmx:configRequest', (event) => {
  260. event.detail.headers['X-CSRFToken'] = '{{ csrf_token }}';
  261. })
  262. var clipboard = new ClipboardJS('.copy-btn');
  263. // Get the input field
  264. var input = document.getElementById("unTubeSearchBar");
  265. // Execute a function when the user releases a key on the keyboard
  266. input.addEventListener("click", function(event) {
  267. document.getElementById("unTubeSearchBtn").click();
  268. });
  269. document.getElementById('select-all-btn').onclick = function() {
  270. document.getElementById('select-all-btn').style.display = "none";
  271. document.getElementById('deselect-all-btn').style.display = "block";
  272. var checkboxes = document.getElementsByClassName('video-checkboxes');
  273. for (var checkbox of checkboxes) {
  274. checkbox.checked = true;
  275. }
  276. }
  277. document.getElementById('deselect-all-btn').onclick = function() {
  278. document.getElementById('deselect-all-btn').style.display = "none";
  279. document.getElementById('select-all-btn').style.display = "block";
  280. var checkboxes = document.getElementsByClassName('video-checkboxes');
  281. for (var checkbox of checkboxes) {
  282. checkbox.checked = false;
  283. }
  284. }
  285. function row1_hide() {
  286. document.getElementById("row1").style.display = "none";
  287. var checkboxes = document.getElementsByClassName('video-checkboxes'); //Cache the collection here, so that even a new element added with the same class later we can avoid querying this again by using the cached collection.
  288. for(var i=0, len=checkboxes.length; i<len; i++)
  289. {
  290. checkboxes[i].style.display = "block";
  291. }
  292. document.getElementById("row2").style.display = "block";
  293. }
  294. function row1_show() {
  295. document.getElementById("row1").style.display = "block";
  296. var checkboxes = document.getElementsByClassName('video-checkboxes'); //Cache the collection here, so that even a new element added with the same class later we can avoid querying this again by using the cached collection.
  297. for(var i=0, len=checkboxes.length; i<len; i++)
  298. {
  299. checkboxes[i].style.display = "none";
  300. }
  301. document.getElementById("row2").style.display = "none";
  302. }
  303. function select_all_checkboxes(source) {
  304. checkboxes = document.getElementsByClassName('big-checkbox');
  305. for(var i=0, n=checkboxes.length;i<n;i++) {
  306. checkboxes[i].checked = source.checked;
  307. }
  308. }
  309. //Get the button
  310. let mybutton = document.getElementById("btn-back-to-top");
  311. // When the user scrolls down 20px from the top of the document, show the button
  312. window.onscroll = function () {
  313. scrollFunction();
  314. };
  315. function scrollFunction() {
  316. if (
  317. document.body.scrollTop > 550 ||
  318. document.documentElement.scrollTop > 550
  319. ) {
  320. mybutton.style.display = "block";
  321. } else {
  322. mybutton.style.display = "none";
  323. }
  324. }
  325. // When the user clicks on the button, scroll to the top of the document
  326. mybutton.addEventListener("click", backToTop);
  327. function backToTop() {
  328. document.body.scrollTop = 0;
  329. document.documentElement.scrollTop = 0;
  330. }
  331. </script>
  332. <script type="text/javascript" src="{% static 'jquery3.6.0/js/jquery-3.6.0.min.js' %}"></script>
  333. <!--
  334. <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.1/dist/js/bootstrap.bundle.min.js" integrity="sha384-gtEjrD/SeCtmISkJkNUaaKMoLD0//ElJ19smozuHV6z3Iehds+3Ulb9Bn9Plx0x4" crossorigin="anonymous"></script>
  335. -->
  336. <script type="text/javascript" src="{% static 'bootstrap5.0.1/js/bootstrap.bundle.js' %}"></script>
  337. <!--
  338. <script src="https://cdn.jsdelivr.net/npm/feather-icons@4.28.0/dist/feather.min.js" integrity="sha384-uO3SXW5IuS1ZpFPKugNNWqTZRRglnUJK6UAZ/gxOX80nxEkN9NcGZTftn6RzhGWE" crossorigin="anonymous"></script>
  339. <script src="https://cdn.jsdelivr.net/npm/chart.js@2.9.4/dist/Chart.min.js" integrity="sha384-zNy6FEbO50N+Cg5wap8IKA4M/ZnLJgzc6w2NqACZaK0u0FXfOWRRJOnQtpZun8ha" crossorigin="anonymous"></script>
  340. -->
  341. </body>
  342. </html>