Skip to content

Massively rewrite Micropub server

Jamie Tanna requested to merge refactor/mf2-object into develop

As part of #231 (closed), I wanted to convert the specific implementation for posts' that I currently interact with via my Micropub server, HugoMicroformats2, to a more generic interface.

However, this has ballooned into a 9-week journey of chaos, ending up touching most files in the project, because I relied on its implementation everywhere, and resulted in me deciding that instead of trying to break things down, I'd instead bundle it into one horrible, sad, stressful commit.

As part of this disgustingly large commit I have:

= Migrated to generic Microformats2Json implementation #19 (closed), #231 (closed), #208 (closed)

  • Depending on the Kind, we'll store it in a specific place, based on how the HugoPersistenceService wants it, but in a way that if we moved to a future persistence means, we could migrate to a new PersistenceService (#208 (closed))
  • Serialisation of a post is based on a Kind, therefore the HugoMicroformats2Json is used to wrap this logic, and take a "pure" Microformats2Json and set Hugo-specific fields
  • We have the Microformats2ObjectParser to handle parsing it, and creating the specific Microformats2Json implementation we need
  • This also required implementing post-type-discovery, which is amended from the IndieWeb wiki

= Migrated to use JSR380 validation for the incoming data #232 (closed)

  • This includes the ability for Kind-specific properties to be required/optional in a more maintainable way than was previously done

= Utilise HandlerMethodArgumentResolver to parse the HTTP request, to simplify the controller code, and give us a MicropubRequest

= Added support for JSON create #152 (closed)

As part of the above changes for MicropubRequest, it made it super straightforward to add support for this.

= Added support for form-based delete/undelete #192 (closed)

As part of the above changes for MicropubRequest, it made it super straightforward to add support for this.

= Extracted out decorator configuration to Microformats2ObjectDecoratorFactory

Although it's currently not implemented, it's a step towards making it easier in the future.

= Moved configuration to the config package

= Fixed several IntelliJ warnings

= Extracted photo URL validation be configuration-only, to allow for adding new URLs more easily

= Created TestMicroformats2Object to make an easier implementation for unit tests

= Split MicropubController to domain-specific endpoints #244 (closed)

= Add convenience method for getNickname()

= Made it easier to support new queries

  • Delegating the request to a QueryService makes it more manageable, and it can perform specific processing before actually handling it
  • With the new QueryHandler interface, we can more easily provide new implementations which can handle the query as it needs to
  • New queries can now be @Component'd and will automagically be usable, and appear on q=config

= Add support for content[html]

= Refactored MicropubExceptionHandler to simplify the handling of various internal exceptions that mapped to invalid_request

= Remove unused methods in MicropubPersistenceRepository

= Rename MicropubConfigurationService as it is actually a service

= Create a MicropubRequestService to handle the processing of Micropub requests, instead of having the processing in the controller.

Closes #19 (closed), #152 (closed), #192 (closed), #208 (closed), #231 (closed) #232 (closed), #244 (closed)

Additionally:

Add content-negotiation for Micropub requests

When using a Micropub client in the browser, such as Micropublish, the experience is much better than www-editor, as it handles the response from the server and returns an HTML response, rather than the Location header being hidden in the response from the server.

As per my proposal in https://github.com/indieweb/micropub-extensions/issues/28, we can perform content-negotiation to return HTML when the client is providng an Accept header that contains HTML as one of the expected types.

This requires a slight tweak to our tests for MicropubControllerUnitTest so we can verify that the full URL is sent to the user on Micropub Create.

Closes #260 (closed).

Edited by Jamie Tanna

Merge request reports