Skip to main content

逐步建立

想要一次把所有事物建立成功是不太可能的,我們將透過一步一步小型的、容易測試的步驟,來完成建置。

{"BaseFileName": "test.txt", "Size": 11}
  1. 在專用伺服器或虛擬機器中安裝 OxOffice Online,並確定瀏覽器可以正確連接到 OxOffice Online。
    https://<WOPI 客戶端 URL(OxOffice Online)>:<port>/hosting/discovery
  2. 在您的應用程式增加 WOPI REST API 的接口。目前只須在 GET 請求時,回應「Hello World」即可,您可以透過瀏覽器進行測試。必要的話,需要用伺服器 rewrite 功能,將 REST API 導向您設計的接口。此時,測試該接口,應該會得到 Hello World 的回應:

    https://<WOPI 主機 URL>/<...>/wopi/files/<file id>/contents
  3. 實作 CheckFileInfo 接口。確保以下位址:

    https://<WOPI 主機 URL>/<...>/wopi/files/<file id>

    回應 JSON 內容,類似:

    {"BaseFileName": "test.txt", "Size": 11}

     

  4. At您應該可以從步驟 this1,取得 moment,OxOffice youOnline will預先建置的 bediscovery.xml,其中的 ableurlsrc to即為 seeOxOffice aOnline constructed document in Collabora Online: Create a URL by concatenating URL from the discovery XML (see the point 1), and add編輯擋案用的位址,您可以把 WOPISrc=https://<WOPI host主機 URL>/<...>/wopi/files/<file id> at the end, resulting in URL like加在其後,結果如下:

    https://<WOPI client客戶端 URL>:<port>/browser/loleaflet/<hash>/cool.loleaflet.html?WOPISrc=https://<WOPI host主機 URL>/<...>/wopi/files/<file id>

    Create a small接著建立一個名為 test.html file containing:的測試頁,其中包含以下內容:

    1<html><body>
    2        <form action="...URL you constructed...前面所建立的位址" enctype="multipart/form-data" method="post">
    3        <input name="access_token" value="test" type="hidden"/>
    4        <input type="submit" value="Load OxOffice Online"/>
    5        </form>
    6</body></html>
    

    When當您從瀏覽器載入 youtest.html load並點擊 it in the browser and click the Load CollaboraOxOffice Online button,按鈕,將會開啟一份文字文件,內容是步驟 it will open a text document that shows “Hello World” provided by the2 WOPI endpoints.REST IfAPI your所提供的「Hello World」。如果您的 WOPI host主機和 isOxOffice onOnline a位於不同的電腦上,請修改位於 differentOxOffice machineOnline than主機的 Collabora’s, make sure to add that host along with the port in the configuration file coolwsd.xml under /etc/oxool/oxoolwsd.xml,在<storage> → <wopi>下,新增一筆 tag.<host> WOPI 主機的位址及埠號。

  5. From this point, you have the basics working, and you have to extend the到了這裡您已經掌握了基本要領了,然後我們開始擴充 JavaScript pieces:的部份:建立一個包含 Create an iframe that will contain the Collabora Online, and provide that with a real access token. From the CollaboraOxOffice Online point ofiframe,並且提供一個真正有存取權的 view,token。對 theOxOffice accessOnline 而言,這個存取用的 token can be any random text or number that contains just numbers, characters, and underlines.可以是隨機的文字、或是只有數字、字元以及底線所組成。

  6. Update your現在,請更新您的 REST endpointsAPI so that they provide real data instead of a synthesized “接口,讓它能提供真實的檔案資料,以代替「Hello World”World」 and以及步驟 hard-coded3 document所寫死的 length.JSON 回應。這裡,您需要送出真實檔案,並參考 CheckFileInfo 表列屬性,送出相應的 JSON 回應。

  7. Implement the PutFile end point, so that the results of editing can appear in your file storage too. To do this, implement the POST request to

    https://<WOPI host主機 URL>/<...>/wopi/files/<file id>/contents
    
  8. Either implement the PutRelativeFile endpoint, so that the option to Save As appears in the UI, or change CheckFileInfo to return UserCanNotWriteRelative with value true if you don’t want to do that yet.