From f42d355fd74fc32ea62fd85e17de304e146ca9c3 Mon Sep 17 00:00:00 2001 From: Abijeet Date: Tue, 13 Mar 2018 09:10:23 +0530 Subject: [PATCH 01/25] Fixes issue with the validation message not being translated. Signed-off-by: Abijeet --- app/Http/Controllers/ImageController.php | 2 +- app/Providers/AppServiceProvider.php | 2 +- resources/lang/en/validation.php | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/Http/Controllers/ImageController.php b/app/Http/Controllers/ImageController.php index a61f447eb..17e690813 100644 --- a/app/Http/Controllers/ImageController.php +++ b/app/Http/Controllers/ImageController.php @@ -120,7 +120,7 @@ class ImageController extends Controller { $this->checkPermission('image-create-all'); $this->validate($request, [ - 'file' => 'is_image' + 'file' => 'image' ]); if (!$this->imageRepo->isValidType($type)) { diff --git a/app/Providers/AppServiceProvider.php b/app/Providers/AppServiceProvider.php index b06b2f3a2..57e5c8ed5 100644 --- a/app/Providers/AppServiceProvider.php +++ b/app/Providers/AppServiceProvider.php @@ -15,7 +15,7 @@ class AppServiceProvider extends ServiceProvider public function boot() { // Custom validation methods - Validator::extend('is_image', function ($attribute, $value, $parameters, $validator) { + Validator::extend('image', function ($attribute, $value, $parameters, $validator) { $imageMimes = ['image/png', 'image/bmp', 'image/gif', 'image/jpeg', 'image/jpg', 'image/tiff', 'image/webp']; return in_array($value->getMimeType(), $imageMimes); }); diff --git a/resources/lang/en/validation.php b/resources/lang/en/validation.php index b75af7485..7c06264ab 100644 --- a/resources/lang/en/validation.php +++ b/resources/lang/en/validation.php @@ -37,7 +37,7 @@ return [ 'email' => 'The :attribute must be a valid email address.', 'filled' => 'The :attribute field is required.', 'exists' => 'The selected :attribute is invalid.', - 'image' => 'The :attribute must be an image.', + 'image' => 'The :attribute must be an image.', 'in' => 'The selected :attribute is invalid.', 'integer' => 'The :attribute must be an integer.', 'ip' => 'The :attribute must be a valid IP address.', From d859be3a128cf3a624f70cd082d3ed09124769a3 Mon Sep 17 00:00:00 2001 From: Abijeet Date: Sun, 18 Mar 2018 18:44:11 +0530 Subject: [PATCH 02/25] Fixes a number of issues with the image uploader. Read below, - Added a remove link to remove files that have an error. - Error will appear below the progress bar. - Hovering on dz-image or dz-details will display the error message. Otherwise error message was covering the remove link as well. - Removed styling around the file size. - Removed gradient effect in accordance with BookStack styling. - Dropzone filenae will not overflow the container element. Also done for page attachments - Added a 'uploaded' error message. this error was being thrown when the file size exceeded the server configured file size. (https://stackoverflow.com/a/42934387/903324) Towards #741 Signed-off-by: Abijeet --- .../assets/js/vues/components/dropzone.js | 6 +++-- resources/assets/sass/_components.scss | 27 +++++++++++-------- resources/assets/sass/_pages.scss | 3 +++ resources/lang/en/components.php | 3 ++- resources/lang/en/errors.php | 3 ++- resources/lang/en/validation.php | 2 +- 6 files changed, 28 insertions(+), 16 deletions(-) diff --git a/resources/assets/js/vues/components/dropzone.js b/resources/assets/js/vues/components/dropzone.js index 0f31bd579..e0a6d8b9d 100644 --- a/resources/assets/js/vues/components/dropzone.js +++ b/resources/assets/js/vues/components/dropzone.js @@ -13,6 +13,8 @@ function mounted() { let container = this.$el; let _this = this; new DropZone(container, { + addRemoveLinks: true, + dictRemoveFile: trans('components.image_upload_remove'), url: function() { return _this.uploadUrl; }, @@ -41,7 +43,7 @@ function mounted() { $(file.previewElement).find('[data-dz-errormessage]').text(message); } - if (xhr.status === 413) setMessage(trans('errors.server_upload_limit')); + if (xhr && xhr.status === 413) setMessage(trans('errors.server_upload_limit')); if (errorMessage.file) setMessage(errorMessage.file[0]); }); } @@ -57,4 +59,4 @@ module.exports = { props, mounted, data, -}; \ No newline at end of file +}; diff --git a/resources/assets/sass/_components.scss b/resources/assets/sass/_components.scss index 70cfaf2b4..30edd0451 100644 --- a/resources/assets/sass/_components.scss +++ b/resources/assets/sass/_components.scss @@ -207,6 +207,7 @@ body.flexbox-support #entity-selector-wrap .popup-body .form-group { margin-left: 1px; padding: $-m $-l; overflow-y: auto; + overflow-x: hidden; border-left: 1px solid #DDD; .dropzone-container { margin-top: $-m; @@ -311,8 +312,7 @@ body.flexbox-support #entity-selector-wrap .popup-body .form-group { .dz-preview.dz-file-preview .dz-image { border-radius: 4px; - background: #999; - background: linear-gradient(to bottom, #eee, #ddd); + background: #e9e9e9; } .dz-preview.dz-file-preview .dz-details { @@ -328,11 +328,12 @@ body.flexbox-support #entity-selector-wrap .popup-body .form-group { } .dz-preview .dz-remove { - font-size: 14px; + font-size: 13px; text-align: center; display: block; cursor: pointer; border: none; + margin-top: 3px; } .dz-preview .dz-remove:hover { @@ -381,7 +382,7 @@ body.flexbox-support #entity-selector-wrap .popup-body .form-group { border: 1px solid transparent; } -.dz-preview .dz-details .dz-filename span, .dz-preview .dz-details .dz-size span { +.dz-preview .dz-details .dz-filename span { background-color: rgba(255, 255, 255, 0.4); padding: 0 0.4em; border-radius: 3px; @@ -417,13 +418,13 @@ body.flexbox-support #entity-selector-wrap .popup-body .form-group { .dz-preview .dz-success-mark, .dz-preview .dz-error-mark { pointer-events: none; opacity: 0; - z-index: 500; + z-index: 1001; position: absolute; display: block; top: 50%; left: 50%; margin-left: -27px; - margin-top: -27px; + margin-top: -35px; } .dz-preview .dz-success-mark svg, .dz-preview .dz-error-mark svg { @@ -478,9 +479,13 @@ body.flexbox-support #entity-selector-wrap .popup-body .form-group { display: block; } -.dz-preview.dz-error:hover .dz-error-message { - opacity: 1; - pointer-events: auto; +.dz-preview.dz-error { + .dz-image, .dz-details { + &:hover ~ .dz-error-message { + opacity: 1; + pointer-events: auto; + } + } } .dz-preview .dz-error-message { @@ -492,7 +497,7 @@ body.flexbox-support #entity-selector-wrap .popup-body .form-group { opacity: 0; transition: opacity 0.3s ease; border-radius: 4px; - font-size: 11.5px; + font-size: 12px; line-height: 1.2; top: 88px; left: -26px; @@ -593,4 +598,4 @@ body.flexbox-support #entity-selector-wrap .popup-body .form-group { .text-muted { color: #999; } -} \ No newline at end of file +} diff --git a/resources/assets/sass/_pages.scss b/resources/assets/sass/_pages.scss index 8eb3d2923..cb1cae19f 100755 --- a/resources/assets/sass/_pages.scss +++ b/resources/assets/sass/_pages.scss @@ -209,6 +209,9 @@ flex: 1; padding-top: 0; } + div[toolbox-tab-content] .padded.files { + overflow-x: hidden; + } h4 { font-size: 24px; margin: $-m 0 0 0; diff --git a/resources/lang/en/components.php b/resources/lang/en/components.php index 334502d05..2266fe2b2 100644 --- a/resources/lang/en/components.php +++ b/resources/lang/en/components.php @@ -21,6 +21,7 @@ return [ 'image_upload_success' => 'Image uploaded successfully', 'image_update_success' => 'Image details successfully updated', 'image_delete_success' => 'Image successfully deleted', + 'image_upload_remove' => 'Remove', /** * Code editor @@ -29,4 +30,4 @@ return [ 'code_language' => 'Code Language', 'code_content' => 'Code Content', 'code_save' => 'Save Code', -]; \ No newline at end of file +]; diff --git a/resources/lang/en/errors.php b/resources/lang/en/errors.php index 3b1d6e8b3..a86a1cdfc 100644 --- a/resources/lang/en/errors.php +++ b/resources/lang/en/errors.php @@ -35,6 +35,7 @@ return [ 'cannot_get_image_from_url' => 'Cannot get image from :url', 'cannot_create_thumbs' => 'The server cannot create thumbnails. Please check you have the GD PHP extension installed.', 'server_upload_limit' => 'The server does not allow uploads of this size. Please try a smaller file size.', + 'uploaded' => 'The server does not allow uploads of this size. Please try a smaller file size.', 'image_upload_error' => 'An error occurred uploading the image', 'image_upload_type_error' => 'The image type being uploaded is invalid', @@ -78,4 +79,4 @@ return [ 'error_occurred' => 'An Error Occurred', 'app_down' => ':appName is down right now', 'back_soon' => 'It will be back up soon.', -]; \ No newline at end of file +]; diff --git a/resources/lang/en/validation.php b/resources/lang/en/validation.php index 7c06264ab..b75af7485 100644 --- a/resources/lang/en/validation.php +++ b/resources/lang/en/validation.php @@ -37,7 +37,7 @@ return [ 'email' => 'The :attribute must be a valid email address.', 'filled' => 'The :attribute field is required.', 'exists' => 'The selected :attribute is invalid.', - 'image' => 'The :attribute must be an image.', + 'image' => 'The :attribute must be an image.', 'in' => 'The selected :attribute is invalid.', 'integer' => 'The :attribute must be an integer.', 'ip' => 'The :attribute must be a valid IP address.', From bb7fab1dc0a97d35a7430e8cc70974fffa64342f Mon Sep 17 00:00:00 2001 From: Alwaysin Date: Sun, 18 Mar 2018 14:20:20 +0100 Subject: [PATCH 03/25] Update activities.php --- resources/lang/fr/activities.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/resources/lang/fr/activities.php b/resources/lang/fr/activities.php index 32f225d5d..a59c9a543 100644 --- a/resources/lang/fr/activities.php +++ b/resources/lang/fr/activities.php @@ -37,4 +37,7 @@ return [ 'book_sort' => 'a réordonné le livre', 'book_sort_notification' => 'Livre réordonné avec succès', + // Other + 'commented_on' => 'a commenté' + ]; From 098b5941047e21431f7f0be44282ea4c6ecb115e Mon Sep 17 00:00:00 2001 From: Alwaysin Date: Sun, 18 Mar 2018 14:21:11 +0100 Subject: [PATCH 04/25] Update auth.php --- resources/lang/fr/auth.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/resources/lang/fr/auth.php b/resources/lang/fr/auth.php index 015bfdff0..154066ae4 100644 --- a/resources/lang/fr/auth.php +++ b/resources/lang/fr/auth.php @@ -18,6 +18,8 @@ return [ */ 'sign_up' => "S'inscrire", 'log_in' => 'Se connecter', + 'log_in_with' => 'Se connecter avec :socialDriver', + 'sign_up_with' => 'S\'inscrire avec :socialDriver', 'logout' => 'Se déconnecter', 'name' => 'Nom', From 018084a9515129455953992bde0745eb81104a56 Mon Sep 17 00:00:00 2001 From: Alwaysin Date: Sun, 18 Mar 2018 14:23:08 +0100 Subject: [PATCH 05/25] Update common.php --- resources/lang/fr/common.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/resources/lang/fr/common.php b/resources/lang/fr/common.php index 2553d1482..823c6ee2f 100644 --- a/resources/lang/fr/common.php +++ b/resources/lang/fr/common.php @@ -10,6 +10,7 @@ return [ 'save' => 'Enregistrer', 'continue' => 'Continuer', 'select' => 'Sélectionner', + 'more' => 'Montrer plus', /** * Form Labels @@ -29,11 +30,13 @@ return [ 'edit' => 'Editer', 'sort' => 'Trier', 'move' => 'Déplacer', + 'reply' => 'Répondre', 'delete' => 'Supprimer', 'search' => 'Chercher', 'search_clear' => 'Réinitialiser la recherche', 'reset' => 'Réinitialiser', 'remove' => 'Enlever', + 'add' => 'Ajouter', /** @@ -45,6 +48,9 @@ return [ 'back_to_top' => 'Retour en haut', 'toggle_details' => 'Afficher les détails', 'toggle_thumbnails' => 'Afficher les vignettes', + 'details' => 'Détails', + 'grid_view' => 'Vue en grille', + 'list_view' => 'Vue en liste', /** * Header From 880987f15c2621fabc3c9ef27c2dbad5693f14ba Mon Sep 17 00:00:00 2001 From: Alwaysin Date: Sun, 18 Mar 2018 14:23:42 +0100 Subject: [PATCH 06/25] Update components.php --- resources/lang/fr/components.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/resources/lang/fr/components.php b/resources/lang/fr/components.php index 7c9c4cfc0..ddfe665d9 100644 --- a/resources/lang/fr/components.php +++ b/resources/lang/fr/components.php @@ -20,5 +20,13 @@ return [ 'image_preview' => 'Prévisualiser l\'image', 'image_upload_success' => 'Image ajoutée avec succès', 'image_update_success' => 'Détails de l\'image mis à jour', - 'image_delete_success' => 'Image supprimée avec succès' + 'image_delete_success' => 'Image supprimée avec succès', + + /** + * Code editor + */ + 'code_editor' => 'Editer le code', + 'code_language' => 'Language du code', + 'code_content' => 'Contenu du code', + 'code_save' => 'Enregistrer le code', ]; From accd936781fc80ed020fe9118a86571d0d4b924d Mon Sep 17 00:00:00 2001 From: Alwaysin Date: Sun, 18 Mar 2018 14:24:39 +0100 Subject: [PATCH 07/25] Update settings.php --- resources/lang/fr/settings.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/resources/lang/fr/settings.php b/resources/lang/fr/settings.php index 2f0163368..ea6214d84 100644 --- a/resources/lang/fr/settings.php +++ b/resources/lang/fr/settings.php @@ -31,6 +31,9 @@ return [ 'app_logo_desc' => 'Cette image doit faire 43px de hauteur.
Les images plus larges seront réduites.', 'app_primary_color' => 'Couleur principale de l\'application', 'app_primary_color_desc' => 'Cela devrait être une valeur hexadécimale.
Laisser vide pour rétablir la couleur par défaut.', + 'app_homepage' => 'Page d\'accueil de l\'application', + 'app_homepage_desc' => 'Choisissez une page à afficher sur la page d\'accueil au lieu de la vue par défaut. Les permissions sont ignorées pour les pages sélectionnées.', + 'app_homepage_default' => 'Page d\'accueil par défaut sélectionnée', 'app_disable_comments' => 'Désactiver les commentaires', 'app_disable_comments_desc' => 'Désactive les commentaires sur toutes les pages de l\'application. Les commentaires existants ne sont pas affichés.', /** From 83d830fd7dce94ba776bb6db9356f52ef9f98092 Mon Sep 17 00:00:00 2001 From: Abijeet Date: Sun, 18 Mar 2018 18:58:04 +0530 Subject: [PATCH 08/25] Fixes the icons not being aligned properly in attached items section for the page. Also formatting. Signed-off-by: Abijeet --- resources/assets/sass/_blocks.scss | 8 ++++---- resources/assets/sass/_components.scss | 12 ++++++------ 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/resources/assets/sass/_blocks.scss b/resources/assets/sass/_blocks.scss index e3238f4b4..4cf2397bc 100644 --- a/resources/assets/sass/_blocks.scss +++ b/resources/assets/sass/_blocks.scss @@ -224,15 +224,15 @@ padding: 0; align-items: center; text-align: center; + justify-content: center; width: 28px; padding-left: $-xs; padding-right: $-xs; &:hover { background-color: #EEE; } - i { - flex: 1; - padding: 0; + .svg-icon { + margin-right: 0px; } } > div .outline input { @@ -258,4 +258,4 @@ background-color: #F8F8F8; padding: $-m; border: 1px solid #DDD; -} \ No newline at end of file +} diff --git a/resources/assets/sass/_components.scss b/resources/assets/sass/_components.scss index 30edd0451..0b5d767fa 100644 --- a/resources/assets/sass/_components.scss +++ b/resources/assets/sass/_components.scss @@ -480,12 +480,12 @@ body.flexbox-support #entity-selector-wrap .popup-body .form-group { } .dz-preview.dz-error { - .dz-image, .dz-details { - &:hover ~ .dz-error-message { - opacity: 1; - pointer-events: auto; - } - } + .dz-image, .dz-details { + &:hover ~ .dz-error-message { + opacity: 1; + pointer-events: auto; + } + } } .dz-preview .dz-error-message { From 35c7e002030ff9b5bb6f4b60ed9d6e955352a4ef Mon Sep 17 00:00:00 2001 From: Alwaysin Date: Sun, 18 Mar 2018 14:46:56 +0100 Subject: [PATCH 09/25] Update entities.php --- resources/lang/fr/entities.php | 38 ++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/resources/lang/fr/entities.php b/resources/lang/fr/entities.php index d4d9d2475..011d8678c 100644 --- a/resources/lang/fr/entities.php +++ b/resources/lang/fr/entities.php @@ -14,6 +14,7 @@ return [ 'recent_activity' => 'Activité récente', 'create_now' => 'En créer un maintenant', 'revisions' => 'Révisions', + 'meta_revision' => 'Révision #:revisionCount', 'meta_created' => 'Créé :timeLength', 'meta_created_name' => 'Créé :timeLength par :user', 'meta_updated' => 'Mis à jour :timeLength', @@ -43,19 +44,39 @@ return [ * Search */ 'search_results' => 'Résultats de recherche', + 'search_total_results_found' => ':count résultats trouvés|:count résultats trouvés au total', 'search_clear' => 'Réinitialiser la recherche', 'search_no_pages' => 'Aucune page correspondant à cette recherche', 'search_for_term' => 'recherche pour :term', + 'search_more' => 'Plus de résultats', + 'search_filters' => 'Filtres de recherche', + 'search_content_type' => 'Type de contenu', + 'search_exact_matches' => 'Correspondances exactes', + 'search_tags' => 'Recherche par tags', + 'search_viewed_by_me' => 'Vu par moi', + 'search_not_viewed_by_me' => 'Non vu par moi', + 'search_permissions_set' => 'Ensemble d\'autorisations', + 'search_created_by_me' => 'Créé par moi', + 'search_updated_by_me' => 'Mis à jour par moi', + 'search_updated_before' => 'Mis à jour avant', + 'search_updated_after' => 'Mis à jour après', + 'search_created_before' => 'Créé avant', + 'search_created_after' => 'Créé après', + 'search_set_date' => 'Choisir la date', + 'search_update' => 'Actualiser la recherche' /** * Books */ 'book' => 'Livre', 'books' => 'Livres', + 'x_books' => ':count livre|:count livres', 'books_empty' => 'Aucun livre n\'a été créé', 'books_popular' => 'Livres populaires', 'books_recent' => 'Livres récents', + 'books_new' => 'Nouveaux livres', 'books_popular_empty' => 'Les livres les plus populaires apparaîtront ici.', + 'books_new_empty' => 'Les livres les plus récents apparaitront ici.', 'books_create' => 'Créer un nouveau livre', 'books_delete' => 'Supprimer un livre', 'books_delete_named' => 'Supprimer le livre :bookName', @@ -85,6 +106,7 @@ return [ */ 'chapter' => 'Chapitre', 'chapters' => 'Chapitres', + 'x_chapters' => ':count chapitre|:count chapitres', 'chapters_popular' => 'Chapitres populaires', 'chapters_new' => 'Nouveau chapitre', 'chapters_create' => 'Créer un nouveau chapitre', @@ -102,6 +124,7 @@ return [ 'chapters_empty' => 'Il n\'y a pas de page dans ce chapitre actuellement.', 'chapters_permissions_active' => 'Permissions du chapitre activées', 'chapters_permissions_success' => 'Permissions du chapitre mises à jour', + 'chapters_search_this' => 'Rechercher dans ce chapitre', /** * Pages @@ -139,16 +162,19 @@ return [ 'pages_md_preview' => 'Prévisualisation', 'pages_md_insert_image' => 'Insérer une image', 'pages_md_insert_link' => 'Insérer un lien', + 'pages_md_insert_drawing' => 'Insérer un dessin', 'pages_not_in_chapter' => 'La page n\'est pas dans un chapitre', 'pages_move' => 'Déplacer la page', 'pages_move_success' => 'Page déplacée à ":parentName"', 'pages_permissions' => 'Permissions de la page', 'pages_permissions_success' => 'Permissions de la page mises à jour', + 'pages_revision' => 'Révision', 'pages_revisions' => 'Révisions de la page', 'pages_revisions_named' => 'Révisions pour :pageName', 'pages_revision_named' => 'Révision pour :pageName', 'pages_revisions_created_by' => 'Créé par', 'pages_revisions_date' => 'Date de révision', + 'pages_revisions_number' => '#', 'pages_revisions_changelog' => 'Journal des changements', 'pages_revisions_changes' => 'Changements', 'pages_revisions_current' => 'Version courante', @@ -219,6 +245,18 @@ return [ */ 'comment' => 'Commentaire', 'comments' => 'Commentaires', + 'comment_add' => 'Ajouter un commentaire', 'comment_placeholder' => 'Entrez vos commentaires ici', + 'comment_count' => '{0} Pas de commentaires|{1} 1 Commentaire|[2,*] :count Commentaires', 'comment_save' => 'Enregistrer le commentaire', + 'comment_saving' => 'Enregistrement du commentaire...', + 'comment_deleting' => 'Suppression du commentaire...', + 'comment_new' => 'Nouveau commentaire', + 'comment_created' => 'commenté :createDiff', + 'comment_updated' => 'Mis à jour :updateDiff par :username', + 'comment_deleted_success' => 'Commentaire supprimé', + 'comment_created_success' => 'Commentaire ajouté', + 'comment_updated_success' => 'Commentaire mis à jour', + 'comment_delete_confirm' => 'Etes-vous sûr de vouloir supprimer ce commentaire?', + 'comment_in_reply_to' => 'En réponse à :commentId', ]; From 3a5c20c17e4228ad37a35e7267ab890c7ae92bcb Mon Sep 17 00:00:00 2001 From: Abijeet Date: Sun, 18 Mar 2018 23:38:37 +0530 Subject: [PATCH 10/25] Removing the selected image and clearing the dropdzone on dialog close. Towards #741 Signed-off-by: Abijeet --- resources/assets/js/vues/components/dropzone.js | 11 +++++++++-- resources/assets/js/vues/image-manager.js | 4 +++- resources/views/components/image-manager.blade.php | 6 +++--- 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/resources/assets/js/vues/components/dropzone.js b/resources/assets/js/vues/components/dropzone.js index e0a6d8b9d..65717b86b 100644 --- a/resources/assets/js/vues/components/dropzone.js +++ b/resources/assets/js/vues/components/dropzone.js @@ -12,7 +12,7 @@ const props = ['placeholder', 'uploadUrl', 'uploadedTo']; function mounted() { let container = this.$el; let _this = this; - new DropZone(container, { + this._dz = new DropZone(container, { addRemoveLinks: true, dictRemoveFile: trans('components.image_upload_remove'), url: function() { @@ -51,12 +51,19 @@ function mounted() { } function data() { - return {} + return {}; } +const methods = { + onClose: function () { + this._dz.removeAllFiles(true); + } +}; + module.exports = { template, props, mounted, data, + methods }; diff --git a/resources/assets/js/vues/image-manager.js b/resources/assets/js/vues/image-manager.js index 12ccc970d..89fe6769e 100644 --- a/resources/assets/js/vues/image-manager.js +++ b/resources/assets/js/vues/image-manager.js @@ -43,6 +43,8 @@ const methods = { hide() { this.showing = false; + this.selectedImage = false; + this.$refs.dropzone.onClose(); this.$el.children[0].components.overlay.hide(); }, @@ -175,4 +177,4 @@ module.exports = { data, computed, components: {dropzone}, -}; \ No newline at end of file +}; diff --git a/resources/views/components/image-manager.blade.php b/resources/views/components/image-manager.blade.php index b860038b4..78c6435d6 100644 --- a/resources/views/components/image-manager.blade.php +++ b/resources/views/components/image-manager.blade.php @@ -1,10 +1,10 @@
-
+
From bf8dddd99c6adec29c58e30697980f858c494667 Mon Sep 17 00:00:00 2001 From: Abijeet Date: Mon, 19 Mar 2018 01:44:33 +0530 Subject: [PATCH 11/25] Not resizing gif images. See - https://github.com/Intervention/image/issues/176 Fixes #223 Signed-off-by: Abijeet --- app/Services/ImageService.php | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/app/Services/ImageService.php b/app/Services/ImageService.php index 9755ea307..6686082ee 100644 --- a/app/Services/ImageService.php +++ b/app/Services/ImageService.php @@ -170,6 +170,15 @@ class ImageService extends UploadService return $image->path; } + /** + * Checks if the image is a gif. Returns true if it is, else false. + * @param Image $image + * @return boolean + */ + protected function isGif(Image $image) { + return strtolower(pathinfo($this->getPath($image), PATHINFO_EXTENSION)) === 'gif'; + } + /** * Get the thumbnail for an image. * If $keepRatio is true only the width will be used. @@ -184,6 +193,10 @@ class ImageService extends UploadService */ public function getThumbnail(Image $image, $width = 220, $height = 220, $keepRatio = false) { + if ($keepRatio && $this->isGif($image)) { + return $this->getPublicUrl($this->getPath($image)); + } + $thumbDirName = '/' . ($keepRatio ? 'scaled-' : 'thumbs-') . $width . '-' . $height . '/'; $imagePath = $this->getPath($image); $thumbFilePath = dirname($imagePath) . $thumbDirName . basename($imagePath); From 2cfcbe0a3cd6700b562a81fd46b71549667d048a Mon Sep 17 00:00:00 2001 From: Abijeet Date: Mon, 19 Mar 2018 02:09:01 +0530 Subject: [PATCH 12/25] Fixes an issue with handling of large image files. Signed-off-by: Abijeet --- resources/assets/js/vues/components/dropzone.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/assets/js/vues/components/dropzone.js b/resources/assets/js/vues/components/dropzone.js index 0f31bd579..3e6e6c730 100644 --- a/resources/assets/js/vues/components/dropzone.js +++ b/resources/assets/js/vues/components/dropzone.js @@ -42,7 +42,7 @@ function mounted() { } if (xhr.status === 413) setMessage(trans('errors.server_upload_limit')); - if (errorMessage.file) setMessage(errorMessage.file[0]); + else if (errorMessage.file) setMessage(errorMessage.file); }); } }); From 2d1567ea300f67c84e1b57afcb9712d98ff345a1 Mon Sep 17 00:00:00 2001 From: Soseki Masao Date: Fri, 23 Mar 2018 17:35:21 +0900 Subject: [PATCH 13/25] update japanese translation --- resources/lang/ja/common.php | 1 + resources/lang/ja/entities.php | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/resources/lang/ja/common.php b/resources/lang/ja/common.php index 185e6116c..8b6ffb777 100644 --- a/resources/lang/ja/common.php +++ b/resources/lang/ja/common.php @@ -23,6 +23,7 @@ return [ */ 'actions' => '実行', 'view' => '表示', + 'reply' => '返信', 'create' => '作成', 'update' => '更新', 'edit' => '編集', diff --git a/resources/lang/ja/entities.php b/resources/lang/ja/entities.php index 8d215516d..f56eaab2e 100644 --- a/resources/lang/ja/entities.php +++ b/resources/lang/ja/entities.php @@ -233,4 +233,23 @@ return [ 'profile_not_created_pages' => ':userNameはページを作成していません', 'profile_not_created_chapters' => ':userNameはチャプターを作成していません', 'profile_not_created_books' => ':userNameはブックを作成していません', + + /** + * Comments + */ + 'comment' => 'コメント', + 'comments' => 'コメント', + 'comment_placeholder' => 'コメントを記入してく下さい', + 'comment_count' => '{0} コメントはありません|{1} コメント(1)|[2,*] コメント(:count)', + 'comment_save' => 'コメントを保存', + 'comment_saving' => 'コメントを保存...', + 'comment_deleting' => 'コメントを削除...', + 'comment_new' => '新規コメント作成', + 'comment_created' => 'commented :createDiff', + 'comment_updated' => 'Updated :updateDiff by :username', + 'comment_deleted_success' => 'コメントを削除しました', + 'comment_created_success' => 'コメントを追加しました', + 'comment_updated_success' => 'コメントを更新しました', + 'comment_delete_confirm' => '本当にこのコメントを削除しますか?', + 'comment_in_reply_to' => ':commentIdへ返信', ]; From 696ef3ff33911ace0096119cd863add2e941a30a Mon Sep 17 00:00:00 2001 From: Soseki Masao Date: Fri, 23 Mar 2018 18:20:44 +0900 Subject: [PATCH 14/25] fix entities.php --- resources/lang/ja/entities.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/resources/lang/ja/entities.php b/resources/lang/ja/entities.php index f56eaab2e..4431e0578 100644 --- a/resources/lang/ja/entities.php +++ b/resources/lang/ja/entities.php @@ -242,11 +242,11 @@ return [ 'comment_placeholder' => 'コメントを記入してく下さい', 'comment_count' => '{0} コメントはありません|{1} コメント(1)|[2,*] コメント(:count)', 'comment_save' => 'コメントを保存', - 'comment_saving' => 'コメントを保存...', - 'comment_deleting' => 'コメントを削除...', + 'comment_saving' => 'コメントを保存中...', + 'comment_deleting' => 'コメントを削除中...', 'comment_new' => '新規コメント作成', - 'comment_created' => 'commented :createDiff', - 'comment_updated' => 'Updated :updateDiff by :username', + 'comment_created' => 'コメントを作成しました :createDiff', + 'comment_updated' => ':username により更新しました :updateDiff', 'comment_deleted_success' => 'コメントを削除しました', 'comment_created_success' => 'コメントを追加しました', 'comment_updated_success' => 'コメントを更新しました', From 3df7d828eb1134009d2d4bd65edc4ddffa750844 Mon Sep 17 00:00:00 2001 From: Dan Brown Date: Sat, 24 Mar 2018 15:25:13 +0000 Subject: [PATCH 15/25] Fixed failing tests Fixed syntax error in french translations. Removed 'required' on image validation which was breaking tests --- app/Http/Controllers/ImageController.php | 3 ++- app/Providers/AppServiceProvider.php | 2 +- resources/lang/fr/entities.php | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/app/Http/Controllers/ImageController.php b/app/Http/Controllers/ImageController.php index 9782a94c4..8437c80d7 100644 --- a/app/Http/Controllers/ImageController.php +++ b/app/Http/Controllers/ImageController.php @@ -120,7 +120,7 @@ class ImageController extends Controller { $this->checkPermission('image-create-all'); $this->validate($request, [ - 'file' => 'required|image' + 'file' => 'is_image' ]); if (!$this->imageRepo->isValidType($type)) { @@ -136,6 +136,7 @@ class ImageController extends Controller return response($e->getMessage(), 500); } + return response()->json($image); } diff --git a/app/Providers/AppServiceProvider.php b/app/Providers/AppServiceProvider.php index 57e5c8ed5..b06b2f3a2 100644 --- a/app/Providers/AppServiceProvider.php +++ b/app/Providers/AppServiceProvider.php @@ -15,7 +15,7 @@ class AppServiceProvider extends ServiceProvider public function boot() { // Custom validation methods - Validator::extend('image', function ($attribute, $value, $parameters, $validator) { + Validator::extend('is_image', function ($attribute, $value, $parameters, $validator) { $imageMimes = ['image/png', 'image/bmp', 'image/gif', 'image/jpeg', 'image/jpg', 'image/tiff', 'image/webp']; return in_array($value->getMimeType(), $imageMimes); }); diff --git a/resources/lang/fr/entities.php b/resources/lang/fr/entities.php index 011d8678c..7d0696c2a 100644 --- a/resources/lang/fr/entities.php +++ b/resources/lang/fr/entities.php @@ -63,7 +63,7 @@ return [ 'search_created_before' => 'Créé avant', 'search_created_after' => 'Créé après', 'search_set_date' => 'Choisir la date', - 'search_update' => 'Actualiser la recherche' + 'search_update' => 'Actualiser la recherche', /** * Books From f101c1a622fbce7e22ad94bc93b17f234cc841cb Mon Sep 17 00:00:00 2001 From: Dan Brown Date: Sat, 24 Mar 2018 18:46:31 +0000 Subject: [PATCH 16/25] Made search more efficient and tweaked weighting Added per-entity weighting changes. Now Books score higher than chapters which score higher than pages. Reduced queries required on search by only searching once but at a higher count to see if there's another page. --- app/Book.php | 1 + app/Chapter.php | 2 ++ app/Entity.php | 9 +++++++++ app/Http/Controllers/SearchController.php | 3 +-- app/Services/SearchService.php | 17 +++++++++-------- 5 files changed, 22 insertions(+), 10 deletions(-) diff --git a/app/Book.php b/app/Book.php index 457a4c928..51ea226b4 100644 --- a/app/Book.php +++ b/app/Book.php @@ -2,6 +2,7 @@ class Book extends Entity { + public $searchFactor = 2; protected $fillable = ['name', 'description', 'image_id']; diff --git a/app/Chapter.php b/app/Chapter.php index 6dab9dc47..3726c57f4 100644 --- a/app/Chapter.php +++ b/app/Chapter.php @@ -2,6 +2,8 @@ class Chapter extends Entity { + public $searchFactor = 1.3; + protected $fillable = ['name', 'description', 'priority', 'book_id']; protected $with = ['book']; diff --git a/app/Entity.php b/app/Entity.php index 1ea4e8dac..aeeab4960 100644 --- a/app/Entity.php +++ b/app/Entity.php @@ -5,8 +5,16 @@ use Illuminate\Database\Eloquent\Relations\MorphMany; class Entity extends Ownable { + /** + * @var string - Name of property where the main text content is found + */ public $textField = 'description'; + /** + * @var float - Multiplier for search indexing. + */ + public $searchFactor = 1.0; + /** * Compares this entity to another given entity. * Matches by comparing class and id. @@ -193,4 +201,5 @@ class Entity extends Ownable { return '/'; } + } diff --git a/app/Http/Controllers/SearchController.php b/app/Http/Controllers/SearchController.php index 0827eeb71..ddc92f705 100644 --- a/app/Http/Controllers/SearchController.php +++ b/app/Http/Controllers/SearchController.php @@ -40,13 +40,12 @@ class SearchController extends Controller $nextPageLink = baseUrl('/search?term=' . urlencode($searchTerm) . '&page=' . ($page+1)); $results = $this->searchService->searchEntities($searchTerm, 'all', $page, 20); - $hasNextPage = $this->searchService->searchEntities($searchTerm, 'all', $page+1, 20)['count'] > 0; return view('search/all', [ 'entities' => $results['results'], 'totalResults' => $results['total'], 'searchTerm' => $searchTerm, - 'hasNextPage' => $hasNextPage, + 'hasNextPage' => $results['has_more'], 'nextPageLink' => $nextPageLink ]); } diff --git a/app/Services/SearchService.php b/app/Services/SearchService.php index 6786c5cf4..cb445eed1 100644 --- a/app/Services/SearchService.php +++ b/app/Services/SearchService.php @@ -72,7 +72,6 @@ class SearchService $terms = $this->parseSearchString($searchString); $entityTypes = array_keys($this->entities); $entityTypesToSearch = $entityTypes; - $results = collect(); if ($entityType !== 'all') { $entityTypesToSearch = $entityType; @@ -80,21 +79,23 @@ class SearchService $entityTypesToSearch = explode('|', $terms['filters']['type']); } + $results = collect(); $total = 0; foreach ($entityTypesToSearch as $entityType) { if (!in_array($entityType, $entityTypes)) { continue; } - $search = $this->searchEntityTable($terms, $entityType, $page, $count); - $total += $this->searchEntityTable($terms, $entityType, $page, $count, true); + $search = $this->searchEntityTable($terms, $entityType, $page, $count + 1); + $total += $this->searchEntityTable($terms, $entityType, $page, $count + 1, true); $results = $results->merge($search); } return [ 'total' => $total, 'count' => count($results), - 'results' => $results->sortByDesc('score')->values() + 'has_more' => $results->count() > $count, + 'results' => $results->sortByDesc('score')->slice(0, $count)->values() ]; } @@ -322,8 +323,8 @@ class SearchService public function indexEntity(Entity $entity) { $this->deleteEntityTerms($entity); - $nameTerms = $this->generateTermArrayFromText($entity->name, 5); - $bodyTerms = $this->generateTermArrayFromText($entity->getText(), 1); + $nameTerms = $this->generateTermArrayFromText($entity->name, 5 * $entity->searchFactor); + $bodyTerms = $this->generateTermArrayFromText($entity->getText(), 1 * $entity->searchFactor); $terms = array_merge($nameTerms, $bodyTerms); foreach ($terms as $index => $term) { $terms[$index]['entity_type'] = $entity->getMorphClass(); @@ -340,8 +341,8 @@ class SearchService { $terms = []; foreach ($entities as $entity) { - $nameTerms = $this->generateTermArrayFromText($entity->name, 5); - $bodyTerms = $this->generateTermArrayFromText($entity->getText(), 1); + $nameTerms = $this->generateTermArrayFromText($entity->name, 5 * $entity->searchFactor); + $bodyTerms = $this->generateTermArrayFromText($entity->getText(), 1 * $entity->searchFactor); foreach (array_merge($nameTerms, $bodyTerms) as $term) { $term['entity_id'] = $entity->id; $term['entity_type'] = $entity->getMorphClass(); From 1e015af3c9de40dd0e815c6a7821979c835ead84 Mon Sep 17 00:00:00 2001 From: Dan Brown Date: Sat, 24 Mar 2018 19:04:18 +0000 Subject: [PATCH 17/25] Fixed incorrect search logic in last commit Incorrect cross-entity pagination could lead to hidden entities. --- app/Services/SearchService.php | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/app/Services/SearchService.php b/app/Services/SearchService.php index cb445eed1..056e1f077 100644 --- a/app/Services/SearchService.php +++ b/app/Services/SearchService.php @@ -64,7 +64,7 @@ class SearchService * @param string $searchString * @param string $entityType * @param int $page - * @param int $count + * @param int $count - Count of each entity to search, Total returned could can be larger and not guaranteed. * @return array[int, Collection]; */ public function searchEntities($searchString, $entityType = 'all', $page = 1, $count = 20) @@ -81,21 +81,26 @@ class SearchService $results = collect(); $total = 0; + $hasMore = false; foreach ($entityTypesToSearch as $entityType) { if (!in_array($entityType, $entityTypes)) { continue; } - $search = $this->searchEntityTable($terms, $entityType, $page, $count + 1); - $total += $this->searchEntityTable($terms, $entityType, $page, $count + 1, true); + $search = $this->searchEntityTable($terms, $entityType, $page, $count); + $entityTotal = $this->searchEntityTable($terms, $entityType, $page, $count, true); + if ($entityTotal > $page * $count) { + $hasMore = true; + } + $total += $entityTotal; $results = $results->merge($search); } return [ 'total' => $total, 'count' => count($results), - 'has_more' => $results->count() > $count, - 'results' => $results->sortByDesc('score')->slice(0, $count)->values() + 'has_more' => $hasMore, + 'results' => $results->sortByDesc('score')->values() ]; } From df1a3a0715fb724d32cc51c3008545424c38379e Mon Sep 17 00:00:00 2001 From: Dan Brown Date: Sun, 25 Mar 2018 11:06:21 +0100 Subject: [PATCH 18/25] Properly escaped search results Prevents vue-like syntax in results causing errors. Related to #748 --- resources/views/search/all.blade.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/views/search/all.blade.php b/resources/views/search/all.blade.php index b4da1a576..f24e83bc2 100644 --- a/resources/views/search/all.blade.php +++ b/resources/views/search/all.blade.php @@ -193,7 +193,7 @@ @section('body') -
+

{{ trans('entities.search_results') }}

From 1a9f6764164cb730399a47969d1c33099f1682b8 Mon Sep 17 00:00:00 2001 From: Dan Brown Date: Sun, 25 Mar 2018 11:34:42 +0100 Subject: [PATCH 19/25] Updated create routes to prevent slug clashes Fixes #758 --- resources/views/books/create.blade.php | 2 +- resources/views/books/index.blade.php | 4 +- resources/views/books/show.blade.php | 8 ++-- resources/views/chapters/create.blade.php | 6 +-- resources/views/chapters/form.blade.php | 2 +- resources/views/pages/guest-create.blade.php | 2 +- routes/web.php | 12 +++--- tests/Entity/EntityTest.php | 6 +-- tests/Entity/PageDraftTest.php | 4 +- tests/Permissions/RestrictionsTest.php | 16 +++---- tests/Permissions/RolesTest.php | 44 +++++++++----------- 11 files changed, 51 insertions(+), 55 deletions(-) diff --git a/resources/views/books/create.blade.php b/resources/views/books/create.blade.php index eb0664ad8..a86cb3352 100644 --- a/resources/views/books/create.blade.php +++ b/resources/views/books/create.blade.php @@ -5,7 +5,7 @@
@stop diff --git a/resources/views/books/index.blade.php b/resources/views/books/index.blade.php index d66612f62..d1435ab66 100644 --- a/resources/views/books/index.blade.php +++ b/resources/views/books/index.blade.php @@ -18,7 +18,7 @@ @@ -78,7 +78,7 @@ @else

{{ trans('entities.books_empty') }}

@if(userCan('books-create-all')) - @icon('edit'){{ trans('entities.create_one_now') }} + @icon('edit'){{ trans('entities.create_one_now') }} @endif @endif
diff --git a/resources/views/books/show.blade.php b/resources/views/books/show.blade.php index bb5189187..d3a51cb3a 100644 --- a/resources/views/books/show.blade.php +++ b/resources/views/books/show.blade.php @@ -15,10 +15,10 @@ @if(userCan('page-create', $book)) - @icon('add'){{ trans('entities.pages_new') }} + @icon('add'){{ trans('entities.pages_new') }} @endif @if(userCan('chapter-create', $book)) - @icon('add'){{ trans('entities.chapters_new') }} + @icon('add'){{ trans('entities.chapters_new') }} @endif @if(userCan('book-update', $book) || userCan('restrictions-manage', $book) || userCan('book-delete', $book))