Изменения документа PDF Viewer Macro
Редактировал(а) Coluns 19.11.2023
Сводка
Подробности
- pdfviewer.zip
-
- Размер
-
... ... @@ -1,1 +1,1 @@ 1 - 2.5MB1 +1.6 MB - Содержимое
- XWiki.WikiMacroClass[0]
-
- Код
-
... ... @@ -2,64 +2,24 @@ 2 2 #set($width = $context.macro.params.width) 3 3 #set($height = $context.macro.params.height) 4 4 #set($file = $context.macro.params.file) 5 -#set($docname = $context.macro.params.document) 6 -#set($asAuthor = $context.macro.params.asauthor && ($context.macro.params.asauthor == "true" || $context.macro.params.asauthor == "yes" || $context.macro.params.asauthor == "1")) 7 7 #if(!$file) 8 - {{error}}$services.localization.render('pdfviewer.error.nofile'){{/error}}6 +No pdf URL provided 9 9 #else 10 - #if($file.startsWith("http://") || $file.startsWith("https://")) 11 - #set($url = $file) 12 - #else 13 - #if("$!docname" != "") 14 - #set($document = $xwiki.getDocument($docname)) 15 - #else 16 - #set($document = $doc) 17 - #end 18 - #set($attachment = $document.getAttachment($file)) 19 - #set($url = $NULL) 20 - #if($attachment) 21 - #set($url = $document.getAttachmentURL($file)) 22 - #elseif ($asAuthor && $xwiki.hasProgrammingRights() && $xwiki.exists('XWiki.PDFViewerService')) 23 - #set($document = $xwiki.getDocumentAsAuthor($docname)) 24 - #set($attachment = $document.getAttachment($file)) 25 - #if($attachment) 26 - #set($digestFactory = $services.component.getInstance('org.xwiki.crypto.DigestFactory', 'SHA-1')) 27 - #set($encoder = $services.component.getInstance('org.xwiki.crypto.BinaryStringEncoder', 'URLBase64')) 28 - #if ($digestFactory && $encoder) 29 - #set($contentAuthor = $services.model.serialize($doc.contentAuthorReference, 'default')) 30 - #set($digest = $digestFactory.instance) 31 - #set($is = $digest.getInputStream($attachment.contentInputStream)) 32 - #set($discard = $digest.getInputStream($attachment.contentInputStream).skip(1000)) 33 - #set($discard = $is.close()) 34 - #if ($xcontext.userReference) 35 - #set($discard = $digest.update($services.model.serialize($xcontext.userReference, 'default').getBytes('UTF-8'))) 36 - #end 37 - #set($discard = $digest.update($contentAuthor.getBytes('UTF-8'))) 38 - #set($digest = $encoder.encode($digest.digest)) 39 - #set($url = $xwiki.getDocument("XWiki.PDFViewerService").getExternalURL('get', "reference=$escapetool.url($services.model.serialize($document.documentReference, 'default'))&filename=$escapetool.url($attachment.filename)&user=$escapetool.url($contentAuthor)&key=$digest")) 40 - #end 41 - #end 42 - #end 43 - #end 44 - #if ($url) 45 - #set($url = $escapetool.url($url)) 46 - #set($pdfviewerurl = $xwiki.getDocument("XWiki.PDFViewerMacro").getAttachmentURL("pdfviewer.zip")) 47 - ## Attachment URL have query parameters for cache issue. 48 - #set($pdfviewerurl = $pdfviewerurl.split("\?")[0]) 49 - {{html clean=false}} 50 - <div> 51 - <!--[if lt IE 10]> 52 - <div class="box warningmessage">PDF Viewer : Not compatible with IE < 10</div> 53 - <![endif]--> 54 - <![if !(lt IE 10)]> 55 - <iframe src="${pdfviewerurl}/pdf-viewer/web/viewer.html?file=${url}#locale=${context.language}" width="${width}" height="${height}"></iframe> 56 - <![endif]--> 57 - </div> 58 - {{/html}} 59 - #elseif (!$document || $document.isNew()) 60 - {{error}}$services.localization.render('pdfviewer.error.nodocument', [$escapetool.html($escapetool.html($docname))]){{/error}} 61 - #else 62 - {{error}}$services.localization.render('pdfviewer.error.noattachment', [$escapetool.html($file), $escapetool.html($services.model.serialize($document.documentReference, 'default'))]){{/error}} 63 - #end 8 +#if($file.startsWith("http")) 9 + #set($url = $file) 10 +#else 11 + #set($url = $doc.getAttachmentURL($file)) 64 64 #end 13 +#set($url = $escapetool.url($url)) 14 +#set($pdfviewerurl = $xwiki.getDocument("XWiki.PDFViewerMacro").getAttachmentURL("pdfviewer.zip")) 15 +{{html clean=false}} 16 + <!--[if lt IE 10]> 17 + <div class="box warningmessage">PDF Viewer : Not compatible with IE < 10</div> 18 + <![endif]--> 19 + <![if !(lt IE 10)]> 20 + <iframe src="${pdfviewerurl}/pdf-viewer/root/viewer.html?file=${url}#locale=${context.language}" width="${width}" height="${height}"&></iframe> 21 + <![endif]--> 22 + </script> 23 +{{/html}} 24 +#end 65 65 {{/velocity}} - defaultCategory
-
... ... @@ -1,0 +1,1 @@ 1 +content
- XWiki.WikiMacroParameterClass[1]
-
- Значение параметра по-умолчанию
-
... ... @@ -1,0 +1,1 @@ 1 +700 - Имя параметра
-
... ... @@ -1,1 +1,1 @@ 1 -d ocument1 +width - Описание параметра
-
... ... @@ -1,1 +1,0 @@ 1 -Reference of the document containing the file (not used if file is a URL)
- XWiki.WikiMacroParameterClass[2]
-
- Значение параметра по-умолчанию
-
... ... @@ -1,1 +1,1 @@ 1 -100 %1 +1000 - Имя параметра
-
... ... @@ -1,1 +1,1 @@ 1 - width1 +height
- XWiki.WikiMacroParameterClass[3]
-
- Значение параметра по-умолчанию
-
... ... @@ -1,1 +1,0 @@ 1 -1000 - Имя параметра
-
... ... @@ -1,1 +1,0 @@ 1 -height
- XWiki.WikiMacroParameterClass[4]
-
- Значение параметра по-умолчанию
-
... ... @@ -1,1 +1,0 @@ 1 -0 - Описание параметра
-
... ... @@ -1,1 +1,0 @@ 1 -If this value is true (or 1 or yes) and the user has no access to the document to which the PDF file is attached, the PDF file could still be viewed on behalf of the author of the document containing the macro (if that author has access to the containing document obviously). - Имя параметра
-
... ... @@ -1,1 +1,0 @@ 1 -asauthor