Compare commits

...

9 Commits

11 changed files with 54 additions and 40 deletions

View File

@ -4,7 +4,7 @@ ENV SERVERNAME=localhost
ENV UPLOAD_MAX_FILESIZE=24M ENV UPLOAD_MAX_FILESIZE=24M
ENV POST_MAX_SIZE=24M ENV POST_MAX_SIZE=24M
ENV MAX_FILE_UPLOADS=201 ENV MAX_FILE_UPLOADS=201
ENV PDF_STORAGE_PATH= ENV PDF_STORAGE_PATH=/data
ENV DISABLE_ORGANIZATION=false ENV DISABLE_ORGANIZATION=false
ENV PDF_DEMO_LINK=true ENV PDF_DEMO_LINK=true
@ -14,15 +14,11 @@ RUN apt update && \
COPY . /usr/local/signaturepdf COPY . /usr/local/signaturepdf
RUN chown -R www-data:www-data /usr/local/signaturepdf && chmod 750 -R /usr/local/signaturepdf && \ RUN envsubst < /usr/local/signaturepdf/config/php.ini > /usr/local/etc/php/conf.d/uploads.ini && \
chmod 775 -R /usr/local/signaturepdf/entrypoint.sh && \
envsubst < /usr/local/signaturepdf/config/php.ini > /usr/local/etc/php/conf.d/uploads.ini && \
envsubst < /usr/local/signaturepdf/config/apache.conf > /etc/apache2/sites-available/signaturepdf.conf && \ envsubst < /usr/local/signaturepdf/config/apache.conf > /etc/apache2/sites-available/signaturepdf.conf && \
envsubst < /usr/local/signaturepdf/config/config.ini.tpl > /usr/local/signaturepdf/config/config.ini && \ envsubst < /usr/local/signaturepdf/config/config.ini.tpl > /usr/local/signaturepdf/config/config.ini && \
a2enmod rewrite && a2ensite signaturepdf a2enmod rewrite && a2ensite signaturepdf
WORKDIR /usr/local/signaturepdf WORKDIR /usr/local/signaturepdf
USER www-data
CMD /usr/local/signaturepdf/entrypoint.sh CMD /usr/local/signaturepdf/entrypoint.sh

View File

@ -11,7 +11,7 @@ Liste des instances permettant d'utiliser ce logiciel :
- [pdf.hostux.net](https://pdf.hostux.net) - [pdf.hostux.net](https://pdf.hostux.net)
- [pdf.nebulae.co](https://pdf.nebulae.co) - [pdf.nebulae.co](https://pdf.nebulae.co)
*N'hésitez pas à rajouter la votre via une issue ou une pull request* _N'hésitez pas à rajouter la votre via une issue ou une pull request_
## License ## License
@ -23,7 +23,7 @@ Logiciel libre sous license AGPL V3
Dépendances : Dépendances :
- php >= 5.6 - php >= 5.6
- rsvg-convert - rsvg-convert
- pdftk - pdftk
- imagemagick - imagemagick
@ -75,13 +75,13 @@ DocumentRoot /path/to/signaturepdf/public
```bash ```bash
docker build -t signaturepdf . docker build -t signaturepdf .
```` ```
#### Lancement d'un conteneur #### Lancement d'un conteneur
```bash ```bash
docker run -d --name=signaturepdf -p 8080:80 signaturepdf docker run -d --name=signaturepdf -p 8080:80 signaturepdf
```` ```
[localhost:8080](http://localhost:8080) [localhost:8080](http://localhost:8080)
@ -89,15 +89,15 @@ docker run -d --name=signaturepdf -p 8080:80 signaturepdf
Les variables suivantes permettent de configurer le déployement : Les variables suivantes permettent de configurer le déployement :
|Variable|description|exemple|defaut| | Variable | description | exemple | defaut |
|-----|-----|-----|-----| | ---------------------- | ------------------------------------------------------------------ | -------------------------------- | --------- |
|`SERVERNAME`|url de déploiement|`pdf.24eme.fr`|localhost| | `SERVERNAME` | url de déploiement | `pdf.24eme.fr` | localhost |
|`UPLOAD_MAX_FILESIZE`|Taille maximum du fichier PDF à signer|48M|24M| | `UPLOAD_MAX_FILESIZE` | Taille maximum du fichier PDF à signer | 48M | 24M |
|`POST_MAX_SIZE`|Taille maximum du fichier PDF à signer|48M|24M| | `POST_MAX_SIZE` | Taille maximum du fichier PDF à signer | 48M | 24M |
|`MAX_FILE_UPLOADS`|Nombre de pages maximum du PDF, ici 200 pages + le PDF d'origine|401|201| | `MAX_FILE_UPLOADS` | Nombre de pages maximum du PDF, ici 200 pages + le PDF d'origine | 401 | 201 |
|`PDF_STORAGE_PATH`|chemin vers lequel les fichiers pdf uploadés pourront être stockés|/data|| | `PDF_STORAGE_PATH` | chemin vers lequel les fichiers pdf uploadés pourront être stockés | /data | /data |
|`DISABLE_ORGANIZATION`|Desactiver la route Organiser|true|false| | `DISABLE_ORGANIZATION` | Desactiver la route Organiser | true | false |
|`PDF_DEMO_LINK`|Afficher, retirer ou changer le lien de PDF de démo|false, `link` or `relative path`|true| | `PDF_DEMO_LINK` | Afficher, retirer ou changer le lien de PDF de démo | false, `link` or `relative path` | true |
```bash ```bash
docker run -d --name=signaturepdf -p 8080:80 -e SERVERNAME=pdf.example.org -e UPLOAD_MAX_FILESIZE=48M -e POST_MAX_SIZE=48M -e MAX_FILE_UPLOADS=401 -e PDF_STORAGE_PATH=/data signaturepdf docker run -d --name=signaturepdf -p 8080:80 -e SERVERNAME=pdf.example.org -e UPLOAD_MAX_FILESIZE=48M -e POST_MAX_SIZE=48M -e MAX_FILE_UPLOADS=401 -e PDF_STORAGE_PATH=/data signaturepdf
@ -109,6 +109,7 @@ Voici un script permettant d'installer la solution sous Linux Alpine (testé en
Pensez à éditer la variable "domain" en début de script pour correspondre à l'URL avec laquelle elle sera appelée. Pensez à éditer la variable "domain" en début de script pour correspondre à l'URL avec laquelle elle sera appelée.
Les composants principaux sont : Les composants principaux sont :
- php 8 + php-fpm - php 8 + php-fpm
- Nginx - Nginx
- pdftk (installation "manuelle" nécessitant openjdk8) - pdftk (installation "manuelle" nécessitant openjdk8)
@ -117,6 +118,7 @@ Les composants principaux sont :
- librsvg - librsvg
Ce que fait le script : Ce que fait le script :
- Installation des dépendances - Installation des dépendances
- Configuration de php et php-fpm - Configuration de php et php-fpm
- Configuration d'Nginx - Configuration d'Nginx
@ -128,7 +130,7 @@ Ce que fait le script :
domain='sign.example.com' domain='sign.example.com'
apk update apk update
apk add bash nginx git php8 php8-fpm php8-session php8-gd php8-fileinfo openjdk8 imagemagick potrace librsvg apk add bash nginx git php8 php8-fpm php8-session php8-gd php8-fileinfo openjdk8 imagemagick potrace librsvg
cd /tmp cd /tmp
@ -164,7 +166,7 @@ server {
server_name ${domain}; server_name ${domain};
client_max_body_size 0; client_max_body_size 0;
root /var/www/signaturepdf/public/; root /var/www/signaturepdf/public/;
index index.php index.html; index index.php index.html;
@ -185,7 +187,7 @@ server {
fastcgi_buffers 128 128k; fastcgi_buffers 128 128k;
fastcgi_param PATH_INFO \$fastcgi_path_info; fastcgi_param PATH_INFO \$fastcgi_path_info;
fastcgi_param SCRIPT_FILENAME \$document_root\$fastcgi_script_name; fastcgi_param SCRIPT_FILENAME \$document_root\$fastcgi_script_name;
fastcgi_pass 127.0.0.1:9000; fastcgi_pass 127.0.0.1:9000;
} }
@ -223,11 +225,13 @@ cp config/config.ini{.example,}
``` ```
Dans ce fichier `config/config.ini`, il suffit ce configurer la variable `PDF_STORAGE_PATH` avec le chemin vers lequel les fichiers pdf uploadés pourront être stockés : Dans ce fichier `config/config.ini`, il suffit ce configurer la variable `PDF_STORAGE_PATH` avec le chemin vers lequel les fichiers pdf uploadés pourront être stockés :
``` ```
PDF_STORAGE_PATH=/path/to/folder PDF_STORAGE_PATH=/path/to/folder
``` ```
Créer ce dossier : Créer ce dossier :
``` ```
mkdir /path/to/folder mkdir /path/to/folder
``` ```
@ -235,6 +239,7 @@ mkdir /path/to/folder
Le serveur web devra avoir les droits en écriture sur ce dossier. Le serveur web devra avoir les droits en écriture sur ce dossier.
Par exemple pour apache : Par exemple pour apache :
``` ```
chown www-data /path/to/folder/to/store/pdf chown www-data /path/to/folder/to/store/pdf
``` ```
@ -296,6 +301,7 @@ DEBUG=1 make test
- **OpenType.js** outils de transformation d'un texte et sa police en chemin : https://github.com/opentypejs/opentype.js (MIT) - **OpenType.js** outils de transformation d'un texte et sa police en chemin : https://github.com/opentypejs/opentype.js (MIT)
- **ImageMagick** ensemble d'outils de manipulation d'images : https://imagemagick.org/ (Apache-2.0) - **ImageMagick** ensemble d'outils de manipulation d'images : https://imagemagick.org/ (Apache-2.0)
- **Caveat** police de caractères style écriture à la main : https://github.com/googlefonts/caveat (OFL-1.1) - **Caveat** police de caractères style écriture à la main : https://github.com/googlefonts/caveat (OFL-1.1)
- **PDF-LIB** librairie js permettant de manipuler un PDF qui est utilisé pour écrire dans les métadonnées : https://pdf-lib.js.org/ (MIT)
Pour les tests : Pour les tests :
@ -313,6 +319,3 @@ Pour les tests :
Logilab a apporté une contribution financière de 1 365 € TTC à la société 24ème pour développer le mode multi signature. Logilab a apporté une contribution financière de 1 365 € TTC à la société 24ème pour développer le mode multi signature.
Le développement du logiciel a principalement été réalisé sur le temps de travail de salariés du 24ème. Le développement du logiciel a principalement été réalisé sur le temps de travail de salariés du 24ème.

View File

@ -16,7 +16,7 @@ if($f3->get('PDF_STORAGE_PATH') && !preg_match('|/$|', $f3->get('PDF_STORAGE_PAT
$f3->set('PDF_STORAGE_PATH', $f3->get('PDF_STORAGE_PATH').'/'); $f3->set('PDF_STORAGE_PATH', $f3->get('PDF_STORAGE_PATH').'/');
} }
if(!$f3->get('PDF_DEMO_LINK') && $f3->get('PDF_DEMO_LINK') !== false) { if($f3->get('PDF_DEMO_LINK') === null || $f3->get('PDF_DEMO_LINK') === true) {
$f3->set('PDF_DEMO_LINK', 'https://raw.githubusercontent.com/24eme/signaturepdf/master/tests/files/document.pdf'); $f3->set('PDF_DEMO_LINK', 'https://raw.githubusercontent.com/24eme/signaturepdf/master/tests/files/document.pdf');
} }

View File

@ -7,7 +7,7 @@ PDF_STORAGE_PATH=/path/to/folder
; Disable organization tab and routes ; Disable organization tab and routes
;DISABLE_ORGANIZATION=false ;DISABLE_ORGANIZATION=false
; Manage demo link pdf : true (by default, show), false (hide), or custom link ; Manage demo link pdf : true (by default, show with default link), false (hide), or custom link
;PDF_DEMO_LINK=true ;PDF_DEMO_LINK=true
; Metadata default fields ; Metadata default fields

6
entrypoint.sh Normal file → Executable file
View File

@ -1,17 +1,11 @@
#! /bin/bash #! /bin/bash
envsubst < /usr/local/signaturepdf/config/apache.conf > /etc/apache2/sites-available/signaturepdf.conf envsubst < /usr/local/signaturepdf/config/apache.conf > /etc/apache2/sites-available/signaturepdf.conf
envsubst < /usr/local/signaturepdf/config/php.ini > /usr/local/etc/php/conf.d/uploads.ini envsubst < /usr/local/signaturepdf/config/php.ini > /usr/local/etc/php/conf.d/uploads.ini
envsubst < /usr/local/signaturepdf/config/config.ini.tpl > /usr/local/signaturepdf/config/config.ini envsubst < /usr/local/signaturepdf/config/config.ini.tpl > /usr/local/signaturepdf/config/config.ini
chown -R www-data:www-data /usr/local/signaturepdf && chmod 750 -R /usr/local/signaturepdf
if [[ ! -z $PDF_STORAGE_PATH ]] ; then if [[ ! -z $PDF_STORAGE_PATH ]] ; then
mkdir -p $PDF_STORAGE_PATH mkdir -p $PDF_STORAGE_PATH
chown -R www-data:www-data $PDF_STORAGE_PATH
chmod 750 -R $PDF_STORAGE_PATH
fi fi
apache2-foreground apache2-foreground

View File

@ -246,7 +246,14 @@ var pageUpload = async function() {
document.getElementById('page-upload').classList.remove('d-none'); document.getElementById('page-upload').classList.remove('d-none');
document.getElementById('page-metadata').classList.add('d-none'); document.getElementById('page-metadata').classList.add('d-none');
document.getElementById('input_pdf_upload').focus(); document.getElementById('input_pdf_upload').focus();
const cache = await caches.open('pdf'); let cache;
try {
cache = await caches.open('pdf');
} catch (e) {
console.error(e)
alert("Erreur d'accès au cache. Cette application ne fonctionne pas en mode de navigation privée");
return;
}
document.getElementById('input_pdf_upload').addEventListener('change', async function(event) { document.getElementById('input_pdf_upload').addEventListener('change', async function(event) {
let filename = document.getElementById('input_pdf_upload').files[0].name; let filename = document.getElementById('input_pdf_upload').files[0].name;
let response = new Response(document.getElementById('input_pdf_upload').files[0], { "status" : 200, "statusText" : "OK" }); let response = new Response(document.getElementById('input_pdf_upload').files[0], { "status" : 200, "statusText" : "OK" });

View File

@ -740,7 +740,14 @@ var pageUpload = async function() {
document.getElementById('page-upload').classList.remove('d-none'); document.getElementById('page-upload').classList.remove('d-none');
document.getElementById('page-organization').classList.add('d-none'); document.getElementById('page-organization').classList.add('d-none');
document.getElementById('input_pdf_upload').focus(); document.getElementById('input_pdf_upload').focus();
const cache = await caches.open('pdf'); let cache;
try {
cache = await caches.open('pdf');
} catch (e) {
console.error(e)
alert("Erreur d'accès au cache. Cette application ne fonctionne pas en mode de navigation privée");
return;
}
document.getElementById('input_pdf_upload').addEventListener('change', async function(event) { document.getElementById('input_pdf_upload').addEventListener('change', async function(event) {
if(document.getElementById('input_pdf_upload').files[0].size > maxSize) { if(document.getElementById('input_pdf_upload').files[0].size > maxSize) {

View File

@ -996,7 +996,14 @@ var pageUpload = async function() {
document.getElementById('page-upload').classList.remove('d-none'); document.getElementById('page-upload').classList.remove('d-none');
document.getElementById('page-signature').classList.add('d-none'); document.getElementById('page-signature').classList.add('d-none');
document.getElementById('input_pdf_upload').focus(); document.getElementById('input_pdf_upload').focus();
const cache = await caches.open('pdf'); let cache;
try {
cache = await caches.open('pdf');
} catch (e) {
console.error(e)
alert("Erreur d'accès au cache. Cette application ne fonctionne pas en mode de navigation privée");
return;
}
document.getElementById('input_pdf_upload').addEventListener('change', async function(event) { document.getElementById('input_pdf_upload').addEventListener('change', async function(event) {
if(document.getElementById('input_pdf_upload').files[0].size > maxSize) { if(document.getElementById('input_pdf_upload').files[0].size > maxSize) {

View File

@ -35,7 +35,7 @@
<p class="fw-light mb-3 subtitle text-dark text-nowrap" style="overflow: hidden; text-overflow: ellipsis;">Ajouter, modifier ou supprimer les métadonnées d'un PDF</p> <p class="fw-light mb-3 subtitle text-dark text-nowrap" style="overflow: hidden; text-overflow: ellipsis;">Ajouter, modifier ou supprimer les métadonnées d'un PDF</p>
<div class="col-md-6 col-lg-5 col-xl-4 col-xxl-3 mx-auto"> <div class="col-md-6 col-lg-5 col-xl-4 col-xxl-3 mx-auto">
<div class="col-12"> <div class="col-12">
<label class="form-label mt-3" for="input_pdf_upload">Choisir un PDF <small class="opacity-75" style="cursor: help" title="Le PDF ne doit pas dépasser <?php echo round($maxSize / 1024 / 1024) ?> Mo"><i class="bi bi-info-circle"></i></small></label> <label class="form-label mt-3" for="input_pdf_upload">Choisir un PDF</label>
<input id="input_pdf_upload" placeholder="Choisir un PDF" class="form-control form-control-lg" type="file" accept=".pdf,application/pdf" /> <input id="input_pdf_upload" placeholder="Choisir un PDF" class="form-control form-control-lg" type="file" accept=".pdf,application/pdf" />
<p class="mt-2 small fw-light text-dark">&nbsp;</p> <p class="mt-2 small fw-light text-dark">&nbsp;</p>
<?php if($PDF_DEMO_LINK): ?> <?php if($PDF_DEMO_LINK): ?>
@ -102,6 +102,6 @@
<script> <script>
var defaultFields = <?php echo json_encode(isset($METADATA_DEFAULT_FIELDS) ? $METADATA_DEFAULT_FIELDS : array()); ?>; var defaultFields = <?php echo json_encode(isset($METADATA_DEFAULT_FIELDS) ? $METADATA_DEFAULT_FIELDS : array()); ?>;
</script> </script>
<script src="/js/metadata.js?202304201611"></script> <script src="/js/metadata.js?202304030148"></script>
</body> </body>
</html> </html>

View File

@ -157,6 +157,6 @@
<script> <script>
var maxSize = <?php echo $maxSize ?>; var maxSize = <?php echo $maxSize ?>;
</script> </script>
<script src="/js/organization.js?202212070154"></script> <script src="/js/organization.js?202304030148"></script>
</body> </body>
</html> </html>

View File

@ -265,6 +265,6 @@
hash = "<?php echo $hash ?>"; hash = "<?php echo $hash ?>";
<?php endif; ?> <?php endif; ?>
</script> </script>
<script src="/js/signature.js?202204270035"></script> <script src="/js/signature.js?202304030148"></script>
</body> </body>
</html> </html>