How to use the rdflib.Util function in rdflib

To help you get started, we’ve selected a few rdflib examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github solid / solid-panes / src / form / pane.js View on Github external
form,
            store,
            complainIfBad
          )
        }
      }) // end: when store loded
    } // renderFormsFor

    // Figure out what store

    // Which places are editable and have stuff about the subject?

    var store = null

    // 1. The document URI of the subject itself
    var docuri = $rdf.Util.uri.docpart(subject.uri)
    if (subject.uri !== docuri && kb.updater.editable(docuri, kb)) {
      store = subject.doc()
    } // an editable data file with hash

    store = store || kb.any(kb.sym(docuri), ns.link('annotationStore'))

    // 2. where stuff is already stored
    if (!store) {
      var docs = {}
      var docList = []
      store.statementsMatching(subject).map(function (st) {
        docs[st.why.uri] = 1
      })
      store
        .statementsMatching(undefined, undefined, subject)
        .map(function (st) {
github solid / solid-panes / src / ui / pane.js View on Github external
}

    var complainIfBad = function (ok, body) {
      if (ok) {
        // setModifiedDate(store, kb, store);
        // rerender(box);   // Deleted forms at the moment
      } else complain('Sorry, failed to save your change:\n' + body)
    }

    // //////////////////////////////////////////////////////////////////////////////

    var t = kb.findTypeURIs(subject)

    var store = null
    if (subject.uri) {
      var docuri = $rdf.Util.uri.docpart(subject.uri)
      if (subject.uri !== docuri && kb.updater.editable(docuri)) {
        store = kb.sym($rdf.Util.uri.docpart(subject.uri))
      } // an editable ontology with hash
    }
    if (!store) store = kb.any(kb.sym(docuri), ns.link('annotationStore'))
    if (!store) store = UI.widgets.defaultAnnotationStore(subject)

    if (!store) {
      store = kb.sym(
        'https://formsregistry.solid.community/public/formRegistry/'
      ) // fallback
    }
    // if (!store) store = kb.sym('http://tabulator.org/wiki/ontologyAnnotation/common') // fallback

    // A fallback which gives a different store page for each ontology would be good @@
github solid / solid-panes / src / ui / pane.js View on Github external
var complainIfBad = function (ok, body) {
      if (ok) {
        // setModifiedDate(store, kb, store);
        // rerender(box);   // Deleted forms at the moment
      } else complain('Sorry, failed to save your change:\n' + body)
    }

    // //////////////////////////////////////////////////////////////////////////////

    var t = kb.findTypeURIs(subject)

    var store = null
    if (subject.uri) {
      var docuri = $rdf.Util.uri.docpart(subject.uri)
      if (subject.uri !== docuri && kb.updater.editable(docuri)) {
        store = kb.sym($rdf.Util.uri.docpart(subject.uri))
      } // an editable ontology with hash
    }
    if (!store) store = kb.any(kb.sym(docuri), ns.link('annotationStore'))
    if (!store) store = UI.widgets.defaultAnnotationStore(subject)

    if (!store) {
      store = kb.sym(
        'https://formsregistry.solid.community/public/formRegistry/'
      ) // fallback
    }
    // if (!store) store = kb.sym('http://tabulator.org/wiki/ontologyAnnotation/common') // fallback

    // A fallback which gives a different store page for each ontology would be good @@

    var pred
    if (t[ns.rdfs('Class').uri]) {
github solid / solid-panes / src / outline / manager.js View on Github external
if (returnCode === returnConditions[i](subject)) {
        render()
        UI.log.debug('outline 1815')
        if (returnCode[1]) outlineElement.removeChild(outlineElement.lastChild)
        return
      }
    }
    if (
      subject.uri &&
      !immediate &&
      !UI.widgets.isAudio(subject) &&
      !UI.widgets.isVideo(subject) && // Never parse videos as data
      !kb.holds(
        subject,
        UI.ns.rdf('type'),
        $rdf.Util.mediaTypeClass('application/pdf')
      )
    ) {
      // or PDF
      // Wait till at least the main URI is loaded before expanding:
      sf.nowOrWhenFetched(subject.doc(), undefined, function (ok, body) {
        if (ok) {
          sf.lookUpThing(subject)
          render() // inital open, or else full if re-open
          if (options.solo) {
            // Update window title with new information
            // dom.title = UI.utils.label(subject)
            setUrlBarAndTitle(subject)
          }
        } else {
          var message = dom.createElement('pre')
          message.textContent = body
github solid / solid-panes / src / form / pane.js View on Github external
kb.fetcher.nowOrWhenFetched(store.uri, subject, function (ok, body) {
        if (!ok) return complain('Cannot load store ' + store.uri + ': ' + body)

        //              Render the forms

        var forms = UI.widgets.formsFor(subject)

        // complain('Form for editing this form:');
        for (var i = 0; i < forms.length; i++) {
          var form = forms[i]
          var heading = dom.createElement('h4')
          box.appendChild(heading)
          if (form.uri) {
            var formStore = $rdf.Util.uri.document(form)
            if (formStore.uri !== form.uri) {
              // The form is a hash-type URI
              var e = box.appendChild(
                UI.widgets.editFormButton(
                  dom,
                  box,
                  form,
                  formStore,
                  complainIfBad
                )
              )
              e.setAttribute('style', 'float: right;')
            }
          }
          var anchor = dom.createElement('a')
          anchor.setAttribute('href', form.uri)
github solid / solid-ui / src / widgets / buttons.js View on Github external
buttons.isImage = function (file, kind) {
  var dcCLasses = {
    audio: 'http://purl.org/dc/dcmitype/Sound',
    image: 'http://purl.org/dc/dcmitype/Image',
    video: 'http://purl.org/dc/dcmitype/MovingImage'
  }
  var what = kind || 'image'
  var typeURIs = UI.store.findTypeURIs(file)
  var prefix = $rdf.Util.mediaTypeClass(what + '/*').uri.split('*')[0]
  for (var t in typeURIs) {
    if (t.startsWith(prefix)) return true
  }
  if (dcCLasses[what] in typeURIs) return true
  return false
}
github solid / solid-panes / src / audio / audioPane.js View on Github external
label: function (subject, context) {
    var kb = context.session.store
    var typeURIs = kb.findTypeURIs(subject)

    var prefix = $rdf.Util.mediaTypeClass('audio/*').uri.split('*')[0]
    for (var t in typeURIs) {
      if (t.startsWith(prefix)) return 'Play audio'
    }
    return null
  },
github solid / solid-panes / src / video / videoPane.js View on Github external
label: function (subject, context) {
    var kb = context.session.store
    var typeURIs = kb.findTypeURIs(subject)
    var prefix = $rdf.Util.mediaTypeClass('video/*').uri.split('*')[0]
    for (var t in typeURIs) {
      if (t.startsWith(prefix)) return 'Play video'
    }

    return null
  },
github solid / solid-panes / src / humanReadablePane.js View on Github external
var hasContentTypeIn2 = function (kb, x, displayables) {
      var t = kb.findTypeURIs(subject)
      for (var k = 0; k < displayables.length; k++) {
        if ($rdf.Util.mediaTypeClass(displayables[k]).uri in t) {
          return true
        }
      }
      return false
    }
github solid / solid-panes / src / dokieli / dokieliPane.js View on Github external
var hasContentTypeIn2 = function (kb, x, displayables) {
      var t = kb.findTypeURIs(subject)
      for (var k = 0; k < displayables.length; k++) {
        if ($rdf.Util.mediaTypeClass(displayables[k]).uri in t) {
          return true
        }
      }
      return false
    }