BitPoet

LoolEditor: LibreOffice / Collabora inline editing for office documents

Recommended Posts

As threatened in the Pub sub forum in the "What are you currently building?" thread, I've toyed around with Collabora CODE and built file editing capabilities for office documents (Libre-/OpenOffice formats and MS Office as well as a few really old file types) into a PW module.

If you are running OwnCloud or NextCloud, you'll perhaps be familiar with the Collabora app for this purpose.

LoolEditor

Edit office files directly in ProcessWire

Edit your docx, odt, pptx, xlsx or whatever office files you have stored in your file fields directly from ProcessWire's page editor. Upload, click the edit icon, make your changes and save. Can be enabled per field, even in template context.

Currently supports opening and saving of office documents. Locking functionality is in development.

See the README on GitHub for installation instructions. You should be reasonably experienced with configuring HTTPS and running docker images to get things set up quickly.

Pull requests are welcome!

Here is a short demonstration:

LoolEditorScreenrecording2.thumb.gif.c40d779f5b31421d38dd08f1fcda12ca.gif

  • Like 17
  • Thanks 2

Share this post


Link to post
Share on other sites

That kind of inline editing has been on my radar for ages. Until now, all solutions were either incredibly complicated or died before reaching maturity (e.g. WebODF). CODE is going to be the final piece in so many puzzles :-)

  • Like 2

Share this post


Link to post
Share on other sites

Update 11/4/2018:

  • Locking is implemented (though I haven't seen any hints that CODE uses it). Probably needs some serious testing.
  • Editing has now to be enabled on a per-field basis (Details tab in file field configuration). Template context is supported.
  • Added more inline comments to the code and did some cleanup.
  • Like 3

Share this post


Link to post
Share on other sites

Update:

LoolEditor now uses its own simple modal without a title bar since the editor's close button also closes the modal. Things feel a lot smoother now. :)

I think PW is currently the only CMS that integrates LibreOffice for free ;)

  • Like 7

Share this post


Link to post
Share on other sites

That also means I don't need to install LibreOffice but use it within PW on localhost? Cool! ūüėÄ

  • Like 1

Share this post


Link to post
Share on other sites
1 hour ago, BitPoet said:

I think PW is currently the only CMS that integrates LibreOffice for free ;)

Whether it's currently the only one or not, that would deserve an online article and be good advertising for ProcessWire.

As ProcessWire forum topics/posts play well with Google, modifying the topic's title would perhaps be enough or a good start.

  • Like 3

Share this post


Link to post
Share on other sites
5 minutes ago, Christophe said:

Whether it's currently the only one or not, that would deserve an online article and be good advertising for ProcessWire.

That's what I'm thinking too. I'd like to add a few neat things though before I actively go for more spotlight on it on the web. Auto save is a neat feature but probably not wanted in all scenarios, so I want to make it optional, and another feature I definitely want to get "wired" :) in is lool's revision history. Currently, it's far too easy to overwrite a perfectly fine document with no way back.

  • Like 6

Share this post


Link to post
Share on other sites

This is probably one of the most amazing PW modules I've ever seen.

I have pondered about a way to implement a feature where you have a table that automatically calculates totals. And then also: if you have several such "sub-tables", to generate a grand-total table from the "sub-tables". I thought about using JS to do this on the fly, or with hooks (checking td/th CSS classes and :nth-child selectors), or using Google Spreadsheet's API... maybe using your module would solve all this.

What's a good starting point for getting my feet wet with Docker?

Share this post


Link to post
Share on other sites
On 7/28/2018 at 12:11 PM, dragan said:

What's a good starting point for getting my feet wet with Docker?

Somehow your reply slipped by me. In case it's not too late: docker really is fairly simple if you have a reasonably current platform. I have it running on Ubuntu 16 inside a VirtualBox VM and on a recently installed Ubuntu 18.04 server. In both cases, it's little more than running "apt-get install docker".

To get Collabora CODE installed and running is quite smooth too, though you have to look out for one or two pitfalls. The first step is always running "docker pull collabora/code". This command should get things up and running on the CODE side:

server_name=my.host.name docker run -t -d -p 127.0.0.1:9980:9980 -e "domain=my\\.host\\.name" --restart always --cap-add MKNOD --add-host="my.host.name:my.hosts.ip" collabora/code

Of course you have to replace my.host.name with your official hostname (same for my\\.host\\.name) and insert your real IP instead of my.hosts.ip. For the latter, use the internal IP if your server is behind a NAT. Any environment settings ("-e" arguments) are usually documented in the docs for the individual docker image.

Docker will take care of restarting your container when the docker service itself is spun up.

You can see your running docker containers by typing "docker ps". The output will end with some fancy name (like "lucid_pike") here:

CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS                      NAMES
1e5ed6b3922c        collabora/code      "/bin/sh -c 'bash st…"   18 hours ago        Up 18 hours         127.0.0.1:9980->9980/tcp   lucid_pike

This name is used to point other docker commands to the instance. You can e.g. view its logs with "docker logs lucid_pike".

Share this post


Link to post
Share on other sites

Update:

I finally found a little time to work on the module. The WOPI endpoint (the "server" script that LibreOffice Online talks to) is now created by the installer.

Also, there was a bug when PW was installed in a subdirectory, which has been fixed.

The next thing I'm going to work on is revision history. This is quite underdocumented territory, so hold your fingers crossed ūüėČ

  • Like 1

Share this post


Link to post
Share on other sites

And here's another update:

I worked on history support. Now each time a document is saved, the "old" version is saved away (under site/assets/cache/.loolversions/$pageid/ with a unique hash as a name) and an entry is added into the versioning table (lool_versions). These versions can already be listed in the UI (File -> Version history opens a sidebar at the right).

Also, the UI language for the editor can now be set in PW's profile settings.

If you feel daring, you can grab the latest dev branch and take it for a test drive.

  • Like 1

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By Anssi
      A simple module to enable easy navigation between the public and the admin side of the site. After installation a green bar will appear to the upper side of the screen, containing a few navigation elements and displaying the PW version number.
      Heavily inspired by @apeisa's great AdminBar (Thanks!). I needed a bit simpler tool for my projects and as a result, this was made. Available on GitHub .

    • By Sebi
      I've created a small module which lets you define a timestamp after which a page should be accessible. In addition you can define a timestamp when the release should end and the page should not be accessable any more.
      Github: https://github.com/Sebiworld/PageAccessReleasetime
      Usage
      PageAccessReleasetime can be installed like every other module in ProcessWire. Check the following guide for detailed information: How-To Install or Uninstall Modules
      After that, you will find checkboxes for activating the releasetime-fields at the settings-tab of each page. You don't need to add the fields to your templates manually.
      Check e.g. the checkbox "Activate Releasetime from?" and fill in a date in the future. The page will not be accessable for your users until the given date is reached.
      If you have $config->pagefileSecure = true, the module will protect files of unreleased pages as well.
      How it works
      This module hooks into Page::viewable to prevent users to access unreleased pages:
      public function hookPageViewable($event) { $page = $event->object; $viewable = $event->return; if($viewable){ // If the page would be viewable, additionally check Releasetime and User-Permission $viewable = $this->canUserSee($page); } $event->return = $viewable; } To prevent access to the files of unreleased pages, we hook into Page::isPublic and ProcessPageView::sendFile.
      public function hookPageIsPublic($e) { $page = $e->object; if($e->return && $this->isReleaseTimeSet($page)) { $e->return = false; } } The site/assets/files/ directory of pages, which isPublic() returns false, will get a '-' as prefix. This indicates ProcessWire (with activated $config->pagefileSecure) to check the file's permissions via PHP before delivering it to the client.
      The check wether a not-public file should be accessable happens in ProcessPageView::sendFile. We throw an 404 Exception if the current user must not see the file.
      public function hookProcessPageViewSendFile($e) { $page = $e->arguments[0]; if(!$this->canUserSee($page)) { throw new Wire404Exception('File not found'); } } Additionally we hook into ProcessPageEdit::buildForm to add the PageAccessReleasetime fields to each page and move them to the settings tab.
      Limitations
      In the current version, releasetime-protected pages will appear in wire('pages')->find() queries. If you want to display a list of pages, where pages could be releasetime-protected, you should double-check with $page->viewable() wether the page can be accessed. $page->viewable() returns false, if the page is not released yet.
      If you have an idea how unreleased pages can be filtered out of ProcessWire selector queries, feel free to write an issue, comment or make a pull request!
    • By David Karich
      Thanks to the great Pro module "RepeaterMatrix" I have the possibility to create complex repeater items. With it I have created a quite powerful page builder. Many different content modules, with many more possible design options. The RepeaterMatrix module supports the cloning of items, but only within the same page. Now I often have the case that very design-intensive pages and items are created. If you want to use this module on a different page (e.g. in the same design), you have to rebuild each item manually every time.
      With this proof of concept I have created a module which adds the feature to copy a repeater item to the clipboard so that you can paste this item to another page with the same repeater field. The module has been developed very rudimentarily so far. It is currently not possible to copy nested items. There is also no check of Min/Max. You can also only copy items that have the same field on different pages. And surely you can solve all this more elegantly with AJAX. But personally I lack the deeper understanding of the repeaters. Also missing on the Javascript side are event triggers for the repeaters, which would make it easier. Like e.g. RepeaterItemInitReady or similar.
      it would be great if @ryan would implement this functionality in the core of RepeaterMatrix. I think he has better ways to implement this. Or what do you think, Ryan?
      Everybody is welcome to work on this module and improve it, if it should not be integrated into the matrix core. Therefore I put it for testing and as download on GitHub: https://github.com/FlipZoomMedia/InputfieldRepeaterMatrixDublicate
      You can best see the functionality in the screencast: 
       
    • By anderson
      Hi,
      Please take a look at this:
      https://templatemag.com/demo/Good/
      The upper nav bar, including dropdowns like "pages" and "portfolios", what do you call this whole thing? At first I guess it's called "dropdown nav bar", but seems not.
      AND of course, what's the simplest way/module to achieve this in PW?
      Thanks in advance.
    • By Sebi2020
      Hey, I'm new and I created a simple module for tagging pages because I didn't found a module for it (sadly this is not a core feature). This module is licensed under the GPL3 and cames with absolutly no warranty at all. You should test the module before using it in production environments. Currently it's an alpha release. if you like the module or have ideas for improvements feel free to post a comment. Currently this fieldtype is only compatible with the Inputfield I've created to because I haven't found  an Inputfield yet, that returns arrays from a single html input.
      Greetings Sebi2020
      FieldtypeTags.zip.asc
      InputfieldTagify.zip
      InputfieldTagify.zip.asc
      FieldtypeTags.zip