corinthia-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fr...@apache.org
Subject [10/17] incubator-corinthia git commit: Added missing doDummyGet in index.html. And folder refactory
Date Wed, 29 Apr 2015 12:43:51 GMT
Added missing doDummyGet in index.html. And folder refactory


Project: http://git-wip-us.apache.org/repos/asf/incubator-corinthia/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-corinthia/commit/0c004143
Tree: http://git-wip-us.apache.org/repos/asf/incubator-corinthia/tree/0c004143
Diff: http://git-wip-us.apache.org/repos/asf/incubator-corinthia/diff/0c004143

Branch: refs/heads/master
Commit: 0c004143832d468517760d5d388efe86ccaef99d
Parents: 9b84249
Author: franzdecopenhague <franzdecopenhague@outlook.com>
Authored: Thu Mar 26 06:31:24 2015 +0000
Committer: franzdecopenhague <franzdecopenhague@outlook.com>
Committed: Thu Mar 26 06:31:24 2015 +0000

----------------------------------------------------------------------
 consumers/dfwebserver/python/input.docx        | Bin 0 -> 12833 bytes
 consumers/dfwebserver/python/makefile          |  48 +++++++++
 consumers/dfwebserver/python/other.html        |   1 +
 consumers/dfwebserver/python/setup.py          |  64 ++++++++++++
 consumers/dfwebserver/python/src/dfconvert.c   | 108 ++++++++++++++++++++
 consumers/dfwebserver/python/src/dfutil.c      |  64 ++++++++++++
 consumers/dfwebserver/python/test.py           |  42 ++++++++
 consumers/dfwebserver/python/testSubprocess.py |  52 ++++++++++
 consumers/dfwebserver/web/client/index.html    |  10 +-
 9 files changed, 388 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/0c004143/consumers/dfwebserver/python/input.docx
----------------------------------------------------------------------
diff --git a/consumers/dfwebserver/python/input.docx b/consumers/dfwebserver/python/input.docx
new file mode 100644
index 0000000..9de8bc3
Binary files /dev/null and b/consumers/dfwebserver/python/input.docx differ

http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/0c004143/consumers/dfwebserver/python/makefile
----------------------------------------------------------------------
diff --git a/consumers/dfwebserver/python/makefile b/consumers/dfwebserver/python/makefile
new file mode 100644
index 0000000..b3546c3
--- /dev/null
+++ b/consumers/dfwebserver/python/makefile
@@ -0,0 +1,48 @@
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+
+#build
+#  make
+
+#install
+#  sudo python setup.py install
+
+#unistall 
+#  sudo python setup.py install --record files.txt
+#  cat files.txt | sudo xargs rm -rf      
+
+#develoment build
+#  make clean dev
+#  python test.py
+
+LDFLAGS ?= ""
+CFLAGS ?= ""
+
+.PHONY: default build_ext clean
+
+default: build_ext
+
+dev:
+	CFLAGS=$(CFLAGS) LDFLAGS=$(LDFLAGS) python setup.py build_ext --inplace --debug
+
+build_ext:
+	CFLAGS=$(CFLAGS) LDFLAGS=$(LDFLAGS) python setup.py build_ext --debug
+
+clean:
+	- rm -rf build
+	- rm -rf consumers
+	- rm -f output*.html
+	- rm -f output*.docx
+	- rm -f dummy*.docx
+	- find ./ -name '*.so' -delete

http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/0c004143/consumers/dfwebserver/python/other.html
----------------------------------------------------------------------
diff --git a/consumers/dfwebserver/python/other.html b/consumers/dfwebserver/python/other.html
new file mode 100644
index 0000000..14778ef
--- /dev/null
+++ b/consumers/dfwebserver/python/other.html
@@ -0,0 +1 @@
+<begin>text</begin>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/0c004143/consumers/dfwebserver/python/setup.py
----------------------------------------------------------------------
diff --git a/consumers/dfwebserver/python/setup.py b/consumers/dfwebserver/python/setup.py
new file mode 100644
index 0000000..8675b22
--- /dev/null
+++ b/consumers/dfwebserver/python/setup.py
@@ -0,0 +1,64 @@
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+from distutils.core import setup, Extension
+
+# define the extension module
+dfutil_module = Extension('dfutil', 
+    sources=['src/dfutil.c', '../../consumers/dfutil/src/Commands.c'],
+    libraries = ['DocFormats', 'xml2'],
+    extra_compile_args = ['-std=c99'],
+    library_dirs = ['../../build/lib'],
+    include_dirs = [
+        '../../DocFormats/api/headers', 
+        '../../DocFormats/core/src/common',
+        '../../DocFormats/core/src/css', 
+        '../../DocFormats/core/src/html', 
+        '../../DocFormats/core/src/lib', 
+        '../../DocFormats/core/src/names', 
+        '../../DocFormats/core/src/xml', 
+        '../../DocFormats/core/tests/common', 
+        '../../DocFormats/core/tests/html',
+        '../../DocFormats/filters/latex/src',
+        '../../DocFormats/filters/ooxml/src/common', 
+        '../../DocFormats/filters/ooxml/src/word', 
+        '../../DocFormats/filters/ooxml/tests/word',
+        '../../DocFormats/headers',
+    ]
+)
+
+dfconvert_module = Extension('dfconvert', 
+    sources=['src/dfconvert.c'],
+    libraries = ['DocFormats', 'xml2', 'SDL2', 'SDL_image'],
+    extra_compile_args = ['-std=c99'],
+    library_dirs = ['../../build/lib'],
+    include_dirs = [
+        '../../DocFormats/api/headers', 
+        '../../DocFormats/core/src/common',
+        '../../DocFormats/core/src/css', 
+        '../../DocFormats/core/src/html', 
+        '../../DocFormats/core/src/lib', 
+        '../../DocFormats/core/src/names', 
+        '../../DocFormats/core/src/xml', 
+        '../../DocFormats/core/tests/common', 
+        '../../DocFormats/core/tests/html',
+        '../../DocFormats/filters/latex/src',
+        '../../DocFormats/filters/ooxml/src/common', 
+        '../../DocFormats/filters/ooxml/src/word', 
+        '../../DocFormats/filters/ooxml/tests/word',
+        '../../DocFormats/headers',
+    ]
+)
+
+# run the setup
+setup(ext_modules=[dfutil_module, dfconvert_module])  

http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/0c004143/consumers/dfwebserver/python/src/dfconvert.c
----------------------------------------------------------------------
diff --git a/consumers/dfwebserver/python/src/dfconvert.c b/consumers/dfwebserver/python/src/dfconvert.c
new file mode 100644
index 0000000..b284222
--- /dev/null
+++ b/consumers/dfwebserver/python/src/dfconvert.c
@@ -0,0 +1,108 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+#include <Python.h>
+
+typedef struct DFError DFError;
+void DFErrorRelease(DFError *error);
+const char *DFErrorMessage(DFError **error);
+
+// Abstraction level 1
+
+int DFGetFile(const char *concrete, const char *abstract, DFError **error);
+int DFPutFile(const char *concrete, const char *abstract, DFError **error);
+int DFCreateFile(const char *concrete, const char *abstract, DFError **error);
+              
+
+static PyObject* get_func(PyObject* self, PyObject* args)
+{
+    DFError *error = NULL;
+    
+    char * concrete = NULL;
+    char * abstract = NULL;
+    
+    if (!PyArg_ParseTuple(args, "ss", &concrete, &abstract)) {
+        return NULL;
+    }    
+    
+    if (DFGetFile(concrete, abstract, &error)) {
+        Py_RETURN_TRUE;
+    }
+
+    fprintf(stderr,"%s\n",DFErrorMessage(&error));
+    DFErrorRelease(error);
+    Py_RETURN_FALSE;
+}
+
+static PyObject* put_func(PyObject* self, PyObject* args)
+{
+    DFError *error = NULL;
+    
+    char * concrete = NULL;
+    char * abstract = NULL;
+    
+    if (!PyArg_ParseTuple(args, "ss", &concrete, &abstract)) {
+        return NULL;
+    }    
+    
+    if (DFPutFile(concrete, abstract, &error)) {
+        Py_RETURN_TRUE;
+    }
+
+    fprintf(stderr,"%s\n",DFErrorMessage(&error));
+    DFErrorRelease(error);
+    Py_RETURN_FALSE;
+}
+
+static PyObject* create_func(PyObject* self, PyObject* args)
+{
+    DFError *error = NULL;
+    
+    char * concrete = NULL;
+    char * abstract = NULL;
+    
+    if (!PyArg_ParseTuple(args, "ss", &concrete, &abstract)) {
+        return NULL;
+    }    
+    
+    if (DFCreateFile(concrete, abstract, &error)) {
+        Py_RETURN_TRUE;
+    }
+
+    fprintf(stderr,"%s\n",DFErrorMessage(&error));
+    DFErrorRelease(error);
+    Py_RETURN_FALSE;
+}
+
+
+/*  define functions in module */
+static PyMethodDef dfconvertMethods[] =
+{
+     {"get", get_func, METH_VARARGS, "Create a new HTML file from input document"},
+     {"put", put_func, METH_VARARGS, "Update an existing Word document based on a modified
HTML file."},
+     {"create", create_func, METH_VARARGS, "Create a new Word document from a HTML file.
The Word document must not already exist."},
+     {NULL, NULL, 0, NULL}
+};
+
+
+/* module initialization */
+PyMODINIT_FUNC
+
+initdfconvert(void)
+{
+     (void) Py_InitModule("dfconvert", dfconvertMethods);
+}

http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/0c004143/consumers/dfwebserver/python/src/dfutil.c
----------------------------------------------------------------------
diff --git a/consumers/dfwebserver/python/src/dfutil.c b/consumers/dfwebserver/python/src/dfutil.c
new file mode 100644
index 0000000..9e7b689
--- /dev/null
+++ b/consumers/dfwebserver/python/src/dfutil.c
@@ -0,0 +1,64 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+#include <Python.h>
+
+typedef struct DFError DFError;
+void DFErrorRelease(DFError *error);
+const char *DFErrorMessage(DFError **error);
+
+int normalizeFile(const char *filename, DFError **error);
+
+static PyObject* normalize_func(PyObject* self, PyObject* args)
+{
+    DFError *dferr = NULL;
+    
+    char * filename = NULL;
+    
+    if (!PyArg_ParseTuple(args, "s", &filename)) {
+        return NULL;
+        /* if the above function returns -1, an appropriate Python exception will
+        * have been set, and the function simply returns NULL
+        */
+    }
+    
+    if (filename!=NULL) {
+        if (1 == normalizeFile(filename, &dferr)) {
+            Py_RETURN_TRUE;
+        }
+        fprintf(stderr,"%s\n",DFErrorMessage(&dferr));
+        DFErrorRelease(dferr);
+    }
+    
+    Py_RETURN_FALSE;
+}
+
+
+/*  define functions in module */
+static PyMethodDef dfutilMethods[] =
+{
+     {"normalize", normalize_func, METH_VARARGS, "evaluate the sine"},
+     {NULL, NULL, 0, NULL}
+};
+
+/* module initialization */
+PyMODINIT_FUNC
+
+initdfutil(void)
+{
+     (void) Py_InitModule("dfutil", dfutilMethods);
+}

http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/0c004143/consumers/dfwebserver/python/test.py
----------------------------------------------------------------------
diff --git a/consumers/dfwebserver/python/test.py b/consumers/dfwebserver/python/test.py
new file mode 100644
index 0000000..213ee2b
--- /dev/null
+++ b/consumers/dfwebserver/python/test.py
@@ -0,0 +1,42 @@
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+# To test:
+#
+# make clean dev
+# python test.py
+
+import unittest
+
+import dfutil
+import dfconvert
+import shutil
+
+
+class MyTest(unittest.TestCase):
+    def test(self):
+        
+        self.assertTrue(dfutil.normalize("other.html"))
+
+        self.assertTrue(dfconvert.get("input.docx", "output.html"))
+        
+        shutil.copyfile("input.docx", "dummy.docx");
+        
+        self.assertTrue(dfconvert.put("dummy.docx", "output.html"))
+        
+        self.assertTrue(dfconvert.create("output.docx", "output.html"))
+        
+        
+if __name__ == '__main__':
+    unittest.main()        
+

http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/0c004143/consumers/dfwebserver/python/testSubprocess.py
----------------------------------------------------------------------
diff --git a/consumers/dfwebserver/python/testSubprocess.py b/consumers/dfwebserver/python/testSubprocess.py
new file mode 100644
index 0000000..e3bcfa6
--- /dev/null
+++ b/consumers/dfwebserver/python/testSubprocess.py
@@ -0,0 +1,52 @@
+#!/usr/bin/python
+
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+import threading
+import time
+
+import dfconvert
+
+exitFlag = 0
+
+class dfconvertThread (threading.Thread):
+    def __init__(self, threadID, name, input, abstract):
+        threading.Thread.__init__(self)
+        self.threadID = threadID
+        self.name = name
+        self.input = input
+        self.abstract = abstract
+    def run(self):
+        print "Starting " + self.name
+        if exitFlag:
+            thread.exit()
+        status = dfconvert.get(self.input, self.abstract);
+        print "%s: %s status:%s" % (self.name, time.ctime(time.time()), status)
+        print "Exiting " + self.name
+
+# Create new threads
+thread1 = dfconvertThread(1, "Thread-1", "input.docx", "output1.html")
+thread2 = dfconvertThread(2, "Thread-2", "input.docx", "output2.html")
+thread3 = dfconvertThread(3, "Thread-3", "input.docx", "output3.html")
+thread4 = dfconvertThread(4, "Thread-4", "input.docx", "output4.html")
+thread5 = dfconvertThread(5, "Thread-5", "input.docx", "output5.html")
+
+# Start new Threads
+thread1.start()
+thread2.start()
+thread3.start()
+thread4.start()
+thread5.start()
+
+print "Exiting Main Thread"
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/0c004143/consumers/dfwebserver/web/client/index.html
----------------------------------------------------------------------
diff --git a/consumers/dfwebserver/web/client/index.html b/consumers/dfwebserver/web/client/index.html
index 47e5220..4b983f6 100644
--- a/consumers/dfwebserver/web/client/index.html
+++ b/consumers/dfwebserver/web/client/index.html
@@ -18,9 +18,14 @@
         iface.setup(function() {
             console.log("iface setup complete");
         }, 
-        "/consumers/web/client/sample.html", 
+        "", 
         "/Editor/src", "/consumers/web/client");
     }
+    
+    function doDummyGet() {
+        document.getElementById("_content").src = "/consumers/dfwebserver/pool/sample.docx/sample.html";
+        
+    }
 </script>
 <style>
     html,
@@ -35,6 +40,7 @@
         padding-top: 64px;
     }
     div.toolbar {
+        padding: 0;
         border: none;
         position: absolute;
         top: 0px;
@@ -53,6 +59,7 @@
         height: 14px;
         background-color: #ddd;
         xvisibility: hidden;
+        text-align: center;
     }
     
     iframe.contentframe {
@@ -68,6 +75,7 @@
     <div class="toolbar" id="_toolbar">
     </div>
     <div class="toolbar2" id="_toolbar2">
+        <a href="javascript:doDummyGet();">GET</a> 
     </div>
     <div style="border: 1px solid black; display: none">
         Formatting


Mime
View raw message