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

Cool, I saw you swing by #libreoffice-dev to give thanks just now :)

  • Like 1

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 blad
      Hi guys!
      I just uploaded a module to explore files based on elFinder. By default it will show the "Files" folder.
      Screenshots:

      Video:
       
      To do:
       More options To fix:
       The function of rotating or scaling an image fails  Image editors V 1.01 (view issue)
      Fixed the bug working with the Multi-Language support ( translation of folders ). Fixed the name of elfinder.en  Github:
      https://github.com/LuisSantiago/ProcessElFinder/
      I hope you like it.
    • By BitPoet
      I'm really in love with FormBuilder, but the one thing missing to match all my end users' expectations were repeatable field groups. Think repeaters, in ProcessWire terms. Our primary application of PW is our corporate intranet, so "lines" of fields are quite common in the forms I build. We have all kinds of request forms where the information for a varying number of colleagues needs to be entered (from meal order to flight booking request) and where it is simply impractical to send a form for each, and I don't want to clutter my forms with multiple instances of fields that may only get used ten percent of the time.
      That's why I started to build FormBuilderMultiplier (link to GitHub).
      What it does:
      Adds an option to make a regular Fieldgroup repeatable Lets you limit the number of instances of a Fieldgroup on the form Adds an "Add row" button the form that adds another instance of the Fieldgroup's fields Adds a counter suffix at the end of every affected field's label Stores the entered values just like regular fields Makes the entered values available in preview and email notifications Supports most text based fields, textareas and selects (really, I haven't had enough time to test all the available choices yet) What it doesn't do (yet):
      Support saving to ProcessWire pages (i.e. real Repeaters) I haven't tested all the validation stuff, Date/Time inputs etc. yet, but since I'm utterly swamped with other stuff at work, I didn't want to wait until I have it polished. Any feedback is welcome. There might also be some issues with different output frameworks that I haven't encountered yet. The forms I work with mostly use UIKit.
      Status:
      Still alpha, so test well before using it in the field.
      Known issues:
      When rows are added, the form's iframe needs to be resized, which isn't completely clean yet.
      How it works:
      The Fieldgroup settings are added through regular hooks, as is the logic that adds the necessary field copies for processing the form and displaying previews.
      "Multiplied" field instances are suffixed with _NUM, where NUM is an incremental integer starting from 1. So if you have add two fields named "surname" and "givenname" to a fieldgroup and check the "multiply" checkbox, the form will initially have "surname_1" and "givenname_1" field (I'm still considering changing that to make the risk to shoot oneself into the foot by having a regular "surname_1" field somewhere else in the form less likely).
      When a "row" is added, the first row is cloned through JS and the counter in the fields' IDs, names and "for" attributes as well as the counter in the label are incremented before appending the copies to the Fieldset container in the form.
      To keep backend and frontend in sync, a hidden field named [name of the fieldset]__multiplier_rows is added to the form. Both the backend and the frontend script use this to store and retrieve the number of "rows".
      ToDo:
      Naturally, add the option to store the data in real repeaters when saving to pages. Do a lot of testing (and likely fixing). Make a few things (like the "Add row" button label etc.) configurable in field(set) context. Add a smooth API to retrieve the multiplied values as WireArrays. The mandatory moving screenshot:

    • By MoritzLost
      Hello there,
      I'm working on a tiny textformatter module that searches the text for titles of other pages on your site and creates hyperlinks to them. I'm not sure if something like this exists already, but I haven't found anything in the module directory, so I wrote my own solution 🙂
      It's not properly tested yet and is still missing some functionality I would like to implement, so at the moment it should be considered in BETA. Features include limiting the pages that will get searched by template, and adding a custom CSS class to the generated hyperlinks. As I'm writing this I noticed that it will probably include unpublished and hidden pages at the moment, so yeah ... it's still in development alright 😅
      You can download the module from Github:
      https://github.com/MoritzLost/TextformatterPageTitleLinks
      There's some more information in the readme as well.
      Anyway, let me know what you think! I'm happy about any feedback, possible improvements or ideas on how to improve the module. Cheers.
    • By adrian
      This module provides a way to rapidly generate Page fields and the required templates and pages for use as a drop down select (or any other Page field type).
      This module will let you create a full page field setup in literally a few seconds 
      To use, run Page Field Select Creator from the Setup Menu
      Enter a Field Title, eg: Room Types Select Options - These will become the child pages that will populate the page field select options. There are two different options.
       
      Option 1. TITLE FIELD ONLY - enter one option per line, eg:
       
      Single
      Double
      Suite
       
       
      Option 2. MULTIPLE FIELDS - the first line is used for the field names and the first field must be 'Title'. Subsequent lines are the values for the fields, eg:
       
      Title, Number of Beds, Number of People, Kitchen Facilities
      Single, 1, 1, Fridge Only
      Double, 2, 2, Fridge Only
      Suite, 3, 6, Full Kitchen
        Choose the parent where the page tree of options will be created, eg a hidden "Options" parent page Select a "Deference in API as" option depending on your needs Choose the input field type Check whether "Allow new pages to be created from field?" should be enabled. As an example, if you entered "Room Types" as the field title, you would end up with all of the following automatically created:
      a fully configured page field called: room_types MULTIPLE FIELDS OPTION - 3 additional fields - number_of_beds, number_of_people, kitchen a parent template called: room_types a child template called: room_types_items (with either just a title field, or with the 3 additional fields as well) a parent page called: Room Types a series of child pages named and titled based on the per line entries in the Select Options textarea The templates are configured such that the "room_types_items" child template can only have the main "room_types" template as a parent, and vice versa.

      Then all you have to do is add the newly created page field to any template you want and you're ready to go!
       
      You can grab it from:
       
      Modules directory: http://modules.processwire.com/modules/process-page-field-select-creator/
      Github: https://github.com/adrianbj/ProcessPageFieldSelectCreator