如何使用node.js在localhost中使用webodf编辑器

我没有find任何教程如何运行webodf我读他的API和源代码,我得到如何启动它可以有人分享这个想法。

- WebODF version 0.5.10-8-gf5949f3 -- Found Java: /usr/bin/java (found version "1.7.0.91") -- external downloads will be stored/expected in: /home/peoplelink/build/downloads -- Installed Node.js found: /usr/bin/nodejs - 0.10.25 -- good Node.js found: 0.10.25 (0.10.5 required.) -- npm found: /usr/bin/npm -- Android was not found: APK will not be built. JS file dependencies were updated. -- Configuring done -- Generating done -- Build files have been written to: 

我得到了这个,但我没有得到它的webodf.js文件,我错过了任何东西。

我不知道你现在有什么。 但是,您可以使用node.js来configuration应用程序来提供html文件和查看/编辑odf文件。

让我们从你的Node.js服务器开始

  1. 首先在应用程序目录中创build一个index.js文件(将其命名),然后使用node init初始化节点应用程序。

    我们将有以下文件夹结构:

    • ./文档编辑器
    • ../app(我们的html代码和库)
    • ../index.js
    • ../package.json
    • ../和其他一些自动生成的文件。
  2. 包括所有必要的模块。我们将使用Express,Multer和其他util函数库。

     var express = require("express"); var multer = require('multer'); //for file handling var util = require('util'); var app = express(); // init express app 
  3. 将路由和Html文件configuration为根据用户请求提供给您的服务器。

      app.use(express.static('app')); // use this as resource directory //APP ROUTING URL => FUNCTIONS app.get('/', function (req, res) { res.sendFile(__dirname + "/app/index.html"); }); // this means when we get a request on 'myAppContext/' url provide index.html 
  4. 启动服务器

      //START THE SERVER app.listen(3000, function () { console.log("Listening on port 3000"); }); 

注意*:在开始之前,请确保已在系统上安装了node.js环境。

现在让我们看看我们如何将webodf包含到我们的应用程序中。

  1. 首先在主文件夹中创build一个目录(我们将其命名为'app'),其中将存储所有html,样式和脚本..等等。

    • / app(我们的html代码和库)
    • ../index.html
    • ../脚本
      • ..wodotexteditor-0.5.9(文件夹)
      • ..myScript.js
    • ../styles
    • ../图片
    • ../和其他一些文件。
  2. 创build一个index.html文件,并包含webodf和/或编辑器 JavaScript库(包含构build中包含的Webodf …因此需要单独下载)。

  3. 创build运行webodf编辑器所需的容器元素和本地脚本。确保为目录添加一个odt文件以供testing,或者您可以使用wodo-editor附带的文件。

    你可以参考这个链接创build一个本地的webodf编辑器,使用wodo-text-editor并完成上面的步骤(2&3)。

  4. 完成上述操作之后,我们将进入我们的根目录并运行'node index'命令….这就是我们的伙计。

    只要打localhost:3000 /,你会看到一个可行的webodf编辑器。

我希望这有助于开始使用node.js和webodf。 我将很快创build和完整的应用程序打开/编辑和使用webodf和node.js保存function。 谢谢 :)