lpaulsen93 / dokuwiki-plugin-odt

Exports a page to the Open Document format used by OpenOffice.org and other word processors
http://www.dokuwiki.org/plugin:odt
13 stars 26 forks source link

Only evaluate the first template definition #282

Closed ternite closed 1 year ago

ternite commented 1 year ago

Uses the usecounter plugin to be able to restrict multiple template definitions to the first one, instead of the last one.

Comes with a boolean configuration option firsttemplatedefinitionwins. If set to true, only the first template command will be evaluated. If set to false, the original behavior will be enacted, i.e. all commands are executing, which results in the last command actually setting the template.

resolves #281

Klap-in commented 1 year ago

For the settings via syntax I did saw two other templates odt_template or css_template settings, but not yet template. Are these also supported?

{{odt>setting:value}}

https://www.dokuwiki.org/plugin:odt#configuration

Further, it seems you are using tabs. Could you please change these in spaces?

I understand this change as not completely backward compatible. So in the changelog we need to pay attention to it.

ternite commented 1 year ago

@Klap-in Thanks for your comment! I wasn't aware of the other configuration options. Looks like I implemented my wiki when those were not existing, yet. I made an update to the branch with the following properties:

Here are the additions that could be made to the dokuwiki page of the odt plugin:

In section "Configuration" - addition of:

| firsttemplatedefinitionwins      | In case of multiple definitions of template, templatepage, css_template, or odt_template, the first will be used. (The value false will apply the last definition, instead.) **Needs the usecounter plugin!**                                                                                              |

In section "Templates support" - addition of a new paragraph right before the next section "PDF conversion":

=== Use the first or last template defition? ===

In a setting with nested pages, e.g. when using the [[plugin:include|include plugin]], the classic behavior of this plugin was to use the very last template definition, when multiples were made. This may be undesired, so there is a configuration setting ''firsttemplatedefinitionwins'' which changes this behavior to evaluating only the very first template definition. This configuration parameter needs the [[plugin:usecounter]] plugin to work! Also, the default value of this config option is ''0'' (''false''), so it does not change the plugin behavior if you upgraded from an earlier version of this plugin.

Best regards Thomas

Klap-in commented 1 year ago

Thanks for improving. I did not realise the dependency of the usecounter plugin, even while you mentioned it already. My feeling is that implementing a counter directly in odt can be quite straight forward, this extra plugin does it nice, but for me it still feels as extra burden for the user to install an extra plugin only for just this setting and it is an extra possibility for confusion. Would it not simplify the usage of the setting to implement the counter directly in odt plugin?

With the new default setting the situation is indeed backward compatible.

Nice that you propose already the documentation updates.

ternite commented 1 year ago

I implemented it this way because I am using another private plugin which needs the same functionality. Also, since you have to actively opt-in the new behavior, you will have to manually set the configuration value and you're reminded therein of this dependency. I don't feel it's much of a burden to install another small plugin if you want/need this functionality.

Also, there is way more code in that plugin than in this branch, here. You need an action handler, and a helper class. To integrate that code into plugin:odt seemed complicating the matter a lot in relativity to the few lines added within this branch. I did not want to blow up the odt plugin even more than it already is, just because of some niche functionality (I seem to be the first person to perceive the resolved problem).

ternite commented 1 year ago

@Klap-in hi, you merged master into this branch - will you be going to merge the branch into master, too?