From: Dan Brown Date: Sun, 27 May 2018 18:42:25 +0000 (+0100) Subject: Merge branch 'drawing_updates' X-Git-Tag: v0.22.0~1^2~5 X-Git-Url: http://source.bookstackapp.com/bookstack/commitdiff_plain/6b84a76af1917ff8e53c4636cb5fe08d1b40ccdd?ds=inline;hp=-c Merge branch 'drawing_updates' --- 6b84a76af1917ff8e53c4636cb5fe08d1b40ccdd diff --combined resources/assets/js/components/wysiwyg-editor.js index 701a1fec6,72263e2f2..f7e9bfeed --- a/resources/assets/js/components/wysiwyg-editor.js +++ b/resources/assets/js/components/wysiwyg-editor.js @@@ -221,8 -221,6 +221,6 @@@ function codePlugin() function drawIoPlugin() { - const drawIoUrl = 'https://www.draw.io/?embed=1&ui=atlas&spin=1&proto=json'; - let iframe = null; let pageEditor = null; let currentNode = null; @@@ -230,6 -228,22 +228,22 @@@ return node.hasAttribute('drawio-diagram'); } + function showDrawingManager(mceEditor, selectedNode = null) { + pageEditor = mceEditor; + currentNode = selectedNode; + // Show image manager + window.ImageManager.show(function (image) { + if (selectedNode) { + let imgElem = selectedNode.querySelector('img'); + pageEditor.dom.setAttrib(imgElem, 'src', image.url); + pageEditor.dom.setAttrib(selectedNode, 'drawio-diagram', image.id); + } else { + let imgHTML = `
`; + pageEditor.insertContent(imgHTML); + } + }, 'drawio'); + } + function showDrawingEditor(mceEditor, selectedNode = null) { pageEditor = mceEditor; currentNode = selectedNode; @@@ -248,9 -262,9 +262,9 @@@ if (currentNode) { DrawIO.close(); let imgElem = currentNode.querySelector('img'); - let drawingId = currentNode.getAttribute('drawio-diagram'); - window.$http.put(window.baseUrl(`/images/drawing/upload/${drawingId}`), data).then(resp => { - pageEditor.dom.setAttrib(imgElem, 'src', `${resp.data.url}?updated=${Date.now()}`); + window.$http.post(window.baseUrl(`/images/drawing/upload`), data).then(resp => { + pageEditor.dom.setAttrib(imgElem, 'src', resp.data.url); + pageEditor.dom.setAttrib(currentNode, 'drawio-diagram', resp.data.id); }).catch(err => { window.$events.emit('error', trans('errors.image_upload_error')); console.log(err); @@@ -287,13 -301,24 +301,24 @@@ window.tinymce.PluginManager.add('drawio', function(editor, url) { editor.addCommand('drawio', () => { - showDrawingEditor(editor); + let selectedNode = editor.selection.getNode(); + showDrawingEditor(editor, isDrawing(selectedNode) ? selectedNode : null); }); editor.addButton('drawio', { + type: 'splitbutton', tooltip: 'Drawing', - image: window.baseUrl('/icon/drawing.svg?color=000000'), + image: `data:image/svg+xml;base64,PHN2ZyB2aWV3Qm94PSIwIDAgMjQgMjQiIGZpbGw9IiMwMDAwMDAiICB4bWxucz0iaHR0cDovL3d3 dy53My5vcmcvMjAwMC9zdmciPgogICAgPHBhdGggZD0iTTIzIDdWMWgtNnYySDdWMUgxdjZoMnYx MEgxdjZoNnYtMmgxMHYyaDZ2LTZoLTJWN2gyek0zIDNoMnYySDNWM3ptMiAxOEgzdi0yaDJ2Mnpt MTItMkg3di0ySDVWN2gyVjVoMTB2MmgydjEwaC0ydjJ6bTQgMmgtMnYtMmgydjJ6TTE5IDVWM2gy djJoLTJ6bS01LjI3IDloLTMuNDlsLS43MyAySDcuODlsMy40LTloMS40bDMuNDEgOWgtMS42M2wt Ljc0LTJ6bS0zLjA0LTEuMjZoMi42MUwxMiA4LjkxbC0xLjMxIDMuODN6Ii8+CiAgICA8cGF0aCBk PSJNMCAwaDI0djI0SDB6IiBmaWxsPSJub25lIi8+Cjwvc3ZnPg==`, - cmd: 'drawio' + cmd: 'drawio', + menu: [ + { + text: 'Drawing Manager', + onclick() { + let selectedNode = editor.selection.getNode(); + showDrawingManager(editor, isDrawing(selectedNode) ? selectedNode : null); + } + } + ] }); editor.on('dblclick', event => { @@@ -443,7 -468,7 +468,7 @@@ class WysiwygEditor html += `${image.name}`; html += ''; win.tinyMCE.activeEditor.execCommand('mceInsertContent', false, html); - }); + }, 'gallery'); } }, @@@ -522,7 -547,7 +547,7 @@@ html += `${image.name}`; html += ''; editor.execCommand('mceInsertContent', false, html); - }); + }, 'gallery'); } }); diff --combined resources/lang/en/settings.php index b699b5c4b,3a3dbb9a4..30abbc1b9 --- a/resources/lang/en/settings.php +++ b/resources/lang/en/settings.php @@@ -34,7 -34,6 +34,7 @@@ return 'app_homepage' => 'Application Homepage', 'app_homepage_desc' => 'Select a page to show on the homepage instead of the default view. Page permissions are ignored for selected pages.', 'app_homepage_default' => 'Default homepage view chosen', + 'app_homepage_books' => 'Or select the books page as your homepage. This will override any page selected as your homepage.', 'app_disable_comments' => 'Disable comments', 'app_disable_comments_desc' => 'Disable comments across all pages in the application. Existing comments are not shown.', @@@ -51,6 -50,19 +51,19 @@@ 'reg_confirm_restrict_domain_desc' => 'Enter a comma separated list of email domains you would like to restrict registration to. Users will be sent an email to confirm their address before being allowed to interact with the application.
Note that users will be able to change their email addresses after successful registration.', 'reg_confirm_restrict_domain_placeholder' => 'No restriction set', + /** + * Maintenance settings + */ + + 'maint' => 'Maintenance', + 'maint_image_cleanup' => 'Cleanup Images', + 'maint_image_cleanup_desc' => "Scans page & revision content to check which images and drawings are currently in use and which images are redundant. Ensure you create a full database and image backup before running this.", + 'maint_image_cleanup_ignore_revisions' => 'Ignore images in revisions', + 'maint_image_cleanup_run' => 'Run Cleanup', + 'maint_image_cleanup_warning' => ':count potentially unused images were found. Are you sure you want to delete these images?', + 'maint_image_cleanup_success' => ':count potentially unused images found and deleted!', + 'maint_image_cleanup_nothing_found' => 'No unused images found, Nothing deleted!', + /** * Role settings */ diff --combined resources/lang/sv/components.php index ec1dad1aa,318a2ee5c..8b1e95ec6 --- a/resources/lang/sv/components.php +++ b/resources/lang/sv/components.php @@@ -13,7 -13,8 +13,8 @@@ return 'image_uploaded' => 'Laddades upp :uploadedDate', 'image_load_more' => 'Ladda fler', 'image_image_name' => 'Bildnamn', - 'image_delete_confirm' => 'Den här bilden används på nedanstående sidor, klicka på "ta bort" en gång till för att bekräfta att du vill ta bort bilden.', + 'image_delete_used' => 'Den här bilden används på nedanstående sidor.', + 'image_delete_confirm' => 'Klicka på "ta bort" en gång till för att bekräfta att du vill ta bort bilden.', 'image_select_image' => 'Välj bild', 'image_dropzone' => 'Släpp bilder här eller klicka för att ladda upp', 'images_deleted' => 'Bilder borttagna', @@@ -21,7 -22,6 +22,7 @@@ 'image_upload_success' => 'Bilden har laddats upp', 'image_update_success' => 'Bildens uppgifter har ändrats', 'image_delete_success' => 'Bilden har tagits bort', + 'image_upload_remove' => 'Radera', /** * Code editor @@@ -30,4 -30,4 +31,4 @@@ 'code_language' => 'Språk', 'code_content' => 'Kod', 'code_save' => 'Spara', -]; +]; diff --combined routes/web.php index a857bce6c,7c9a5a60e..c4e7469fe --- a/routes/web.php +++ b/routes/web.php @@@ -1,6 -1,7 +1,6 @@@ 'auth'], Route::get('/base64/{id}', 'ImageController@getBase64Image'); Route::put('/update/{imageId}', 'ImageController@update'); Route::post('/drawing/upload', 'ImageController@uploadDrawing'); - Route::put('/drawing/upload/{id}', 'ImageController@replaceDrawing'); + Route::get('/usage/{id}', 'ImageController@usage'); Route::post('/{type}/upload', 'ImageController@uploadByType'); Route::get('/{type}/all', 'ImageController@getAllByType'); Route::get('/{type}/all/{page}', 'ImageController@getAllByType'); @@@ -151,6 -152,10 +151,10 @@@ Route::get('/', 'SettingController@index')->name('settings'); Route::post('/', 'SettingController@update'); + // Maintenance + Route::get('/maintenance', 'SettingController@showMaintenance'); + Route::delete('/maintenance/cleanup-images', 'SettingController@cleanupImages'); + // Users Route::get('/users', 'UserController@index'); Route::get('/users/create', 'UserController@create'); @@@ -196,6 -201,4 +200,6 @@@ Route::post('/password/email', 'Auth\Fo // Password reset routes... Route::get('/password/reset/{token}', 'Auth\ResetPasswordController@showResetForm'); -Route::post('/password/reset', 'Auth\ResetPasswordController@reset'); +Route::post('/password/reset', 'Auth\ResetPasswordController@reset'); + +Route::fallback('HomeController@getNotFound');