src/app-registry.js
/**
 * Initializes the public App Registry resource, updates
 * the profile with the initialized registry, and returns the updated profile.
 * @method initAppRegistryPublic
 * @param profile {SolidProfile} User's WebID profile
 * @param [options] Options hashmap (see solid.web.solidRequest() function docs)
 * @return {Promise<SolidProfile>} Resolves with the updated profile instance.
 */
Initializes the public App Registry resource, updates
the profile with the initialized registry, and returns the updated profile.
@method initAppRegistryPublic
@param profile {SolidProfile} User's WebID profile
@param [options] Options hashmap  function docs)
@return {Promise} Resolves with the updated profile instance.
Initializes the public App Registry resource updates the profile with the initialized registry and returns the updated profile . @method initAppRegistryPublic @param profile { SolidProfile } User ' s WebID profile @param [ options ] Options hashmap function docs ) @return { Promise } Resolves with the updated profile instance .
function initAppRegistryPublic (profile, webClient, options) {
  options = options || {}
  var rdf = profile.rdf
  var ns = vocab(rdf)
  var registryContainerUri = profile.appRegistryDefaultContainer()
  var webId = rdf.namedNode(profile.webId)
  var registry = blankPublicAppRegistry(rdf)
  return webClient.post(registryContainerUri, registry.data,
    registry.slug)
    .catch(function (err) {
      throw new Error('Could not create public registry document:', err)
    })
    .then(function (response) {
      registry.uri = util.absoluteUrl(webUtil.hostname(registryContainerUri),
        response.url)
      var toAdd = [
        rdf.triple(webId, ns.solid('publicAppRegistry'),
          rdf.namedNode(registry.uri))
      ]
      var toDel = []
      return webClient.patch(profile.webId, toDel, toAdd, options)
    })
    .catch(function (err) {
      throw new Error('Could not update profile with public registry:', err)
    })
    .then(function (response) {
      profile.appRegistryListed = registry
      return profile
    })
}
function initAppRegistryPublic ( profile , webClient , options ) { options = options || { } var rdf = profile . rdf var ns = vocab ( rdf ) var registryContainerUri = profile . appRegistryDefaultContainer ( ) var webId = rdf . namedNode ( profile . webId ) var registry = blankPublicAppRegistry ( rdf ) return webClient . post ( registryContainerUri , registry . data , registry . slug ) . catch ( function ( err ) { throw new Error ( 'Could not create public registry document:' , err ) } ) . then ( function ( response ) { registry . uri = util . absoluteUrl ( webUtil . hostname ( registryContainerUri ) , response . url ) var toAdd = [ rdf . triple ( webId , ns . solid ( 'publicAppRegistry' ) , rdf . namedNode ( registry . uri ) ) ] var toDel = [ ] return webClient . patch ( profile . webId , toDel , toAdd , options ) } ) . catch ( function ( err ) { throw new Error ( 'Could not update profile with public registry:' , err ) } ) . then ( function ( response ) { profile . appRegistryListed = registry return profile } ) }
Initializes the public App Registry resource, updates
 the profile with the initialized registry, and returns the updated profile.
Initializes the public App Registry resource updates the profile with the initialized registry and returns the updated profile .
// First, create the public registry Registry resource // Public registry resource created. Update the profile to link to it. // Profile successfully patched with a link to the created public registry // It's safe to update this instance of profile // Finally, return the updated profile with registry loaded