From fd9164545d4a1cf2d508b4125a45643a0b8375fa Mon Sep 17 00:00:00 2001 From: Radek Czajka Date: Wed, 25 Nov 2026 10:58:33 +0100 Subject: [PATCH] Maint --- Dockerfile | 4 ++-- src/cover/tests.py | 6 +++--- .../templates/documents/book_text.html | 2 +- src/redakcja/context_processors.py | 10 ---------- src/redakcja/settings/defaults.py | 18 ++++++------------ .../static/js/wiki/view_editor_wysiwyg.js | 1 - src/redakcja/static/js/wiki/view_properties.js | 9 --------- src/redakcja/static/js/wiki/wikiapi.js | 5 ----- src/redakcja/static/js/wiki/xslt.js | 9 +-------- src/redakcja/templates/base.html | 1 - 10 files changed, 13 insertions(+), 52 deletions(-) diff --git a/Dockerfile b/Dockerfile index c62efe42..e4fcb807 100644 --- a/Dockerfile +++ b/Dockerfile @@ -54,11 +54,11 @@ ARG GID=8200 COPY scripts/nginx.conf /etc/nginx/conf.d/default.conf RUN addgroup -g $GID app && addgroup nginx app -COPY --from=static-builder /app/src/static /app/var/static +COPY --from=static-builder /app/var/static /app/var/static FROM prod-base AS prod -COPY --from=static-builder /app/src/static/staticfiles.json /app/src/static/staticfiles.json +COPY --from=static-builder /app/var/static/staticfiles.json /app/var/static/staticfiles.json diff --git a/src/cover/tests.py b/src/cover/tests.py index 5436100a..910b0df5 100644 --- a/src/cover/tests.py +++ b/src/cover/tests.py @@ -126,13 +126,13 @@ class CoverPreviewTest(TestCase): def test_preview_from_bad_xml(self): response = self.client.post('/cover/preview/', data={"xml": ''}) self.assertEqual(response.status_code, 200) - self.assertEqual(response.content, b'/media/static/img/sample_cover.png') + self.assertEqual(response.content, b'/static/img/sample_cover.png') @patch('cover.views.make_cover') def test_preview_from_minimal_xml(self, make_cover): response = self.client.post('/cover/preview/', data={"xml": SAMPLE_XML}) self.assertEqual(response.status_code, 200) - self.assertIn(b'/media/dynamic/cover/preview/', response.content) + self.assertIn(b'/media/cover/preview/', response.content) def test_bad_book(self): response = self.client.get('/cover/preview/test/') @@ -221,4 +221,4 @@ class TestCover(TestCase): def test_image_file(self): response = self.client.get('/cover/image/1/file/') - self.assertRegex(response['Location'], r'^/media/dynamic/cover/image/') + self.assertRegex(response['Location'], r'^/media/cover/image/') diff --git a/src/documents/templates/documents/book_text.html b/src/documents/templates/documents/book_text.html index a88aad50..c17c1dae 100644 --- a/src/documents/templates/documents/book_text.html +++ b/src/documents/templates/documents/book_text.html @@ -21,7 +21,7 @@ {{ html|safe }} diff --git a/src/redakcja/context_processors.py b/src/redakcja/context_processors.py index e750fd2a..1eba2805 100644 --- a/src/redakcja/context_processors.py +++ b/src/redakcja/context_processors.py @@ -4,17 +4,7 @@ def settings(request): from django.conf import settings - if settings.SHOW_APP_VERSION: - import subprocess - process = subprocess.Popen(["git", "show", "--oneline"], stdout=subprocess.PIPE) - data, _err = process.communicate() - # get app version - VERSION = data.splitlines()[0].split()[0] - else: - VERSION = '' - return { 'MEDIA_URL': settings.MEDIA_URL, 'STATIC_URL': settings.STATIC_URL, - 'APP_VERSION': VERSION, } diff --git a/src/redakcja/settings/defaults.py b/src/redakcja/settings/defaults.py index 11edc514..2be9aa51 100644 --- a/src/redakcja/settings/defaults.py +++ b/src/redakcja/settings/defaults.py @@ -3,8 +3,6 @@ # import os -PROJECT_ROOT = os.path.realpath(os.path.dirname(os.path.dirname(__file__))) - DATABASES = { 'default': { 'ENGINE': 'django.db.backends.postgresql', @@ -46,25 +44,21 @@ USE_L10N = True # Absolute path to the directory that holds media. # Example: "/home/media/media.lawrence.com/" -MEDIA_ROOT = PROJECT_ROOT + '/media/dynamic' -STATIC_ROOT = PROJECT_ROOT + '/../static/' -CATALOGUE_REPO_PATH = MEDIA_ROOT + '/repo' -CATALOGUE_IMAGE_REPO_PATH = MEDIA_ROOT + '/imgrepo' +MEDIA_ROOT = '/app/var/media' +STATIC_ROOT = '/app/var/static' +CATALOGUE_REPO_PATH = '/app/var/dvcs' +CATALOGUE_IMAGE_REPO_PATH = '/app/var/dvcs-img' # URL that handles the media served from MEDIA_ROOT. Make sure to use a # trailing slash if there is a path component (optional in other cases). # Examples: "http://media.lawrence.com", "http://example.com/media/" -MEDIA_URL = '/media/dynamic/' -STATIC_URL = '/media/static/' +MEDIA_URL = '/media/' +STATIC_URL = '/static/' SESSION_COOKIE_NAME = "redakcja_sessionid" IMAGE_DIR = 'images/' -BROKER_URL = 'django://' - -SHOW_APP_VERSION = False - CAS_SERVER_URL = None CAS_APPLY_ATTRIBUTES_TO_USER = True CAS_RENAME_ATTRIBUTES = { diff --git a/src/redakcja/static/js/wiki/view_editor_wysiwyg.js b/src/redakcja/static/js/wiki/view_editor_wysiwyg.js index afd81082..1c9f2ed3 100644 --- a/src/redakcja/static/js/wiki/view_editor_wysiwyg.js +++ b/src/redakcja/static/js/wiki/view_editor_wysiwyg.js @@ -763,7 +763,6 @@ let self = this; xml2html({ xml: this.doc.text, - base: this.doc.getBase(), success: function(element){ var htmlView = $('#html-view'); diff --git a/src/redakcja/static/js/wiki/view_properties.js b/src/redakcja/static/js/wiki/view_properties.js index 6ae6e571..be027e02 100644 --- a/src/redakcja/static/js/wiki/view_properties.js +++ b/src/redakcja/static/js/wiki/view_properties.js @@ -1,8 +1,5 @@ (function($){ - let w = function() {}; - w = console.log; - const elementDefs = { "ilustr": { "attributes": [ @@ -89,17 +86,11 @@ html2text({ element: self.$edited[0], success: function(xml) { - w(222) let $xmlelem = $($.parseXML(xml)); - w(333, $xmlelem) - w($input.data('property'), $input.val()); $xmlelem.contents().attr($input.data('property'), inputval); - w(444, $xmlelem) let newxml = (new XMLSerializer()).serializeToString($xmlelem[0]); - w(555, newxml) xml2html({ xml: newxml, - base: self.doc.getBase(), success: function(html) { let htmlElem = $(html); self.$edited.replaceWith(htmlElem); diff --git a/src/redakcja/static/js/wiki/wikiapi.js b/src/redakcja/static/js/wiki/wikiapi.js index 56759134..a420e3ba 100644 --- a/src/redakcja/static/js/wiki/wikiapi.js +++ b/src/redakcja/static/js/wiki/wikiapi.js @@ -546,11 +546,6 @@ text = $.trim(text.replace(/\s{2,}/g, ' ')); return text.length; } - - /* Temporary workaround for relative images. */ - getBase() { - return '/media/dynamic/images/' + this.galleryLink + '/'; - } } $.wikiapi.WikiDocument = WikiDocument; diff --git a/src/redakcja/static/js/wiki/xslt.js b/src/redakcja/static/js/wiki/xslt.js index 922a3ba2..00854a79 100644 --- a/src/redakcja/static/js/wiki/xslt.js +++ b/src/redakcja/static/js/wiki/xslt.js @@ -60,17 +60,10 @@ function xml2html(options) { source.text(''); options.error(error.text(), source_text); } else { - let galleryUrl = new URL( - options.base, - window.location.href - ); $("img", $(doc.childNodes)).each(function() { $(this).attr( 'src', - new URL( - $(this).attr('src'), - galleryUrl - ) + $(this).attr('src'), ); }) diff --git a/src/redakcja/templates/base.html b/src/redakcja/templates/base.html index 01fb09bf..e212e895 100644 --- a/src/redakcja/templates/base.html +++ b/src/redakcja/templates/base.html @@ -19,7 +19,6 @@ - {% block maincontent %} {% endblock %}