Änderungen von Dokument Gliffy Macro
Zuletzt geändert von xwikiadmin am 2023/10/26 09:30
Von Version 2.1
bearbeitet von xwikiadmin
am 2022/08/11 17:13
am 2022/08/11 17:13
Änderungskommentar:
Migrated property [defaultCategories] from class [XWiki.WikiMacroClass]
Auf Version 4.1
bearbeitet von xwikiadmin
am 2023/10/26 09:30
am 2023/10/26 09:30
Änderungskommentar:
Migrated property [type] from class [XWiki.WikiMacroParameterClass]
Zusammenfassung
-
Seiteneigenschaften (1 geändert, 0 hinzugefügt, 0 gelöscht)
-
Objekte (1 geändert, 0 hinzugefügt, 2 gelöscht)
Details
- Seiteneigenschaften
-
- Inhalt
-
... ... @@ -1,37 +1,30 @@ 1 +{{include reference="Confluence.Macros.DiagramMacros" /}} 2 + 1 1 {{velocity}} 2 -#if (!$services.diagram) 3 - {{warning}} 4 - #set ($queryString = $escapetool.url({ 5 - 'section': 'XWiki.Extensions', 6 - 'search': 'Diagram' 7 - })) 8 - #set ($installURL = $xwiki.getURL('XWiki.XWikiPreferences', 'admin', $queryString)) 9 - $services.localization.render('gliffy.diagram.installRequired', ['[[', ">>path:$installURL||target='_blank']]"]) 10 - {{/warning}} 11 -#end 4 +#checkDiagramAppInstall() 12 12 {{/velocity}} 13 13 14 14 = Description = 15 15 16 -The Gliffy macro is a bridge between Gliffy macro used in Confluence and the [[Diagram>>https://extensions.xwiki.org/xwiki/bin/view/Extension/Diagram%20Application]] macro used in XWiki. The aim of this macro is to allow users to view and also to modify the diagrams migrated from Confluence. By default, the macro displays the preview of the Gliffy diagram. The user can create the editable version of the diagram, by using its representation into an XWiki diagram, having always the option to go back to the preview of the original diagram.9 +The Gliffy macro is a bridge between Gliffy macro used in Confluence and the [[Diagram>>https://extensions.xwiki.org/xwiki/bin/view/Extension/Diagram%20Application]] macro used in XWiki. The aim of this macro is to allow users to view and also to modify the diagrams migrated from Confluence. By default, the macro displays the preview of the Gliffy diagram. The user can create the editable version of the diagram, by using its representation into an XWiki diagram, always having the option to go back to the preview of the original diagram. 17 17 18 18 = Parameters = 19 19 20 20 |=Parameter|=Description 21 -|**name**|The diagram identifier. It should be the **name of the attachment** storing the Gliffy diagram data. (% style="color: red"%)It should not have a filename extension(%%). The Gliffy diagram exports consist in attachments added to the parent page. For example, for a diagram called //MyGliffyDiagram//, there will be two attachments on the parent page 14 +|**name**|The diagram identifier. It should be the **name of the attachment** storing the Gliffy diagram data. (% style="color: red"%)It should not have a filename extension(%%). The Gliffy diagram exports consist in attachments added to the parent page. For example, for a diagram called //MyGliffyDiagram//, there will be two attachments on the parent page: //MyGliffyDiagram.png// (the filename with a ".png" extension) representing the preview of the diagram and //MyGliffyDiagram// (with **no filename extention**) representing the diagram data. 22 22 23 23 {{info}} 24 - 17 +Besides the **name** parameter, the ~{~{gliffy}} macro used in Confluence has other parameters that don't have to be cleaned, because these parameters are being ignored by this bridge macro. 25 25 {{/info}} 26 26 27 27 = Example of usage = 28 28 29 -The syntax of the macro using the diagram called "MyGliffyDiagram" is the following 22 +The syntax of the macro using the diagram called "MyGliffyDiagram" is the following: 30 30 31 31 {{code}} 32 - 25 +{{gliffy name="MyGliffyDiagram" /}} 33 33 {{/code}} 34 34 35 -The result is the following 28 +The result is the following: 36 36 37 37 {{gliffy name="MyGliffyDiagram" /}}
- XWiki.JavaScriptExtension[0]
-
- Pufferstrategie
-
... ... @@ -1,1 +1,0 @@ 1 -long - Code
-
... ... @@ -1,61 +1,0 @@ 1 -require(['jquery', 'xwiki-events-bridge'], function($) { 2 - var serviceURL = new XWiki.Document( 3 - XWiki.Model.resolve('Confluence.Macros.GliffyService', XWiki.EntityType.DOCUMENT)) 4 - .getURL('get', 'outputSyntax=plain'), 5 - createSuccessMessage = "$escapetool.javascript($services.localization.render('gliffy.diagram.create.success'))", 6 - createFailureMessage = "$escapetool.javascript($services.localization.render('gliffy.diagram.create.error'))", 7 - deleteSuccessMessage = "$escapetool.javascript($services.localization.render('gliffy.diagram.delete.success'))", 8 - deleteFailureMessage = "$escapetool.javascript($services.localization.render('gliffy.diagram.delete.error'))"; 9 - 10 - var handleCreateDiagram = function () { 11 - $('.create-diagram-btn').on('click', function(e){ 12 - e.preventDefault(); 13 - 14 - var pageReferenceSerialized = $(this).prevAll('.create-diagram-page:first').val(), 15 - diagramName = $(this).prevAll('.create-diagram-name:first').val(); 16 - $.ajax({ 17 - url: serviceURL, 18 - data: { 19 - 'action' : 'create', 20 - 'page' : pageReferenceSerialized, 21 - 'diagramName' : diagramName 22 - }, 23 - success: function(data, status) { 24 - new XWiki.widgets.Notification(createSuccessMessage, 'done'); 25 - location.reload(); 26 - }, 27 - error: function() { 28 - new XWiki.widgets.Notification(createFailureMessage, 'error'); 29 - } 30 - }); 31 - }); 32 - } 33 - 34 - var handleDeleteDiagram = function() { 35 - $('.delete-diagram-btn').on('click', function(e){ 36 - e.preventDefault(); 37 - 38 - var pageReferenceSerialized = $(this).prevAll('.delete-diagram-page:first').val(); 39 - $.ajax({ 40 - url: serviceURL, 41 - data: { 42 - 'action' : 'delete', 43 - 'page' : pageReferenceSerialized 44 - }, 45 - success: function(data, status) { 46 - new XWiki.widgets.Notification(deleteSuccessMessage, 'done'); 47 - location.reload(); 48 - }, 49 - error: function() { 50 - new XWiki.widgets.Notification(deleteFailureMessage, 'error'); 51 - } 52 - }); 53 - }); 54 - } 55 - 56 - var init = function() { 57 - handleCreateDiagram(); 58 - handleDeleteDiagram(); 59 - } 60 - XWiki.domIsLoaded && init(); 61 -}); - Name
-
... ... @@ -1,1 +1,0 @@ 1 -Gliffy Macro Scripts - Inhalt parsen
-
... ... @@ -1,1 +1,0 @@ 1 -Ja - Benutze diese Erweiterung
-
... ... @@ -1,1 +1,0 @@ 1 -onDemand
- XWiki.StyleSheetExtension[0]
-
- Pufferstrategie
-
... ... @@ -1,1 +1,0 @@ 1 -long - Code
-
... ... @@ -1,12 +1,0 @@ 1 -.gliffy-diagram-contaier { 2 - .modal-header { 3 - .close { 4 - margin-top: -1.2em; 5 - } 6 - } 7 - .modal-footer { 8 - form { 9 - display: inline; 10 - } 11 - } 12 -} - Content Type
-
... ... @@ -1,1 +1,0 @@ 1 -LESS - Name
-
... ... @@ -1,1 +1,0 @@ 1 -Gliffy Macro Styles - Benutze diese Erweiterung
-
... ... @@ -1,1 +1,0 @@ 1 -onDemand
- XWiki.WikiMacroClass[0]
-
- Makro-Code
-
... ... @@ -1,109 +1,16 @@ 1 -{{velocity output="false"}} 2 -#macro(displayModal $id $diagram) 1 +{{include reference="Confluence.Macros.DiagramMacros" /}} 3 3 4 - {{html clean="false"}} 5 - <!-- Modal --> 6 - <div class="modal fade" id="gliffy-${id}-modal" tabindex="-1" role="dialog" aria-labelledby="gliffy-${id}-title" aria-hidden="true"> 7 - <div class="modal-dialog modal-dialog-centered" role="document"> 8 - <div class="modal-content"> 9 - <div class="modal-header"> 10 - <div class="modal-title" id="gliffy-${id}-title">$services.localization.render('gliffy.diagram.modal.title')</div> 11 - <button type="button" class="close" data-dismiss="modal" aria-label="Close"> 12 - <span aria-hidden="true">×</span> 13 - </button> 14 - </div> 15 - <div class="modal-body"> 16 - $services.localization.render('gliffy.diagram.modal.text') 17 - </div> 18 - <div class="modal-footer"> 19 - <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button> 20 - <form action="" method="post"> 21 - <input name="action" value="createDiagram" type="hidden" /> 22 - <input name="diagram" class="delete-diagram-page" type="hidden" value="$escapetool.xml($diagram)"/> 23 - <button type="submit" class="btn btn-primary delete-diagram-btn">$services.localization.render("gliffy.diagram.modal.btn.confirm")</button> 24 - </form> 25 - </div> 26 - </div> 27 - </div> 28 - </div> 29 - {{/html}} 30 -#end 31 -{{/velocity}} 3 +{{include reference="Licenses.Code.VelocityMacros"/}} 32 32 33 33 {{velocity}} 34 -#if (!$services.diagram) 35 - {{warning}} 36 - #set ($queryString = $escapetool.url({ 37 - 'section': 'XWiki.Extensions', 38 - 'search': 'Diagram' 39 - })) 40 - #set ($installURL = $xwiki.getURL('XWiki.XWikiPreferences', 'admin', $queryString)) 41 - $services.localization.render('gliffy.diagram.installRequired', ['[[', ">>path:$installURL||target='_blank']]"]) 42 - {{/warning}} 6 +## We need to check if there is a valid license because the macro is registered even if the user doesn't have view right 7 +## on the macro definition page. See XWIKI-14828: Rendering macros defined in wiki pages are available to users that 8 +## don't have view right on those pages. 9 +#if ($services.licensing.licensor.hasLicensureForEntity($xcontext.macro.doc.documentReference)) 10 + #displayConfluenceDiagram() 43 43 #else 44 - #set($discard = $xwiki.jsx.use('Confluence.Macros.Gliffy')) 45 - #set($discard = $xwiki.ssx.use('Confluence.Macros.Gliffy')) 46 - ## Macro parameters 47 - #set($diagramName = $xcontext.macro.params.name) 48 - ## "Constants" 49 - #set($previewImageName = "${diagramName}.png") 50 - #set($previewImage = $doc.getAttachment($previewImageName)) 51 - ## Variables 52 - #set($displayDiagram = true) 53 - #set($diagram = $NULL) 54 - ## 55 - ## Check if the diagram page exists 56 - #set($docReferenceSerialized = $services.model.serialize($doc.documentReference, 'local')) 57 - #set($diagrams = $services.query.xwql('from doc.object(Confluence.Macros.GliffyClass) as gliffyObj where gliffyObj.page = :page and gliffyObj.diagramName = :diagramName').bindValue('page', $docReferenceSerialized).bindValue('diagramName', $diagramName).setLimit(1).execute()) 58 - #if($diagrams.size() > 0) 59 - #set($diagram = $diagrams.get(0)) 60 - #end 61 - ## 62 - (% class="gliffy-diagram-contaier" %)((( 63 - ## The diagram exists -> display it 64 - #if($displayDiagram && $diagram) 65 - {{diagram reference="$diagram" cached="false" /}} 66 - 67 - #if($diagram && $xcontext.action != 'export') 68 - ## 69 - ## If Display a button allowing the user to go back to gliffy mode 70 - #if ($services.security.authorization.hasAccess('delete', $diagram)) 71 - #set($id = $mathtool.random(1, 100000)) 72 - $services.localization.render('gliffy.diagram.delete') 73 - 74 - {{html clean="false"}} 75 - <a class="btn btn-primary" data-toggle="modal" data-target="#gliffy-${id}-modal">$services.localization.render('gliffy.diagram.delete.link')</a> 76 - {{/html}} 77 - 78 - #displayModal($id $diagram) 79 - #end 80 - #end 81 - #else 82 - #set($displayDiagram = false) 83 - #end 84 - ## Display the preview image if it exists 85 - #if($previewImage && !$displayDiagram) 86 - (% class="thumbnail" %)((( 87 - [[image:${previewImageName}]] 88 - 89 - ## 90 - ## If Display a button allowing the user to create an XWiki diagram 91 - #if ($services.security.authorization.hasAccess('edit', $doc.documentReference) && $xcontext.action != 'export') 92 - (% class="caption" %)((( 93 - $services.localization.render('gliffy.diagram.create') 94 - 95 - {{html clean=false}} 96 - <form action="" method="post"> 97 - <input name="action" value="createDiagram" type="hidden" /> 98 - <input name="pageReferenceSerialized" class="create-diagram-page" value="$escapetool.xml($docReferenceSerialized)" type="hidden" /> 99 - <input name="diagramName" class="create-diagram-name" value="$escapetool.xml($diagramName)" type="hidden" /> 100 - <button type="submit" class="btn btn-primary create-diagram-btn">$services.localization.render('gliffy.diagram.create.confirm')</button> 101 - </form> 102 - {{/html}} 103 - ))) 104 - ))) 105 - #end 106 - #end 107 - ))) 12 + {{error}} 13 + #getMissingLicenseMessage('proMacros.extension.name') 14 + {{/error}} 108 108 #end 109 109 {{/velocity}}