From de1bd373f49c91576d5b64cd7e60b2d9f87b7f52 Mon Sep 17 00:00:00 2001 From: LeXofLeviafan Date: Sun, 25 Aug 2024 20:31:19 +0200 Subject: [PATCH] [jarun#753] migrate to Bootstrap v4 --- bukuserver/README.md | 2 +- bukuserver/bookmarklet.js | 2 +- bukuserver/server.py | 2 +- bukuserver/static/bukuserver/css/list.css | 4 ++ bukuserver/static/bukuserver/css/modal.css | 2 +- bukuserver/static/bukuserver/js/page_size.js | 24 ++++++------ .../templates/bukuserver/bookmark_create.html | 1 + .../bukuserver/bookmark_create_modal.html | 3 +- .../templates/bukuserver/bookmark_edit.html | 5 ++- .../bukuserver/bookmark_edit_modal.html | 1 + .../templates/bukuserver/bookmarklet.url | 2 +- bukuserver/templates/bukuserver/home.html | 28 +++++++------- bukuserver/templates/bukuserver/lib.html | 33 +++++++++++++--- .../templates/bukuserver/statistic.html | 38 +++++++++---------- bukuserver/templates/bukuserver/tag_edit.html | 1 + .../templates/bukuserver/tags_list.html | 6 ++- bukuserver/views.py | 9 +++-- tests/test_views.py | 8 ++-- 18 files changed, 100 insertions(+), 71 deletions(-) create mode 100644 bukuserver/static/bukuserver/css/list.css diff --git a/bukuserver/README.md b/bukuserver/README.md index b3b8f849..c8dc92e5 100644 --- a/bukuserver/README.md +++ b/bukuserver/README.md @@ -118,7 +118,7 @@ The following are os env config variables available for bukuserver. | DISABLE_FAVICON | disable bookmark [favicons](https://wikipedia.org/wiki/Favicon) | boolean [default: `true`] ([here's why](#why-favicons-are-disabled-by-default))| | OPEN_IN_NEW_TAB | url link open in new tab | boolean [default: `false`] | | REVERSE_PROXY_PATH | reverse proxy path | string | -| THEME | [GUI theme](https://bootswatch.com/3) | string [default: `default`] (`slate` is a good pick for dark mode) | +| THEME | [GUI theme](https://bootswatch.com/4) | string [default: `default`] (`slate` is a good pick for dark mode) | | LOCALE | GUI language (partial support) | string [default: `en`] | Note: `BUKUSERVER_` is the common prefix (_every variable starts with it_). diff --git a/bukuserver/bookmarklet.js b/bukuserver/bookmarklet.js index e0b126d4..644526fc 100644 --- a/bukuserver/bookmarklet.js +++ b/bukuserver/bookmarklet.js @@ -16,4 +16,4 @@ url = "{{url}}" + "?url=" + encodeURIComponent(url) + "&title=" + encodeURIComponent(title) + "&description=" + encodeURIComponent(desc); -window.open(url, '_blank', 'menubar=no, height=600, width=800, toolbar=no, scrollbars=yes, status=no, dialog=1'); +window.open(url, '_blank', 'menubar=no, height=700, width=800, toolbar=no, scrollbars=yes, status=no, dialog=1'); diff --git a/bukuserver/server.py b/bukuserver/server.py index 205c3273..cbbb62fa 100644 --- a/bukuserver/server.py +++ b/bukuserver/server.py @@ -120,7 +120,7 @@ def shell_context(): app.jinja_env.filters['netloc'] = lambda x: urlparse(x).netloc # pylint: disable=no-member admin = Admin( - app, name='buku server', template_mode='bootstrap3', + app, name='buku server', template_mode='bootstrap4', index_view=views.CustomAdminIndexView( template='bukuserver/home.html', url='/' ) diff --git a/bukuserver/static/bukuserver/css/list.css b/bukuserver/static/bukuserver/css/list.css new file mode 100644 index 00000000..96ff9cb2 --- /dev/null +++ b/bukuserver/static/bukuserver/css/list.css @@ -0,0 +1,4 @@ +/* overriding icon-button text color with theme color */ +form.icon button { + color: inherit; +} diff --git a/bukuserver/static/bukuserver/css/modal.css b/bukuserver/static/bukuserver/css/modal.css index 20de439b..764e50d9 100644 --- a/bukuserver/static/bukuserver/css/modal.css +++ b/bukuserver/static/bukuserver/css/modal.css @@ -5,7 +5,7 @@ body.modal-open { /* limit dialog height with a scrollbox */ .modal-content { - max-height: calc(100vh - 60px); + max-height: calc(100vh - 3.5rem); display: flex; flex-direction: column; } diff --git a/bukuserver/static/bukuserver/js/page_size.js b/bukuserver/static/bukuserver/js/page_size.js index 23612d36..98ae3d81 100644 --- a/bukuserver/static/bukuserver/js/page_size.js +++ b/bukuserver/static/bukuserver/js/page_size.js @@ -1,20 +1,18 @@ $(document).ready(function() { const SIZES = [20, 50, 100]; // hardcoded list; see page_size_form in admin/model/layout.html let pageSize = url => new URL(url || location.host).searchParams.get('page_size'); - $(`.actions-nav .dropdown-menu`).each(function () { - let _sizes = $(`li a`, this).map(function () {return pageSize(this.href)}).get(); + $(`.nav.nav-tabs .dropdown-menu`).each(function () { + let _sizes = $(`a.dropdown-item`, this).map(function () {return pageSize(this.href)}).get(); if (SIZES.every((x, i) => x == _sizes[i])) - $(`li`, this).last().clone().each(function () { - $('a', this).text("custom").attr('href', `#`).on('click', () => { - let page = prompt(`Set custom page size (empty for default)`, pageSize(location) || ''); - if (Number(page) || (page == "")) { - let search = new URL(location).searchParams; - (page ? search.set('page_size', page) : search.delete('page_size')); - location.search = search; - } else if (page != null) - alert(`Invalid page size: "${page}"`); - return false; - }); + $('a', this).last().clone().text("custom").attr('href', `#`).on('click', () => { + let page = prompt(`Set custom page size (empty for default)`, pageSize(location) || ''); + if (Number(page) || (page == "")) { + let search = new URL(location).searchParams; + (page ? search.set('page_size', page) : search.delete('page_size')); + location.search = search; + } else if (page != null) + alert(`Invalid page size: "${page}"`); + return false; }).appendTo(this); }) }); diff --git a/bukuserver/templates/bukuserver/bookmark_create.html b/bukuserver/templates/bukuserver/bookmark_create.html index 974da099..8906a686 100644 --- a/bukuserver/templates/bukuserver/bookmark_create.html +++ b/bukuserver/templates/bukuserver/bookmark_create.html @@ -6,6 +6,7 @@ {{ buku.limit_navigation_if_popup() }} {{ buku.script('bookmark.js') }} {{ buku.fetch_checkbox() }} + {{ buku.horizontal_form(excluding_popups=True) }} {{ buku.focus() }} {{ buku.link_saved() }} {% endblock %} diff --git a/bukuserver/templates/bukuserver/bookmark_create_modal.html b/bukuserver/templates/bukuserver/bookmark_create_modal.html index 30c6e45f..645c3680 100644 --- a/bukuserver/templates/bukuserver/bookmark_create_modal.html +++ b/bukuserver/templates/bukuserver/bookmark_create_modal.html @@ -10,6 +10,7 @@ {% block tail %} {{ super() }} {{ buku.script('bookmark.js') }} - {{ buku.fetch_checkbox() }} + {{ buku.fetch_checkbox(modal=True) }} + {{ buku.horizontal_form() }} {{ buku.focus('.modal-body') }} {% endblock %} diff --git a/bukuserver/templates/bukuserver/bookmark_edit.html b/bukuserver/templates/bukuserver/bookmark_edit.html index 82d5ff89..f8824f9e 100644 --- a/bukuserver/templates/bukuserver/bookmark_edit.html +++ b/bukuserver/templates/bukuserver/bookmark_edit.html @@ -7,7 +7,7 @@ {% block edit_form %} {{ super() }} -
+ {% if csrf_token %} @@ -23,7 +23,8 @@ {{ super() }} {{ buku.limit_navigation_if_popup() }} {{ buku.script('bookmark.js') }} + + {{ buku.horizontal_form(excluding_popups=True) }} {{ buku.focus() }} {{ buku.link_saved() }} - {% endblock %} diff --git a/bukuserver/templates/bukuserver/bookmark_edit_modal.html b/bukuserver/templates/bukuserver/bookmark_edit_modal.html index 3ddf6484..ac491a62 100644 --- a/bukuserver/templates/bukuserver/bookmark_edit_modal.html +++ b/bukuserver/templates/bukuserver/bookmark_edit_modal.html @@ -4,5 +4,6 @@ {% block tail %} {{ super() }} {{ buku.script('bookmark.js') }} + {{ buku.horizontal_form() }} {{ buku.focus('.modal-body') }} {% endblock %} diff --git a/bukuserver/templates/bukuserver/bookmarklet.url b/bukuserver/templates/bukuserver/bookmarklet.url index d692019b..23446b66 100644 --- a/bukuserver/templates/bukuserver/bookmarklet.url +++ b/bukuserver/templates/bukuserver/bookmarklet.url @@ -1 +1 @@ -javascript:void%20function(){var%20e=location.href,t=document.title.trim()||%22%22,o=document.getSelection().toString().trim()||(document.querySelector(%22meta[name$=description%20i],%20meta[property$=description%20i]%22)||{}).content||%22%22;o.length%3E4e3%26%26(o=o.substr(0,4e3)+%22...%22,alert(%22The%20selected%20text%20is%20too%20long,%20it%20will%20be%20truncated.%22)),e=%22{{url}}%3Furl=%22+encodeURIComponent(e)+%22%26title=%22+encodeURIComponent(t)+%22%26description=%22+encodeURIComponent(o),window.open(e,%22_blank%22,%22menubar=no,%20height=600,%20width=800,%20toolbar=no,%20scrollbars=yes,%20status=no,%20dialog=1%22)}(); +javascript:void%20function(){var%20e=location.href,t=document.title.trim()||%22%22,o=document.getSelection().toString().trim()||(document.querySelector(%22meta[name$=description%20i],%20meta[property$=description%20i]%22)||{}).content||%22%22;o.length%3E4e3%26%26(o=o.substr(0,4e3)+%22...%22,alert(%22The%20selected%20text%20is%20too%20long,%20it%20will%20be%20truncated.%22)),e=%22{{url}}%3Furl=%22+encodeURIComponent(e)+%22%26title=%22+encodeURIComponent(t)+%22%26description=%22+encodeURIComponent(o),window.open(e,%22_blank%22,%22menubar=no,%20height=700,%20width=800,%20toolbar=no,%20scrollbars=yes,%20status=no,%20dialog=1%22)}(); diff --git a/bukuserver/templates/bukuserver/home.html b/bukuserver/templates/bukuserver/home.html index afe1c414..590ce8fa 100644 --- a/bukuserver/templates/bukuserver/home.html +++ b/bukuserver/templates/bukuserver/home.html @@ -9,18 +9,17 @@ {% block menu_links %} {{ super() }} - -
+ +
- + {% endblock %} {% block body %} {{ super() }} -
-
+

BUKU

Bookmark manager like a text-based mini-web

@@ -28,21 +27,21 @@

BUKU

Tags Statistics

-
+
{{ form.keyword.label }} - {{ form.keyword(class_='form-control', style='display: inline; width: auto') }} + {{ form.keyword(class_='form-control d-inline', style='width: auto') }}
-
-
{{form.deep()}} {{form.deep.label}}
-
{{form.regex()}} {{form.regex.label}}
+
+
{{form.deep()}} {{form.deep.label}}
+
{{form.regex()}} {{form.regex.label}}
- +
-
-

Bookmarklet: +

+

Bookmarklet: ✚ Add to Buku
@@ -50,7 +49,7 @@

BUKU

-
+
Location Bar (keyboard-only) shortcut
in Firefox:
@@ -70,6 +69,5 @@

BUKU

-
{% endblock %} diff --git a/bukuserver/templates/bukuserver/lib.html b/bukuserver/templates/bukuserver/lib.html index 4fe43eec..3ad9ab0a 100644 --- a/bukuserver/templates/bukuserver/lib.html +++ b/bukuserver/templates/bukuserver/lib.html @@ -17,8 +17,9 @@ {% macro limit_navigation_if_popup() %} {% endmacro %} @@ -31,17 +32,37 @@ {% endif %} {% endmacro %} -{% macro fetch_checkbox(checked=True) %} +{% macro fetch_checkbox(checked=True, modal=False) %} +{% endmacro %} + +{% macro horizontal_form(excluding_popups=False) %} + {% endmacro %} {% macro details_formatting(prefix='') %} {% endmacro %} diff --git a/bukuserver/templates/bukuserver/statistic.html b/bukuserver/templates/bukuserver/statistic.html index 9bcc105b..fbebcd00 100644 --- a/bukuserver/templates/bukuserver/statistic.html +++ b/bukuserver/templates/bukuserver/statistic.html @@ -16,23 +16,23 @@ {% endblock %} {% block body %} -
-
+
+ Data created {{ datetime_text }} - +

Netloc

{% if netlocs %} -
+
{% if netlocs.cropped %} - {% endif %} @@ -65,12 +65,12 @@

Netloc