redmine_apijs 6.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (51) hide show
  1. checksums.yaml +7 -0
  2. data/Gemfile +2 -0
  3. data/LICENSE +339 -0
  4. data/README +74 -0
  5. data/app/controllers/apijs_controller.rb +326 -0
  6. data/app/views/application/_browser.html.erb +45 -0
  7. data/app/views/attachments/_links.html.erb +146 -0
  8. data/app/views/settings/_apijs.html.erb +256 -0
  9. data/assets/fonts/apijs/config.json +130 -0
  10. data/assets/fonts/apijs/fontello.woff +0 -0
  11. data/assets/fonts/apijs/fontello.woff2 +0 -0
  12. data/assets/images/apijs/player-black-200.png +0 -0
  13. data/assets/images/apijs/player-black-400.png +0 -0
  14. data/assets/images/apijs/player-white-200.png +0 -0
  15. data/assets/images/apijs/player-white-400.png +0 -0
  16. data/assets/images/apijs/tv.gif +0 -0
  17. data/assets/javascripts/apijs-redmine.min.js +7 -0
  18. data/assets/javascripts/apijs.min.js +7 -0
  19. data/assets/javascripts/app.js +224 -0
  20. data/assets/stylesheets/apijs-print.min.css +8 -0
  21. data/assets/stylesheets/apijs-redmine-rtl.min.css +8 -0
  22. data/assets/stylesheets/apijs-redmine.min.css +8 -0
  23. data/assets/stylesheets/apijs-screen-rtl.min.css +8 -0
  24. data/assets/stylesheets/apijs-screen.min.css +8 -0
  25. data/assets/stylesheets/styles.css +73 -0
  26. data/config/locales/cs.yml +30 -0
  27. data/config/locales/de.yml +30 -0
  28. data/config/locales/en.yml +30 -0
  29. data/config/locales/es.yml +30 -0
  30. data/config/locales/fr.yml +30 -0
  31. data/config/locales/it.yml +30 -0
  32. data/config/locales/ja.yml +30 -0
  33. data/config/locales/nl.yml +30 -0
  34. data/config/locales/pl.yml +30 -0
  35. data/config/locales/pt-BR.yml +30 -0
  36. data/config/locales/pt.yml +30 -0
  37. data/config/locales/ru.yml +30 -0
  38. data/config/locales/sk.yml +30 -0
  39. data/config/locales/tr.yml +30 -0
  40. data/config/locales/zh.yml +30 -0
  41. data/config/routes.rb +86 -0
  42. data/init.rb +69 -0
  43. data/lib/apijs_attachment.rb +252 -0
  44. data/lib/apijs_const.rb +35 -0
  45. data/lib/apijs_files.rb +55 -0
  46. data/lib/image.py +201 -0
  47. data/lib/redmine_apijs.rb +46 -0
  48. data/lib/useragentparser.rb +175 -0
  49. data/lib/video.py +78 -0
  50. data/redmine_apijs.gemspec +69 -0
  51. metadata +94 -0
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 82ac4a73949ff6d90bc59b69f5db15fe179ec5ffaa466ef31b4413fb52f4a383
4
+ data.tar.gz: e7d2b7425e17b595bd7cc95f628159a696a23a59abea180185fd39c55da7ebde
5
+ SHA512:
6
+ metadata.gz: f879b8198eecc08a15fdbe0cb7cc14504bf36f0509f4f979d1f3caec3d6cf1e67ca07de476aac2bdbac95862ffada95b59b3c43cbb690d28060dbd69512e7b2d
7
+ data.tar.gz: 85b5081091c5baf97088b20018f3ca6c0f0899bb0441597b1321aad48d4006361345b9abcd72284b40bd1d51d4d930d7713545a3365a63053cec970a7743b55b
data/Gemfile ADDED
@@ -0,0 +1,2 @@
1
+ source 'https://rubygems.org'
2
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,339 @@
1
+ GNU GENERAL PUBLIC LICENSE
2
+ Version 2, June 1991
3
+
4
+ Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
5
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
6
+ Everyone is permitted to copy and distribute verbatim copies
7
+ of this license document, but changing it is not allowed.
8
+
9
+ Preamble
10
+
11
+ The licenses for most software are designed to take away your
12
+ freedom to share and change it. By contrast, the GNU General Public
13
+ License is intended to guarantee your freedom to share and change free
14
+ software--to make sure the software is free for all its users. This
15
+ General Public License applies to most of the Free Software
16
+ Foundation's software and to any other program whose authors commit to
17
+ using it. (Some other Free Software Foundation software is covered by
18
+ the GNU Lesser General Public License instead.) You can apply it to
19
+ your programs, too.
20
+
21
+ When we speak of free software, we are referring to freedom, not
22
+ price. Our General Public Licenses are designed to make sure that you
23
+ have the freedom to distribute copies of free software (and charge for
24
+ this service if you wish), that you receive source code or can get it
25
+ if you want it, that you can change the software or use pieces of it
26
+ in new free programs; and that you know you can do these things.
27
+
28
+ To protect your rights, we need to make restrictions that forbid
29
+ anyone to deny you these rights or to ask you to surrender the rights.
30
+ These restrictions translate to certain responsibilities for you if you
31
+ distribute copies of the software, or if you modify it.
32
+
33
+ For example, if you distribute copies of such a program, whether
34
+ gratis or for a fee, you must give the recipients all the rights that
35
+ you have. You must make sure that they, too, receive or can get the
36
+ source code. And you must show them these terms so they know their
37
+ rights.
38
+
39
+ We protect your rights with two steps: (1) copyright the software, and
40
+ (2) offer you this license which gives you legal permission to copy,
41
+ distribute and/or modify the software.
42
+
43
+ Also, for each author's protection and ours, we want to make certain
44
+ that everyone understands that there is no warranty for this free
45
+ software. If the software is modified by someone else and passed on, we
46
+ want its recipients to know that what they have is not the original, so
47
+ that any problems introduced by others will not reflect on the original
48
+ authors' reputations.
49
+
50
+ Finally, any free program is threatened constantly by software
51
+ patents. We wish to avoid the danger that redistributors of a free
52
+ program will individually obtain patent licenses, in effect making the
53
+ program proprietary. To prevent this, we have made it clear that any
54
+ patent must be licensed for everyone's free use or not licensed at all.
55
+
56
+ The precise terms and conditions for copying, distribution and
57
+ modification follow.
58
+
59
+ GNU GENERAL PUBLIC LICENSE
60
+ TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
61
+
62
+ 0. This License applies to any program or other work which contains
63
+ a notice placed by the copyright holder saying it may be distributed
64
+ under the terms of this General Public License. The "Program", below,
65
+ refers to any such program or work, and a "work based on the Program"
66
+ means either the Program or any derivative work under copyright law:
67
+ that is to say, a work containing the Program or a portion of it,
68
+ either verbatim or with modifications and/or translated into another
69
+ language. (Hereinafter, translation is included without limitation in
70
+ the term "modification".) Each licensee is addressed as "you".
71
+
72
+ Activities other than copying, distribution and modification are not
73
+ covered by this License; they are outside its scope. The act of
74
+ running the Program is not restricted, and the output from the Program
75
+ is covered only if its contents constitute a work based on the
76
+ Program (independent of having been made by running the Program).
77
+ Whether that is true depends on what the Program does.
78
+
79
+ 1. You may copy and distribute verbatim copies of the Program's
80
+ source code as you receive it, in any medium, provided that you
81
+ conspicuously and appropriately publish on each copy an appropriate
82
+ copyright notice and disclaimer of warranty; keep intact all the
83
+ notices that refer to this License and to the absence of any warranty;
84
+ and give any other recipients of the Program a copy of this License
85
+ along with the Program.
86
+
87
+ You may charge a fee for the physical act of transferring a copy, and
88
+ you may at your option offer warranty protection in exchange for a fee.
89
+
90
+ 2. You may modify your copy or copies of the Program or any portion
91
+ of it, thus forming a work based on the Program, and copy and
92
+ distribute such modifications or work under the terms of Section 1
93
+ above, provided that you also meet all of these conditions:
94
+
95
+ a) You must cause the modified files to carry prominent notices
96
+ stating that you changed the files and the date of any change.
97
+
98
+ b) You must cause any work that you distribute or publish, that in
99
+ whole or in part contains or is derived from the Program or any
100
+ part thereof, to be licensed as a whole at no charge to all third
101
+ parties under the terms of this License.
102
+
103
+ c) If the modified program normally reads commands interactively
104
+ when run, you must cause it, when started running for such
105
+ interactive use in the most ordinary way, to print or display an
106
+ announcement including an appropriate copyright notice and a
107
+ notice that there is no warranty (or else, saying that you provide
108
+ a warranty) and that users may redistribute the program under
109
+ these conditions, and telling the user how to view a copy of this
110
+ License. (Exception: if the Program itself is interactive but
111
+ does not normally print such an announcement, your work based on
112
+ the Program is not required to print an announcement.)
113
+
114
+ These requirements apply to the modified work as a whole. If
115
+ identifiable sections of that work are not derived from the Program,
116
+ and can be reasonably considered independent and separate works in
117
+ themselves, then this License, and its terms, do not apply to those
118
+ sections when you distribute them as separate works. But when you
119
+ distribute the same sections as part of a whole which is a work based
120
+ on the Program, the distribution of the whole must be on the terms of
121
+ this License, whose permissions for other licensees extend to the
122
+ entire whole, and thus to each and every part regardless of who wrote it.
123
+
124
+ Thus, it is not the intent of this section to claim rights or contest
125
+ your rights to work written entirely by you; rather, the intent is to
126
+ exercise the right to control the distribution of derivative or
127
+ collective works based on the Program.
128
+
129
+ In addition, mere aggregation of another work not based on the Program
130
+ with the Program (or with a work based on the Program) on a volume of
131
+ a storage or distribution medium does not bring the other work under
132
+ the scope of this License.
133
+
134
+ 3. You may copy and distribute the Program (or a work based on it,
135
+ under Section 2) in object code or executable form under the terms of
136
+ Sections 1 and 2 above provided that you also do one of the following:
137
+
138
+ a) Accompany it with the complete corresponding machine-readable
139
+ source code, which must be distributed under the terms of Sections
140
+ 1 and 2 above on a medium customarily used for software interchange; or,
141
+
142
+ b) Accompany it with a written offer, valid for at least three
143
+ years, to give any third party, for a charge no more than your
144
+ cost of physically performing source distribution, a complete
145
+ machine-readable copy of the corresponding source code, to be
146
+ distributed under the terms of Sections 1 and 2 above on a medium
147
+ customarily used for software interchange; or,
148
+
149
+ c) Accompany it with the information you received as to the offer
150
+ to distribute corresponding source code. (This alternative is
151
+ allowed only for noncommercial distribution and only if you
152
+ received the program in object code or executable form with such
153
+ an offer, in accord with Subsection b above.)
154
+
155
+ The source code for a work means the preferred form of the work for
156
+ making modifications to it. For an executable work, complete source
157
+ code means all the source code for all modules it contains, plus any
158
+ associated interface definition files, plus the scripts used to
159
+ control compilation and installation of the executable. However, as a
160
+ special exception, the source code distributed need not include
161
+ anything that is normally distributed (in either source or binary
162
+ form) with the major components (compiler, kernel, and so on) of the
163
+ operating system on which the executable runs, unless that component
164
+ itself accompanies the executable.
165
+
166
+ If distribution of executable or object code is made by offering
167
+ access to copy from a designated place, then offering equivalent
168
+ access to copy the source code from the same place counts as
169
+ distribution of the source code, even though third parties are not
170
+ compelled to copy the source along with the object code.
171
+
172
+ 4. You may not copy, modify, sublicense, or distribute the Program
173
+ except as expressly provided under this License. Any attempt
174
+ otherwise to copy, modify, sublicense or distribute the Program is
175
+ void, and will automatically terminate your rights under this License.
176
+ However, parties who have received copies, or rights, from you under
177
+ this License will not have their licenses terminated so long as such
178
+ parties remain in full compliance.
179
+
180
+ 5. You are not required to accept this License, since you have not
181
+ signed it. However, nothing else grants you permission to modify or
182
+ distribute the Program or its derivative works. These actions are
183
+ prohibited by law if you do not accept this License. Therefore, by
184
+ modifying or distributing the Program (or any work based on the
185
+ Program), you indicate your acceptance of this License to do so, and
186
+ all its terms and conditions for copying, distributing or modifying
187
+ the Program or works based on it.
188
+
189
+ 6. Each time you redistribute the Program (or any work based on the
190
+ Program), the recipient automatically receives a license from the
191
+ original licensor to copy, distribute or modify the Program subject to
192
+ these terms and conditions. You may not impose any further
193
+ restrictions on the recipients' exercise of the rights granted herein.
194
+ You are not responsible for enforcing compliance by third parties to
195
+ this License.
196
+
197
+ 7. If, as a consequence of a court judgment or allegation of patent
198
+ infringement or for any other reason (not limited to patent issues),
199
+ conditions are imposed on you (whether by court order, agreement or
200
+ otherwise) that contradict the conditions of this License, they do not
201
+ excuse you from the conditions of this License. If you cannot
202
+ distribute so as to satisfy simultaneously your obligations under this
203
+ License and any other pertinent obligations, then as a consequence you
204
+ may not distribute the Program at all. For example, if a patent
205
+ license would not permit royalty-free redistribution of the Program by
206
+ all those who receive copies directly or indirectly through you, then
207
+ the only way you could satisfy both it and this License would be to
208
+ refrain entirely from distribution of the Program.
209
+
210
+ If any portion of this section is held invalid or unenforceable under
211
+ any particular circumstance, the balance of the section is intended to
212
+ apply and the section as a whole is intended to apply in other
213
+ circumstances.
214
+
215
+ It is not the purpose of this section to induce you to infringe any
216
+ patents or other property right claims or to contest validity of any
217
+ such claims; this section has the sole purpose of protecting the
218
+ integrity of the free software distribution system, which is
219
+ implemented by public license practices. Many people have made
220
+ generous contributions to the wide range of software distributed
221
+ through that system in reliance on consistent application of that
222
+ system; it is up to the author/donor to decide if he or she is willing
223
+ to distribute software through any other system and a licensee cannot
224
+ impose that choice.
225
+
226
+ This section is intended to make thoroughly clear what is believed to
227
+ be a consequence of the rest of this License.
228
+
229
+ 8. If the distribution and/or use of the Program is restricted in
230
+ certain countries either by patents or by copyrighted interfaces, the
231
+ original copyright holder who places the Program under this License
232
+ may add an explicit geographical distribution limitation excluding
233
+ those countries, so that distribution is permitted only in or among
234
+ countries not thus excluded. In such case, this License incorporates
235
+ the limitation as if written in the body of this License.
236
+
237
+ 9. The Free Software Foundation may publish revised and/or new versions
238
+ of the General Public License from time to time. Such new versions will
239
+ be similar in spirit to the present version, but may differ in detail to
240
+ address new problems or concerns.
241
+
242
+ Each version is given a distinguishing version number. If the Program
243
+ specifies a version number of this License which applies to it and "any
244
+ later version", you have the option of following the terms and conditions
245
+ either of that version or of any later version published by the Free
246
+ Software Foundation. If the Program does not specify a version number of
247
+ this License, you may choose any version ever published by the Free Software
248
+ Foundation.
249
+
250
+ 10. If you wish to incorporate parts of the Program into other free
251
+ programs whose distribution conditions are different, write to the author
252
+ to ask for permission. For software which is copyrighted by the Free
253
+ Software Foundation, write to the Free Software Foundation; we sometimes
254
+ make exceptions for this. Our decision will be guided by the two goals
255
+ of preserving the free status of all derivatives of our free software and
256
+ of promoting the sharing and reuse of software generally.
257
+
258
+ NO WARRANTY
259
+
260
+ 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
261
+ FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
262
+ OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
263
+ PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
264
+ OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
265
+ MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
266
+ TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
267
+ PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
268
+ REPAIR OR CORRECTION.
269
+
270
+ 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
271
+ WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
272
+ REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
273
+ INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
274
+ OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
275
+ TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
276
+ YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
277
+ PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
278
+ POSSIBILITY OF SUCH DAMAGES.
279
+
280
+ END OF TERMS AND CONDITIONS
281
+
282
+ How to Apply These Terms to Your New Programs
283
+
284
+ If you develop a new program, and you want it to be of the greatest
285
+ possible use to the public, the best way to achieve this is to make it
286
+ free software which everyone can redistribute and change under these terms.
287
+
288
+ To do so, attach the following notices to the program. It is safest
289
+ to attach them to the start of each source file to most effectively
290
+ convey the exclusion of warranty; and each file should have at least
291
+ the "copyright" line and a pointer to where the full notice is found.
292
+
293
+ <one line to give the program's name and a brief idea of what it does.>
294
+ Copyright (C) <year> <name of author>
295
+
296
+ This program is free software; you can redistribute it and/or modify
297
+ it under the terms of the GNU General Public License as published by
298
+ the Free Software Foundation; either version 2 of the License, or
299
+ (at your option) any later version.
300
+
301
+ This program is distributed in the hope that it will be useful,
302
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
303
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
304
+ GNU General Public License for more details.
305
+
306
+ You should have received a copy of the GNU General Public License along
307
+ with this program; if not, write to the Free Software Foundation, Inc.,
308
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
309
+
310
+ Also add information on how to contact you by electronic and paper mail.
311
+
312
+ If the program is interactive, make it output a short notice like this
313
+ when it starts in an interactive mode:
314
+
315
+ Gnomovision version 69, Copyright (C) year name of author
316
+ Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
317
+ This is free software, and you are welcome to redistribute it
318
+ under certain conditions; type `show c' for details.
319
+
320
+ The hypothetical commands `show w' and `show c' should show the appropriate
321
+ parts of the General Public License. Of course, the commands you use may
322
+ be called something other than `show w' and `show c'; they could even be
323
+ mouse-clicks or menu items--whatever suits your program.
324
+
325
+ You should also get your employer (if you work as a programmer) or your
326
+ school, if any, to sign a "copyright disclaimer" for the program, if
327
+ necessary. Here is a sample; alter the names:
328
+
329
+ Yoyodyne, Inc., hereby disclaims all copyright interest in the program
330
+ `Gnomovision' (which makes passes at compilers) written by James Hacker.
331
+
332
+ <signature of Ty Coon>, 1 April 1989
333
+ Ty Coon, President of Vice
334
+
335
+ This General Public License does not permit incorporating your program into
336
+ proprietary programs. If your program is a subroutine library, you may
337
+ consider it more useful to permit linking proprietary applications with the
338
+ library. If this is what you want to do, use the GNU Lesser General
339
+ Public License instead of this License.
data/README ADDED
@@ -0,0 +1,74 @@
1
+ Docs : https://www.luigifab.fr/redmine/apijs
2
+ Tracker : https://github.com/luigifab/redmine-apijs
3
+ Rubygems : https://rubygems.org/gems/redmine_apijs
4
+ Plugin : Luigifab/Apijs
5
+ License : GNU GPL 2+ (https://opensource.org/licenses/gpl-2.0)
6
+ Copyright : 2008-2020 Fabrice Creuzot (luigifab) <code~luigifab~fr>
7
+
8
+
9
+
10
+
11
+
12
+
13
+
14
+
15
+ IF YOU FOUND A MISTAKE OR A BUG, PLEASE, CONTACT ME (IN FRENCH OR IN ENGLISH) AT code~luigifab~fr
16
+ CSS AND JS FILES ARE MINIFIED WITH clean-css (github.com/jakubpawlowicz/clean-css) AND uglify-js (github.com/mishoo/UglifyJS2).
17
+ ALL FILES (INCLUDING DOCUMENTATION AND TRANSLATIONS) ARE LICENSED UNDER THE TERMS OF THE GNU GPL 2+ LICENSE.
18
+ THAT BEING SAID SOME FILES COME FROM OTHER PROJECTS AND ARE UNDER OTHER LICENSES (SEE AT THE END OF THIS FILE).
19
+
20
+
21
+ Rewrite
22
+ - app/views/attachments/_links.html.erb
23
+ - lib/apijs_attachment.rb
24
+ Depends
25
+ - python-pil
26
+ - python-scour
27
+ - libimage-exiftool-perl (optional)
28
+ - ffmpegthumbnailer (optional)
29
+ - also used: command -v, python3 or python or python2, nproc, du -hs, cut -f1
30
+ Notes
31
+ - For the app, read: https://www.luigifab.fr/apijs
32
+ - For the Redmine plugin, read: https://www.luigifab.fr/redmine/apijs
33
+ - For the Magento module, read: https://www.luigifab.fr/magento/apijs
34
+ - For the OpenMage module, read: https://www.luigifab.fr/openmage/apijs
35
+
36
+
37
+ Translations in de-DE (deutsch/Deutschland) by:
38
+ - Philip Junietz <info~label-park~com> 2016
39
+ - Pamela Steinborn <st.pamela~laposte~net> 2016
40
+ Translations in en-US (english/United-States) by:
41
+ - Fabrice Creuzot (luigifab) <code~luigifab~fr> 2008-2020
42
+ - Brian Legrand <mrbibi1987~gmail~com> 2012
43
+ - Pascale Scellier <scellier.pascale~orange~fr> 2016
44
+ Translations in es-ES (español/España) by:
45
+ - Paco Aguayo <francisco.aguayocanela~gmail~com> 2014
46
+ - Hugo Baugé & Cédric Scaramuzza <info~label-park~com> 2016
47
+ - Pascale Scellier <scellier.pascale~orange~fr> 2016
48
+ - Hélène Vergine <vergineh~gmail~com> 2017, 2020
49
+ - Guillaume Genetet <genetet.incorporated~gmail~com> 2018 https://fr.tipeee.com/william-broome
50
+ Translations in fr-FR (français/France) by:
51
+ - Fabrice Creuzot (luigifab) <code~luigifab~fr> 2008-2020
52
+ - Pascale Scellier <scellier.pascale~orange~fr> 2016
53
+ Translations in it-IT (italiano/Italia) by:
54
+ - Maria Grasso <mgrasso~outlook~fr> 2016-2017
55
+ Translations in pt-PT (português/Portugal) by:
56
+ - Greg Lacan <greg.lacan~label-park~com> 2016
57
+ - Isabel Mendes <isabel.2012~orange~fr> 2016
58
+ Translations in ru-RU (русский/Россия) by:
59
+ - Eugene Parfenov (igro) <admin~mytona~com>
60
+ Translations in tr-TR (türkçe/Türkiye) by:
61
+ - Adnan Topcu <adnan~topcu~name>
62
+
63
+ If you like, take some of your time to improve the translations, go to https://bit.ly/2HyCCEc
64
+
65
+
66
+ File: /lib/useragentparser.rb
67
+ Source: https://github.com/donatj/PhpUserAgent + https://gist.github.com/luigifab/19a68d9aa98fa80f2961809d7cec59c0 (1.0.0-fork2)
68
+ Copyright: 2013-2020 Jesse G. Donat <donatj~gmail~com>
69
+ Copyright: 2019-2020 Fabrice Creuzot (luigifab) <code~luigifab~fr>
70
+ License: MIT (https://opensource.org/licenses/mit)
71
+
72
+ Files: /assets/fonts/apijs/fontello.woff /assets/fonts/apijs/fontello.woff2
73
+ Source: http://fontello.com/
74
+ License: SIL (https://opensource.org/licenses/ofl-1.1)
@@ -0,0 +1,326 @@
1
+ # encoding: utf-8
2
+ # Created J/12/12/2013
3
+ # Updated D/26/07/2020
4
+ #
5
+ # Copyright 2008-2020 | Fabrice Creuzot (luigifab) <code~luigifab~fr>
6
+ # https://www.luigifab.fr/redmine/apijs
7
+ #
8
+ # This program is free software, you can redistribute it or modify
9
+ # it under the terms of the GNU General Public License (GPL) as published
10
+ # by the free software foundation, either version 2 of the license, or
11
+ # (at your option) any later version.
12
+ #
13
+ # This program is distributed in the hope that it will be useful,
14
+ # but without any warranty, without even the implied warranty of
15
+ # merchantability or fitness for a particular purpose. See the
16
+ # GNU General Public License (GPL) for more details.
17
+
18
+ class ApijsController < AttachmentsController
19
+
20
+ if Redmine::VERSION::MAJOR >= 4
21
+ before_action :find_project, except: [:upload]
22
+ before_action :authorize_global, only: [:upload]
23
+ before_action :read_authorize, :file_readable, only: [:thumb, :show, :download, :thumbnail]
24
+ before_action :read_authorize, only: [:editdesc, :delete]
25
+ else
26
+ before_filter :find_project, except: [:upload]
27
+ before_filter :authorize_global, only: [:upload]
28
+ before_filter :read_authorize, :file_readable, only: [:thumb, :show, :download, :thumbnail]
29
+ before_filter :read_authorize, only: [:editdesc, :delete]
30
+ end
31
+
32
+ # n'existe plus avec Redmine 3+ (copie de 2.6.10)
33
+ if Redmine::VERSION::MAJOR >= 3
34
+ def find_project
35
+ @attachment = Attachment.find(params[:id])
36
+ raise ActiveRecord::RecordNotFound if params[:filename] && params[:filename] != @attachment.filename
37
+ @project = @attachment.project
38
+ rescue ActiveRecord::RecordNotFound
39
+ render_404
40
+ end
41
+ end
42
+
43
+
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
46
+ # » 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)
48
+ # » Utilise un script python pour générer l'image show (taille 1200x900)
49
+ # » Enregistre les commandes et leurs résultats dans le log
50
+ # » Téléchargement d'une image avec mise en cache (inline/stale)
51
+ def thumb
52
+
53
+ source = @attachment.diskfile
54
+ img_thumb = @attachment.getImgThumb
55
+
56
+ if File.file?(source) && @attachment.isPhoto? && Setting.plugin_redmine_apijs['create_all'] == '2'
57
+ # génération de l'image thumb
58
+ t1 = Thread.new {
59
+ unless File.file?(img_thumb)
60
+ cmd = @attachment.getCmd(source, img_thumb, 200, 150, true)
61
+ logger.info 'APIJS::ApijsController#thumb:t1: ' + cmd + ' (' + `#{cmd}`.gsub(/^\s+|\s+$/, '') + ')'
62
+ end
63
+ }
64
+ # génération des images srcset et show
65
+ t2 = Thread.new {
66
+ img_srcset = @attachment.getImgSrcset
67
+ unless File.file?(img_srcset)
68
+ cmd = @attachment.getCmd(source, img_srcset, 400, 300, true)
69
+ logger.info 'APIJS::ApijsController#thumb:t2: ' + cmd + ' (' + `#{cmd}`.gsub(/^\s+|\s+$/, '') + ')'
70
+ end
71
+ }
72
+ t3 = Thread.new {
73
+ img_show = @attachment.getImgShow
74
+ unless File.file?(img_show)
75
+ cmd = @attachment.getCmd(source, img_show, 1200, 900, false)
76
+ logger.info 'APIJS::ApijsController#thumb:t3: ' + cmd + ' (' + `#{cmd}`.gsub(/^\s+|\s+$/, '') + ')'
77
+ end
78
+ }
79
+ # attends la fin des threads
80
+ t1.join
81
+ t2.join
82
+ t3.join
83
+ elsif File.file?(source)
84
+ # génération de l'image thumb
85
+ unless File.file?(img_thumb)
86
+ cmd = @attachment.getCmd(source, img_thumb, 200, 150, true)
87
+ logger.info 'APIJS::ApijsController#thumb: ' + cmd + ' (' + `#{cmd}`.gsub(/^\s+|\s+$/, '') + ')'
88
+ end
89
+ # génération des images srcset et show
90
+ if @attachment.isPhoto? && Setting.plugin_redmine_apijs['create_all'] == '1'
91
+ img_srcset = @attachment.getImgSrcset
92
+ unless File.file?(img_srcset)
93
+ cmd = @attachment.getCmd(source, img_srcset, 400, 300, true)
94
+ logger.info 'APIJS::ApijsController#thumb: ' + cmd + ' (' + `#{cmd}`.gsub(/^\s+|\s+$/, '') + ')'
95
+ end
96
+ img_show = @attachment.getImgShow
97
+ unless File.file?(img_show)
98
+ cmd = @attachment.getCmd(source, img_show, 1200, 900, false)
99
+ logger.info 'APIJS::ApijsController#thumb: ' + cmd + ' (' + `#{cmd}`.gsub(/^\s+|\s+$/, '') + ')'
100
+ end
101
+ end
102
+ end
103
+
104
+ # vérification d'accès
105
+ if !User.current.allowed_to?({controller: 'projects', action: 'show'}, @project)
106
+ deny_access
107
+ # envoie de l'image avec mise en cache
108
+ elsif File.file?(img_thumb) && stale?(etag: img_thumb)
109
+ send_file(img_thumb, filename: filename_for_content_disposition(@attachment.filename),
110
+ type: Redmine::MimeType.of(img_thumb), disposition: 'inline')
111
+ end
112
+ end
113
+
114
+
115
+ # #### Gestion de l'image miniature 2x (photo ou vidéo) ############################## #
116
+ # » Vérifie si l'utilisateur a accès au projet avant l'envoi de l'aperçu
117
+ # » Utilise un script python pour générer l'image srcset (taille 400x300)
118
+ # » Utilise un script python pour générer l'image thumb (taille 200x150)
119
+ # » Utilise un script python pour générer l'image show (taille 1200x900)
120
+ # » Enregistre les commandes et leurs résultats dans le log
121
+ # » Téléchargement d'une image avec mise en cache (inline/stale)
122
+ def srcset
123
+
124
+ source = @attachment.diskfile
125
+ img_srcset = @attachment.getImgSrcset
126
+
127
+ if File.file?(source) && @attachment.isPhoto? && Setting.plugin_redmine_apijs['create_all'] == '2'
128
+ # génération de l'image srcset
129
+ t1 = Thread.new {
130
+ unless File.file?(img_srcset)
131
+ cmd = @attachment.getCmd(source, img_srcset, 400, 300, true)
132
+ logger.info 'APIJS::ApijsController#srcset:t1: ' + cmd + ' (' + `#{cmd}`.gsub(/^\s+|\s+$/, '') + ')'
133
+ end
134
+ }
135
+ # génération des images thumb et show
136
+ t2 = Thread.new {
137
+ img_thumb = @attachment.getImgThumb
138
+ unless File.file?(img_thumb)
139
+ cmd = @attachment.getCmd(source, img_thumb, 200, 150, true)
140
+ logger.info 'APIJS::ApijsController#srcset:t2: ' + cmd + ' (' + `#{cmd}`.gsub(/^\s+|\s+$/, '') + ')'
141
+ end
142
+ }
143
+ t3 = Thread.new {
144
+ img_show = @attachment.getImgShow
145
+ unless File.file?(img_show)
146
+ cmd = @attachment.getCmd(source, img_show, 1200, 900, false)
147
+ logger.info 'APIJS::ApijsController#srcset:t3: ' + cmd + ' (' + `#{cmd}`.gsub(/^\s+|\s+$/, '') + ')'
148
+ end
149
+ }
150
+ # attends la fin des threads
151
+ t1.join
152
+ t2.join
153
+ t3.join
154
+ elsif File.file?(source)
155
+ # génération de l'image srcset
156
+ unless File.file?(img_srcset)
157
+ cmd = @attachment.getCmd(source, img_srcset, 400, 300, true)
158
+ logger.info 'APIJS::ApijsController#srcset: ' + cmd + ' (' + `#{cmd}`.gsub(/^\s+|\s+$/, '') + ')'
159
+ end
160
+ # génération des images thumb et show
161
+ if @attachment.isPhoto? && Setting.plugin_redmine_apijs['create_all'] == '1'
162
+ img_thumb = @attachment.getImgThumb
163
+ unless File.file?(img_thumb)
164
+ cmd = @attachment.getCmd(source, img_thumb, 200, 150, true)
165
+ logger.info 'APIJS::ApijsController#srcset: ' + cmd + ' (' + `#{cmd}`.gsub(/^\s+|\s+$/, '') + ')'
166
+ end
167
+ img_show = @attachment.getImgShow
168
+ unless File.file?(img_show)
169
+ cmd = @attachment.getCmd(source, img_show, 1200, 900, false)
170
+ logger.info 'APIJS::ApijsController#srcset: ' + cmd + ' (' + `#{cmd}`.gsub(/^\s+|\s+$/, '') + ')'
171
+ end
172
+ end
173
+ end
174
+
175
+ # vérification d'accès
176
+ if !User.current.allowed_to?({controller: 'projects', action: 'show'}, @project)
177
+ deny_access
178
+ # envoie de l'image avec mise en cache
179
+ elsif File.file?(img_srcset) && stale?(etag: img_srcset)
180
+ send_file(img_srcset, filename: filename_for_content_disposition(@attachment.filename),
181
+ type: Redmine::MimeType.of(img_srcset), disposition: 'inline')
182
+ end
183
+ end
184
+
185
+
186
+ # #### Gestion de l'image aperçu (photo) ############################################# #
187
+ # » Vérifie si l'utilisateur a accès au projet avant l'envoi de l'aperçu
188
+ # » Utilise un script python pour générer l'image show (taille 1200x900)
189
+ # » Enregistre les commandes et leurs résultats dans le log
190
+ # » Téléchargement d'une image avec mise en cache (inline/stale)
191
+ def show
192
+
193
+ source = @attachment.diskfile
194
+ img_show = @attachment.getImgShow
195
+
196
+ # génération de l'image show
197
+ if File.file?(source) && !File.file?(img_show)
198
+ cmd = @attachment.getCmd(source, img_show, 1200, 900, false)
199
+ logger.info 'APIJS::ApijsController#show: ' + cmd + ' (' + `#{cmd}`.gsub(/^\s+|\s+$/, '') + ')'
200
+ end
201
+
202
+ # vérification d'accès
203
+ if !User.current.allowed_to?({controller: 'projects', action: 'show'}, @project)
204
+ deny_access
205
+ # envoie de l'image avec mise en cache
206
+ elsif File.file?(img_show) && stale?(etag: img_show)
207
+ send_file(img_show, filename: filename_for_content_disposition(@attachment.filename),
208
+ type: Redmine::MimeType.of(img_show), disposition: 'inline')
209
+ end
210
+ end
211
+
212
+
213
+ # #### Gestion du téléchargement des fichiers ######################################## #
214
+ # » Vérifie si l'utilisateur a accès au projet avant
215
+ # » Téléchargement d'une vidéo en 206 Partial Content (inline)
216
+ # » Téléchargement d'une image avec mise en cache (inline/stale) ou téléchargement d'un fichier (attachment)
217
+ def download
218
+
219
+ # vérification d'accès
220
+ if !User.current.allowed_to?({controller: 'projects', action: 'show'}, @project)
221
+ deny_access
222
+ # télachargement d'une vidéo en 206 Partial Content (https://stackoverflow.com/a/7604330 + https://stackoverflow.com/a/16593030)
223
+ # ou téléchargement d'une image avec mise en cache
224
+ # ou téléchargement d'un fichier
225
+ elsif !params[:filename] || params[:inline] || params[:stream]
226
+ @attachment.increment_download if @attachment.container.is_a?(Version) || @attachment.container.is_a?(Project)
227
+ # vidéo
228
+ if @attachment.isVideo?
229
+ file_begin = 0
230
+ file_size = @attachment.filesize
231
+ file_end = file_size - 1
232
+
233
+ if request.headers['Range']
234
+ match = request.headers['Range'].match(/bytes=(\d+)-(\d*)/)
235
+ if match
236
+ file_begin = match[1].to_i
237
+ file_end = match[2].to_i if match[2] && !match[2].empty?
238
+ end
239
+ end
240
+
241
+ response.header['Accept-Ranges'] = 'bytes'
242
+ response.header['Content-Range'] = 'bytes ' + file_begin.to_s + '-' + file_end.to_s + '/' + file_size.to_s
243
+ response.header['Content-Length'] = (file_end - file_begin + 1).to_s
244
+ response.header['Last-Modified'] = @attachment.created_on.strftime('%a, %d %b %Y %H:%M:%S %z').to_s
245
+
246
+ if !request.headers['Range']
247
+ send_file(@attachment.diskfile,
248
+ filename: filename_for_content_disposition(@attachment.filename),
249
+ type: @attachment.content_type, disposition: 'inline')
250
+ else
251
+ send_data(File.binread(@attachment.diskfile, file_end - file_begin + 1, file_begin),
252
+ filename: filename_for_content_disposition(@attachment.filename),
253
+ type: @attachment.content_type, disposition: 'inline', status: '206 Partial Content')
254
+ end
255
+
256
+ response.close
257
+ # image
258
+ elsif @attachment.isImage?
259
+ if stale?(etag: @attachment.diskfile)
260
+ send_file(@attachment.diskfile, filename: filename_for_content_disposition(@attachment.filename),
261
+ type: @attachment.content_type, disposition: 'inline')
262
+ end
263
+ # fichier
264
+ else
265
+ send_file(@attachment.diskfile, filename: filename_for_content_disposition(@attachment.filename),
266
+ type: @attachment.content_type, disposition: 'attachment')
267
+ end
268
+ # téléchargement d'un fichier
269
+ else
270
+ @attachment.increment_download if @attachment.container.is_a?(Version) || @attachment.container.is_a?(Project)
271
+ send_file(@attachment.diskfile, filename: filename_for_content_disposition(@attachment.filename),
272
+ type: @attachment.content_type, disposition: 'attachment')
273
+ end
274
+ end
275
+
276
+
277
+ # #### Modification d'une description ################################################ #
278
+ # » Vérifie si l'utilisateur a accès au projet et à la modification
279
+ # » Renvoie l'id du fichier suivi de la description en cas de modification réussie
280
+ # » Supprime certains caractères de la description avant son enregistrement
281
+ def editdesc
282
+
283
+ @attachment.description = params[:description].gsub(/["\\\x0]/, '')
284
+ @attachment.description.strip!
285
+
286
+ # vérification d'accès
287
+ if !User.current.allowed_to?({controller: 'projects', action: 'show'}, @project) || !User.current.allowed_to?(:edit_attachments, @project)
288
+ deny_access
289
+ # modification
290
+ elsif @attachment.save
291
+ if Rails::VERSION::MAJOR >= 5
292
+ render(plain: 'attachmentId' + @attachment.id.to_s + ':' + @attachment.description)
293
+ else
294
+ render(text: 'attachmentId' + @attachment.id.to_s + ':' + @attachment.description)
295
+ end
296
+ # en cas d'erreur
297
+ else
298
+ render_validation_errors(@attachment)
299
+ end
300
+ end
301
+
302
+
303
+ # #### Suppression d'un fichier ###################################################### #
304
+ # » Vérifie si l'utilisateur a accès au projet et à la suppresion
305
+ # » Renvoie l'id du fichier suivi en cas de suppression réussie
306
+ def delete
307
+
308
+ # vérification d'accès
309
+ if !User.current.allowed_to?({controller: 'projects', action: 'show'}, @project) || !User.current.allowed_to?(:delete_attachments, @project)
310
+ deny_access
311
+ # suppression
312
+ elsif @attachment.delete
313
+ @attachment.container.init_journal(User.current) if @attachment.container.respond_to?(:init_journal)
314
+ @attachment.container.attachments.delete(@attachment)
315
+
316
+ if Rails::VERSION::MAJOR >= 5
317
+ render(plain: 'attachmentId' + @attachment.id.to_s)
318
+ else
319
+ render(text: 'attachmentId' + @attachment.id.to_s)
320
+ end
321
+ # en cas d'erreur
322
+ else
323
+ render_validation_errors(@attachment)
324
+ end
325
+ end
326
+ end