Skip to content
This repository was archived by the owner on Dec 20, 2023. It is now read-only.

Commit 66f2e17

Browse files
author
Barry de Graaff
committed
- show .scad OpenSCAD files in the preview pane, as they are text/plain.
- fix issue displaying quotes in properties dialog. - remove support for numbered file names.
1 parent d12e37d commit 66f2e17

File tree

7 files changed

+15
-84
lines changed

7 files changed

+15
-84
lines changed

README.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,6 @@ Please note that a preference set by the user has priority over a preference set
123123
| owncloud_zimlet_extra_toolbar_button_url | owncloud_zimlet_oc_folder | URL to open when `Go to Nextcloud` is clicked. Instead of a URL you can set it to `owncloud_zimlet_server_name` it opens the URL set in owncloud_zimlet_server_name (may be set by user). When set to `owncloud_zimlet_oc_folder` it opens the URL set in owncloud_zimlet_server_name combined with owncloud_zimlet_oc_folder (maybe set by user). See: owncloud_zimlet_extra_toolbar_button_title | |
124124
| owncloud_zimlet_app_title | WebDAV | Change this if you want to rebrand WebDAV Client for your users. For example: ownCloud. | |
125125
| owncloud_zimlet_max_upload_size | 104857600 (100MB) | Maximum upload size for upload dialog MB * 1024 * 1024. The back-end has a hardcoded maximum of 1048576000 (1GB). | |
126-
| owncloud_zimlet_use_numbers | false | If set to true, a number will be used instead of filename when saving attachments. | |
127-
| file_number | 1000000 | The number to start counting from. See owncloud_zimlet_use_numbers. | |
128126
| owncloud_zimlet_disable_ocs_public_link_shares | false | Controls if users can share items with a public link. Set this to true if you use a DAV server that is not ownCloud/Nextcloud or if you want to disable public link sharing. | |
129127
| owncloud_zimlet_welcome_url | https://barrydegraaff.github.io/owncloud/ | Page to load in the preview window when then the tab is clicked. | |
130128
| owncloud_zimlet_accountname_with_domain | false | When false the username field in settings dialog is set to `username`, when true it is set to `username@domain.com` | |

extension/src/com/zextras/dav/UploadHandler.java

Lines changed: 1 addition & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ public void doPost(
163163
}
164164

165165
//to-do implement proper encoding and better sanitizing (allow more characters)
166-
String fileNameString = getFileName(item.getName().replaceAll("\\\\|\\/|\\:|\\*|\\?|\\\"|\\<|\\>|\\||\\%|\\&|\\@|\\!|\\'|\\[|\\]", "").replace(" ", "%20"), userProperties.get(ZimletProperty.USE_NUMBERS));
166+
String fileNameString = item.getName().replaceAll("\\\\|\\/|\\:|\\*|\\?|\\\"|\\<|\\>|\\||\\%|\\&|\\@|\\!|\\'|\\[|\\]", "").replace(" ", "%20");
167167

168168
fileNames.add(fileNameString);
169169

@@ -253,42 +253,6 @@ private String uriDecode(String dirty) {
253253
}
254254
}
255255

256-
private String getFileName(String filename, String numberedFilenames) {
257-
try {
258-
FileInputStream input = new FileInputStream("/opt/zimbra/lib/ext/ownCloud/config.properties");
259-
Properties prop = new Properties();
260-
prop.load(input);
261-
input.close();
262-
String fileNumberStr = prop.getProperty("file_number");
263-
264-
265-
if ("true".equals(numberedFilenames)) {
266-
int fileNumber = Integer.parseInt(fileNumberStr);
267-
268-
fileNumber = fileNumber + 1;
269-
270-
FileOutputStream out = new FileOutputStream("/opt/zimbra/lib/ext/ownCloud/config.properties");
271-
prop.setProperty("file_number", Integer.toString(fileNumber));
272-
prop.store(out, "Updated file_number via getFileName.");
273-
out.close();
274-
275-
276-
if (filename.lastIndexOf(".") > -1) {
277-
filename = fileNumberStr + filename.substring(filename.lastIndexOf("."));
278-
} else {
279-
filename = fileNumberStr;
280-
}
281-
282-
}
283-
return filename;
284-
285-
} catch (IOException ex) {
286-
ex.printStackTrace();
287-
288-
return filename;
289-
}
290-
}
291-
292256
@Override
293257
public void doOptions(
294258
HttpServletRequest httpServletRequest,

extension/src/com/zextras/dav/ZimletProperty.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ public class ZimletProperty
99
public static String DAV_SERVER_NAME = "owncloud_zimlet_server_name";
1010
public static String DAV_SERVER_PORT = "owncloud_zimlet_server_port";
1111
public static String DAV_SERVER_PATH = "owncloud_zimlet_server_path";
12-
public static String USE_NUMBERS = "owncloud_zimlet_use_numbers";
1312

1413
public static String OC_PATH = "owncloud_zimlet_oc_folder";
1514
}

webdav-client-installer.sh

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -239,8 +239,6 @@ owncloud_zimlet_extra_toolbar_button_title=Go to Nextcloud
239239
owncloud_zimlet_extra_toolbar_button_url=owncloud_zimlet_oc_folder
240240
owncloud_zimlet_app_title=WebDAV
241241
owncloud_zimlet_max_upload_size=104857600
242-
owncloud_zimlet_use_numbers=false
243-
file_number=1000000
244242
owncloud_zimlet_welcome_url=${OWNCLOUD_DOC_URL}
245243
owncloud_zimlet_accountname_with_domain=false
246244
owncloud_zimlet_disable_auto_upload_on_exceed=false

zimlet/OwnCloudListView.js

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -598,17 +598,17 @@ OwnCloudListView.prototype._onItemSelected = function(ev) {
598598
zimletInstance.onlyOfficeToken = dav_download_options[1];
599599
if(dav_download_options[0] == 'true')
600600
{
601-
var regex = /\.pdf$|\.odt$|\.ods$|\.odp$|\.mp4$|\.webm$|\.jpg$|\.jpeg$|\.png$|\.txt$|\.md$|\.doc$|\.docx$|\.xls$|\.xlsx$|\.ppt$|\.pptx$|\.djvu$/i;
601+
var regex = /\.pdf$|\.odt$|\.ods$|\.odp$|\.mp4$|\.webm$|\.jpg$|\.jpeg$|\.png$|\.txt$|\.scad$|\.md$|\.doc$|\.docx$|\.xls$|\.xlsx$|\.ppt$|\.pptx$|\.djvu$/i;
602602
}
603603
else
604604
{
605605
if(zimletInstance._zimletContext.getConfig("owncloud_zimlet_onlyoffice_api_url"))
606606
{
607-
var regex = /\.pdf$|\.mp4$|\.webm$|\.jpg$|\.jpeg$|\.png$|\.txt$|\.md$|\.docx$|\.xlsx$|\.pptx$/i;
607+
var regex = /\.pdf$|\.mp4$|\.webm$|\.jpg$|\.jpeg$|\.png$|\.txt$|\.scad$|\.md$|\.docx$|\.xlsx$|\.pptx$/i;
608608
}
609609
else
610610
{
611-
var regex = /\.pdf$|\.mp4$|\.webm$|\.jpg$|\.jpeg$|\.png$|\.txt$|\.md$/i;
611+
var regex = /\.pdf$|\.mp4$|\.webm$|\.jpg$|\.jpeg$|\.png$|\.txt$|\.scad$|\.md$/i;
612612
}
613613
}
614614
if(!item.isDirectory() && davResource._href.match(regex))
@@ -667,6 +667,9 @@ OwnCloudListView.prototype.preview = function(davResource, token) {
667667
case (davResource._href.match(/\.txt$/i) || {}).input:
668668
contentType = 'text/plain';
669669
break;
670+
case (davResource._href.match(/\.scad$/i) || {}).input:
671+
contentType = 'text/plain';
672+
break;
670673
case (davResource._href.match(/\.md$/i) || {}).input:
671674
contentType = 'text/plain';
672675
break;
@@ -860,7 +863,7 @@ OwnCloudListView.prototype.preview = function(davResource, token) {
860863
//see also function OwnCloudApp
861864
document.getElementById('WebDAVPreviewContainer').innerHTML='<iframe id="WebDAVPreview" src="" style="width:'+(zimletInstance.appWidth/2+zimletInstance.appWidthCorrection)+'px; height:'+ zimletInstance.appHeight +'px; border:0px">';
862865

863-
if(davResource._href.match(/\.txt$/i))
866+
if(davResource._href.match(/\.txt$|\.scad$/i))
864867
{
865868
document.getElementById('WebDAVPreview').src=href;
866869
}
@@ -938,8 +941,9 @@ OwnCloudListView.prototype._itemPropertiesListener = function(ev) {
938941

939942
var content = "<table>";
940943
var location = "/"+(davResource.getHref()).replace(tk_barrydegraaff_owncloud_zimlet_HandlerObject.settings['owncloud_zimlet_server_path'], "");
941-
content += "<tr><td style='width:100px'>"+ ZmMsg.path + ": </td><td style='width:550px;'><input id='props_owncloud_zimlet_server_path' readonly style='width:98%;color:black;border:0;' value='"+location+"'></td></tr>";
942-
content += "<tr><td style='width:100px'>"+ ZmMsg.type + ": </td><td style='width:550px;'><input readonly style='width:98%;color:black;border:0;' value='"+davResource.getContentType()+"'></td></tr>";
944+
945+
content += "<tr><td style='width:100px'>"+ ZmMsg.path + ": </td><td style='width:550px;'><input id='props_owncloud_zimlet_server_path' readonly style='width:98%;color:black;border:0;'></td></tr>";
946+
content += "<tr><td style='width:100px'>"+ ZmMsg.type + ": </td><td style='width:550px;'><input readonly style='width:98%;color:black;border:0;' value='"+davResource.getContentType()+"'></td></tr>";
943947
if(!davResource.isDirectory())
944948
{
945949
content += "<tr><td style='width:100px'>"+ ZmMsg.size + ": </td><td style='width:550px;'><input readonly style='width:98%;color:black;border:0;' value='"+AjxUtil.formatSize(davResource.getContentLength())+"'></td></tr>";
@@ -949,6 +953,7 @@ OwnCloudListView.prototype._itemPropertiesListener = function(ev) {
949953

950954
zimletInstance._propertiesdialog = new ZmDialog( { title:ZmMsg.properties, parent:zimletInstance.getShell(), standardButtons:[DwtDialog.OK_BUTTON], disposeOnPopDown:true } );
951955
zimletInstance._propertiesdialog.setContent('<div style=\'width:600px; height: 75px;\'>'+content+'</div>');
956+
document.getElementById('props_owncloud_zimlet_server_path').value = location;
952957
zimletInstance._propertiesdialog.setButtonListener(DwtDialog.OK_BUTTON, new AjxListener(this, this.okbtnProperties,[davResource]));
953958
zimletInstance._propertiesdialog._setAllowSelection();
954959
document.getElementById(zimletInstance._propertiesdialog.__internalId+'_handle').style.backgroundColor = '#eeeeee';

zimlet/tk_barrydegraaff_owncloud_zimlet.js

Lines changed: 2 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -162,25 +162,6 @@ ownCloudZimlet.prototype.init =
162162
tk_barrydegraaff_owncloud_zimlet_HandlerObject.settings['owncloud_zimlet_oc_folder'] = this.getUserProperty("owncloud_zimlet_oc_folder");
163163
}
164164

165-
//Set default value in case no owncloud_zimlet_use_numbers is set
166-
if(!this.getUserProperty("owncloud_zimlet_use_numbers"))
167-
{
168-
if(this._zimletContext.getConfig("owncloud_zimlet_use_numbers"))
169-
{
170-
//Did the admin specify one? Use that:
171-
tk_barrydegraaff_owncloud_zimlet_HandlerObject.settings['owncloud_zimlet_use_numbers'] = this._zimletContext.getConfig("owncloud_zimlet_use_numbers");
172-
}
173-
else
174-
{
175-
//Seems like the admins wants to clear this field, do it:
176-
tk_barrydegraaff_owncloud_zimlet_HandlerObject.settings['owncloud_zimlet_use_numbers'] = "";
177-
}
178-
}
179-
else
180-
{
181-
tk_barrydegraaff_owncloud_zimlet_HandlerObject.settings['owncloud_zimlet_use_numbers'] = this.getUserProperty("owncloud_zimlet_use_numbers");
182-
}
183-
184165
//Set default value
185166
if(!this.getUserProperty("owncloud_zimlet_template"))
186167
{
@@ -1337,7 +1318,6 @@ ownCloudZimlet.prototype.displayDialog =
13371318
"<td style='min-width:200px'>"+ZmMsg.location+"&nbsp;ownCloud/Nextcloud:&nbsp;</td>" +
13381319
"<td style='min-width:400px'><input style='width:98%' type='text' id='owncloud_zimlet_oc_folder' value='"+tk_barrydegraaff_owncloud_zimlet_HandlerObject.settings['owncloud_zimlet_oc_folder']+"'></td>" +
13391320
"</tr>" +
1340-
"<tr class='owncloud_zimlet_userprefs'><td style='min-width:200px'>"+ZmMsg.usePrefix + " " + (ZmMsg.number).toLowerCase()+":&nbsp;</td><td><table><tr class='oc_userprefs'><td><input type='checkbox' id='owncloud_zimlet_use_numbers' value='true' " + (tk_barrydegraaff_owncloud_zimlet_HandlerObject.settings['owncloud_zimlet_use_numbers']=='false' ? '' : 'checked') +"></td></tr></table></td></tr>" +
13411321
"<tr class='owncloud_zimlet_userprefs'><td style='min-width:200px'>"+ZmMsg.template+":&nbsp;</td><td style='min-width:400px'><textarea placeholder='"+ZmMsg.clickToAdd+"' onclick='ownCloudZimlet.prototype.setTemplate()' rows='6' id='owncloud_zimlet_template'>" + tk_barrydegraaff_owncloud_zimlet_HandlerObject.settings['owncloud_zimlet_template'] +"</textarea></td></tr>" +
13421322
"<tr><td colspan=2><br><br><small>"+ZmMsg.versionLabel+" "+ownCloudZimlet.version +"</small></td></tr>"
13431323
"</table>" +
@@ -1354,11 +1334,10 @@ ownCloudZimlet.prototype.displayDialog =
13541334
zimletInstance._dialog._tabGroup.addMember(document.getElementById('owncloud_zimlet_server_port'),4);
13551335
zimletInstance._dialog._tabGroup.addMember(document.getElementById('owncloud_zimlet_server_path'),5);
13561336
zimletInstance._dialog._tabGroup.addMember(document.getElementById('owncloud_zimlet_oc_folder'),6);
1357-
zimletInstance._dialog._tabGroup.addMember(document.getElementById('owncloud_zimlet_use_numbers'),7);
1358-
zimletInstance._dialog._tabGroup.addMember(document.getElementById('owncloud_zimlet_template'),8);
1337+
zimletInstance._dialog._tabGroup.addMember(document.getElementById('owncloud_zimlet_template'),7);
13591338
zimletInstance._dialog._tabGroup.addMember(document.getElementById(zimletInstance._dialog._button[1].__internalId));
13601339
zimletInstance._dialog._tabGroup.addMember(document.getElementById(zimletInstance._dialog._button[2].__internalId));
1361-
zimletInstance._dialog._baseTabGroupSize = 8;
1340+
zimletInstance._dialog._baseTabGroupSize = 7;
13621341
break;
13631342
case 2:
13641343
//Default dialog
@@ -1495,17 +1474,6 @@ ownCloudZimlet.prototype.prefSaveBtn = function()
14951474
}
14961475
tk_barrydegraaff_owncloud_zimlet_HandlerObject.settings['owncloud_zimlet_password'] = document.getElementById('owncloud_zimlet_password').value;
14971476

1498-
if(document.getElementById("owncloud_zimlet_use_numbers").checked)
1499-
{
1500-
this.setUserProperty("owncloud_zimlet_use_numbers", "true", false);
1501-
tk_barrydegraaff_owncloud_zimlet_HandlerObject.settings['owncloud_zimlet_use_numbers'] = "true";
1502-
}
1503-
else
1504-
{
1505-
this.setUserProperty("owncloud_zimlet_use_numbers", "false", false);
1506-
tk_barrydegraaff_owncloud_zimlet_HandlerObject.settings['owncloud_zimlet_use_numbers'] = "false";
1507-
}
1508-
15091477
this.setUserProperty("owncloud_zimlet_server_name", serverName, false);
15101478
tk_barrydegraaff_owncloud_zimlet_HandlerObject.settings['owncloud_zimlet_server_name'] = serverName;
15111479

zimlet/tk_barrydegraaff_owncloud_zimlet.xml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ along with this program. If not, see http://www.gnu.org/licenses/.
2323
2424
-->
2525
<zimlet name="tk_barrydegraaff_owncloud_zimlet"
26-
version="1.1.2"
26+
version="1.1.3"
2727
target="main compose-window view-window"
2828
label="WebDAV"
2929
description="Attach from and save to WebDAV">
@@ -51,7 +51,6 @@ along with this program. If not, see http://www.gnu.org/licenses/.
5151
<property type="string" label="" name="owncloud_zimlet_server_port" rows="1"/>
5252
<property type="string" label="" name="owncloud_zimlet_server_path" rows="1"/>
5353
<property type="string" label="" name="owncloud_zimlet_oc_folder" rows="1"/>
54-
<property type="string" label="" name="owncloud_zimlet_use_numbers" rows="1"/>
5554
<property type="string" label="" name="owncloud_zimlet_template" rows="1"/>
5655
</userProperties>
5756
<contentObject>

0 commit comments

Comments
 (0)