Skip to content

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
mar10 committed Aug 13, 2018
1 parent ed9b224 commit 3743ace
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 703 deletions.
2 changes: 0 additions & 2 deletions doc/sample_wsgidav.conf
Original file line number Diff line number Diff line change
Expand Up @@ -151,8 +151,6 @@ dir_browser = {
"davmount": False, # Send <dm:mount> response if request URL contains '?davmount'
"ms_mount": False, # Add an 'open as webfolder' link (requires Windows)
"ms_sharepoint_support": True, # Invoke MS Offce documents for editing using WebDAV
; "ms_sharepoint_plugin": False, # Invoke MS Offce documents for editing using WebDAV
; "ms_sharepoint_urls": False, # Prepend 'ms-word:ofe|u|' to URL for MS Offce documents
# "app_class": MyBrowser, # (DEPRECATED with 2.4.0) Used instead of WsgiDavDirBrowser
}

Expand Down
7 changes: 0 additions & 7 deletions sample_wsgidav.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -161,13 +161,6 @@ dir_browser:
#: https://docs.microsoft.com/en-us/previous-versions/office/developer/sharepoint-2010/ff407576(v%3Doffice.14)
#: - Otherwise the Office URL prefix is used (e.g. 'ms-word:ofe|u|http://server/path/file.docx')
ms_sharepoint_support: true
# #: Invoke MS Office documents for editing using WebDAV by adding JavaScript
# #: code that invokes the SharePoint plugin ActiveXObject("SharePoint.OpenDocuments")
# #: (Requires MS IE 8-11, but not Edge)
# ms_sharepoint_plugin: false
# #: Prepend 'ms-word:ofe|u|' to URLs for MS Office documents
# #: (This option is ignored if ms_sharepoint_plugin is true.)
# ms_sharepoint_urls: false
# ----------------------------------------------------------------------------
Expand Down
3 changes: 1 addition & 2 deletions wsgidav.conf
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,7 @@ dir_browser = {
"response_trailer": "", # Raw HTML code, appended as footer
"davmount": True, # Send <dm:mount> response if request URL contains '?davmount'
"ms_mount": True, # Add an 'open as webfolder' link (requires Windows)
"ms_sharepoint_plugin": True, # Invoke MS Offce documents for editing using WebDAV
"ms_sharepoint_urls": False, # Prepend 'ms-word:ofe|u|' to URL for MS Offce documents
"ms_sharepoint_support": True, # Invoke MS Offce documents for editing using WebDAV
}


Expand Down
8 changes: 4 additions & 4 deletions wsgidav/addons/dir_browser/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,10 +186,10 @@ def _get_context(self, environ, davres):
if dirConfig.get("ms_sharepoint_support"):
ofe_prefix = "ms-{}:ofe|u|".format(officeType)
a_classes.append("msoffice")
elif dirConfig.get("ms_sharepoint_plugin"):
a_classes.append("msoffice")
elif dirConfig.get("ms_sharepoint_urls"):
href = "ms-{}:ofe|u|{}".format(officeType, href)
# elif dirConfig.get("ms_sharepoint_plugin"):
# a_classes.append("msoffice")
# elif dirConfig.get("ms_sharepoint_urls"):
# href = "ms-{}:ofe|u|{}".format(officeType, href)

entry = {
"href": href,
Expand Down
71 changes: 11 additions & 60 deletions wsgidav/addons/dir_browser/htdocs/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ function onLoad() {


/**
* Find (and cache) an available ActiveXObject Sharepoint plugin.
*
* @returns {ActiveXObject} or null
*/
function getSharePointPlugin() {
if( sharePointPlugin !== undefined ) {
Expand All @@ -31,7 +33,7 @@ function getSharePointPlugin() {
try {
plugin = new ActiveXObject("SharePoint.OpenDocuments.1"); // Office 2000/XP
} catch(e3) {
window.console && console.warn("Could not create ActiveXObject('SharePoint.OpenDocuments'): (requires IE <= 11 and check security settings.");
window.console && console.warn("Could not create ActiveXObject('SharePoint.OpenDocuments'): (requires IE <= 11 and matching security settings.");
}
}
}
Expand All @@ -45,25 +47,18 @@ function getSharePointPlugin() {


/**
* Open an MS Office document either with SharePoint plugin or using the 'ms-' URL prefix.
*
* @param {object} opts
* @returns {boolean} true if the URL could be opened
*/
function openWebDavDocument(opts) {
var //webDavPath = opts.webDavPath,
// URL with a prefix like ''
ofe_link = opts.ofe + opts.href, // (e.g. 'ms-word:ofe|u|http://server/path/file.docx')
var ofe_link = opts.ofe + opts.href, // (e.g. 'ms-word:ofe|u|http://server/path/file.docx')
url = opts.href;
// url = window.location.protocol + "//" + window.location.host + opts.href;
// webDavPlugin = document.getElementById("winFirefoxPlugin"),
// fileExt = opts.fileName.split(".").pop(),
// errorMsg = "Could not open '" + webDavPath + "'. check MS Office installation and security settings.";
// errorMsg = getContext("msg_could_not_open_document_make_sure_program_for_file_type_installed_fmt").replace("{file_ext}", fileExt);

var plugin = getSharePointPlugin();
var res = false;

alert("url " + url + ", " + ofe_link)

if( plugin ) {
try {
res = plugin.EditDocument(url);
Expand All @@ -78,60 +73,16 @@ function openWebDavDocument(opts) {
if( ofe_link ) {
window.console && console.log("Could not use SharePoint plugin: trying " + ofe_link);
window.open(ofe_link, "_self");
return false;
res = true;
}
}
return res;
}


// /**
// *
// * @param {*} url
// */
// function openWithSharePointPlugin(url) {
// var res = false,
// control = null,
// isFF = false;

// // Get the most recent version of the SharePoint plugin
// if( "ActiveXObject" in window ){
// try {
// control = new ActiveXObject("SharePoint.OpenDocuments.3"); // Office 2007+
// } catch(e) {
// try {
// control = new ActiveXObject("SharePoint.OpenDocuments.2"); // Office 2003
// } catch(e2) {
// try {
// control = new ActiveXObject("SharePoint.OpenDocuments.1"); // Office 2000/XP
// } catch(e3) {
// window.console && console.warn("Could not create ActiveXObject('SharePoint.OpenDocuments'). Check your browsers security settings.");
// return false;
// }
// }
// }
// if( !control ){
// window.console && console.warn("Cannot instantiate the required ActiveX control to open the document. This is most likely because you do not have Office installed or you have an older version of Office.");
// }
// } else {
// window.console && console.warn("Non-IE: trying FFWinPlugin Plug-in...");
// control = document.getElementById("winFirefoxPlugin");
// isFF = true;
// }

// try {
// res = control.EditDocument(url);
// if( !res ){
// window.console && console.warn("SharePoint.OpenDocuments.EditDocument('" + url + "') returned false.");
// }
// } catch (e){
// window.console && console.warn("SharePoint.OpenDocuments.EditDocument('" + url + "') failed.", e);
// }
// return res;
// }


/* Event delegation handler for clicks on a-tags with class 'msoffice'. */
/**
* Event delegation handler for clicks on a-tags with class 'msoffice'.
*/
function onClickTable(event) {
var target = event.target || event.srcElement,
opts = {
Expand All @@ -141,7 +92,7 @@ function onClickTable(event) {

if( target.className === "msoffice" ){
if( openWebDavDocument(opts) ){
// prevent default processing
// prevent default processing if the document could be opened
return false;
}
}
Expand Down
Loading

0 comments on commit 3743ace

Please sign in to comment.