You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

147 lines
4.9 KiB

4 years ago
4 years ago
4 years ago
  1. {% extends "bootstrap/base.html" %}
  2. {% block title %}Read TI Later{% endblock %}
  3. {% block styles %}
  4. {{super()}}
  5. <link rel="stylesheet" href="{{url_for('.static', filename='style.css')}}">
  6. {% endblock %}
  7. {% block navbar %}
  8. <div id="navbar" class="navbar navbar-expand-lg sticky-top navbar-dark bg-dark">
  9. <div class="navbar-brand">Read TI Later</div>
  10. <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarNavDropdown"
  11. aria-controls="navbarNavDropdown" aria-expanded="false" aria-label="Toggle navigation">
  12. <span class="navbar-toggler-icon"></span>
  13. </button>
  14. <div class="collapse navbar-collapse" id="navbarNavDropdown">
  15. <ul class="navbar-nav">
  16. <li class="nav-item">
  17. <a class="nav-link" href="{{ url_for('index') }}">My List</a>
  18. </li>
  19. <li class="nav-item">
  20. <a class="nav-link" href="{{ url_for('archived') }}">Archived</a>
  21. </li>
  22. </ul>
  23. <form class="form-inline ml-auto">
  24. <a class="btn btn-primary" href="/logout" role="button">Logout</a>
  25. </form>
  26. </div>
  27. </div>
  28. {% endblock %}
  29. {% block content %}
  30. <div class="wrapper">
  31. <!-- Sidebar -->
  32. <div id="sidebar">
  33. <ul class="list-unstyled components">
  34. {% if request.path == url_for('index') %}
  35. <li class="nav-item active">
  36. {% else %}
  37. <li class="nav-item">
  38. {% endif %}
  39. <a href="{{ url_for('index') }}">
  40. <svg
  41. width="24"
  42. height="24"
  43. fill="none"
  44. stroke="currentColor"
  45. stroke-width="2"
  46. stroke-linecap="round"
  47. stroke-linejoin="round"
  48. style="height: 1rem; vertical-align: middle; margin-bottom: 4px;">
  49. <use xlink:href="{{url_for('.static', filename='feather-sprite.svg')}}#home"/>
  50. </svg>My List
  51. </a>
  52. </li>
  53. {% if request.path == url_for('archived') %}
  54. <li class="nav-item active">
  55. {% else %}
  56. <li class="nav-item">
  57. {% endif %}
  58. <a href="{{ url_for('archived') }}"><svg
  59. width="24"
  60. height="24"
  61. fill="none"
  62. stroke="currentColor"
  63. stroke-width="2"
  64. stroke-linecap="round"
  65. stroke-linejoin="round"
  66. style="height: 1rem; vertical-align: middle; margin-bottom: 4px;">
  67. <use xlink:href="{{url_for('.static', filename='feather-sprite.svg')}}#archive"/>
  68. </svg>Archived</a>
  69. </li>
  70. </ul>
  71. </div>
  72. <!-- Page Content -->
  73. <div id="content">
  74. <div id="error-alert" class="alert alert-danger" role="alert" style="display: none;">
  75. This is a danger alert—check it out!
  76. </div>
  77. <form>
  78. <div class="row justify-content-center">
  79. <div class="col-lg-8">
  80. <label for="formGroupExampleInput4">URL</label>
  81. <input id="link-form" type="text" class="form-control" placeholder="https://example.com">
  82. <br>
  83. <button type="button" class="btn btn-primary" onclick="addUrl();">Add</button>
  84. <br>
  85. <br>
  86. </div>
  87. <div style="position:fixed; bottom: 20px;">
  88. <p style="text-align: center;">Would you rather save on the go? Try our bookmarklet!</p>
  89. <code>
  90. javascript:(function(){var%20url%20=%20location.href;var%20otherWindow=window.open('about:blank','_blank');otherWindow.opener=null;otherWindow.location='{{ request.url_root }}add?close=1&url='+encodeURIComponent(url);})();
  91. </code>
  92. </div>
  93. </div>
  94. </form>
  95. </div>
  96. </div>
  97. {% endblock %}
  98. {% block scripts %}
  99. {{ super() }}
  100. <script>
  101. function addUrl() {
  102. url = $('#link-form').val();
  103. if (url.trim().length === 0) {
  104. showError('URL is required');
  105. return false;
  106. }
  107. $.ajax({
  108. url: '/add',
  109. method: 'POST',
  110. data: { "url": url },
  111. success: function(data) {
  112. if (data !== 'Error')
  113. window.location.reload();
  114. else
  115. showError('URL cannot be empty');
  116. }
  117. });
  118. }
  119. function showError(error) {
  120. hideSuccess();
  121. $('#error-alert').text(error);
  122. $('#error-alert').show();
  123. }
  124. function showArticle(message) {
  125. hideError();
  126. $('#article').html(message);
  127. $('#article img').css('max-width', '100%')
  128. $('#article').show();
  129. }
  130. function hideError(error) {
  131. $('#error-alert').hide();
  132. }
  133. function hideArticle(error) {
  134. $('#article').hide();
  135. }
  136. </script>
  137. {% endblock %}