base.html 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246
  1. {% load i18n static %}<!DOCTYPE html>
  2. {% get_current_language as LANGUAGE_CODE %}{% get_current_language_bidi as LANGUAGE_BIDI %}
  3. <html lang="{{ LANGUAGE_CODE|default:"en-us" }}" {% if LANGUAGE_BIDI %}dir="rtl"{% endif %}>
  4. <head>
  5. <title>{% block title %}{% endblock %} | ArchiveBox</title>
  6. <link rel="stylesheet" type="text/css" href="{% block stylesheet %}{% static "admin/css/base.css" %}{% endblock %}">
  7. {% block extrastyle %}{% endblock %}
  8. {% if LANGUAGE_BIDI %}<link rel="stylesheet" type="text/css" href="{% block stylesheet_rtl %}{% static "admin/css/rtl.css" %}{% endblock %}">{% endif %}
  9. {% block extrahead %}{% endblock %}
  10. {% block responsive %}
  11. <meta name="viewport" content="user-scalable=no, width=device-width, initial-scale=1.0, maximum-scale=1.0">
  12. <link rel="stylesheet" type="text/css" href="{% static "admin/css/responsive.css" %}">
  13. {% if LANGUAGE_BIDI %}<link rel="stylesheet" type="text/css" href="{% static "admin/css/responsive_rtl.css" %}">{% endif %}
  14. {% endblock %}
  15. {% block blockbots %}<meta name="robots" content="NONE,NOARCHIVE">{% endblock %}
  16. <link rel="stylesheet" type="text/css" href="{% static "admin.css" %}">
  17. </head>
  18. {% load i18n %}
  19. <body class="{% if is_popup %}popup {% endif %}{% block bodyclass %}{% endblock %}"
  20. data-admin-utc-offset="{% now "Z" %}">
  21. <style nonce="{{nonce}}">
  22. /* Loading Progress Bar */
  23. #progress {
  24. position: absolute;
  25. z-index: 1000;
  26. top: 0px;
  27. left: -6px;
  28. width: 2%;
  29. opacity: 1;
  30. height: 2px;
  31. background: #1a1a1a;
  32. border-radius: 1px;
  33. transition: width 4s ease-out, opacity 400ms linear;
  34. }
  35. @-moz-keyframes bugfix { from { padding-right: 1px ; } to { padding-right: 0; } }
  36. </style>
  37. <script>
  38. // Page Loading Bar
  39. window.loadStart = function(distance) {
  40. var distance = distance || 0;
  41. // only add progrstess bar if not already present
  42. if (django.jQuery("#loading-bar").length == 0) {
  43. django.jQuery("body").add("<div id=\"loading-bar\"></div>");
  44. }
  45. if (django.jQuery("#progress").length === 0) {
  46. django.jQuery("body").append(django.jQuery("<div></div>").attr("id", "progress"));
  47. let last_distance = (distance || (30 + (Math.random() * 30)))
  48. django.jQuery("#progress").width(last_distance + "%");
  49. setInterval(function() {
  50. last_distance += Math.random()
  51. django.jQuery("#progress").width(last_distance + "%");
  52. }, 1000)
  53. }
  54. };
  55. window.loadFinish = function() {
  56. django.jQuery("#progress").width("101%").delay(200).fadeOut(400, function() {
  57. django.jQuery(this).remove();
  58. });
  59. };
  60. window.loadStart();
  61. window.addEventListener('beforeunload', function() {window.loadStart(27)});
  62. document.addEventListener('DOMContentLoaded', function() {window.loadFinish()});
  63. </script>
  64. <!-- Container -->
  65. <div id="container">
  66. {% if not is_popup %}
  67. <!-- Header -->
  68. <div id="header">
  69. <div id="branding">
  70. <h1 id="site-name">
  71. <a href="{% url 'Home' %}">
  72. <img src="{% static 'archive.png' %}" id="logo">
  73. ArchiveBox
  74. </a>
  75. </h1>
  76. </div>
  77. {% block usertools %}
  78. {% if has_permission %}
  79. <div id="user-tools">
  80. <a href="{% url 'admin:Add' %}">Add ➕</a> /
  81. <a href="{% url 'Home' %}">Snapshots</a> /
  82. <a href="/admin/core/tag/">Tags</a> /
  83. <a href="/admin/auth/user/">Users</a> /
  84. <a href="{% url 'Docs' %}">Docs</a>
  85. &nbsp; &nbsp;
  86. {% block welcome-msg %}
  87. {% trans 'User' %}
  88. <strong>{% firstof user.get_short_name user.get_username %}</strong> &nbsp; &nbsp;
  89. {% endblock %}
  90. {% block userlinks %}
  91. {% if user.is_active and user.is_staff %}
  92. {% url 'django-admindocs-docroot' as docsroot %}
  93. {% if docsroot %}
  94. <a href="{{ docsroot }}">{% trans 'Documentation' %}</a> /
  95. {% endif %}
  96. {% endif %}
  97. {% if user.has_usable_password %}
  98. <a href="{% url 'admin:password_change' %}">{% trans 'Change password' %}</a> /
  99. {% endif %}
  100. <a href="{% url 'admin:logout' %}">{% trans 'Log out' %}</a>
  101. |
  102. <a> <span id="snapshotListView" style="cursor: pointer">☰</span> </a>
  103. <a> <span id="snapshotGridView"style="letter-spacing: -.4em; cursor: pointer;">⣿⣿</span></a>
  104. {% endblock %}
  105. </div>
  106. {% endif %}
  107. {% endblock %}
  108. {% block nav-global %}{% endblock %}
  109. </div>
  110. <!-- END Header -->
  111. {% block breadcrumbs %}
  112. <div class="breadcrumbs">
  113. <a href="{% url 'admin:index' %}">{% trans 'Home' %}</a>
  114. {% if title %} &rsaquo; {{ title }}{% endif %}
  115. </div>
  116. {% endblock %}
  117. {% endif %}
  118. {% block messages %}
  119. {% if messages %}
  120. <ul class="messagelist">{% for message in messages %}
  121. <li{% if message.tags %} class="{{ message.tags }}"{% endif %}>{{ message|capfirst }}</li>
  122. {% endfor %}</ul>
  123. {% endif %}
  124. {% endblock messages %}
  125. <!-- Content -->
  126. <div id="content" class="{% block coltype %}colM{% endblock %}">
  127. {% block pretitle %}{% endblock %}
  128. {% block content_title %}{# {% if title %}<h1>{{ title }}</h1>{% endif %} #}{% endblock %}
  129. {% block content %}
  130. {% block object-tools %}{% endblock %}
  131. {{ content }}
  132. {% endblock %}
  133. {% block sidebar %}{% endblock %}
  134. <br class="clear">
  135. </div>
  136. <!-- END Content -->
  137. {% block footer %}<div id="footer"></div>{% endblock %}
  138. </div>
  139. <!-- END Container -->
  140. <script>
  141. (function ($) {
  142. $.fn.reverse = [].reverse;
  143. function fix_actions() {
  144. var container = $('div.actions');
  145. if (container.find('option').length < 10) {
  146. container.find('label, button').hide();
  147. var buttons = $('<div></div>')
  148. .prependTo(container)
  149. .css('display', 'inline')
  150. .addClass('class', 'action-buttons');
  151. container.find('option:gt(0)').reverse().each(function () {
  152. const name = this.value
  153. $('<button>')
  154. .appendTo(buttons)
  155. .attr('name', this.value)
  156. .addClass('button')
  157. .text(this.text)
  158. .click(function () {
  159. container.find('select')
  160. .find(':selected').attr('selected', '').end()
  161. .find('[value=' + this.name + ']').attr('selected', 'selected');
  162. $('#changelist-form button[name="index"]').click();
  163. document.querySelector('#logo').outerHTML = '<div class="loader"></div>'
  164. });
  165. });
  166. }
  167. };
  168. function redirectWithQuery(uri){
  169. uri_query = uri + document.location.search;
  170. window.location = uri_query;
  171. };
  172. function selectSnapshotListView(){
  173. localStorage.setItem('currentSnapshotView', 'List');
  174. redirectWithQuery("{% url 'admin:core_snapshot_changelist' %}");
  175. };
  176. function selectSnapshotGridView(){
  177. localStorage.setItem('currentSnapshotView', 'Grid');
  178. redirectWithQuery("{% url 'admin:grid' %}");
  179. };
  180. function setPreferredSnapshotView(view){
  181. urlPath = window.location.pathname;
  182. if((view==="Grid") && urlPath == "{% url 'admin:core_snapshot_changelist' %}"){
  183. selectSnapshotGridView();
  184. }
  185. {% comment %}
  186. else if((view==="List") && urlPath == "{% url 'admin:grid' %}"){
  187. selectSnapshotListView();
  188. }
  189. {% endcomment %}
  190. };
  191. function setupSnapshotViews() {
  192. const preferredSnapshotView = localStorage.getItem('currentSnapshotView');
  193. setPreferredSnapshotView(preferredSnapshotView);
  194. $( document ).ready(function() {
  195. $("#snapshotListView").click(function() {
  196. selectSnapshotListView();
  197. });
  198. $("#snapshotGridView").click(function() {
  199. selectSnapshotGridView();
  200. });
  201. $('input:checkbox').change(function(){
  202. if($(this).is(':checked'))
  203. $(this).parent().parent().parent().parent().addClass('selected-card');
  204. else
  205. $(this).parent().parent().parent().parent().removeClass('selected-card')
  206. });
  207. });
  208. };
  209. $(function () {
  210. fix_actions();
  211. setupSnapshotViews();
  212. });
  213. })(django.jQuery);
  214. </script>
  215. </body>
  216. </html>