【问题标题】:how to use the webodf editor in localhost with node.js如何通过 node.js 在 localhost 中使用 webodf 编辑器
【发布时间】:2015-12-17 06:08:09
【问题描述】:

我没有找到任何关于如何运行 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 webodf


    【解决方案1】:

    我不确定您目前拥有什么。但这是您可以使用 node.js 配置应用程序以提供 html 文件和查看/编辑 odf 文件的方式。

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

    1. 首先在我们的应用程序目录中创建一个 index.js 文件(随便命名),然后使用 node init 初始化节点应用程序。

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

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

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

       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. 首先在您的主文件夹中创建一个目录(我们将其命名为“app”),其中所有 将存储 html、样式和脚本..等。

      • /app(我们的 html 代码和库)
      • ../index.html
      • ../脚本
        • ..wodotexteditor-0.5.9(文件夹)
        • ..myScript.js
      • ../样式
      • ../图像
      • ../还有一些其他文件。
    2. 创建一个 index.html 文件并包含 webodf 和/或 Editor JavaScript 库(包含构建中包含的 Webodf...所以需要单独下载)。

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

      您可以参考this链接使用 wodo-text-editor 创建本地 webodf 编辑器,并完成上述步骤(2 和 3)。

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

      只需点击 localhost:3000/,您就会看到一个可用的 webodf 编辑器。

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-06-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-09-10
      • 2017-02-26
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多