@@ -34,7 +34,7 @@ import escapeHTML from 'escape-html'
3434 * "user@example.com/path/to/owncloud"
3535 * "user@anotherexample.com@example.com/path/to/owncloud
3636 */
37- _REMOTE_OWNER_REGEXP : new RegExp ( '^(([^@]*)@(([^@^/^ \\s]*)@)?)([^[\\s/]*)([/](.*))?$' ) ,
37+ _REMOTE_OWNER_REGEXP : new RegExp ( '^(([^@]*)@(([^@^/\\s]*)@)?)((https://)? [^[\\s/]*)([/](.*))?$' ) ,
3838
3939 /**
4040 * Initialize the sharing plugin.
@@ -343,137 +343,140 @@ import escapeHTML from 'escape-html'
343343 }
344344 icon . removeClass ( 'icon-shared icon-public' ) . addClass ( iconClass )
345345 } ,
346- /**
347- * Format a remote address
348- *
349- * @param {String } shareWith userid, full remote share, or whatever
350- * @param {String } shareWithDisplayName
351- * @param {String } message
352- * @returns {String } HTML code to display
353- */
354- _formatRemoteShare : function ( shareWith , shareWithDisplayName , message ) {
355- var parts = OCA . Sharing . Util . _REMOTE_OWNER_REGEXP . exec ( shareWith )
356- if ( ! parts || ! parts [ 6 ] ) {
357- // display avatar of the user
358- var avatar = '<span class="avatar" data-username="' + escapeHTML ( shareWith ) + '" title="' + message + ' ' + escapeHTML ( shareWithDisplayName ) + '"></span>'
359- var hidden = '<span class="hidden-visually">' + message + ' ' + escapeHTML ( shareWithDisplayName ) + '</span> '
360- return avatar + hidden
361- }
346+ /**
347+ * Format a remote address
348+ *
349+ * @param {String } shareWith userid, full remote share, or whatever
350+ * @param {String } shareWithDisplayName
351+ * @param {String } message
352+ * @returns {String } HTML code to display
353+ */
354+ _formatRemoteShare : function ( shareWith , shareWithDisplayName , message ) {
355+ var parts = OCA . Sharing . Util . _REMOTE_OWNER_REGEXP . exec ( shareWith )
356+ console . error ( parts ) ;
357+ if ( ! parts || ! parts [ 7 ] ) {
358+ // display avatar of the user
359+ var avatar = '<span class="avatar" data-username="' + escapeHTML ( shareWith ) + '" title="' + message + ' ' + escapeHTML ( shareWithDisplayName ) + '"></span>'
360+ var hidden = '<span class="hidden-visually">' + message + ' ' + escapeHTML ( shareWithDisplayName ) + '</span> '
361+ return avatar + hidden
362+ }
362363
363364 var userName = parts [ 2 ]
364365 var userDomain = parts [ 4 ]
365366 var server = parts [ 5 ]
367+ var protocol = parts [ 6 ]
368+ var serverPath = parts [ 8 ] ? parts [ 7 ] : '' ; // no trailing slash on root
366369
367370 var tooltip = message + ' ' + userName
368371 if ( userDomain ) {
369372 tooltip += '@' + userDomain
370373 }
371374 if ( server ) {
372- tooltip += '@' + server
375+ tooltip += '@' + server . replace ( protocol , '' ) + serverPath
373376 }
374377
375- var html = '<span class="remoteAddress" title="' + escapeHTML ( tooltip ) + '">'
376- html += '<span class="username">' + escapeHTML ( userName ) + '</span>'
377- if ( userDomain ) {
378- html += '<span class="userDomain">@' + escapeHTML ( userDomain ) + '</span>'
379- }
380- html += '</span> '
381- return html
382- } ,
383- /**
384- * Loop over all recipients in the list and format them using
385- * all kind of fancy magic.
386- *
387- * @param {Object } recipients array of all the recipients
388- * @returns {String[] } modified list of recipients
389- */
390- _formatShareList : function ( recipients ) {
391- var _parent = this
392- recipients = _ . toArray ( recipients )
393- recipients . sort ( function ( a , b ) {
394- return a . shareWithDisplayName . localeCompare ( b . shareWithDisplayName )
395- } )
396- return $ . map ( recipients , function ( recipient ) {
397- return _parent . _formatRemoteShare ( recipient . shareWith , recipient . shareWithDisplayName , t ( 'core' , 'Shared with' ) )
398- } )
378+ var html = '<span class="remoteAddress" title="' + escapeHTML ( tooltip ) + '">'
379+ html += '<span class="username">' + escapeHTML ( userName ) + '</span>'
380+ if ( userDomain ) {
381+ html += '<span class="userDomain">@' + escapeHTML ( userDomain ) + '</span>'
382+ }
383+ html += '</span> '
384+ return html
385+ } ,
386+ /**
387+ * Loop over all recipients in the list and format them using
388+ * all kind of fancy magic.
389+ *
390+ * @param {Object } recipients array of all the recipients
391+ * @returns {String[] } modified list of recipients
392+ */
393+ _formatShareList : function ( recipients ) {
394+ var _parent = this
395+ recipients = _ . toArray ( recipients )
396+ recipients . sort ( function ( a , b ) {
397+ return a . shareWithDisplayName . localeCompare ( b . shareWithDisplayName )
398+ } )
399+ return $ . map ( recipients , function ( recipient ) {
400+ return _parent . _formatRemoteShare ( recipient . shareWith , recipient . shareWithDisplayName , t ( 'core' , 'Shared with' ) )
401+ } )
399402 } ,
400-
401- /**
402- * Marks/unmarks a given file as shared by changing its action icon
403- * and folder icon.
404- *
405- * @param $tr file element to mark as shared
406- * @param hasShares whether shares are available
407- * @param hasLink whether link share is available
408- */
409- markFileAsShared : function ( $tr , hasShares , hasLink ) {
410- var action = $tr . find ( '.fileactions .action[data-action="Share"]' )
411- var type = $tr . data ( 'type' )
412- var icon = action . find ( '.icon' )
413- var message , recipients , avatars
414- var ownerId = $tr . attr ( 'data-share-owner-id' )
415- var owner = $tr . attr ( 'data-share-owner' )
416- var mountType = $tr . attr ( 'data-mounttype' )
417- var shareFolderIcon
418- var iconClass = 'icon-shared'
419- action . removeClass ( 'shared-style' )
420- // update folder icon
421- if ( type === 'dir' && ( hasShares || hasLink || ownerId ) ) {
422- if ( typeof mountType !== 'undefined' && mountType !== 'shared-root' && mountType !== 'shared' ) {
423- shareFolderIcon = OC . MimeType . getIconUrl ( 'dir-' + mountType )
424- } else if ( hasLink ) {
425- shareFolderIcon = OC . MimeType . getIconUrl ( 'dir-public' )
426- } else {
427- shareFolderIcon = OC . MimeType . getIconUrl ( 'dir-shared' )
428- }
429- $tr . find ( '.filename .thumbnail' ) . css ( 'background-image' , 'url(' + shareFolderIcon + ')' )
430- $tr . attr ( 'data-icon' , shareFolderIcon )
431- } else if ( type === 'dir' ) {
432- var isEncrypted = $tr . attr ( 'data-e2eencrypted' )
433- // FIXME: duplicate of FileList._createRow logic for external folder,
434- // need to refactor the icon logic into a single code path eventually
435- if ( isEncrypted === 'true' ) {
436- shareFolderIcon = OC . MimeType . getIconUrl ( 'dir-encrypted' )
437- $tr . attr ( 'data-icon' , shareFolderIcon )
438- } else if ( mountType && mountType . indexOf ( 'external' ) === 0 ) {
439- shareFolderIcon = OC . MimeType . getIconUrl ( 'dir-external' )
440- $tr . attr ( 'data-icon' , shareFolderIcon )
441- } else {
442- shareFolderIcon = OC . MimeType . getIconUrl ( 'dir' )
443- // back to default
444- $tr . removeAttr ( 'data-icon' )
445- }
446- $tr . find ( '.filename .thumbnail' ) . css ( 'background-image' , 'url(' + shareFolderIcon + ')' )
447- }
448- // update share action text / icon
449- if ( hasShares || ownerId ) {
450- recipients = $tr . data ( 'share-recipient-data' )
451- action . addClass ( 'shared-style' )
452-
453- avatars = '<span>' + t ( 'core' , 'Shared' ) + '</span>'
454- // even if reshared, only show "Shared by"
455- if ( ownerId ) {
456- message = t ( 'core' , 'Shared by' )
457- avatars = this . _formatRemoteShare ( ownerId , owner , message )
458- } else if ( recipients ) {
459- avatars = this . _formatShareList ( recipients )
460- }
461- action . html ( avatars ) . prepend ( icon )
462-
463- if ( ownerId || recipients ) {
464- var avatarElement = action . find ( '.avatar' )
465- avatarElement . each ( function ( ) {
466- $ ( this ) . avatar ( $ ( this ) . data ( 'username' ) , 32 )
467- } )
468- action . find ( 'span[title]' ) . tooltip ( { placement : 'top' } )
469- }
470- } else {
471- action . html ( '<span class="hidden-visually">' + t ( 'core' , 'Shared' ) + '</span>' ) . prepend ( icon )
472- }
473- if ( hasLink ) {
474- iconClass = 'icon-public'
475- }
476- icon . removeClass ( 'icon-shared icon-public' ) . addClass ( iconClass )
403+
404+ /**
405+ * Marks/unmarks a given file as shared by changing its action icon
406+ * and folder icon.
407+ *
408+ * @param $tr file element to mark as shared
409+ * @param hasShares whether shares are available
410+ * @param hasLink whether link share is available
411+ */
412+ markFileAsShared : function ( $tr , hasShares , hasLink ) {
413+ var action = $tr . find ( '.fileactions .action[data-action="Share"]' )
414+ var type = $tr . data ( 'type' )
415+ var icon = action . find ( '.icon' )
416+ var message , recipients , avatars
417+ var ownerId = $tr . attr ( 'data-share-owner-id' )
418+ var owner = $tr . attr ( 'data-share-owner' )
419+ var mountType = $tr . attr ( 'data-mounttype' )
420+ var shareFolderIcon
421+ var iconClass = 'icon-shared'
422+ action . removeClass ( 'shared-style' )
423+ // update folder icon
424+ if ( type === 'dir' && ( hasShares || hasLink || ownerId ) ) {
425+ if ( typeof mountType !== 'undefined' && mountType !== 'shared-root' && mountType !== 'shared' ) {
426+ shareFolderIcon = OC . MimeType . getIconUrl ( 'dir-' + mountType )
427+ } else if ( hasLink ) {
428+ shareFolderIcon = OC . MimeType . getIconUrl ( 'dir-public' )
429+ } else {
430+ shareFolderIcon = OC . MimeType . getIconUrl ( 'dir-shared' )
431+ }
432+ $tr . find ( '.filename .thumbnail' ) . css ( 'background-image' , 'url(' + shareFolderIcon + ')' )
433+ $tr . attr ( 'data-icon' , shareFolderIcon )
434+ } else if ( type === 'dir' ) {
435+ var isEncrypted = $tr . attr ( 'data-e2eencrypted' )
436+ // FIXME: duplicate of FileList._createRow logic for external folder,
437+ // need to refactor the icon logic into a single code path eventually
438+ if ( isEncrypted === 'true' ) {
439+ shareFolderIcon = OC . MimeType . getIconUrl ( 'dir-encrypted' )
440+ $tr . attr ( 'data-icon' , shareFolderIcon )
441+ } else if ( mountType && mountType . indexOf ( 'external' ) === 0 ) {
442+ shareFolderIcon = OC . MimeType . getIconUrl ( 'dir-external' )
443+ $tr . attr ( 'data-icon' , shareFolderIcon )
444+ } else {
445+ shareFolderIcon = OC . MimeType . getIconUrl ( 'dir' )
446+ // back to default
447+ $tr . removeAttr ( 'data-icon' )
448+ }
449+ $tr . find ( '.filename .thumbnail' ) . css ( 'background-image' , 'url(' + shareFolderIcon + ')' )
450+ }
451+ // update share action text / icon
452+ if ( hasShares || ownerId ) {
453+ recipients = $tr . data ( 'share-recipient-data' )
454+ action . addClass ( 'shared-style' )
455+
456+ avatars = '<span>' + t ( 'core' , 'Shared' ) + '</span>'
457+ // even if reshared, only show "Shared by"
458+ if ( ownerId ) {
459+ message = t ( 'core' , 'Shared by' )
460+ avatars = this . _formatRemoteShare ( ownerId , owner , message )
461+ } else if ( recipients ) {
462+ avatars = this . _formatShareList ( recipients )
463+ }
464+ action . html ( avatars ) . prepend ( icon )
465+
466+ if ( ownerId || recipients ) {
467+ var avatarElement = action . find ( '.avatar' )
468+ avatarElement . each ( function ( ) {
469+ $ ( this ) . avatar ( $ ( this ) . data ( 'username' ) , 32 )
470+ } )
471+ action . find ( 'span[title]' ) . tooltip ( { placement : 'top' } )
472+ }
473+ } else {
474+ action . html ( '<span class="hidden-visually">' + t ( 'core' , 'Shared' ) + '</span>' ) . prepend ( icon )
475+ }
476+ if ( hasLink ) {
477+ iconClass = 'icon-public'
478+ }
479+ icon . removeClass ( 'icon-shared icon-public' ) . addClass ( iconClass )
477480 } ,
478481
479482 /**
0 commit comments