From eafa9fe61be21a299c84f2d40edfd96a4c3acfff Mon Sep 17 00:00:00 2001 From: LeXofLeviafan Date: Sat, 24 Aug 2024 01:02:51 +0200 Subject: [PATCH] [jarun#753] pre-migration WebUI fixes --- bukuserver/bookmarklet.js | 2 +- bukuserver/requirements.txt | 1 - bukuserver/server.py | 2 - bukuserver/static/bukuserver/css/bookmark.css | 15 + .../static/bukuserver/css/statistic.css | 16 + bukuserver/static/bukuserver/js/bookmark.js | 12 +- .../templates/bukuserver/bookmarklet.url | 2 +- bukuserver/templates/bukuserver/home.html | 28 +- bukuserver/templates/bukuserver/lib.html | 4 +- .../templates/bukuserver/statistic.html | 330 ++++++++++-------- .../templates/bukuserver/tags_list.html | 7 +- bukuserver/views.py | 235 +++++-------- setup.py | 1 - tests/test_views.py | 67 ++-- 14 files changed, 359 insertions(+), 363 deletions(-) create mode 100644 bukuserver/static/bukuserver/css/statistic.css diff --git a/bukuserver/bookmarklet.js b/bukuserver/bookmarklet.js index ded096ef..e0b126d4 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=600, toolbar=no, scrollbars=yes, status=no, dialog=1'); +window.open(url, '_blank', 'menubar=no, height=600, width=800, toolbar=no, scrollbars=yes, status=no, dialog=1'); diff --git a/bukuserver/requirements.txt b/bukuserver/requirements.txt index 3e8304c1..e19a983d 100644 --- a/bukuserver/requirements.txt +++ b/bukuserver/requirements.txt @@ -1,7 +1,6 @@ arrow>=1.2.2 Flask-Admin>=1.6.1,<2 Flask-API>=3.0.post1 -Flask-Bootstrap>=3.3.7.1 flask-paginate>=2022.1.8 Flask-WTF>=1.0.1 Flask>=2.2.2,<2.3 diff --git a/bukuserver/server.py b/bukuserver/server.py index 087a48f3..205c3273 100644 --- a/bukuserver/server.py +++ b/bukuserver/server.py @@ -9,7 +9,6 @@ from flask.cli import FlaskGroup from flask_admin import Admin from flask_api import FlaskAPI -from flask_bootstrap import Bootstrap import buku from buku import BukuDb, __version__ @@ -120,7 +119,6 @@ def shell_context(): app.jinja_env.filters['netloc'] = lambda x: urlparse(x).netloc # pylint: disable=no-member - Bootstrap(app) admin = Admin( app, name='buku server', template_mode='bootstrap3', index_view=views.CustomAdminIndexView( diff --git a/bukuserver/static/bukuserver/css/bookmark.css b/bukuserver/static/bukuserver/css/bookmark.css index 694cc4f1..7e99b829 100644 --- a/bukuserver/static/bukuserver/css/bookmark.css +++ b/bukuserver/static/bukuserver/css/bookmark.css @@ -9,3 +9,18 @@ table tr td:not(:first-child) { width: min(1000px, 80%); } } + +.link { + display: block; +} + +.tag-list { + font-size: larger; + display: flex; + gap: 1px; + flex-wrap: wrap; +} + +.description { + white-space: pre-wrap; +} diff --git a/bukuserver/static/bukuserver/css/statistic.css b/bukuserver/static/bukuserver/css/statistic.css new file mode 100644 index 00000000..fcf12d2c --- /dev/null +++ b/bukuserver/static/bukuserver/css/statistic.css @@ -0,0 +1,16 @@ +/* limit dialog height with a scrollbox */ +.modal-body { + max-height: calc(100vh - 120px); + overflow: auto; +} + +/* make the table header sticky */ +.modal-body thead { + position: sticky; + /* setting `top:` with JS, to account for theme differences */ +} + +/* overriding icon-button text color with theme color */ +.modal-header :is(button, button:hover) { + color: inherit; +} diff --git a/bukuserver/static/bukuserver/js/bookmark.js b/bukuserver/static/bukuserver/js/bookmark.js index 7c6e57ac..ad7767ca 100644 --- a/bukuserver/static/bukuserver/js/bookmark.js +++ b/bukuserver/static/bukuserver/js/bookmark.js @@ -1,8 +1,8 @@ $(document).ready(function() { - $.getJSON( "/api/tags", function( json ) { - $('input#tags').select2({ - tags: json.tags, - tokenSeparators: [','], - }); - }); + window._tags = (Date.now() - (window._tagsQueried||0) < 1000 ? _tags : + new Promise(resolve => { + window._tagsQueried = Date.now(); + $.getJSON('/api/tags', ({tags}) => resolve(tags)); + })); + _tags.then(tags => $('input#tags').select2({tags, tokenSeparators: [',']})); }); diff --git a/bukuserver/templates/bukuserver/bookmarklet.url b/bukuserver/templates/bukuserver/bookmarklet.url index cf6a011b..d692019b 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=600,%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=600,%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 d3263bee..fa874b88 100644 --- a/bukuserver/templates/bukuserver/home.html +++ b/bukuserver/templates/bukuserver/home.html @@ -8,7 +8,7 @@ {% block menu_links %} {{ super() }} -