base.html 19 KB

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