You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@clerezza.apache.org by re...@apache.org on 2015/04/20 17:59:56 UTC

clerezza git commit: CLEREZZA-829:a very crude way to add new content sections to existing ordered-contents

Repository: clerezza
Updated Branches:
  refs/heads/master dce3718e6 -> c70a78b30


CLEREZZA-829:a very crude way to add new content sections to existing ordered-contents

Project: http://git-wip-us.apache.org/repos/asf/clerezza/repo
Commit: http://git-wip-us.apache.org/repos/asf/clerezza/commit/c70a78b3
Tree: http://git-wip-us.apache.org/repos/asf/clerezza/tree/c70a78b3
Diff: http://git-wip-us.apache.org/repos/asf/clerezza/diff/c70a78b3

Branch: refs/heads/master
Commit: c70a78b3000848f34749495d9bfbc3bd6c9988bc
Parents: dce3718
Author: Reto Gmuer <re...@apache.org>
Authored: Mon Apr 20 15:58:15 2015 +0000
Committer: Reto Gmuer <re...@apache.org>
Committed: Mon Apr 20 15:58:15 2015 +0000

----------------------------------------------------------------------
 .../resources/tools/editor/images/add-icon.png  | Bin 0 -> 8074 bytes
 .../resources/tools/editor/scripts/editor.js    |  67 ++++++++++++++++++-
 2 files changed, 65 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/clerezza/blob/c70a78b3/platform/editor/src/main/resources/META-INF/resources/tools/editor/images/add-icon.png
----------------------------------------------------------------------
diff --git a/platform/editor/src/main/resources/META-INF/resources/tools/editor/images/add-icon.png b/platform/editor/src/main/resources/META-INF/resources/tools/editor/images/add-icon.png
new file mode 100644
index 0000000..2944ff3
Binary files /dev/null and b/platform/editor/src/main/resources/META-INF/resources/tools/editor/images/add-icon.png differ

http://git-wip-us.apache.org/repos/asf/clerezza/blob/c70a78b3/platform/editor/src/main/resources/META-INF/resources/tools/editor/scripts/editor.js
----------------------------------------------------------------------
diff --git a/platform/editor/src/main/resources/META-INF/resources/tools/editor/scripts/editor.js b/platform/editor/src/main/resources/META-INF/resources/tools/editor/scripts/editor.js
index 9a95c36..61ca92f 100644
--- a/platform/editor/src/main/resources/META-INF/resources/tools/editor/scripts/editor.js
+++ b/platform/editor/src/main/resources/META-INF/resources/tools/editor/scripts/editor.js
@@ -137,8 +137,8 @@ $(function () {
                 });
             });
             elem.after(editLink);
-        })
-
+        });
+        
         $article = $('[typeof="disco:XHTMLInfoDiscoBit"]');
         _.forEach($article, function (art) {
             console.log(art);
@@ -151,6 +151,69 @@ $(function () {
             new InfoBitView({model: model, el: art, tagName: art.tagName});
             discoBitsCollection.add(model)
         });
+        
+        $('[typeof="disco:OrderedContent"]').each(function() {
+            var elem = $(this);
+            //add "add element"-link
+            var entryCount = elem.children('[typeof="disco:Entry"]').size();
+            var baseURI = elem.attr('about');
+            if (!baseURI.endsWith('/')) {
+                baseURI += '-el/';
+            }
+            function alreadyExists(uri) {
+                var exists = false;
+                elem.children('[typeof="disco:Entry"]').children('[property="disco:holds"]').each(
+                        function() {
+                            if ($(this).attr("resource") === uri) {
+                                exists = true;
+                            }
+                        });
+                //TODO also check that the URI 404s
+                return exists;
+            } 
+            while (alreadyExists(baseURI+entryCount)) {
+                entryCount ++;
+            }
+            var newURI = baseURI+entryCount;
+            elem.children('[typeof="disco:Entry"]').children('[property="disco:holds"]').each(function() {console.log($(this).attr("resource"))});
+            var addLink = $('<div>New: <select><option value="titled">Titled content</option></select>\n\
+                            At IRI:<input type="text" size="80" value="'+newURI+'"></input>\n\
+                            <a><img src="/tools/editor/images/add-icon.png" alt="add new element"  width="23" height="23" /></a>');
+            addLink.children('a').on('click', function() {
+               if (addLink.children('select').val() === 'titled') { 
+                   var uri = addLink.children('input').val()
+                   var newTitledContent = '<div typeof="disco:Entry" property="disco:contains">\n\
+                    <div style="display: none" property="disco:pos">'+elem.children('[typeof="disco:Entry"]').size()+'</div>\n\
+                    <div resource="'+uri+'" property="disco:holds">\n\
+                     <div typeof="disco:TitledContent" about="'+uri+'">\n\
+                       <span property="disco:contains" typeof="disco:Entry">\n\
+                       <span property="disco:pos" style="display: none">0</span>\n\
+                         <h1 resource="'+uri+'-title" property="disco:holds">\n\
+                           <div typeof="disco:XHTMLInfoDiscoBit" about="'+uri+'-title">\n\
+                           <span property="disco:infoBit" datatype="rdf:XMLLiteral">Title</span>\n\
+                           </div>\n\
+                         </h1>\n\
+                       </span>\n\
+                       <div property="disco:contains" typeof="disco:Entry">\n\
+                         <div property="disco:pos" style="display: none">1</div>\n\
+                         <div property="disco:holds" resource="'+uri+'-content">\n\
+                         <div about="'+uri+'-content" typeof="disco:OrderedContent">\n\
+                           <div property="disco:contains" typeof="disco:Entry">\n\
+                              <div property="disco:pos" style="display: none">0</div>\n\
+                              <div property="disco:holds" resource="'+uri+'-content-el/0">\n\
+                              <div typeof="disco:XHTMLInfoDiscoBit" about="'+uri+'-content-el/0">\n\
+                              <span property="disco:infoBit" datatype="rdf:XMLLiteral">content 1</span>\n\
+                           </div>\n\
+                         </div>\n\
+                       </div>\n\
+                     </div>\n\
+                    </div></div>'
+                    addLink.before(newTitledContent)
+               }  
+               alert('please save and reload'); 
+            });
+            elem.append(addLink);
+        });