From 9b533fdbfd08bd764744ae3a0d4717c87b61cf18 Mon Sep 17 00:00:00 2001 From: Radek Czajka Date: Tue, 12 Nov 2024 12:01:43 +0100 Subject: [PATCH 1/5] Fix. --- src/catalogue/wikidata.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/catalogue/wikidata.py b/src/catalogue/wikidata.py index 84f899ac..731e55f2 100644 --- a/src/catalogue/wikidata.py +++ b/src/catalogue/wikidata.py @@ -164,9 +164,10 @@ class WikidataModel(models.Model): except: pass else: - max_length = getattr(model_field, 'max_length', None) - if max_length: - wdvalue = wdvalue[:max_length] + if isinstance(wdvalue, str): + max_length = getattr(model_field, 'max_length', None) + if max_length: + wdvalue = wdvalue[:max_length] setattr(self, attname, wdvalue) def wikidata_link(self): -- 2.20.1 From 18948ce1d84878c6307f2d0b732a9dbd03778cfb Mon Sep 17 00:00:00 2001 From: Radek Czajka Date: Wed, 27 Nov 2024 10:25:52 +0100 Subject: [PATCH 2/5] ptrad --- src/documents/xml_tools.py | 2 +- src/redakcja/static/js/wiki/view_editor_wysiwyg.js | 2 +- src/redakcja/static/js/wiki/wikiapi.js | 2 +- src/wiki/templates/wiki/tabs/annotations_view.html | 5 ++++- 4 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/documents/xml_tools.py b/src/documents/xml_tools.py index ac145db4..d7e3fcfd 100644 --- a/src/documents/xml_tools.py +++ b/src/documents/xml_tools.py @@ -107,7 +107,7 @@ def split_xml(text): # find the chapter's title name_elem = deepcopy(element) - for tag in 'extra', 'motyw', 'pa', 'pe', 'pr', 'pt', 'uwaga': + for tag in 'extra', 'motyw', 'pa', 'pe', 'pr', 'pt', 'ptrad', 'uwaga': for a in name_elem.findall('.//' + tag): a.text='' del a[:] diff --git a/src/redakcja/static/js/wiki/view_editor_wysiwyg.js b/src/redakcja/static/js/wiki/view_editor_wysiwyg.js index e43905c9..726c2439 100644 --- a/src/redakcja/static/js/wiki/view_editor_wysiwyg.js +++ b/src/redakcja/static/js/wiki/view_editor_wysiwyg.js @@ -56,7 +56,7 @@ } /* Convert HTML fragment to plaintext */ - var ANNOT_FORBIDDEN = ['pt', 'pa', 'pr', 'pe', 'begin', 'end', 'motyw']; + var ANNOT_FORBIDDEN = ['pt', 'pa', 'pr', 'pe', 'ptrad', 'begin', 'end', 'motyw']; function html2plainText(fragment){ var text = ""; diff --git a/src/redakcja/static/js/wiki/wikiapi.js b/src/redakcja/static/js/wiki/wikiapi.js index 73642ac0..56759134 100644 --- a/src/redakcja/static/js/wiki/wikiapi.js +++ b/src/redakcja/static/js/wiki/wikiapi.js @@ -537,7 +537,7 @@ $.xmlns["rdf"] = "http://www.w3.org/1999/02/22-rdf-syntax-ns#"; $('rdf|RDF', doc).remove(); if (params.noFootnotes) { - $('pa, pe, pr, pt', doc).remove(); + $('pa, pe, pr, pt, ptrad', doc).remove(); } if (params.noThemes) { $('motyw', doc).remove(); diff --git a/src/wiki/templates/wiki/tabs/annotations_view.html b/src/wiki/templates/wiki/tabs/annotations_view.html index 6cfef199..1c6bcc0b 100644 --- a/src/wiki/templates/wiki/tabs/annotations_view.html +++ b/src/wiki/templates/wiki/tabs/annotations_view.html @@ -15,7 +15,10 @@ pt +
-- 2.20.1 From 6655e0be8684f27c4475154b3c4ced64839cba0d Mon Sep 17 00:00:00 2001 From: Radek Czajka Date: Fri, 3 Jan 2025 14:36:16 +0100 Subject: [PATCH 3/5] reference previews --- src/redakcja/static/css/html.scss | 15 ++++++++---- .../static/js/wiki/view_editor_wysiwyg.js | 23 ++++++++++++++++++- src/wlxml/templates/wlxml/wl2html.xsl | 8 +++++++ 3 files changed, 41 insertions(+), 5 deletions(-) diff --git a/src/redakcja/static/css/html.scss b/src/redakcja/static/css/html.scss index d9886d4f..91482107 100644 --- a/src/redakcja/static/css/html.scss +++ b/src/redakcja/static/css/html.scss @@ -300,12 +300,19 @@ div[x-node] > .uwaga { * Przypisy w tekście */ -.htmlview .annotation-inline-box { - &:hover > span[x-annotation-box] { - display: block; +.htmlview .annotation-inline-box, +.htmlview .reference-inline-box { + &:hover { + > span[x-annotation-box], + > span[x-preview] + { + display: block; + } } - > span[x-annotation-box] { + > span[x-annotation-box], + > span[x-preview] + { display: none; width: 300px; font-size: 10pt; diff --git a/src/redakcja/static/js/wiki/view_editor_wysiwyg.js b/src/redakcja/static/js/wiki/view_editor_wysiwyg.js index 726c2439..c5fa8c13 100644 --- a/src/redakcja/static/js/wiki/view_editor_wysiwyg.js +++ b/src/redakcja/static/js/wiki/view_editor_wysiwyg.js @@ -515,7 +515,8 @@ element: source, stripOuter: true, success: function(text){ - $('textarea', $overlay).val($.trim(text)); + let ttext = $.trim(text); + $('textarea', $overlay).val(ttext); setTimeout(function(){ $('textarea', $overlay).elastic().focus(); @@ -659,6 +660,26 @@ $('*[x-annotation-box]', editable).css({ }).show(); } + if (editable.is('.reference-inline-box')) { + let preview = $('*[x-preview]', editable); + preview.show(); + let link = $("a", preview); + let href = link.attr('href'); + if (link.attr('title') == '?' && href.startsWith('https://www.wikidata.org/wiki/')) { + link.attr('title', '…'); + let qid = href.split('/').reverse()[0]; + $.ajax({ + url: 'https://www.wikidata.org/w/rest.php/wikibase/v1/entities/items/' + qid + '?_fields=labels', + dataType: "json", + success: function(data) { + link.attr( + 'title', + data['labels']['pl'] || data['labels']['en'] + ); + }, + }); + } + } }); self.caret = new Caret(element); diff --git a/src/wlxml/templates/wlxml/wl2html.xsl b/src/wlxml/templates/wlxml/wl2html.xsl index c3af0ff4..fbb66fba 100644 --- a/src/wlxml/templates/wlxml/wl2html.xsl +++ b/src/wlxml/templates/wlxml/wl2html.xsl @@ -178,6 +178,14 @@ 📌 + + + + + + + + -- 2.20.1 From d86195c3b7dc2726a9eff10fdb2b9f5190ca15fe Mon Sep 17 00:00:00 2001 From: Radek Czajka Date: Tue, 14 Jan 2025 16:15:17 +0100 Subject: [PATCH 4/5] numeracja --- src/redakcja/static/css/html.scss | 24 +++++++++++++++++++ .../static/js/wiki/view_editor_wysiwyg.js | 18 ++++++++++++++ src/wlxml/templates/wlxml/wl2html.xsl | 14 +++++++++++ 3 files changed, 56 insertions(+) diff --git a/src/redakcja/static/css/html.scss b/src/redakcja/static/css/html.scss index 91482107..3819c821 100644 --- a/src/redakcja/static/css/html.scss +++ b/src/redakcja/static/css/html.scss @@ -556,3 +556,27 @@ div[x-node] > .uwaga { } } } + + + +div[x-node="numeracja"] { + background: lightblue; + margin: 2em; + padding: 2em; + border-radius: 1em; + &::before { + content: "Reset numeracji"; + } +} + +*[x-number]::before { + display: block; + content: attr(x-number); + position: absolute; + text-align: right; + width: 40px; + left: -60px; + font-size: .9em; + opacity: .8; + +} diff --git a/src/redakcja/static/js/wiki/view_editor_wysiwyg.js b/src/redakcja/static/js/wiki/view_editor_wysiwyg.js index c5fa8c13..2e1c28d2 100644 --- a/src/redakcja/static/js/wiki/view_editor_wysiwyg.js +++ b/src/redakcja/static/js/wiki/view_editor_wysiwyg.js @@ -753,6 +753,7 @@ callback(); } + let self = this; xml2html({ xml: this.doc.text, base: this.doc.getBase(), @@ -760,6 +761,7 @@ var htmlView = $('#html-view'); htmlView.html(element); + self.renumber(); if ('PropertiesPerspective' in $.wiki.perspectives) $.wiki.perspectives.PropertiesPerspective.enable(); @@ -942,6 +944,22 @@ } }) } + + renumber() { + let number = 0; + $('#html-view *').each((i, e) => { + let $e = $(e); + if ($e.closest('[x-node="abstrakt"]').length) return; + if ($e.closest('[x-node="nota_red"]').length) return; + let node = $e.attr('x-node'); + if (node == 'numeracja') { + number = 0; + } else if (['werset', 'akap', 'wers'].includes(node)) { + number ++; + $e.attr('x-number', number); + } + }) + } } $.wiki.VisualPerspective = VisualPerspective; diff --git a/src/wlxml/templates/wlxml/wl2html.xsl b/src/wlxml/templates/wlxml/wl2html.xsl index fbb66fba..9716e19f 100644 --- a/src/wlxml/templates/wlxml/wl2html.xsl +++ b/src/wlxml/templates/wlxml/wl2html.xsl @@ -57,6 +57,20 @@
+ +
+ +
+ + + + + + +
+
+
+