Adding custom modules to ONLYOFFICE Workspace

Introduction

If you want to create your own modules for ONLYOFFICE and add them to ONLYOFFICE Workspace, now you can easily do that. Sample project is available here: https://github.com/ONLYOFFICE/CommunityServer/tree/master/web/studio/ASC.Web.Studio/Products/Sample

You can modify this sample or create a new custom module on its base. Make sure that all necessary components are available in the specified folders and certain code lines are added to the specified files as it is described below.

How it works

  1. Get ONLYOFFICE Community Server from https://github.com/ONLYOFFICE/CommunityServer
  2. The Sample project is available in the Products folder here:

    https://github.com/ONLYOFFICE/CommunityServer/tree/master/web/studio/ASC.Web.Studio/Products

  3. The ASC.Api.Sample is available in the ASC.Api folder here:

    https://github.com/ONLYOFFICE/CommunityServer/tree/master/module/ASC.Api

  4. The following code lines are added to the https://github.com/ONLYOFFICE/CommunityServer/blob/master/build/msbuild/build.proj file:
    <!-- Sample --><ProjectToBuild Include="$(ASCDir)web\studio\ASC.Web.Studio\Products\Sample\ASC.Web.Sample.csproj"/>

    and

    <ProjectToBuild Include="$(ASCDir)module\ASC.Api\ASC.Api.Sample\ASC.Api.Sample.csproj"/>

    You can also see other existing projects to find out where these lines should be added.

    Please note! The order you type in the lines is very important.
  5. The ASC.Api.Sample.SampleApi is added to the web\studio\ASC.Web.Studio\web.autofac.config file like this:
    <componenttype="ASC.Api.Sample.SampleApi, ASC.Api.Sample"service="ASC.Api.Interfaces.IApiEntryPoint, ASC.Api"name="sample"/>
  6. The Build.bat file can be run here:

    https://github.com/ONLYOFFICE/CommunityServer/blob/master/build/Build.bat

How to create your own module for ONLYOFFICE

  1. Create an ASP.NET Web Application (ASC.Web.Sample) project and put it to the ...web\studio\ASC.Web.Studio\Products\Sample folder.
    IMPORTANT!!! The output dll file name must be "ASC.Web.*.dll".
  2. Connect the required references from ...\web\studio\ASC.Web.Studio\bin\:
    ASC.Common.dll
    ASC.Core.Common.dll
    ASC.Data.Storage.dll
    ASC.Web.Core.dll
    ASC.Web.Studio.dll
  3. Implement the IProduct interface in the ProductEntryPoint.cs file.
    IMPORTANT!!! The ProductID must be unique Guid (in VS2012 it is generated as TOOLS -> GUID -> New GUID)
  4. Add the following lines to the AssemblyInfo.cs file:
    [assembly: Product(typeof(ASC.Web.Sample.Configuration.ProductEntryPoint))]
  5. Inherit the Master from web\studio\ASC.Web.Studio\Masters\BaseTemplate.master
  6. Set the output path in the project properties like this:
    <OutputPath>..\..\bin\</OutputPath>

    so that the builds were created at the web\studio\ASC.Web.Studio\bin folder.

  7. The project can be built manually or using the builder. For the latter add the following lines to the build\msbuild\build.proj file:
    <ProjectToBuild Include="$(ASCDir)web\studio\ASC.Web.Studio\Products\Sample\ASC.Web.Sample.csproj"/>

    and run the build\Build.bat file.

  8. After the build, run the website at the localhost:port address, go to the "Modules & Tools" Settings page (http://localhost:port/management.aspx?type=2) and enable the new Sample module. It will be available in the portal header drop-down menu afterwards or using the direct link: http://localhost:port/products/sample/default.aspx

Now you can create API for your own module following these instructions.

Host ONLYOFFICE Workspace on your own server

Article with the tag:
Browse all tags