function (newPaneOptions) {
    var kb = UI.store
    var newInstance = newPaneOptions.newInstance
    if (!newInstance) {
      let uri = newPaneOptions.newBase
      if (uri.endsWith('/')) {
        uri = uri.slice(0, -1)
        newPaneOptions.newBase = uri
      }
      newInstance = kb.sym(uri)
    }

    var contentType = mime.lookup(newInstance.uri)
    if (!contentType || !contentType.includes('html')) {
      newInstance = $rdf.sym(newInstance.uri + '.html')
    }
    newPaneOptions.newInstance = newInstance // Save for creation system

    console.log('New dokieli will make: ' + newInstance)

    var htmlContents = DOKIELI_TEMPLATE
    var filename = newInstance.uri.split('/').slice(-1)[0]
    filename = decodeURIComponent(filename.split('.')[0])
    const encodedTitle = filename.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;')
    htmlContents = htmlContents.replace('<title>', '<title>' + encodedTitle)
    htmlContents = htmlContents.replace('</article>', '<h1>' + encodedTitle + '</h1></article>')
    console.log('@@ New HTML for Dok:' + htmlContents)
    return new Promise(function (resolve, reject) {
      kb.fetcher.webOperation('PUT', newInstance.uri, { data: htmlContents, contentType: 'text/html' })
        .then(function () {
          console.log('new Dokieli document created at ' + newPaneOptions.newInstance)
          resolve(newPaneOptions)
        }).catch(function (err) {
          console.log('Error creating dokelili dok at ' +
            newPaneOptions.newInstance + ': ' + err)
        })
    })
  }
function (newPaneOptions) {
    var kb = UI.store
    var newInstance = newPaneOptions.newInstance
    if (!newInstance) {
      let uri = newPaneOptions.newBase
      if (uri.endsWith('/')) {
        uri = uri.slice(0, -1)
        newPaneOptions.newBase = uri
      }
      newInstance = kb.sym(uri)
    }

    var contentType = mime.lookup(newInstance.uri)
    if (!contentType || !contentType.includes('html')) {
      newInstance = $rdf.sym(newInstance.uri + '.html')
    }
    newPaneOptions.newInstance = newInstance 

    console.log('New dokieli will make: ' + newInstance)

    var htmlContents = DOKIELI_TEMPLATE
    var filename = newInstance.uri.split('/').slice(-1)[0]
    filename = decodeURIComponent(filename.split('.')[0])
    const encodedTitle = filename.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;')
    htmlContents = htmlContents.replace('<title>', '<title>' + encodedTitle)
    htmlContents = htmlContents.replace('</article>', '<h1>' + encodedTitle + '</h1></article>')
    console.log('@@ New HTML for Dok:' + htmlContents)
    return new Promise(function (resolve, reject) {
      kb.fetcher.webOperation('PUT', newInstance.uri, { data: htmlContents, contentType: 'text/html' })
        .then(function () {
          console.log('new Dokieli document created at ' + newPaneOptions.newInstance)
          resolve(newPaneOptions)
        }).catch(function (err) {
          console.log('Error creating dokelili dok at ' +
            newPaneOptions.newInstance + ': ' + err)
        })
    })
  }
function ( newPaneOptions ) { var kb = UI . store var newInstance = newPaneOptions . newInstance if ( ! newInstance ) { let uri = newPaneOptions . newBase if ( uri . endsWith ( '/' ) ) { uri = uri . slice ( 0 , - 1 ) newPaneOptions . newBase = uri } newInstance = kb . sym ( uri ) } var contentType = mime . lookup ( newInstance . uri ) if ( ! contentType || ! contentType . includes ( 'html' ) ) { newInstance = $rdf . sym ( newInstance . uri + '.html' ) } newPaneOptions . newInstance = newInstance // Save for creation system console . log ( 'New dokieli will make: ' + newInstance ) var htmlContents = DOKIELI_TEMPLATE var filename = newInstance . uri . split ( '/' ) . slice ( - 1 ) [ 0 ] filename = decodeURIComponent ( filename . split ( '.' ) [ 0 ] ) const encodedTitle = filename . replace ( / & / g , '&amp;' ) . replace ( / < / g , '&lt;' ) . replace ( / > / g , '&gt;' ) htmlContents = htmlContents . replace ( '<title>' , '<title>' + encodedTitle ) htmlContents = htmlContents . replace ( '</article>' , '<h1>' + encodedTitle + '</h1></article>' ) console . log ( '@@ New HTML for Dok:' + htmlContents ) return new Promise ( function ( resolve , reject ) { kb . fetcher . webOperation ( 'PUT' , newInstance . uri , { data : htmlContents , contentType : 'text/html' } ) . then ( function ( ) { console . log ( 'new Dokieli document created at ' + newPaneOptions . newInstance ) resolve ( newPaneOptions ) } ) . catch ( function ( err ) { console . log ( 'Error creating dokelili dok at ' + newPaneOptions . newInstance + ': ' + err ) } ) } ) }
Create a new folder in a Solid system, with a dokieli editable document in it
Create a new folder in a Solid system with a dokieli editable document in it