solid-panes
Version: 
Solid-compatible Panes: applets and views for the mashlib and databrowser
59 lines (56 loc) • 2.88 kB
JavaScript
;
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.RDFXMLPane = void 0;
var UI = _interopRequireWildcard(require("solid-ui"));
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, "default": e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
/*      RDF/XML content Pane
 **
 **  This pane shows the content of a particular RDF resource
 ** or at least the RDF semantics we attribute to that resource,
 ** in generated N3 syntax.
 */
var ns = UI.ns;
var RDFXMLPane = exports.RDFXMLPane = {
  icon: UI.icons.originalIconBase + '22-text-xml4.png',
  name: 'RDFXML',
  audience: [ns.solid('Developer')],
  label: function label(subject, context) {
    var store = context.session.store;
    if ('http://www.w3.org/2007/ont/link#ProtocolEvent' in store.findTypeURIs(subject)) {
      return null;
    }
    var n = store.statementsMatching(undefined, undefined, undefined, subject).length;
    if (n === 0) return null;
    return 'As RDF/XML (' + n + ')';
  },
  render: function render(subject, context) {
    var myDocument = context.dom;
    var kb = context.session.store;
    var div = myDocument.createElement('div');
    div.setAttribute('class', 'RDFXMLPane');
    // Because of smushing etc, this will not be a copy of the original source
    // We could instead either fetch and re-parse the source,
    // or we could keep all the pre-smushed triples.
    var sts = kb.statementsMatching(undefined, undefined, undefined, subject); // @@ slow with current store!
    /*
    var kludge = kb.formula([]) // No features
    for (var i=0; i< sts.length; i++) {
        s = sts[i]
        kludge.add(s.subject, s.predicate, s.object)
    }
    */
    var sz = UI.rdf.Serializer(kb);
    sz.suggestNamespaces(kb.namespaces);
    sz.setBase(subject.uri);
    var str = sz.statementsToXML(sts);
    var pre = myDocument.createElement('PRE');
    pre.appendChild(myDocument.createTextNode(str));
    div.appendChild(pre);
    return div;
  }
};
// ends
//# sourceMappingURL=RDFXMLPane.js.map