Skip to content

Commit b21a4cd

Browse files
committed
Version 6.2.0
1 parent c809c89 commit b21a4cd

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+524
-255
lines changed

‎README.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ For more information, go to https://www.luigifab.fr/apijs and https://www.luigif
66

77
This repository is a releases mirror. To install the plugin, please read the documentation.
88

9-
- Current version: 6.1.0 (05/05/2020) (archive regenerated on 02/07/2021)
9+
- Current version: 6.2.0 (12/07/2020) (archive regenerated on 02/07/2021)
1010
- Compatibility: Redmine 1.4 / 2.x / 3.x / 4.0 / 4.1 / 4.2, Python 3.3 / 3.4 / 3.5 / 3.6 / 3.7 / 3.8 / 3.9
1111
- Client compatibility: Firefox 36+, Chrome 32+, Opera 19+, Edge 16+, Safari 9+
1212
- Translations: English (en), French (fr-FR/fr-CA), German (de), Italian (it), Portuguese (pt-PT/pt-BR), Spanish (es)

‎src/app/controllers/apijs_controller.rb‎

Lines changed: 50 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# encoding: utf-8
22
# Created J/12/12/2013
3-
# Updated D/03/05/2020
3+
# Updated J/02/07/2020
44
#
55
# Copyright 2008-2020 | Fabrice Creuzot (luigifab) <code~luigifab~fr>
66
# https://www.luigifab.fr/redmine/apijs
@@ -41,29 +41,33 @@ def find_project
4141
end
4242

4343

44-
# #### Gestion de l'image miniature (photo ou vidéo) ################################ public ### #
45-
# » Vérifie si l'utilisateur a accès au projet avant l'envoi de la miniature au format JPG ou PNG
44+
# #### Gestion de l'image miniature (photo ou vidéo) ################################# #
45+
# » Vérifie si l'utilisateur a accès au projet avant l'envoi de la miniature
4646
# » Utilise un script python pour générer l'image thumb (taille 200x150)
47+
# » Utilise un script python pour générer l'image srcset (taille 400x300)
4748
# » Utilise un script python pour générer l'image show (taille 1200x900)
4849
# » Enregistre les commandes et leurs résultats dans le log
4950
# » Téléchargement d'une image avec mise en cache (inline/stale)
5051
def thumb
5152

5253
source = @attachment.diskfile
53-
img_thumb = File.extname(@attachment.filename).downcase == '.png' ? '.png' : '.jpg'
54-
img_thumb = File.join(APIJS_ROOT, 'thumb', @attachment.created_on.strftime('%Y-%m').to_s, @attachment.id.to_s + img_thumb)
54+
img_thumb = File.join(APIJS_ROOT, 'thumb', @attachment.created_on.strftime('%Y-%m').to_s, @attachment.id.to_s + @attachment.getExt)
5555

5656
# génération de l'image thumb
5757
if File.file?(source) && !File.file?(img_thumb)
58-
cmd = @attachment.getCmd(source, img_thumb, 200, 150)
58+
cmd = @attachment.getCmd(source, img_thumb, 200, 150, true)
5959
logger.info 'APIJS::ApijsController#thumb: ' + cmd + ' (' + `#{cmd}`.gsub(/^\s+|\s+$/, '') + ')'
6060
end
61-
# génération de l'image show
61+
# génération des images srcset et show
6262
if @attachment.isPhoto? && Setting.plugin_redmine_apijs['create_all'] == '1' && File.file?(source)
63-
img_show = File.extname(@attachment.filename).downcase == '.png' ? '.png' : '.jpg'
64-
img_show = File.join(APIJS_ROOT, 'show', @attachment.created_on.strftime('%Y-%m').to_s, @attachment.id.to_s + img_show)
63+
img_srcset = File.join(APIJS_ROOT, 'srcset', @attachment.created_on.strftime('%Y-%m').to_s, @attachment.id.to_s + @attachment.getExt)
64+
unless File.file?(img_srcset)
65+
cmd = @attachment.getCmd(source, img_srcset, 400, 300, true)
66+
logger.info 'APIJS::ApijsController#thumb: ' + cmd + ' (' + `#{cmd}`.gsub(/^\s+|\s+$/, '') + ')'
67+
end
68+
img_show = File.join(APIJS_ROOT, 'show', @attachment.created_on.strftime('%Y-%m').to_s, @attachment.id.to_s + @attachment.getExt)
6569
unless File.file?(img_show)
66-
cmd = @attachment.getCmd(source, img_show, 1200, 900)
70+
cmd = @attachment.getCmd(source, img_show, 1200, 900, false)
6771
logger.info 'APIJS::ApijsController#thumb: ' + cmd + ' (' + `#{cmd}`.gsub(/^\s+|\s+$/, '') + ')'
6872
end
6973
end
@@ -74,25 +78,51 @@ def thumb
7478
# envoie de l'image avec mise en cache
7579
elsif File.file?(img_thumb) && stale?(etag: img_thumb)
7680
send_file(img_thumb, filename: filename_for_content_disposition(@attachment.filename),
77-
type: File.extname(img_thumb).downcase == '.png' ? 'image/png' : 'image/jpeg', disposition: 'inline')
81+
type: Redmine::MimeType.of(img_thumb), disposition: 'inline')
82+
end
83+
end
84+
85+
86+
# #### Gestion de l'image miniature 2x (photo ou vidéo) ############################## #
87+
# » Vérifie si l'utilisateur a acc��s au projet avant l'envoi de l'aperçu
88+
# » Utilise un script python pour générer l'image srcset (taille 400x300)
89+
# » Enregistre les commandes et leurs résultats dans le log
90+
# » Téléchargement d'une image avec mise en cache (inline/stale)
91+
def srcset
92+
93+
source = @attachment.diskfile
94+
img_srcset = File.join(APIJS_ROOT, 'srcset', @attachment.created_on.strftime('%Y-%m').to_s, @attachment.id.to_s + @attachment.getExt)
95+
96+
# génération de l'image srcset
97+
if File.file?(source) && !File.file?(img_srcset)
98+
cmd = @attachment.getCmd(source, img_srcset, 400, 300, true)
99+
logger.info 'APIJS::ApijsController#srcset: ' + cmd + ' (' + `#{cmd}`.gsub(/^\s+|\s+$/, '') + ')'
100+
end
101+
102+
# vérification d'accès
103+
if !User.current.allowed_to?({controller: 'projects', action: 'show'}, @project)
104+
deny_access
105+
# envoie de l'image avec mise en cache
106+
elsif File.file?(img_srcset) && stale?(etag: img_srcset)
107+
send_file(img_srcset, filename: filename_for_content_disposition(@attachment.filename),
108+
type: Redmine::MimeType.of(img_srcset), disposition: 'inline')
78109
end
79110
end
80111

81112

82-
# #### Gestion de l'image aperçu (photo) ############################################ public ### #
83-
# » Vérifie si l'utilisateur a accès au projet avant l'envoi de l'aperçu au format JPG ou PNG
113+
# #### Gestion de l'image aperçu (photo) ############################################# #
114+
# » Vérifie si l'utilisateur a accès au projet avant l'envoi de l'aperçu
84115
# » Utilise un script python pour générer l'image show (taille 1200x900)
85116
# » Enregistre les commandes et leurs résultats dans le log
86117
# » Téléchargement d'une image avec mise en cache (inline/stale)
87118
def show
88119

89120
source = @attachment.diskfile
90-
img_show = File.extname(@attachment.filename).downcase == '.png' ? '.png' : '.jpg'
91-
img_show = File.join(APIJS_ROOT, 'show', @attachment.created_on.strftime('%Y-%m').to_s, @attachment.id.to_s + img_show)
121+
img_show = File.join(APIJS_ROOT, 'show', @attachment.created_on.strftime('%Y-%m').to_s, @attachment.id.to_s + @attachment.getExt)
92122

93123
# génération de l'image show
94124
if File.file?(source) && !File.file?(img_show)
95-
cmd = @attachment.getCmd(source, img_show, 1200, 900)
125+
cmd = @attachment.getCmd(source, img_show, 1200, 900, false)
96126
logger.info 'APIJS::ApijsController#show: ' + cmd + ' (' + `#{cmd}`.gsub(/^\s+|\s+$/, '') + ')'
97127
end
98128

@@ -102,12 +132,12 @@ def show
102132
# envoie de l'image avec mise en cache
103133
elsif File.file?(img_show) && stale?(etag: img_show)
104134
send_file(img_show, filename: filename_for_content_disposition(@attachment.filename),
105-
type: File.extname(img_show).downcase == '.png' ? 'image/png' : 'image/jpeg', disposition: 'inline')
135+
type: Redmine::MimeType.of(img_show), disposition: 'inline')
106136
end
107137
end
108138

109139

110-
# #### Gestion du téléchargement des fichiers ####################################### public ### #
140+
# #### Gestion du téléchargement des fichiers ######################################## #
111141
# » Vérifie si l'utilisateur a accès au projet avant
112142
# » Téléchargement d'une vidéo en 206 Partial Content (inline)
113143
# » Téléchargement d'une image avec mise en cache (inline/stale) ou téléchargement d'un fichier (attachment)
@@ -171,7 +201,7 @@ def download
171201
end
172202

173203

174-
# #### Modification d'une description ############################################### public ### #
204+
# #### Modification d'une description ################################################ #
175205
# » Vérifie si l'utilisateur a accès au projet et à la modification
176206
# » Renvoie l'id du fichier suivi de la description en cas de modification réussie
177207
# » Supprime certains caractères de la description avant son enregistrement
@@ -197,7 +227,7 @@ def editdesc
197227
end
198228

199229

200-
# #### Suppression d'un fichier ##################################################### public ### #
230+
# #### Suppression d'un fichier ###################################################### #
201231
# » Vérifie si l'utilisateur a accès au projet et à la suppresion
202232
# » Renvoie l'id du fichier suivi en cas de suppression réussie
203233
def delete

‎src/app/views/application/_browser.html.erb‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<%
22
# Created S/17/08/2019
3-
# Updated V/01/05/2020
3+
# Updated L/25/05/2020
44
#
55
# Copyright 2008-2020 | Fabrice Creuzot (luigifab) <code~luigifab~fr>
66
# https://www.luigifab.fr/redmine/apijs
@@ -20,15 +20,15 @@ data = (Useragentparser.new).parse
2020

2121
if data['browser'] && data['version']
2222
data['version'] = Thread.current[:request].query_parameters[:browser] ? 1 : data['version'].to_f
23-
if (data['browser'] == 'MSIE') && (data['version'] < 13)
23+
if (data['browser'] == 'MSIE') && (data['version'] < 15)
2424
text = raw l(:apijs_browser_warning, { n: 'Internet Explorer', v: data['version'], l: 'href="https://www.microsoft.com/windows/microsoft-edge"' })
25-
elsif (data['browser'] == 'Edge') && (data['version'] < 14)
25+
elsif (data['browser'] == 'Edge') && (data['version'] < 16)
2626
text = raw l(:apijs_browser_warning, { n: 'Edge', v: data['version'], l: 'href="https://www.microsoft.com/windows/microsoft-edge"' })
27-
elsif (data['browser'] == 'Firefox') && (data['version'] < 27)
27+
elsif (data['browser'] == 'Firefox') && (data['version'] < 36)
2828
text = raw l(:apijs_browser_warning, { n: 'Firefox', v: data['version'], l: 'href="https://www.mozilla.org/firefox"' })
29-
elsif (data['browser'] == 'Chrome') && (data['version'] < 29)
29+
elsif (data['browser'] == 'Chrome') && (data['version'] < 31)
3030
text = raw l(:apijs_browser_warning, { n: 'Chrome', v: data['version'], l: 'href="https://www.google.com/chrome"' })
31-
elsif (data['browser'] == 'Opera') && (data['version'] < 17)
31+
elsif (data['browser'] == 'Opera') && (data['version'] < 19)
3232
text = raw l(:apijs_browser_warning, { n: 'Opera', v: data['version'], l: 'href="https://www.opera.com/"' })
3333
elsif (data['browser'] == 'Safari') && (data['version'] < 9)
3434
text = raw l(:apijs_browser_warning, { n: 'Safari', v: data['version'], l: 'href="https://www.apple.com/safari/"' })
@@ -38,7 +38,7 @@ end
3838
<% if text.length > 0 %>
3939
<% if pos == "bottom" %>
4040
<div class="flash error apijs" id="oldBrowser" style="position:absolute; top:25px; left:33%; width:31%; z-index:9000;"><%= text %></div>
41-
<script>var e = document.getElementById('oldBrowser'); document.body.insertBefore(e, document.getElementById('wrapper')); e.removeAttribute('style');</script>
41+
<script>var e = document.getElementById('oldBrowser'); document.querySelector('body').insertBefore(e, document.getElementById('wrapper')); e.removeAttribute('style');</script>
4242
<% else %>
4343
<div class="flash error apijs" id="oldBrowser"><%= text %></div>
4444
<% end %>

‎src/app/views/attachments/_links.html.erb‎

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<%
22
# Created L/21/05/2012
3-
# Updated S/02/05/2020
3+
# Updated D/10/05/2020
44
#
55
# Copyright 2008-2020 | Fabrice Creuzot (luigifab) <code~luigifab~fr>
66
# https://www.luigifab.fr/redmine/apijs
@@ -28,23 +28,23 @@ permission_delete = User.current.allowed_to?(:delete_attachments, @projec
2828
permission_edit = User.current.allowed_to?(:edit_attachments, @project)
2929

3030
@slideshowi = 0 unless defined? @slideshowi
31-
showAlbum = showList = false
31+
show_album = show_list = false
3232

3333
if setting_show_album
3434
attachments.each { |attachment|
3535
if (attachment.isPhoto? || attachment.isVideo?) && !attachment.isExcluded?
36-
showAlbum = true
36+
show_album = true
3737
else
38-
showList = true
38+
show_list = true
3939
end
4040
}
4141
else
42-
showList = true
42+
show_list = true
4343
end
4444
%>
4545

4646
<% if setting_enabled %>
47-
<% if showAlbum %>
47+
<% if show_album %>
4848
<p class="apijs section"><strong><%= l(:apijs_title_album) %></strong></p>
4949
<div class="attachments album" id="slideshow.<%= @slideshowi %>">
5050
<% slideshowj = 0 %>
@@ -54,7 +54,7 @@ end
5454
<dl id="attachmentId<%= attachment.id %>">
5555
<dt>
5656
<a href="<%= (attachment.isVideo?) ? attachment.getDownloadUrl + '?stream=1' : attachment.getShowUrl %>" type="<%= attachment.getMimeType %>" onclick="return false" id="slideshow.<%= @slideshowi %>.<%= slideshowj %>">
57-
<img src="<%= attachment.getThumbUrl %>" width="200" height="150" alt="<%= h(description) %>"/>
57+
<img src="<%= attachment.getThumbUrl %>" srcset="<%= attachment.getSrcsetUrl %> 2x" width="200" height="150" alt="<%= h(description) %>"/>
5858
<input type="hidden" value="<%= (setting_show_filename) ? attachment.filename : 'false' %>|<%= (setting_show_exifdate) ? format_time(attachment.created_on) : 'false' %>|<%= h(description) %>"/>
5959
</a>
6060
</dt>
@@ -85,7 +85,7 @@ end
8585
<% @slideshowi += 1 if slideshowj > 0 %>
8686
</div>
8787
<% end %>
88-
<% if showList %>
88+
<% if show_list %>
8989
<p class="apijs section"><strong><%= l(:apijs_title_files) %></strong></p>
9090
<ul class="attachments" id="slideshow.<%= @slideshowi %>">
9191
<% slideshowj = 0 %>

0 commit comments

Comments
 (0)