clerezza-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From r...@apache.org
Subject svn commit: r1530427 [3/3] - in /clerezza/trunk/platform.editor: ./ src/main/resources/META-INF/ src/main/resources/META-INF/resources/ src/main/resources/META-INF/resources/tools/ src/main/resources/META-INF/resources/tools/editor/ src/main/resources/...
Date Tue, 08 Oct 2013 21:20:14 GMT
Modified: clerezza/trunk/platform.editor/src/main/scala/org/apache/clerezza/platform/editor/renderlets/TitledContentCreate.scala
URL: http://svn.apache.org/viewvc/clerezza/trunk/platform.editor/src/main/scala/org/apache/clerezza/platform/editor/renderlets/TitledContentCreate.scala?rev=1530427&r1=1530426&r2=1530427&view=diff
==============================================================================
--- clerezza/trunk/platform.editor/src/main/scala/org/apache/clerezza/platform/editor/renderlets/TitledContentCreate.scala
(original)
+++ clerezza/trunk/platform.editor/src/main/scala/org/apache/clerezza/platform/editor/renderlets/TitledContentCreate.scala
Tue Oct  8 21:20:13 2013
@@ -19,16 +19,16 @@ import org.apache.felix.scr.annotations.
 @Service(Array(classOf[TypeRenderlet]))
 class TitledContentCreate extends SRenderlet {
 
-	val getRdfType = DISCOBITS.TitledContent 
+  val getRdfType = DISCOBITS.TitledContent 
     
   override val getMediaType = MediaType.TEXT_HTML_TYPE
 
-	override def getModePattern = "create"
+  override def getModePattern = "create"
 
-	override def renderedPage(arguments: XmlResult.Arguments) = {
-		new XmlResult(arguments) {
-			override def content = {
-              val initScript = """
+  override def renderedPage(arguments: XmlResult.Arguments) = {
+    new XmlResult(arguments) {
+      override def content = {
+        val initScript = """
                         var id_counter = 1;
                         
                         jQuery(document).ready(function() {
@@ -57,42 +57,42 @@ class TitledContentCreate extends SRende
                           saveRemote: {"contentType": "application/ld+json"}
                         });*/
                       });"""
-              <html xmlns:disco="http://discobits.org/ontology#"> 
-{for (part <- res/DISCOBITS.contains;  if ((part/DISCOBITS.pos*) == "0")) yield
-                <head>
-                    <link type="text/css" href="/style/style.css" rel="stylesheet" />
-                    <title>Editing: {part/DISCOBITS.holds/DISCOBITS.infoBit*}</title>
-
-                    <link rel="stylesheet" href="/tools/create/font-awesome/css/font-awesome.css"
/>
-
-                    <link rel="stylesheet" href="/tools/create/themes/create-ui/css/create-ui.css"
/>
-
-                    <link rel="stylesheet" href="/tools/create/themes/midgard-notifications/midgardnotif.css"
/>
-
-                    <style>
-                       body {{
-                          padding-left: 20%;
-                          padding-right: 20%;
-                          padding-top: 90px;
-                          background-color: #eeeeec;
-                      }}
-                    </style>
-                    <script src="/tools/create/almond-0.0.2-alpha-1.js" > </script>
-                    <script src="/tools/create/jquery-amd-1.7.1-alpha-1.js" > </script>
-                    <script src="/tools/create/jquery-ui-amd-1.8.16-alpha-1.js" > </script>
-                    <!-- maybe less broken -->
-                    <script src="https://rdfquery.googlecode.com/files/jquery.rdfquery.rules.min-1.0.js"></script>
-                    <script src="/tools/create/createjs-1.0.0alpha1.js" > </script>
-                    <script>{Unparsed(initScript)}
-                    </script>
-                  </head>
-		}
-	<body>
-		{render(res, "create-naked")}
-	</body>
-</html>
-			}
-		}
-	}
+        <html xmlns:disco="http://discobits.org/ontology#"> 
+          {for (part <- res/DISCOBITS.contains;  if ((part/DISCOBITS.pos*) == "0")) yield
+            <head>
+                <link type="text/css" href="/style/style.css" rel="stylesheet" />
+                <title>Editing: {part/DISCOBITS.holds/DISCOBITS.infoBit*}</title>
+
+                <link rel="stylesheet" href="/tools/create/font-awesome/css/font-awesome.css"
/>
+
+                <link rel="stylesheet" href="/tools/create/themes/create-ui/css/create-ui.css"
/>
+
+                <link rel="stylesheet" href="/tools/create/themes/midgard-notifications/midgardnotif.css"
/>
+
+                <style>
+                  body {{
+                  padding-left: 20%;
+                  padding-right: 20%;
+                  padding-top: 90px;
+                  background-color: #eeeeec;
+                  }}
+                </style>
+                <script src="/tools/create/almond-0.0.2-alpha-1.js" > </script>
+                <script src="/tools/create/jquery-amd-1.7.1-alpha-1.js" > </script>
+                <script src="/tools/create/jquery-ui-amd-1.8.16-alpha-1.js" > </script>
+                <!-- maybe less broken -->
+                <script src="https://rdfquery.googlecode.com/files/jquery.rdfquery.rules.min-1.0.js"></script>
+                <script src="/tools/create/createjs-1.0.0alpha1.js" > </script>
+                <script>{Unparsed(initScript)}
+                </script>
+            </head>
+          }
+          <body>
+            {render(res, "rdfa-naked")}
+          </body>
+        </html>
+      }
+    }
+  }
 
 }
\ No newline at end of file

Copied: clerezza/trunk/platform.editor/src/main/scala/org/apache/clerezza/platform/editor/renderlets/TitledContentEtch.scala
(from r1530046, clerezza/trunk/platform.editor/src/main/scala/org/apache/clerezza/platform/editor/renderlets/TitledContentCreate.scala)
URL: http://svn.apache.org/viewvc/clerezza/trunk/platform.editor/src/main/scala/org/apache/clerezza/platform/editor/renderlets/TitledContentEtch.scala?p2=clerezza/trunk/platform.editor/src/main/scala/org/apache/clerezza/platform/editor/renderlets/TitledContentEtch.scala&p1=clerezza/trunk/platform.editor/src/main/scala/org/apache/clerezza/platform/editor/renderlets/TitledContentCreate.scala&r1=1530046&r2=1530427&rev=1530427&view=diff
==============================================================================
--- clerezza/trunk/platform.editor/src/main/scala/org/apache/clerezza/platform/editor/renderlets/TitledContentCreate.scala
(original)
+++ clerezza/trunk/platform.editor/src/main/scala/org/apache/clerezza/platform/editor/renderlets/TitledContentEtch.scala
Tue Oct  8 21:20:13 2013
@@ -17,82 +17,125 @@ import org.apache.felix.scr.annotations.
  */
 @Component
 @Service(Array(classOf[TypeRenderlet]))
-class TitledContentCreate extends SRenderlet {
+class TitledContentEtch extends SRenderlet {
 
-	val getRdfType = DISCOBITS.TitledContent 
+  val getRdfType = DISCOBITS.TitledContent 
     
   override val getMediaType = MediaType.TEXT_HTML_TYPE
 
-	override def getModePattern = "create"
+  override def getModePattern = "edit"
 
-	override def renderedPage(arguments: XmlResult.Arguments) = {
-		new XmlResult(arguments) {
-			override def content = {
-              val initScript = """
-                        var id_counter = 1;
-                        
-                        jQuery(document).ready(function() {
-                        // Prepare VIE
-                        //global for debuging
-                        v = new VIE();
-                        v.use(new v.RdfaService());
-
-                        // Load Create.js with your VIE instance
-                        jQuery("body").midgardCreate({
-                          vie: v,
-                          url: function() {
-                              return "/tools/editor/create/"; },
-                          stanbolUrl: "/"
+  override def renderedPage(arguments: XmlResult.Arguments) = {
+    new XmlResult(arguments) {
+      override def content = {
+        val initScript = """
+                       var discoBitsCollection = new Backbone.Collection();
+            (function() {
+                
+                function saveAllModified() {
+                    var modifiedModels = discoBitsCollection.filter(function(model) {return
model.hasChanged()})
+                    var modified = new Backbone.Collection(modifiedModels);
+                    alert("would save: " +modifiedModels+" models "+ JSON.stringify(modified.toJSON()))
+                }
+                
+                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"
                         });
-                        Backbone.sync = function(method, model) {
-                          console.log("I've been passed " + method + " with " + JSON.stringify(model));
-                          if(method === 'create'){ model.set('id', id_counter++); }
-                          console.log("method: "+method);
-                          console.log(id_counter);
-                          console.log(this.ajaxSettings.contentType);
-                        };
-                        /*jQuery('body').midgardStorage({
-                          vie: new VIE(),
-                          url: function (item) { return '/some32/url'; }, 
-                          saveRemote: {"contentType": "application/ld+json"}
-                        });*/
-                      });"""
-              <html xmlns:disco="http://discobits.org/ontology#"> 
-{for (part <- res/DISCOBITS.contains;  if ((part/DISCOBITS.pos*) == "0")) yield
-                <head>
-                    <link type="text/css" href="/style/style.css" rel="stylesheet" />
-                    <title>Editing: {part/DISCOBITS.holds/DISCOBITS.infoBit*}</title>
-
-                    <link rel="stylesheet" href="/tools/create/font-awesome/css/font-awesome.css"
/>
-
-                    <link rel="stylesheet" href="/tools/create/themes/create-ui/css/create-ui.css"
/>
-
-                    <link rel="stylesheet" href="/tools/create/themes/midgard-notifications/midgardnotif.css"
/>
-
-                    <style>
-                       body {{
-                          padding-left: 20%;
-                          padding-right: 20%;
-                          padding-top: 90px;
-                          background-color: #eeeeec;
-                      }}
-                    </style>
-                    <script src="/tools/create/almond-0.0.2-alpha-1.js" > </script>
-                    <script src="/tools/create/jquery-amd-1.7.1-alpha-1.js" > </script>
-                    <script src="/tools/create/jquery-ui-amd-1.8.16-alpha-1.js" > </script>
-                    <!-- maybe less broken -->
-                    <script src="https://rdfquery.googlecode.com/files/jquery.rdfquery.rules.min-1.0.js"></script>
-                    <script src="/tools/create/createjs-1.0.0alpha1.js" > </script>
-                    <script>{Unparsed(initScript)}
-                    </script>
-                  </head>
-		}
-	<body>
-		{render(res, "create-naked")}
-	</body>
-</html>
-			}
-		}
-	}
+                    }
+                });
+
+                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)
+                });
+                //var view = new articleView({model: model, el: $article[0], tagName: $article[0].tagName});
+
+            })()
+
+            Backbone.on('all', function(s) {
+                console.log('Handling all: ' + s);
+            });"""
+        <html xmlns:disco="http://discobits.org/ontology#"> 
+          {for (part <- res/DISCOBITS.contains;  if ((part/DISCOBITS.pos*) == "0")) yield
+            <head>
+                <link type="text/css" href="/style/style.css" rel="stylesheet" />
+                <link rel="stylesheet" href="/tools/editor/styles/etch.css" />
+                <title>Editing: {part/DISCOBITS.holds/DISCOBITS.infoBit*}</title>
+                
+            </head>
+          }
+          <body>
+            {render(res, "rdfa-naked")}
+            <script src="/tools/editor/scripts/jquery.min.js"></script>
+            <script src="/tools/editor/scripts/underscore-min.js"></script>
+            <script src="/tools/editor/scripts/backbone-min.js"></script>
+            <script src="/tools/editor/scripts/etch.js"></script>
+            <script src="/tools/editor/scripts/backbone.stickit.js"></script>
+            <script>
+              {Unparsed(initScript)}
+            </script>
+          </body>
+        </html>
+      }
+    }
+  }
 
 }
\ No newline at end of file

Copied: clerezza/trunk/platform.editor/src/main/scala/org/apache/clerezza/platform/editor/renderlets/TitledContentRDFaNaked.scala
(from r1530046, clerezza/trunk/platform.editor/src/main/scala/org/apache/clerezza/platform/editor/renderlets/TitledContentCreateNaked.scala)
URL: http://svn.apache.org/viewvc/clerezza/trunk/platform.editor/src/main/scala/org/apache/clerezza/platform/editor/renderlets/TitledContentRDFaNaked.scala?p2=clerezza/trunk/platform.editor/src/main/scala/org/apache/clerezza/platform/editor/renderlets/TitledContentRDFaNaked.scala&p1=clerezza/trunk/platform.editor/src/main/scala/org/apache/clerezza/platform/editor/renderlets/TitledContentCreateNaked.scala&r1=1530046&r2=1530427&rev=1530427&view=diff
==============================================================================
--- clerezza/trunk/platform.editor/src/main/scala/org/apache/clerezza/platform/editor/renderlets/TitledContentCreateNaked.scala
(original)
+++ clerezza/trunk/platform.editor/src/main/scala/org/apache/clerezza/platform/editor/renderlets/TitledContentRDFaNaked.scala
Tue Oct  8 21:20:13 2013
@@ -12,13 +12,13 @@ import org.apache.felix.scr.annotations.
 
 @Component
 @Service(Array(classOf[TypeRenderlet]))
-class TitledContentCreateNaked extends SRenderlet {
+class TitledContentRDFaNaked extends SRenderlet {
 
 	val getRdfType = DISCOBITS.TitledContent 
     
   override val getMediaType = MediaType.TEXT_HTML_TYPE
 
-	override def getModePattern = "create-naked"
+	override def getModePattern = "rdfa-naked"
 
 	override def renderedPage(arguments: XmlResult.Arguments) = {
 		new XmlResult(arguments) {
@@ -27,12 +27,12 @@ class TitledContentCreateNaked extends S
               {for (part <- res/DISCOBITS.contains;  if ((part/DISCOBITS.pos*) == "0"))

                 yield <span property="disco:holds" typeof="disco:Entry">
                    <span property="disco:pos" style="display: none">0</span>
-                   <h1 resource={part/DISCOBITS.holds*} property="disco:holds">{render(part/DISCOBITS.holds,
"create-naked")}</h1>
+                   <h1 resource={part/DISCOBITS.holds*} property="disco:holds">{render(part/DISCOBITS.holds,
"rdfa-naked")}</h1>
                   </span>}
               {for (part <- res/DISCOBITS.contains;  if ((part/DISCOBITS.pos*) == "1"))

                 yield <div property="disco:contains" typeof="disco:Entry">
                        <div property="disco:pos" style="display: none">{part/DISCOBITS.pos*}</div>
-                       <div property="disco:holds" resource={part/DISCOBITS.holds*}>{render(part/DISCOBITS.holds,
"create-naked")}</div>
+                       <div property="disco:holds" resource={part/DISCOBITS.holds*}>{render(part/DISCOBITS.holds,
"rdfa-naked")}</div>
                     </div>}
               </div>
 			}



Mime
View raw message