@@ -289,9 +289,8 @@ <h2>Target</h2>
289289< script src ="https://cdn.jsdelivr.net/npm/n3@1.13.0/browser/n3.min.js "> </ script >
290290
291291< script xtype ="module ">
292- const getDefaultSession = solidClientAuthentication . default . getDefaultSession ;
293- const Parser = N3 . Parser ;
294-
292+ const getDefaultSession = solidClientAuthentication . default . getDefaultSession
293+ const Parser = N3 . Parser
295294 const solidSession = getDefaultSession ( )
296295
297296 const solidApi = {
@@ -409,9 +408,16 @@ <h2>Target</h2>
409408 resource . resourceType = 'account'
410409 } else if ( properties [ 'http://www.w3.org/1999/02/22-rdf-syntax-ns#type' ] !== undefined ) {
411410 const types = properties [ 'http://www.w3.org/1999/02/22-rdf-syntax-ns#type' ]
412- if ( types . includes ( 'http://www.w3.org/ns/ldp#Container' ) || types . includes ( 'http://www.w3.org/ns/ldp#BasicContainer' ) ) {
411+ if (
412+ types . includes ( 'http://www.w3.org/ns/ldp#Container' )
413+ || types . includes ( 'http://www.w3.org/ns/ldp#BasicContainer' )
414+ ) {
413415 resource . resourceType = 'folder'
414- } else if ( types . includes ( 'http://www.w3.org/ns/ldp#Resource' ) || types . includes ( 'http://www.w3.org/ns/ldp#NonRDFSource' ) ) {
416+ } else if (
417+ types . includes ( 'http://www.w3.org/ns/ldp#Resource' )
418+ || types . includes ( 'http://www.w3.org/ns/ldp#NonRDFSource' )
419+ || types . includes ( 'http://www.w3.org/ns/iana/media-types/text/plain#Resource' )
420+ ) {
415421 resource . resourceType = 'file'
416422 } else {
417423 resource . resourceType = 'other'
@@ -481,73 +487,73 @@ <h2>Target</h2>
481487 } ,
482488 writeMeta : ( pods , sources , target ) => {
483489 // do nothing
484- var sourceUrl = pods . source . url ;
485- if ( sourceUrl [ sourceUrl . length - 1 ] !== '/' ) {
486- sourceUrl += '/' ;
490+ var sourceUrl = pods . source . url
491+ if ( sourceUrl [ sourceUrl . length - 1 ] !== '/' ) {
492+ sourceUrl += '/'
487493 }
488- if ( target [ target . length - 1 ] !== '/' ) {
489- target += '/' ;
494+ if ( target [ target . length - 1 ] !== '/' ) {
495+ target += '/'
490496 }
491- var redirects = { } ;
497+ var redirects = { }
492498 sources . forEach ( source => {
493- let filenames = source . split ( '/' ) ;
494- let filename = filenames . pop ( ) ;
495- redirects [ filename ] = target + filename ;
496- } ) ;
497- const parser = new Parser ( { blankNodePrefix : '' , baseIRI : sourceUrl + '.meta' } )
498- var prefixes = { } ;
499- solidApi . fetchFromPod ( sourceUrl + '.meta' )
499+ let filenames = source . split ( '/' )
500+ let filename = filenames . pop ( )
501+ redirects [ filename ] = target + filename
502+ } )
503+ const parser = new Parser ( { blankNodePrefix : '' , baseIRI : sourceUrl + '.meta' } )
504+ var prefixes = { }
505+ solidApi . fetchFromPod ( sourceUrl + '.meta' )
500506 . then ( text => parser . parse ( text , null , ( prefix , url ) => { prefixes [ prefix ] = url . id } ) )
501507 . then ( data => {
502508 return {
503509 data : data ,
504- prefixes : prefixes
505- } ;
510+ prefixes : prefixes ,
511+ }
506512 } )
507513 . then ( meta => {
508- var lm = 'https://purl.org/pdsinterop/link-metadata#' ;
509- var lmPrefix = '' ;
510- var preferredPrefix = 'lm' ;
514+ var lm = 'https://purl.org/pdsinterop/link-metadata#'
515+ var lmPrefix = ''
516+ var preferredPrefix = 'lm'
511517 Object . keys ( meta . prefixes ) . forEach ( prefix => {
512- if ( meta . prefixes [ prefix ] == lm ) {
513- lmPrefix = prefix ;
518+ if ( meta . prefixes [ prefix ] == lm ) {
519+ lmPrefix = prefix
514520 }
515- } ) ;
516- if ( ! lmPrefix ) {
517- count = 0 ;
521+ } )
522+ if ( ! lmPrefix ) {
523+ count = 0
518524 do {
519- lmPrefix = preferredPrefix + ( count ? count : '' ) ;
520- count ++ ;
521- } while ( meta . prefixes [ lmPrefix ] ) ;
522- meta . prefixes [ lmPrefix ] = lm ;
525+ lmPrefix = preferredPrefix + ( count ? count : '' )
526+ count ++
527+ } while ( meta . prefixes [ lmPrefix ] )
528+ meta . prefixes [ lmPrefix ] = lm
523529 }
524- var newMeta = new n3 . Writer ( {
525- format : 'text/turtle'
526- } ) ;
527- newMeta . addPrefixes ( meta . prefixes ) ;
528- newMeta . addQuads ( meta . data ) ;
530+ var newMeta = new N3 . Writer ( {
531+ format : 'text/turtle' ,
532+ } )
533+ newMeta . addPrefixes ( meta . prefixes )
534+ newMeta . addQuads ( meta . data )
529535 Object . keys ( redirects ) . forEach ( redirect => {
530536 newMeta . addQuad (
531- new n3 . NamedNode ( redirect ) ,
532- new n3 . NamedNode ( lm + 'redirectPermanent' ) ,
533- new n3 . NamedNode ( redirects [ redirect ] )
534- ) ;
535- } ) ;
536- newMeta . end ( ( error , result ) => {
537- console . log ( result ) ;
538- solidApi . writeToPod ( sourceUrl + '.meta' , result , 'text/turtle' )
537+ new N3 . NamedNode ( redirect ) ,
538+ new N3 . NamedNode ( lm + 'redirectPermanent' ) ,
539+ new N3 . NamedNode ( redirects [ redirect ] ) ,
540+ )
541+ } )
542+ newMeta . end ( ( error , result ) => {
543+ console . log ( result )
544+ solidApi . writeToPod ( sourceUrl + '.meta' , result , 'text/turtle' )
539545 } )
540546 } )
541547 } ,
542- writeToPod : ( url , content , contentType = false ) => {
548+ writeToPod : ( url , content , contentType = false ) => {
543549 var fetchParams = {
544550 body : content ,
545- method : 'PUT'
546- } ;
547- if ( contentType ) {
551+ method : 'PUT' ,
552+ }
553+ if ( contentType ) {
548554 fetchParams . headers = {
549- 'Content-Type' : contentType
550- } ;
555+ 'Content-Type' : contentType ,
556+ }
551557 }
552558 solidSession . fetch ( url , fetchParams )
553559 } ,
@@ -557,7 +563,7 @@ <h2>Target</h2>
557563 actions : { // Actions should all return a Promise
558564 log : ( message , indent = 0 , type = 'debug' ) => {
559565 solidApp . view . alerts = solidApp . view . alerts . map ( alert => {
560- if ( ! alert || alert . state === 'shown' ) {
566+ if ( ! alert || alert . state === 'shown' ) {
561567 alert = null
562568 } else {
563569 alert . state = 'shown'
@@ -566,7 +572,7 @@ <h2>Target</h2>
566572 return alert
567573 } )
568574
569- solidApp . view . alerts . push ( { message, state : 'new' , " data-simply-template" : type } )
575+ solidApp . view . alerts . push ( { message, state : 'new' , ' data-simply-template' : type } )
570576 } ,
571577 setPodUrl : ( webId , pod ) => solidApi . getPodUrl ( new URL ( webId ) ) . then ( podUrl => solidApp . view . pods [ pod ] . url = podUrl ) ,
572578 } ,
@@ -576,16 +582,16 @@ <h2>Target</h2>
576582 ,
577583 disconnect : ( ) => solidApi . disconnect ( ) . then ( ( ) => { window . location = window . location } ) ,
578584 readPod : ( form , values ) => {
579- if ( ! values . url ) {
585+ if ( ! values . url ) {
580586 return solidApp . actions . log ( `Please provide an URL as ${ values . pod } pod!` , 0 , 'error' )
581587 }
582- if ( values . url [ values . url . length - 1 ] != '/' ) {
583- values . url += '/' ;
588+ if ( values . url [ values . url . length - 1 ] != '/' ) {
589+ values . url += '/'
584590 }
585591 solidApp . view . pods [ values . pod ] . url = values . url
586592
587593 return solidApi . listPodContent ( values . url )
588- . then ( podData => podData . map ( resource => Object . assign ( resource , { " data-simply-template" : resource . resourceType } ) ) )
594+ . then ( podData => podData . map ( resource => Object . assign ( resource , { ' data-simply-template' : resource . resourceType } ) ) )
589595 . then ( podData => solidApp . view . pods [ values . pod ] . data = JSON . parse ( JSON . stringify ( podData ) ) )
590596 . then ( ( ) => {
591597 solidApp . view . isLoaded = solidApp . view . pods . source . data . length > 0
@@ -618,8 +624,8 @@ <h2>Target</h2>
618624
619625 Promise . allSettled ( sourcePromises )
620626 . then ( promises => {
621- promises . forEach ( ( promise , index ) => {
622- if ( ! promise . value ) {
627+ promises . forEach ( ( promise , index ) => {
628+ if ( ! promise . value ) {
623629 solidApp . actions . log ( `Failed copying "${ selectedSources [ index ] } "` , 0 , 'error' )
624630 } else {
625631
@@ -631,17 +637,17 @@ <h2>Target</h2>
631637 } )
632638 }
633639 } )
634- return promises ;
640+ return promises
635641 } )
636642 . then ( ( ) => {
637- solidApp . actions . log ( `Copied selected files to "${ selectedTarget } "` , 0 , 'success' ) ;
638- return solidApi . writeMeta ( solidApp . view . pods , selectedSources , selectedTarget ) ;
643+ solidApp . actions . log ( `Copied selected files to "${ selectedTarget } "` , 0 , 'success' )
644+ return solidApi . writeMeta ( solidApp . view . pods , selectedSources , selectedTarget )
639645
640646 //todo update source and target views
641647 } )
642648 . catch ( error => {
643- solidApp . actions . log ( `Failed Copying selected files to "${ selectedTarget } "` , 0 , 'error' ) ;
644- console . error ( error )
649+ solidApp . actions . log ( `Failed Copying selected files to "${ selectedTarget } "` , 0 , 'error' )
650+ console . error ( error )
645651 } )
646652 } ,
647653 } ,
@@ -674,13 +680,13 @@ <h2>Target</h2>
674680 } )
675681
676682 function dereferencePrefixes ( predicate , prefixes ) {
677- if ( predicate . indexOf ( ':' ) !== false ) {
678- var prefix = predicate . split ( ':' ) [ 0 ] ;
679- if ( prefixes [ prefix ] ) {
680- predicate = prefixes [ prefix ] + predicate . split ( ':' ) [ 1 ] ;
681- }
683+ if ( predicate . indexOf ( ':' ) !== false ) {
684+ var prefix = predicate . split ( ':' ) [ 0 ]
685+ if ( prefixes [ prefix ] ) {
686+ predicate = prefixes [ prefix ] + predicate . split ( ':' ) [ 1 ]
687+ }
682688 }
683- return predicate ;
689+ return predicate
684690 }
685691</ script >
686692</ body >
0 commit comments