本文介绍了如何通过node.js在localhost中使用webodf编辑器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我没有找到任何有关如何运行webodf的教程,我已经阅读了他的api和源代码,我正在了解如何启动它,任何人都可以分享这个想法.

I did not find any tutorials to how to run the webodf i read his apis and source code i am getting how to start it can anybody share the idea.

- 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文件,所以我什么都错过了.

i got this but i am not getting to webodf.js file in it i am missed out anything.

推荐答案

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

I am not not sure what you currently have . But This is how you can configure an application using node.js to serve html files and view/edit odf files.

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

Lets Start with your Node.js Server

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

  1. First Create an index.js file(name it whatever you want)in our application directory,then initialize node application using node init.

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

We will have following folder structure : -

  • ./文档编辑器
  • ../app(我们的html代码和库)
  • ../index.js
  • ../package.json
  • ../和其他一些自动生成的文件.

包括所有必要的模块.我们将使用Express,Multer和 其他实用程序库.

Include all the modules necessary.We are going to use Express,Multer and other util libraries.

var express = require("express"); 
var multer = require('multer');  //for file handling
var util = require('util');
var app = express();   // init express app

  • 配置要根据用户请求向您的服务器提供服务的路由和HTML文件.

  • Configure Routes and Html files to be served on user request to you server.

     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
    

  • 启动服务器

  • Start the Server

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

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

    Note* : Make sure you have node.js envoirnment installed on your system before you start.

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

    Now Lets Look at how we include webodf to our application.

    1. 首先在您的主文件夹(我们将其命名为"app")中创建一个目录,其中所有html,样式和脚本..etc将被存储.

    1. First create a directory in your main folder(we name it 'app'), where all the html,styles and scripts..etc will be stored.

    • /app(我们的html代码和库)
    • ../index.html
    • ../script
      • .. wodotexteditor-0.5.9(文件夹)
      • .. myScript.js
      • /app (our html code and libraries)
      • ../index.html
      • ../script
        • ..wodotexteditor-0.5.9(folder)
        • ..myScript.js

        创建一个index.html文件,并包含webodf和/或编辑器 JavaScript库(包含内部版本中的Webodf ...,因此需要单独下载).

        Create an index.html file and include webodf and/or Editor JavaScript libraries(Contains Webodf included in build... so need to download separately).

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

        Create a container element and local script necessary to run webodf editor.Make sure to add a odt file to directory for you test or you can use the one which comes with wodo-editor.

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

        You can refer this link for creating a local webodf editor using wodo-text-editor and complete the above to steps(2 & 3).

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

        After we have done the above things,we will go into our root directory and run 'node index' command.... and that's it folks.

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

        Just hit localhost:3000/ and you will see a workable webodf editor.

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

        I hope this helps to get started with node.js and webodf. I will soon create and full application with open/edit and save features using webodf and node.js.Thanks :)

        这篇关于如何通过node.js在localhost中使用webodf编辑器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

    09-22 19:01