Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: French translations, prevention of opening SVG directly in browser through canonical url #1430

Merged
merged 30 commits into from
Oct 2, 2023
Merged
Show file tree
Hide file tree
Changes from 27 commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
accd80c
Fix #1377
fsbraun Jul 7, 2023
1ec6d3b
Merge branch 'master' of github.com:django-cms/django-filer
fsbraun Jul 10, 2023
50bb9fb
Merge branch 'django-cms:master' into master
fsbraun Jul 12, 2023
f046125
Merge branch 'django-cms:master' into master
fsbraun Jul 14, 2023
d7809dd
Merge branch 'django-cms:master' into master
fsbraun Aug 1, 2023
32770ea
Merge branch 'django-cms:master' into master
fsbraun Aug 4, 2023
01c9f35
Merge branch 'django-cms:master' into master
fsbraun Aug 20, 2023
a625d80
Merge branch 'django-cms:master' into master
fsbraun Sep 6, 2023
556dacb
Merge branch 'django-cms:master' into master
fsbraun Sep 18, 2023
c3282bb
feat: expand images in `<img>` tag to avoid javascript attacks
fsbraun Sep 28, 2023
c79a487
Embed in img tags svg only
fsbraun Sep 28, 2023
d1d04bb
Remove canonical url display from directory listing for svg
fsbraun Sep 28, 2023
da7b1fe
Merge branch 'master' into fix/expand-image
fsbraun Sep 28, 2023
d458d1b
Add test
fsbraun Sep 28, 2023
47d9dc9
Merge branch 'fix/expand-image' of github.com:fsbraun/django-filer in…
fsbraun Sep 28, 2023
5df6bd1
Remove unused Media class
fsbraun Sep 28, 2023
df83340
Change function of canonical url button
fsbraun Sep 30, 2023
e4bdd4f
Remove superflous `} `
fsbraun Sep 30, 2023
3068e68
Update NL locale
fsbraun Sep 30, 2023
9451600
Fix: Right click "open in new tab" on canonical url now renders svg i…
fsbraun Oct 1, 2023
ac8be9d
Add zoom functionality for expanded svg images
fsbraun Oct 1, 2023
e0a6f60
Fix test and js lint
fsbraun Oct 1, 2023
cf6a065
More js linting fixes
fsbraun Oct 1, 2023
cf44faf
Allow ES6
fsbraun Oct 1, 2023
ff2b2a2
Update French translations
fsbraun Oct 2, 2023
d6fd53a
Merge branch 'master' into fix/expand-image
fsbraun Oct 2, 2023
f2a4768
Fix css map
fsbraun Oct 2, 2023
ec77aac
Update filer/templates/admin/filer/image/expand.html
fsbraun Oct 2, 2023
a1b015a
Fix zoom cursors when displaying svg
fsbraun Oct 2, 2023
01a4f39
... second part
fsbraun Oct 2, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified filer/locale/fr/LC_MESSAGES/django.mo
Binary file not shown.
155 changes: 54 additions & 101 deletions filer/locale/fr/LC_MESSAGES/django.po

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions filer/private/sass/components/_tooltip.scss
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
box-shadow: 0 0 10px rgba(black,.25);
border-radius: 5px;
z-index: 10;
cursor: default;
&:before {
position: absolute;
top: -3px;
Expand Down
2 changes: 1 addition & 1 deletion filer/static/filer/css/admin_filer.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion filer/static/filer/css/maps/admin_filer.css.map

Large diffs are not rendered by default.

13 changes: 8 additions & 5 deletions filer/static/filer/js/base.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// #####################################################################################################################
// #BASE#
// Basic logic django filer
/*jshint esversion: 6 */
'use strict';

var Cl = window.Cl || {};
Expand Down Expand Up @@ -265,18 +266,20 @@ Cl.mediator = new Mediator();
});
})();
$('.js-copy-url').on('click', function (e) {
const url = new URL(this.dataset.url, document.location.href);
const msg = this.dataset.msg || 'URL copied to clipboard';
let infobox = document.createElement('template');
e.preventDefault();
for(var el of document.getElementsByClassName('info filer-tooltip')) {
for (let el of document.getElementsByClassName('info filer-tooltip')) {
el.remove();
}
var url = new URL(this.dataset.url, document.location.href);
var msg = this.dataset.msg || 'URL copied to clipboard';
var infobox = document.createElement('template');
navigator.clipboard.writeText(url.href);
infobox.innerHTML = '<div class="info filer-tooltip">' + msg + '</div>';
this.classList.add('filer-tooltip-wrapper');
this.appendChild(infobox.content.firstChild);
setTimeout(() => {this.getElementsByClassName('info')[0].remove(); }, 1200);
setTimeout(() => {
this.getElementsByClassName('info')[0].remove();
}, 1200);
});
});
})(djQuery);
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@
</td>
<td class="column-action">
{% if file.canonical_url %}
<a href="{{ file.canonical_url }}"
<a href="{% if 'svg' in file.mime_type %}{% url 'admin:filer_image_expand_view' file.pk %}{% else %}{{ file.canonical_url }}{% endif %}"
data-url="{{ file.canonical_url }}"
data-msg="{% trans 'URL copied to clipboard' %}"
rel="noopener noreferrer"
Expand Down
25 changes: 24 additions & 1 deletion filer/templates/admin/filer/image/expand.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,28 @@
<html>
<head>
<style>
img {
cursor: zoom-in;
}
body.scrolling img {
cursor: zoom-in;
}
body.scrolling img.zoom {
cursor: zoom-in;
}
img.zoom {
width: 100%;
cursor: zoom-out;
}
</style>
</head>
<body style="margin: 0;">
<img style="max-width: 100%" src="{{ original_url }}" />
<img id="img" src="{{ original_url }}" onclick="this.classList.toggle('zoom')"/>
<script>
setInterval(function () {
img = document.getElementById('img')
Fixed Show fixed Hide fixed
fsbraun marked this conversation as resolved.
Show resolved Hide resolved
document.body.classList.toggle('scrolling', img.width > document.body.clientWidth)
}, 200);
</script>
</body>
</html>
9 changes: 4 additions & 5 deletions tests/test_admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -346,11 +346,10 @@ def test_image_expand_view(self):

response = self.client.get(url)

self.assertContains(response, f"""<html>
<body style="margin: 0;">
<img style="max-width: 100%" src="{original_url}" />
</body>
</html>""")
self.assertContains(
response,
f"""<img id="img" src="{ original_url }" onclick="this.classList.toggle('zoom')"/>"""
)


class FilerClipboardAdminUrlsTests(TestCase):
Expand Down
Loading