Item15164: Refactoring PublishPlugin

pencil
Priority: Enhancement
Current State: Being Worked On
Released In: n/a
Target Release: n/a
Applies To: Extension
Component: PublishPlugin
Branches:
Reported By: BramVanOosterhout
Waiting For: BramVanOosterhout
Last Change By: BramVanOosterhout

Initial announcement

I am in the process of refactoring PublishPlugin. I have broken the Publisher code into 5 modules:
  • PublishPlugin
  • PublishPlugin/Publisher (Changed)
  • PublishPlugin/Parameters (New)
  • PublishPlugin/TopicsSelector (New)
  • PublishPlugin/TopicsPublisher (New)
  • PublishPlugin/ResourcesPublisher (New)
  • PublishPlugin/Backend...

I have a few dozen unit tests that run against the old and the refactored version.

Publish plugin has many options, so I am sure that there are combinations for which I don't have tests. There are no unit tests on GitHub. Does anyone have any tests in a drawer somewhere? I'll gladly run them against the new code.

Attach your unit tests to this topic if you have any.

I would gladly hear about corner cases that have tripped up previous contributors to PublishPlugin.

As far as the internals of Publisher go, there is one major change. I have replaced the url parsing mechanism built on the cpan URI module with ordinary regular expressions. Whereas the implemented parser was neat, it did my head in and tripped me up many times when adding additional cases. I realise that this code is central to the functioning of Publishplugin. Does anyone see a major issue in replacing the parser with standard regular expressions? All words of caution are welcome.

-- BramVanOosterhout - 12 Aug 2022

I once had a look at PublishPlugin and decided refactoring would break too much. So I've started working on ExportPlugin at Item14547. See https://github.com/foswiki/ExportPlugin

-- MichaelDaum - 12 Aug 2022

I feel your pain! And looking at the ExportPlugin code I see you solved some problems i have encountered. Nice!!! Does ExportPlugin export attachments? At a glance I don't see the code.

I expect that I can get PublishPlugin to work as it used to. So I will continue. Hopefully all done by Xmas smile

-- BramVanOosterhout - 12 Aug 2022

It does copy any asset that the page links to (see copyAssset()). However as the use case is for rendering static content (html, pdf, excel) it does not crawl all attachments indepedent of their visibility on a page...

-- MichaelDaum - 12 Aug 2022

Ahh, I looked for readAttachment. But you do regular file copy for the assets. That will do it. .

-- BramVanOosterhout - 12 Aug 2022

Changes in the algorithm

Backend::file addResource

I created getResourcePath as a separate routine. That wat the URL for the resource can be rewritten, without copying the resource yet. Processing the topics can then be completely separate from processing the attachments/resources.

This was not useful. (13 Sep 2022). Reverted to original.

-- BramVanOosterhout - 08 Sep 2022

Backend::file addTopic

Add an entry in $this->{last_published}->{$path} for the topic added. This avoids publishing the same topic twice when it is referenced twice.

Deleted (in alreadyPublished):
    return 0 unless ( $this->{params}->{keep} // '' ) eq 'unchanged';
to force checking existence of published topics irrespective of keep parameter.

-- BramVanOosterhout - 08 Sep 2022
 
Topic revision: r8 - 13 Sep 2022, BramVanOosterhout
The copyright of the content on this website is held by the contributing authors, except where stated elsewhere. See Copyright Statement. Creative Commons License    Legal Imprint    Privacy Policy