Return-Path: X-Original-To: apmail-clerezza-commits-archive@www.apache.org Delivered-To: apmail-clerezza-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id EE6A710CBD for ; Wed, 4 Jun 2014 21:54:25 +0000 (UTC) Received: (qmail 6910 invoked by uid 500); 4 Jun 2014 21:54:25 -0000 Delivered-To: apmail-clerezza-commits-archive@clerezza.apache.org Received: (qmail 6848 invoked by uid 500); 4 Jun 2014 21:54:25 -0000 Mailing-List: contact commits-help@clerezza.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@clerezza.apache.org Delivered-To: mailing list commits@clerezza.apache.org Received: (qmail 6838 invoked by uid 99); 4 Jun 2014 21:54:25 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 04 Jun 2014 21:54:25 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id A1A9393FC47; Wed, 4 Jun 2014 21:54:25 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: reto@apache.org To: commits@clerezza.apache.org Date: Wed, 04 Jun 2014 21:54:26 -0000 Message-Id: <7cdfeb39ee7b4037bd24fb78a04a2daa@git.apache.org> In-Reply-To: <76fde1399b0a4fd8b962d1536c106717@git.apache.org> References: <76fde1399b0a4fd8b962d1536c106717@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [2/7] CLEREZZA-829: USing rdfstore-js to store the parsed RDFa data, working around changes in literal roundtripping using the content property (even though according to the spec this is ignored for XMLLiterals) http://git-wip-us.apache.org/repos/asf/clerezza/blob/8d34e62b/platform.editor/src/main/scala/org/apache/clerezza/platform/editor/renderlets/DiscobitsContentEtch.scala ---------------------------------------------------------------------- diff --git a/platform.editor/src/main/scala/org/apache/clerezza/platform/editor/renderlets/DiscobitsContentEtch.scala b/platform.editor/src/main/scala/org/apache/clerezza/platform/editor/renderlets/DiscobitsContentEtch.scala index 302834d..36c5d15 100644 --- a/platform.editor/src/main/scala/org/apache/clerezza/platform/editor/renderlets/DiscobitsContentEtch.scala +++ b/platform.editor/src/main/scala/org/apache/clerezza/platform/editor/renderlets/DiscobitsContentEtch.scala @@ -23,103 +23,139 @@ abstract class DiscobitsContentEtch extends SRenderlet { new XmlResult(arguments) { override def content = { val initScript = """ - var discoBitsCollection = new Backbone.Collection(); + var discoBitsCollection = new Backbone.Collection(); $(function() { - - var gp = new GraphRDFaProcessor(); - gp.target.graph = new RDFaGraph(); - gp.process(document); - var origTurtle = gp.target.graph.toString(); - //alert(origTurtle); - function saveAllModified() { - /*var modifiedModels = discoBitsCollection.filter(function(model) {return model.hasChanged()}) - var modified = new Backbone.Collection(modifiedModels); - alert("could save: " +modifiedModels+" models "+ JSON.stringify(modified.toJSON())) - var gp = new GraphRDFaProcessor();*/ - gp.target.graph = new RDFaGraph(); - gp.process(document); - var newTurtle = gp.target.graph.toString() - $.post( "/tools/editor/post", { assert: newTurtle, revoke: origTurtle, rdfFormat: 'text/turtle' }, function( data ) { - alert("saved"); - origTurtle = newTurtle; - }) .fail(function( data) { - errdata = data - alert( "error: " + data.statusText); - }); - } - var InfoBit = Backbone.Model.extend({ - defaults: { - "@type": 'disco:XHTMLInfoDiscoBit', - "disco:infoBit": 'Some content' - }, - initialize: function() { - console.log('This model has been initialized.'); - var m = this; - this.on('change', function(msg) { - console.log('A value for this model has changed: '); - console.log(m.changed); - console.log(m.get("@id")); - console.log('A value for this model has changed: '+m.hasChanged(null)); - m.foo = "bar" + GreenRdfStore.getGraph(document, function(origGraph) { + //now that we have the orig graph we no longer need the content atr + $("span[property='disco:infoBit']").removeAttr("content"); + var InfoBit = Backbone.Model.extend({ + defaults: { + "@type": 'disco:XHTMLInfoDiscoBit', + "disco:infoBit": 'Some content' + }, + initialize: function() { + console.log('This model has been initialized.'); + var m = this; + this.on('change', function(msg) { + console.log('A value for this model has changed: '); + console.log(m.changed); + console.log(m.get("@id")); + console.log('A value for this model has changed: '+m.hasChanged(null)); + m.foo = "bar" + }); + } + }); + function saveAllModified() { + GreenRdfStore.getGraph(document, function(newGraph) { + //alert("orig: "+origGraph.toNT()); + //alert("new: "+ newGraph.toNT()); + $.post( "/tools/editor/post", { assert: newGraph.toNT(), revoke: origGraph.toNT(), rdfFormat: 'text/turtle' }, function( data ) { + alert("saved"); + origTurtle = newTurtle; + }) .fail(function( data) { + errdata = data + alert( "error: " + data.statusText); + }); }); - } - }); - var InfoBitView = Backbone.View.extend({ - initialize: function() { - _.bindAll(this, 'save') - this.model.bind('save', this.save); - var infoBit = $(this.el).find('[property="disco:infoBit"]').html() - console.log(this.model.hasChanged(null)) - //this.model.set("disco:infoBit", infoBit) - console.log(this.model.hasChanged(null)) - this.stickit(); - }, - events: { - 'mousedown .editable': 'editableClick' - }, - bindings: { - '[property="disco:infoBit"]': 'disco:infoBit' - }, - editableClick: etch.editableInit, - save: function() { - - // normally you would call model.save() here but this is a demo - // $(this.el).find('.editable').effect('highlight', {color: 'yellow'}); - // $('.save-event').fadeIn('fast', function() { - // setTimeout($(this).fadeOut('slow'), 10000); - // }); - console.log("this modified: "); - console.log(this.model.get("@id")); - console.log(this.model.changed); - console.log("this is modified: "+this.model.hasChanged(null)); - saveAllModified(); } + var InfoBitView = Backbone.View.extend({ + initialize: function() { + _.bindAll(this, 'save') + this.model.bind('save', this.save); + var infoBit = $(this.el).find('[property="disco:infoBit"]').html() + console.log(this.model.hasChanged(null)) + //this.model.set("disco:infoBit", infoBit) + console.log(this.model.hasChanged(null)) + this.stickit(); + }, + events: { + 'mousedown .editable': 'editableClick' + }, + bindings: { + '[property="disco:infoBit"]': 'disco:infoBit' + }, + editableClick: etch.editableInit, + save: function() { - }); + // normally you would call model.save() here but this is a demo + // $(this.el).find('.editable').effect('highlight', {color: 'yellow'}); + // $('.save-event').fadeIn('fast', function() { + // setTimeout($(this).fadeOut('slow'), 10000); + // }); + console.log("this modified: "); + console.log(this.model.get("@id")); + console.log(this.model.changed); + console.log("this is modified: "+this.model.hasChanged(null)); + saveAllModified(); + } - //$article = $('[property="disco:infoBit"]'); - $('[property="disco:infoBit"]').addClass("editable") - $('[property="disco:infoBit"]').attr("data-button-class", "all") - //this ensure two way binding with stickit - $('[property="disco:infoBit"]').attr("contenteditable", "true") - $article = $('[typeof="disco:XHTMLInfoDiscoBit"]'); - _.forEach($article, function(art) { - console.log(art); - var infoBit = $(art).find('[property="disco:infoBit"]').html() - var about = $(art).attr('about') - var model = new InfoBit({ - "@id": about, - "disco:infoBit": infoBit }); - new InfoBitView({model: model, el: art, tagName: art.tagName}); - discoBitsCollection.add(model) + //$article = $('[property="disco:infoBit"]'); + $('[property="disco:infoBit"]').addClass("editable") + $('[property="disco:infoBit"]').attr("data-button-class", "all") + //this ensure two way binding with stickit + $('[property="disco:infoBit"]').attr("contenteditable", "true") + $article = $('[typeof="disco:XHTMLInfoDiscoBit"]'); + _.forEach($article, function(art) { + console.log(art); + var infoBit = $(art).find('[property="disco:infoBit"]').html() + var about = $(art).attr('about') + var model = new InfoBit({ + "@id": about, + "disco:infoBit": infoBit + }); + new InfoBitView({model: model, el: art, tagName: art.tagName}); + discoBitsCollection.add(model) + }); + + + }); + /*var store = rdfstore.create(); + + CallbackProcessor.prototype = new RDFaProcessor(); + CallbackProcessor.prototype.constructor=RDFaProcessor; + function CallbackProcessor() { + RDFaProcessor.call(this); + } + + CallbackProcessor.prototype.addTriple = function(origin,subject,predicate,object) { + alert("New triple: "+subject+", predicate "+predicate+", object "+object.value+", "+object.language+", "+object.type); + //RDFaProcessor.prototype.addTriple.call(this, origin, subject, predicate, object); + //graph.add(env.createTriple()) + }*/ + //var gp = new GraphRDFaProcessor(); + /*function WrappedGraphProcessor() { + GraphRDFaProcessor.call(this) + } + WrappedGraphProcessor.prototype = new GraphRDFaProcessor(); + WrappedGraphProcessor.prototype.addTriple= function(origin,subject,predicate,object) { + alert("uff "+origin+","+subject+","+predicate+","+object); + if (origin.getAttribute("content")) { + object.value = origin.getAttribute("content"); + } + GraphRDFaProcessor.prototype.addTriple.call(this, origin, subject, predicate, object); + } + var gp = new WrappedGraphProcessor(); + //var gp = new CallbackProcessor(); + gp.target.graph = new RDFaGraph(); + gp.process(document); + var origTurtle = gp.target.graph.toString(); + alert(origTurtle);*/ + + + //}); + + + + + //var view = new articleView({model: model, el: $article[0], tagName: $article[0].tagName}); }); - + Backbone.on('all', function(s) { console.log('Handling all: ' + s); }); @@ -161,7 +197,7 @@ abstract class DiscobitsContentEtch extends SRenderlet { false );*/ """ - val html = + val html = @@ -178,6 +214,8 @@ abstract class DiscobitsContentEtch extends SRenderlet { + + http://git-wip-us.apache.org/repos/asf/clerezza/blob/8d34e62b/platform.editor/src/main/scala/org/apache/clerezza/platform/editor/renderlets/HtmlInfoDicobitRDFaNaked.scala ---------------------------------------------------------------------- diff --git a/platform.editor/src/main/scala/org/apache/clerezza/platform/editor/renderlets/HtmlInfoDicobitRDFaNaked.scala b/platform.editor/src/main/scala/org/apache/clerezza/platform/editor/renderlets/HtmlInfoDicobitRDFaNaked.scala index 8a297d8..5e64b41 100644 --- a/platform.editor/src/main/scala/org/apache/clerezza/platform/editor/renderlets/HtmlInfoDicobitRDFaNaked.scala +++ b/platform.editor/src/main/scala/org/apache/clerezza/platform/editor/renderlets/HtmlInfoDicobitRDFaNaked.scala @@ -25,7 +25,7 @@ class HtmlInfoDicobitRDFaNaked extends SRenderlet { new XmlResult(arguments) { override def content = {
- {Unparsed(res/DISCOBITS.infoBit*)} + {Unparsed(res/DISCOBITS.infoBit*)}
} }