Alfresco media viewer web预览扩展性
所以我遵循指南和源代码在Alfresco中扩展自定义媒体查看器。 不过我有几个问题。 我已经在使用4.2+Alfresco,因此不需要使用Alfresco media viewer web预览扩展性,alfresco,alfresco-share,Alfresco,Alfresco Share,所以我遵循指南和源代码在Alfresco中扩展自定义媒体查看器。 不过我有几个问题。 我已经在使用4.2+Alfresco,因此不需要使用head.ftl作为弃用,我正在使用第二个扩展模块自动添加我自己的配置,但是: 如何在我的web预览.get.js中访问jsNode?或者更好,是否有方法访问正在显示的节点的属性值和方面? 我了解服务器端和客户端var jsNode=new Alfresco.util.Node(model.widgets[I].options.nodeRef)和var jsN
head.ftl
作为弃用,我正在使用第二个扩展模块自动添加我自己的配置,但是:
如何在我的web预览.get.js
中访问jsNode
?或者更好,是否有方法访问正在显示的节点的属性值和方面?
我了解服务器端和客户端var jsNode=new Alfresco.util.Node(model.widgets[I].options.nodeRef)
和var jsNode=AlfrescoUtil.getnodetails(model.widgets[I].options.nodeRef)代码>
这是在另一个问题中提到的,但是除了默认值,比如,mimeType,size,nodeRef,我无法使用这些值从文件中获取数据。
以下是我的变化:
我的自定义媒体查看器的-config
文件夹中的web预览.get.js
//<import resource="classpath:/alfresco/templates/org/alfresco/import/alfresco-util.js">
if (model.widgets)
{
for (var i = 0; i < model.widgets.length; i++)
{
var at = "test";
//var jsNode = AlfrescoUtil.getNodeDetails(model.widgets[i].options.nodeRef);
//var author = jsNode.properties["cm:author"];
var widget = model.widgets[i];
if (widget.id == "WebPreview")
{
var conditions = [];
// Insert new pluginCondition(s) at start of the chain
conditions.push({
attributes: {
mimeType: "application/pdf"
},
plugins: [{
name: "PDF",
attributes: {
}
}]
});
var oldConditions = eval("(" + widget.options.pluginConditions + ")");
// Add the other conditions back in
for (var j = 0; j < oldConditions.length; j++)
{
conditions.push(oldConditions[j]);
}
// Override the original conditions
model.pluginConditions = jsonUtils.toJSONString(conditions);
widget.options.pluginConditions = model.pluginConditions;
}
}
}
//
if(model.widgets)
{
对于(var i=0;i
PDF.js
/**
* Copyright (C) 2014 Will Abson
*/
/**
* This is the "PDF" plug-in used to display documents directly in the web browser.
*
* Supports the "application/pdf" mime types.
*
* @namespace Alfresco.WebPreview.prototype.Plugins
* @class Alfresco.WebPreview.prototype.Plugins.PDF
*/
(function()
{
/**
* PDF plug-in constructor
*
* @param wp {Alfresco.WebPreview} The Alfresco.WebPreview instance that decides which plugin to use
* @param attributes {Object} Arbitrary attributes brought in from the <plugin> element
*/
Alfresco.WebPreview.prototype.Plugins.PDF = function(wp, attributes)
{
this.wp = wp;
this.attributes = YAHOO.lang.merge(Alfresco.util.deepCopy(this.attributes), attributes);
//this.wp.options.nodeRef = this.wp.nodeRef;
return this;
};
Alfresco.WebPreview.prototype.Plugins.PDF.prototype =
{
/**
* Attributes
*/
attributes:
{
/**
* Maximum size to display given in bytes if the node's content is used.
* If the node content is larger than this value the image won't be displayed.
* Note! This doesn't apply if src is set to a thumbnail.
*
* @property srcMaxSize
* @type String
* @default "2000000"
*/
srcMaxSize: "2000000"
},
/**
* Tests if the plugin can be used in the users browser.
*
* @method report
* @return {String} Returns nothing if the plugin may be used, otherwise returns a message containing the reason
* it cant be used as a string.
* @public
*/
report: function PDF_report()
{
// TODO: Detect whether Adobe PDF plugin is installed, or if navigator is Chrome
// See https://stackoverflow.com/questions/185952/how-do-i-detect-the-adobe-acrobat-version-installed-in-firefox-via-javascript
var srcMaxSize = this.attributes.srcMaxSize;
if (!this.attributes.src && srcMaxSize.match(/^\d+$/) && this.wp.options.size > parseInt(srcMaxSize))
{
return this.wp.msg("pdf.tooLargeFile", this.wp.options.name, Alfresco.util.formatFileSize(this.wp.options.size), Alfresco.util.formatFileSize(this.attributes.srcMaxSize));
}
},
/**
* Display the node.
*
* @method display
* @public
*/
display: function PDF_display()
{
// TODO: Support rendering the content of the thumbnail specified
var src = this.wp.getContentUrl();
var test = this.attributes.author;
//var test = this.wp.options.nodeRef;
//var jsNode = new Alfresco.util.Node(test);
//var jsNode = AlfrescoUtil.getNodeDetails(this.wp.options.nodeRef);
//var author = jsNode.properties["cm:author"];
//var test = this.wp.options.author;
//var test1 = this.wp.options.mimeType;
//var test = this.attributes.author.replace(/[^\w_\-\. ]/g, "");
//.replace(/[^\w_\-\. ]/g, "");
return '<iframe name="' + test + '" src="' + src + '"></iframe>';
}
};
})();
/**
*版权(C)2014将免除
*/
/**
*这是用于直接在web浏览器中显示文档的“PDF”插件。
*
*支持“application/pdf”mime类型。
*
*@namespace Alfresco.WebPreview.prototype.Plugins
*@class Alfresco.WebPreview.prototype.Plugins.PDF
*/
(功能()
{
/**
*PDF插件构造函数
*
*@param wp{Alfresco.WebPreview}决定使用哪个插件的Alfresco.WebPreview实例
*@param attributes{Object}从元素引入的任意属性
*/
Alfresco.WebPreview.prototype.Plugins.PDF=函数(wp,属性)
{
this.wp=wp;
this.attributes=YAHOO.lang.merge(Alfresco.util.deepCopy(this.attributes),attributes);
//this.wp.options.nodeRef=this.wp.nodeRef;
归还这个;
};
Alfresco.WebPreview.prototype.Plugins.PDF.prototype=
{
/**
*属性
*/
属性:
{
/**
*如果使用节点的内容,则显示的最大大小(以字节为单位)。
*如果节点内容大于此值,则不会显示图像。
*注意!如果src设置为缩略图,则此项不适用。
*
*@property srcMaxSize
*@type字符串
*@默认值“2000000”
*/
srcMaxSize:“2000000”
},
/**
*测试插件是否可以在用户浏览器中使用。
*
*@方法报告
*@return{String}如果可以使用插件,则不返回任何内容,否则返回包含原因的消息
*它不能用作字符串。
*@公众
*/
报告:功能PDF_报告()
{
//TODO:检测是否安装了Adobe PDF插件,或者navigator是否为Chrome
//看https://stackoverflow.com/questions/185952/how-do-i-detect-the-adobe-acrobat-version-installed-in-firefox-via-javascript
var srcMaxSize=this.attributes.srcMaxSize;
如果(!this.attributes.src&&srcMaxSize.match(/^\d+$/)&&this.wp.options.size>parseInt(srcMaxSize))
{
返回此.wp.msg(“pdf.tooLargeFile”、this.wp.options.name、Alfresco.util.formatFileSize(this.wp.options.size)、Alfresco.util.formatFileSize(this.attributes.srcMaxSize));
}
},
/**
*显示节点。
*
*@方法显示
*@公众
*/
显示:函数PDF_display()
{
//TODO:支持呈现指定缩略图的内容
var src=this.wp.getContentUrl();
var test=this.attributes.author;
//var测试=this.wp.options.nodeRef;
//var jsNode=新的Alfresco.util.Node(测试);
//var jsNode=AlfrescoUtil.getNodeDetails(this.wp.options.nodeRef);
//var author=jsNode.properties[“cm:author”];
//var test=this.wp.options.author;
//var test1=this.wp.options.mimeType;
//var test=this.attributes.author.replace(/[^\w\u \-\.]/g,”);
//.替换(/[^\w\-\.]/g,”);
返回“”;
}
};
})();
正如您在注释部分所看到的,我尝试了不同的方法来访问节点属性/值,甚至是简单的字符串,但我确实缺少一些东西。
谢谢。如果您查看源代码,您会发现helper方法只不过是对var url='/slingshot/doclib2/node/'+nodeRef.replace('://','/')进行远程调用代码>
因此,请查看存储库WebScript返回的内容,并将其与所需的属性进行匹配
我通常不使用这个,我肯定知道/api/metadata
所有属性。谢谢Tahir,我就是这么做的。我创造了一个