From 0cf521c4065ea852aa0db84352346955edd609dd Mon Sep 17 00:00:00 2001 From: Victor Dubiniuk Date: Fri, 12 Jun 2015 18:25:28 +0300 Subject: [PATCH] Update build script and instructions --- .gitignore | 3 + README.md | 10 +- src/patches/MemberListView.js.patch | 91 --------------- ...ssPath.patch => Patch-EditorSession.patch} | 20 +++- src/patches/Patch-MemberListView.patch | 104 ++++++++++++++++++ src/patches/Patch-Tools.patch | 67 +++++++++++ src/patches/hideCaretAvatar.patch | 13 --- src/patches/ocToolbar.patch | 66 ----------- src/updateWebODF.sh | 98 ++++++++++++----- 9 files changed, 267 insertions(+), 205 deletions(-) create mode 100644 .gitignore delete mode 100644 src/patches/MemberListView.js.patch rename src/patches/{fontsCssPath.patch => Patch-EditorSession.patch} (57%) create mode 100644 src/patches/Patch-MemberListView.patch create mode 100644 src/patches/Patch-Tools.patch delete mode 100644 src/patches/hideCaretAvatar.patch delete mode 100644 src/patches/ocToolbar.patch diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..38f7dfe1 --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +tests/clover.xml +webodf/* +build/* \ No newline at end of file diff --git a/README.md b/README.md index be857e23..c7c345c4 100644 --- a/README.md +++ b/README.md @@ -23,11 +23,16 @@ If you don't want to mess around with dependencies, you need simply install `uno ### WebODF upgrade ### 1. Build WebODF: + + ./src/updateWebODF.sh prepare +or + + git clone https://github.com/kogmbh/WebODF.git webodf mkdir build cd build cmake ../webodf - make webodf-debug.js-target editor-compiled.js-target + make all webodf-debug.js-target build-wodocollabtexteditor 2. Refresh code and create a new branch: @@ -38,7 +43,8 @@ If you don't want to mess around with dependencies, you need simply install `uno 3. Run upgrade script: - ./src/updateWebODF.sh /path/to/WebODF/buildDir + ./src/updateWebODF.sh copy + ./src/updateWebODF.sh patch 4. Resolve confilcts in patches (if any). Commit changes. 5. Update patches in `/path/to/documents/src/patches` according to conflicts. Commit changes. diff --git a/src/patches/MemberListView.js.patch b/src/patches/MemberListView.js.patch deleted file mode 100644 index 96fa346a..00000000 --- a/src/patches/MemberListView.js.patch +++ /dev/null @@ -1,91 +0,0 @@ -diff --git a/js/3rdparty/webodf/editor/MemberListView.js b/js/3rdparty/webodf/editor/MemberListView.js ---- a/js/3rdparty/webodf/editor/MemberListView.js 2014-11-19 19:53:11.134235411 +0300 -+++ b/js/3rdparty/webodf/editor/MemberListView.js 2014-11-19 19:56:27.562381909 +0300 -@@ -69,6 +69,8 @@ - - while (node) { - if (node.memberId === memberId) { -+ node.setAttribute('uid', memberDetails.uid); -+ node.setAttribute('count', 1); - node = node.firstChild; - while (node) { - if (node.localName === "img") { -@@ -76,6 +78,11 @@ - node.src = memberDetails.imageUrl; - // update border color - node.style.borderColor = memberDetails.color; -+ } else if (node.localName === "span" && memberDetails.imageUrl){ -+ try { -+ $(node).avatar(memberDetails.imageUrl, 60); -+ } catch (e){} -+ node.style.borderColor = memberDetails.color; - } else if (node.localName === "div") { - node.setAttribute('fullname', memberDetails.fullName); - } -@@ -95,7 +102,7 @@ - var doc = memberListDiv.ownerDocument, - htmlns = doc.documentElement.namespaceURI, - avatarDiv = doc.createElementNS(htmlns, "div"), -- imageElement = doc.createElement("img"), -+ imageElement = doc.createElement("span"), - fullnameNode = doc.createElement("div"); - - avatarDiv.className = "memberListButton"; -@@ -111,12 +118,15 @@ - //avatar.getCaret().hideHandle(); - }; - avatarDiv.onclick = function () { -- var caret = editorSession.sessionView.getCaret(memberId); -- if (caret) { -- caret.toggleHandleVisibility(); -+ if (memberId === editorSession.sessionController.getInputMemberId()){ -+ documentsMain.onNickChange(memberId, fullnameNode); - } - }; -- memberListDiv.appendChild(avatarDiv); -+ if (memberId === editorSession.sessionController.getInputMemberId()){ -+ memberListDiv.insertBefore(avatarDiv, memberListDiv.firstChild); -+ } else { -+ memberListDiv.appendChild(avatarDiv); -+ } - } - - /** -@@ -127,7 +137,12 @@ - var node = memberListDiv.firstChild; - while (node) { - if (node.memberId === memberId) { -- memberListDiv.removeChild(node); -+ var count = parseInt(node.getAttribute('count')); -+ if (count>1){ -+ node.setAttribute('count', count-1); -+ } else { -+ memberListDiv.removeChild(node); -+ } - return; - } - node = node.nextSibling; -@@ -140,8 +155,21 @@ - */ - function addMember(memberId) { - var member = editorSession.getMember(memberId), -- properties = member.getProperties(); -- createAvatarButton(memberId); -+ properties = member.getProperties(), -+ node = memberListDiv.firstChild, -+ found = false; -+ while (node) { -+ if (node.getAttribute('uid') === properties.uid) { -+ var count = parseInt(node.getAttribute('count')); -+ node.setAttribute('count', count+1); -+ found = true; -+ break; -+ } -+ node = node.nextSibling; -+ } -+ if (!found){ -+ createAvatarButton(memberId); -+ } - updateAvatarButton(memberId, properties); - } - diff --git a/src/patches/fontsCssPath.patch b/src/patches/Patch-EditorSession.patch similarity index 57% rename from src/patches/fontsCssPath.patch rename to src/patches/Patch-EditorSession.patch index 1e8f0bb9..6a97b2af 100644 --- a/src/patches/fontsCssPath.patch +++ b/src/patches/Patch-EditorSession.patch @@ -1,9 +1,18 @@ +From 28f377dc8fd3411ce7fad011140626484e180ac8 Mon Sep 17 00:00:00 2001 +From: Victor Dubiniuk +Date: Wed, 10 Jun 2015 19:29:27 +0300 +Subject: [PATCH] Patch EditorSession manually + +--- + js/3rdparty/webodf/editor/EditorSession.js | 4 +++- + 1 file changed, 3 insertions(+), 1 deletion(-) + diff --git a/js/3rdparty/webodf/editor/EditorSession.js b/js/3rdparty/webodf/editor/EditorSession.js -index dc90ac1..d890a8e 100644 +index f2e91b6..709fd24 100644 --- a/js/3rdparty/webodf/editor/EditorSession.js +++ b/js/3rdparty/webodf/editor/EditorSession.js -@@ -39,10 +39,12 @@ - /*global define, runtime, core, gui, ops, document */ +@@ -25,10 +25,12 @@ + /*global runtime, define, document, core, odf, gui, ops*/ define("webodf/editor/EditorSession", [ - "dojo/text!resources/fonts/fonts.css" @@ -13,6 +22,9 @@ index dc90ac1..d890a8e 100644 + fontsCSS = fontsCSS.replace(/\.\/fonts/g, OC.appswebroots['documents']+'/css/fonts'); + + runtime.loadClass("core.Async"); runtime.loadClass("core.DomUtils"); runtime.loadClass("odf.OdfUtils"); - runtime.loadClass("ops.OdtDocument"); +-- +2.1.4 + diff --git a/src/patches/Patch-MemberListView.patch b/src/patches/Patch-MemberListView.patch new file mode 100644 index 00000000..67ead040 --- /dev/null +++ b/src/patches/Patch-MemberListView.patch @@ -0,0 +1,104 @@ +From c3f8c8d13d4fd0c9c4c1c47a5c53c184ad8e1c25 Mon Sep 17 00:00:00 2001 +From: Victor Dubiniuk +Date: Wed, 10 Jun 2015 19:26:42 +0300 +Subject: [PATCH] Patch MemberListView manually + +--- + js/3rdparty/webodf/editor/MemberListView.js | 44 +++++++++++++++++++++++------ + 1 file changed, 36 insertions(+), 8 deletions(-) + +diff --git a/js/3rdparty/webodf/editor/MemberListView.js b/js/3rdparty/webodf/editor/MemberListView.js +index c188e2a..c5ae12b 100644 +--- a/js/3rdparty/webodf/editor/MemberListView.js ++++ b/js/3rdparty/webodf/editor/MemberListView.js +@@ -55,6 +55,8 @@ define("webodf/editor/MemberListView", + + while (node) { + if (node.memberId === memberId) { ++ node.setAttribute('uid', memberDetails.uid); ++ node.setAttribute('count', 1); + node = node.firstChild; + while (node) { + if (node.localName === "img") { +@@ -62,6 +64,11 @@ define("webodf/editor/MemberListView", + node.src = memberDetails.imageUrl; + // update border color + node.style.borderColor = memberDetails.color; ++ } else if (node.localName === "span" && memberDetails.imageUrl){ ++ try { ++ $(node).avatar(memberDetails.imageUrl, 60); ++ } catch (e){} ++ node.style.borderColor = memberDetails.color; + } else if (node.localName === "div") { + node.setAttribute('fullname', memberDetails.fullName); + } +@@ -81,7 +88,7 @@ define("webodf/editor/MemberListView", + var doc = memberListDiv.ownerDocument, + htmlns = doc.documentElement.namespaceURI, + avatarDiv = doc.createElementNS(htmlns, "div"), +- imageElement = doc.createElement("img"), ++ imageElement = doc.createElement("span"), + fullnameNode = doc.createElement("div"); + + avatarDiv.className = "webodfeditor-memberListButton"; +@@ -91,12 +98,15 @@ define("webodf/editor/MemberListView", + avatarDiv.memberId = memberId; // TODO: namespace? + + avatarDiv.onclick = function () { +- var caret = editorSession.sessionView.getCaret(memberId); +- if (caret) { +- caret.toggleHandleVisibility(); ++ if (memberId === editorSession.sessionController.getInputMemberId()){ ++ documentsMain.onNickChange(memberId, fullnameNode); + } + }; +- memberListDiv.appendChild(avatarDiv); ++ if (memberId === editorSession.sessionController.getInputMemberId()){ ++ memberListDiv.insertBefore(avatarDiv, memberListDiv.firstChild); ++ } else { ++ memberListDiv.appendChild(avatarDiv); ++ } + } + + /** +@@ -107,7 +117,12 @@ define("webodf/editor/MemberListView", + var node = memberListDiv.firstChild; + while (node) { + if (node.memberId === memberId) { +- memberListDiv.removeChild(node); ++ var count = parseInt(node.getAttribute('count')); ++ if (count>1){ ++ node.setAttribute('count', count-1); ++ } else { ++ memberListDiv.removeChild(node); ++ } + return; + } + node = node.nextSibling; +@@ -120,8 +135,21 @@ define("webodf/editor/MemberListView", + */ + function addMember(memberId) { + var member = editorSession.getMember(memberId), +- properties = member.getProperties(); +- createAvatarButton(memberId); ++ properties = member.getProperties(), ++ node = memberListDiv.firstChild, ++ found = false; ++ while (node) { ++ if (node.getAttribute('uid') === properties.uid) { ++ var count = parseInt(node.getAttribute('count')); ++ node.setAttribute('count', count+1); ++ found = true; ++ break; ++ } ++ node = node.nextSibling; ++ } ++ if (!found){ ++ createAvatarButton(memberId); ++ } + updateAvatarButton(memberId, properties); + } + +-- +2.1.4 + diff --git a/src/patches/Patch-Tools.patch b/src/patches/Patch-Tools.patch new file mode 100644 index 00000000..264f2678 --- /dev/null +++ b/src/patches/Patch-Tools.patch @@ -0,0 +1,67 @@ +From 1f9288176b2c31ec9a740284275ff9c1f6dbd8f4 Mon Sep 17 00:00:00 2001 +From: Victor Dubiniuk +Date: Wed, 10 Jun 2015 19:35:23 +0300 +Subject: [PATCH] Patch Tools manually + +--- + js/3rdparty/webodf/editor/Tools.js | 14 ++++++++++---- + 1 file changed, 10 insertions(+), 4 deletions(-) + +diff --git a/js/3rdparty/webodf/editor/Tools.js b/js/3rdparty/webodf/editor/Tools.js +index e5e2e9b..5ddf105 100644 +--- a/js/3rdparty/webodf/editor/Tools.js ++++ b/js/3rdparty/webodf/editor/Tools.js +@@ -39,10 +39,11 @@ define("webodf/editor/Tools", [ + "webodf/editor/widgets/editHyperlinks", + "webodf/editor/widgets/imageInserter", + "webodf/editor/widgets/paragraphStylesDialog", +- "webodf/editor/widgets/zoomSlider", ++ "owncloud/widgets/zoomCombo", ++ "owncloud/widgets/ocToolbar", + "webodf/editor/widgets/aboutDialog", + "webodf/editor/EditorSession"], +- function (ready, MenuItem, DropDownMenu, Button, DropDownButton, Toolbar, ParagraphAlignment, SimpleStyles, UndoRedoMenu, CurrentStyle, AnnotationControl, EditHyperlinks, ImageInserter, ParagraphStylesDialog, ZoomSlider, AboutDialog, EditorSession) { ++ function (ready, MenuItem, DropDownMenu, Button, DropDownButton, Toolbar, ParagraphAlignment, SimpleStyles, UndoRedoMenu, CurrentStyle, AnnotationControl, EditHyperlinks, ImageInserter, ParagraphStylesDialog, ZoomCombo, OcToolbar, AboutDialog, EditorSession) { + "use strict"; + + return function Tools(toolbarElementId, args) { +@@ -60,6 +61,7 @@ define("webodf/editor/Tools", [ + paragraphStylesMenuItem, paragraphStylesDialog, + editorSession, + aboutDialog, ++ ocToolbar, + sessionSubscribers = []; + + function placeAndStartUpWidget(widget) { +@@ -145,6 +147,10 @@ define("webodf/editor/Tools", [ + + // init + ready(function () { ++ ocToolbar = new OcToolbar(function (widget) { ++ widget.startup(); ++ }); ++ + toolbar = new Toolbar({}, toolbarElementId); + + // About +@@ -268,7 +274,7 @@ define("webodf/editor/Tools", [ + createTool(CurrentStyle, args.paragraphStyleSelectingEnabled); + + // Zoom Level Selector +- createTool(ZoomSlider, args.zoomingEnabled); ++ createTool(ZoomCombo, args.zoomingEnabled); + + // hyper links + createTool(EditHyperlinks, args.hyperlinkEditingEnabled); +@@ -309,7 +315,7 @@ define("webodf/editor/Tools", [ + }); + + } +- ++ toolbar.startup(); + setEditorSession(editorSession); + }); + }; +-- +2.1.4 + diff --git a/src/patches/hideCaretAvatar.patch b/src/patches/hideCaretAvatar.patch deleted file mode 100644 index dcf5d7d9..00000000 --- a/src/patches/hideCaretAvatar.patch +++ /dev/null @@ -1,13 +0,0 @@ -diff --git a/js/3rdparty/webodf/editor/Editor.js b/js/3rdparty/webodf/editor/Editor.js -index 644f4b5..50881a2 100644 ---- a/js/3rdparty/webodf/editor/Editor.js -+++ b/js/3rdparty/webodf/editor/Editor.js -@@ -383,7 +383,7 @@ define("webodf/editor/Editor", [ - odfCanvas.addListener("statereadychange", function () { - var viewOptions = { - editInfoMarkersInitiallyVisible: collabEditing, -- caretAvatarsInitiallyVisible: collabEditing, -+ caretAvatarsInitiallyVisible: false, - caretBlinksOnRangeSelect: true - }; - diff --git a/src/patches/ocToolbar.patch b/src/patches/ocToolbar.patch deleted file mode 100644 index 4af082c5..00000000 --- a/src/patches/ocToolbar.patch +++ /dev/null @@ -1,66 +0,0 @@ -diff --git a/js/3rdparty/webodf/editor/Tools.js b/js/3rdparty/webodf/editor/Tools.js -index c0aa4da..602edff 100644 ---- a/js/3rdparty/webodf/editor/Tools.js -+++ b/js/3rdparty/webodf/editor/Tools.js -@@ -52,9 +52,10 @@ define("webodf/editor/Tools", [ - "webodf/editor/widgets/editHyperlinks", - "webodf/editor/widgets/imageInserter", - "webodf/editor/widgets/paragraphStylesDialog", -- "webodf/editor/widgets/zoomSlider", -+ "owncloud/widgets/zoomCombo", -+ "owncloud/widgets/ocToolbar", - "webodf/editor/EditorSession"], -- function (ready, MenuItem, DropDownMenu, Button, DropDownButton, Toolbar, ParagraphAlignment, SimpleStyles, UndoRedoMenu, CurrentStyle, AnnotationControl, EditHyperlinks, ImageInserter, ParagraphStylesDialog, ZoomSlider, EditorSession) { -+ function (ready, MenuItem, DropDownMenu, Button, DropDownButton, Toolbar, ParagraphAlignment, SimpleStyles, UndoRedoMenu, CurrentStyle, AnnotationControl, EditHyperlinks, ImageInserter, ParagraphStylesDialog, ZoomCombo, OcToolbar, EditorSession) { - "use strict"; - - return function Tools(args) { -@@ -67,7 +68,8 @@ define("webodf/editor/Tools", [ - loadButton, saveButton, closeButton, - formatDropDownMenu, formatMenuButton, - paragraphStylesMenuItem, paragraphStylesDialog, simpleStyles, currentStyle, -- zoomSlider, -+ zoomCombo, -+ ocToolbar, - undoRedoMenu, - editorSession, - paragraphAlignment, -@@ -121,6 +123,10 @@ define("webodf/editor/Tools", [ - - // init - ready(function () { -+ ocToolbar = new OcToolbar(function (widget) { -+ widget.startup(); -+ }); -+ - toolbar = new Toolbar({}, "toolbar"); - - // Undo/Redo -@@ -171,12 +177,12 @@ define("webodf/editor/Tools", [ - currentStyle.onToolDone = onToolDone; - - // Zoom Level Selector -- zoomSlider = new ZoomSlider(function (widget) { -+ zoomCombo = new ZoomCombo(function (widget) { - widget.placeAt(toolbar); - widget.startup(); - }); -- sessionSubscribers.push(zoomSlider); -- zoomSlider.onToolDone = onToolDone; -+ sessionSubscribers.push(zoomCombo); -+ zoomCombo.onToolDone = onToolDone; - - // Load - if (loadOdtFile) { -@@ -271,7 +277,7 @@ define("webodf/editor/Tools", [ - }); - closeButton.placeAt(toolbar); - } -- -+ toolbar.startup(); - setEditorSession(editorSession); - }); - }; --- - - diff --git a/src/updateWebODF.sh b/src/updateWebODF.sh index ae4bca53..e5f86e59 100755 --- a/src/updateWebODF.sh +++ b/src/updateWebODF.sh @@ -3,39 +3,79 @@ # # Prepare the webodf build dir by calling: make webodf-debug.js-target editor-compiled.js-target -WEBODF_BUILDDIR=${1%/} - -if [ ! -d "$WEBODF_BUILDDIR" ]; then - echo "Provide the toplevel build directory of WebODF pullbox branch." - exit 1 -fi if [ ! -e "README.md" ]; then - echo "Call me in the toplevel dir of OwnCloud Documents." - exit 1 + echo "Call me in the toplevel dir of OwnCloud Documents." + exit 1 +fi + +if [ $# -lt 1 ]; then + echo "Usage : $0 prepare|copy|patch" + exit 1 fi -# copy files +WEBODF_BUILDDIR='build/' +WEBODF_SRCDIR='webodf/' -# webodf.js -cp "$WEBODF_BUILDDIR"/webodf/webodf.js ./js/3rdparty/webodf -cp "$WEBODF_BUILDDIR"/webodf/webodf-debug.js ./js/3rdparty/webodf -# dojo -cp "$WEBODF_BUILDDIR"/programs/editor/dojo-amalgamation.js ./js/3rdparty/webodf +# create folders +function prepare(){ + if [ ! -d "$WEBODF_SRCDIR" ]; then + git clone git@github.com:kogmbh/WebODF.git "$WEBODF_SRCDIR" + else + pushd "$WEBODF_SRCDIR" + git pull --rebase + popd + fi -# Tools, Editor, EditorSession, MemberListView: -cp "$WEBODF_BUILDDIR"/programs/editor/{Tools,Editor,EditorSession,MemberListView}.js ./js/3rdparty/webodf/editor -cp "$WEBODF_BUILDDIR"/programs/editor/server/pullbox/* ./js/3rdparty/webodf/editor/server/pullbox -R -cp "$WEBODF_BUILDDIR"/programs/editor/server/ServerFactory.js ./js/3rdparty/webodf/editor/server -R -cp "$WEBODF_BUILDDIR"/programs/editor/widgets ./js/3rdparty/webodf/editor -R -cp "$WEBODF_BUILDDIR"/programs/editor/editor.css ./css/3rdparty/webodf + if [ ! -d "$WEBODF_BUILDDIR" ]; then + mkdir "$WEBODF_BUILDDIR" + fi + + pushd "$WEBODF_BUILDDIR" + cmake "../${WEBODF_SRCDIR}" + make all webodf-debug.js-target build-wodocollabtexteditor + popd +} + +# copy sources +function copy_sources(){ + # webodf.js + cp "$WEBODF_BUILDDIR"/webodf/webodf.js ./js/3rdparty/webodf + cp "$WEBODF_BUILDDIR"/webodf/webodf-debug.js ./js/3rdparty/webodf + # dojo + cp "$WEBODF_BUILDDIR"/programs/editor/dojo-amalgamation.js ./js/3rdparty/webodf + + # Tools, Editor, EditorSession, MemberListView: + cp "$WEBODF_BUILDDIR"/programs/editor/{Tools,Editor,EditorSession,MemberListView}.js ./js/3rdparty/webodf/editor + cp "$WEBODF_BUILDDIR"/programs/editor/backend/pullbox/* ./js/3rdparty/webodf/editor/backend/pullbox -R + cp "$WEBODF_BUILDDIR"/programs/editor/backend/ServerFactory.js ./js/3rdparty/webodf/editor/backend -R + cp "$WEBODF_BUILDDIR"/programs/editor/widgets ./js/3rdparty/webodf/editor -R + cp "$WEBODF_BUILDDIR"/wodocollabtexteditor/wodo/{wodotexteditor,wodocollabpane}.css ./css/3rdparty/webodf + + cp "$WEBODF_BUILDDIR"/programs/editor/dojo/* ./js/3rdparty/resources/dojo -R + cp "$WEBODF_BUILDDIR"/programs/editor/dojox/* ./js/3rdparty/resources/dojox -R + cp "$WEBODF_BUILDDIR"/programs/editor/dijit/* ./js/3rdparty/resources/dijit -R + + # files which need to be adapted manually: + # "$WEBODF_BUILDDIR"/programs/editor/dojo-deps/src/app/resources/app.css -> ./css/3rdparty/webodf/dojo-app.css + # dojo-app.css has other paths then upstream, needs to be manually adapted to changes + # also is dojo.css is not imported here, other than in upstream +} # patches against upstream -patch -p1 -i src/patches/fontsCssPath.patch -patch -p1 -i src/patches/hideCaretAvatar.patch -patch -p1 -i src/patches/MemberListView.js.patch -patch -p1 -i src/patches/ocToolbar.patch - -# files which need to be adapted manually: -# "$WEBODF_BUILDDIR"/programs/editor/dojo-deps/src/app/resources/app.css -> ./css/3rdparty/webodf/dojo-app.css -# dojo-app.css has other paths then upstream, needs to be manually adapted to changes -# also is dojo.css is not imported here, other than in upstream +function patch_sources(){ + patch -p1 -i src/patches/Patch-EditorSession.patch + patch -p1 -i src/patches/Patch-MemberListView.patch + patch -p1 -i src/patches/Patch-Tools.patch + + #Just for the record + #patch -p1 -i src/patches/dojoStylesPill.patch +} + +case "$1" in + 'prepare' ) + prepare ;; + 'copy' ) + copy_sources ;; + 'patch' ) + patch_sources ;; +esac