knowledgepixels / nanodash

A web client to browse and publish nanopublications.
GNU Affero General Public License v3.0
27 stars 2 forks source link

Make nanopub action buttons modular #39

Closed tkuhn closed 3 years ago

tkuhn commented 3 years ago

The code for the nanopub actions, like "retract...", "comment...", etc., should be made more modular, so new ones can be added in a more flexible way. These different modules could then be activated in a preferences page. This could be the first step towards a full-blown plugin architecture.

vemonet commented 3 years ago

Here is an example of how I added a "Add evidence" button on each nanopublication item: https://github.com/vemonet/nanobench/commit/76bfa0a1d6c77f4cd8486ad3dda81b5d8d2e026b

It only requires to add a small codeblock calling the right template using a URL param

tkuhn commented 3 years ago

OK, this is done with commit 2bcd28c601db9bea028b7a23b38f9a2936154fc9.

Such action links are now created from classes that implement the abstract class NanopubAction: https://github.com/peta-pico/nanobench/tree/master/src/main/java/org/petapico/nanobench/action

In addition to the existing action links, new ones can be added dynamically. For that, such entries can be added to the file $HOME/.nanopub/nanobench-preferences.yml:

nanopubActions:
  - org.petapico.nanobench.action.TestAction

Is this sufficient for your case? We could add this parameter also to other places (e.g. a Java parameter). And of course we should have a Preferences tab in the user interface at some point.