Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parametric page name and other changes (v2) #102

Merged
merged 23 commits into from
Nov 16, 2024
Merged

Parametric page name and other changes (v2) #102

merged 23 commits into from
Nov 16, 2024

Conversation

dregad
Copy link
Owner

@dregad dregad commented Sep 14, 2024

This is @splitbrain's original contribution (see PR #72), with merge conflicts resolved and some additional code cleanup and fixes, including French translation.

  • a new @INPUT@ placeholder can be used to reference the given input in namespace setup. For example you could use something like {{NEWPAGE>foo:@INPUT@:start}} to let users create new namespaces inside the foo namespace. This makes Add alternative syntax to add entire namespace #70 obsolete
  • a new ? syntax allows to overwrite config options from the syntax (defaults still come from the config setting) Example: {{NEWPAGE>foo:bar?nohide}} overwrites the default hide setting.
  • support for strftime placeholders in the namespace config. Allows to create a daily page for example. Example: {{NEWPAGE>projekt:notes:%Y-%m-%d}}
  • New option autopage which hides the input field. Together with the new date placeholder this allows to create a daily page on a single button click. Example: {{NEWPAGE>journal:%Y-%m-%d?noautopage}}
  • This PR includes the changes of Always use id of main page in replacements #71

I did that many months ago, and never managed to finalize the testing due to lack of time.

Feedback and testing is welcome.

micgro42 and others added 17 commits April 11, 2017 14:13
* @input@ placeholder can be used to reference the given input (useful
  to create a new namespace) makes #70 obsolete
* new ? syntax to overwrite config options from the syntax (defaults
  still come from the config setting)
* support for strftime placeholders in the namespace config. Allows to
  create a daily page for example
* New option autopage which hides the input field. Together with the new
  date placeholder this allows to create a daily page on a single button
  click
Options are not used after the handler step, so no need to assign them
to the class member.
This should also catch copy'n'paste actions.

https://caniuse.com/#feat=input-event
Fixes #66

UNTESTED adaptation of commit 9785b7d
to the new preg_match()-based parser.
@dregad dregad changed the title Parametric page name and other changes ( Parametric page name and other changes (v2) Sep 14, 2024
Regression introduced by incorrect implementation of newpagevars in
commit 0d90564 when porting #66 - It
should be a string, not an array.
The regex for newpagetemplate parameters parsing that was implemented in
commit 0d90564 included the leading `#`
in the newpagevars parameter, preventing the newpagetemplate plugin from
processing the first parameter as `#@param@` would not match the
expected `@PARAM@`.

Adapting the regex accordingly.
# Conflicts:
#	plugin.info.txt
#	syntax.php
@Whyglobaleyes
Copy link

Hello,

Firstly many thanks to everyone - DW creators & core team as well as this plugin's authors - I'm not a programmer but manage to follow instructions well enough to meet my simple needs. For a few years I've been using add-new-page for every entry I create and love it.

Do I need to do something else to should use the 7id2fib commit mentioned above please. If so then please can someone describe how I apply it please? If not then any other ideas how I can troubleshoot or fix the behaviour please?
thanks in advance

@dregad
Copy link
Owner Author

dregad commented Nov 8, 2024

@Whyglobaleyes

version 2024-09-14. I think that includes the merge above but it still doesn't work

Actually it does not. If it did, this pull request would not be open, it would have a merged status. You can also see that in the network graph, which shows that this PR's branch (pr72) has not been merged into the master branch, the tip of which is release 2024-09-14.

As explained in the PR's description above, the reason I did not merge it, is because I did not have time to properly test this code (as I don't use this functionality myself), and I was hoping to get feedback from the community but that has yet to come

Do I need to do something else to should use the 7id2fib commit mentioned above please

The easiest way is to manually install the code from this PR (download it from https://github.com/dregad/dokuwiki-plugin-addnewpage/archive/refs/heads/pr72.zip) instead of using the Extension Manager.

It would be great if you could perform some tests and confirm if everything is working as expected.

@Whyglobaleyes
Copy link

Whyglobaleyes commented Nov 9, 2024

Dear @dregad, monsieur
I am not worthy; honestly I'm quite excited to have the attention of a proper programmer and especially one of the team that's done so much - thank you for that. It must be obvious that I don't know the first thing about using github so thanks for explaining. I've tried the PR version and I'm not sure where/ how to report back but here goes my description ...

EDIT:
A few moments later: My entire post earlier can be disregarded. because I rebooted the dokuwiki server and all the code is working as expected.
Beautiful.
Thank-you.
bw
ygi


ORIGINAL POST ...

attempt 1a - core functionality

  • page code = {{NEWPAGE}}
  • input on live page = deleteme_2024_11
  • created new page = deleteme_2024_11 = as expected
  • UNEXPECTED BEHAVIOUR: I think this is new since I installed the PR and didn't happen when I used the last version from the plugin manager:
    • PREVIOUSLY the namespace dropdown selection box would actually show only the 3 or 4 namespaces I actually use ::
    • NOW it shows the plugins folder with dozens of subdirectories (perhaps over 100) and doesn't show the final few actual namespaces.

attempt 1b - core functionality

  • page code = {{NEWPAGE>:}}
  • input on live page = deleteme_2024_11
  • created new page = deleteme_2024_11 = as expected
  • AS EXPECTED: specifying the namespace suppresses the namespace dropdown selection box
  • UNEXPECTED BEHAVIOUR: I think this is new since I installed the PR and didn't happen when I used the last version from the plugin manager:
    • I use the addnewpage plugin in the topbar to create new pages VERY quickly.
    • with the PR72 version the namespace dropdown selection box is shown in the topbar and for some reason I can't see the ROOT namespace (which is where I put the majority of my pages)

attempt 2

  • page code = {{NEWPAGE>wiki:}}
  • input on live page = deleteme2024_11
  • created new page = wiki:input:deleteme2024_11
  • expected new page = wiki:deleteme2024_11

attempt 3

  • page code = {{NEWPAGE>wiki:@INPUT@}}
  • input on live page = deleteme2024_11a
  • created new page = wiki:input:deleteme_2024_11a
  • expected new page = wiki:deleteme2024_11a

attempt 4

  • page code = {{NEWPAGE>wiki:@INPUT@_%Y_%m_%d}}
  • input on live page = deleteme2024_11b
  • created new page = wiki:input_2024_11_09:deleteme_2024_11b
  • expected new page = wiki:deleteme2024_11b_2024_11_09

attempt 5

  • page code = {{NEWPAGE>wiki:%Y-%m-%d?autopage}}
  • the "Add Page" button on the live page isn't clickable

These 4 attempts had the same behaviour when I omitted the wiki: namespace definition.

I'm not sure if that's usable feedback. Please let me know if any other information would be better.
many thanks in advance.

@dregad
Copy link
Owner Author

dregad commented Nov 9, 2024

@Whyglobaleyes
I'm glad I could help. So if I understand correctly, everything is working as expected ?

@WetenSchaap @bhartshorn @Chris75forumname @Hirschii @cblte @Fabien4941 @jonathanwgebb @gnoownow10 @stvoigt
You all mentioned interest in this feature / complained that it didn't work at some point (#72, #98), so it would be great if you guys could also test that this PR fixes the problem for you. Thanks in advance for your feedback.

@bhartshorn
Copy link

I installed using the Extension Manager by pointing to the zip file for the PR. I'm working on testing now, but I apparently deleted the original config which wasn't working. Give me a bit to restore the syntax I was using and try it out, I'll report back.

@bhartshorn
Copy link

I did not test extensively, but the strftime and autopage override feature both seem to be functioning. I didn't notice any bugs but will keep an eye out and update you if I notice anything.

@dregad
Copy link
Owner Author

dregad commented Nov 10, 2024

@bhartshorn many thanks for taking the time to test

@Whyglobaleyes
Copy link

@Whyglobaleyes
I'm glad I could help. So if I understand correctly, everything is working as expected ?

yep exactly1
thank you

@WetenSchaap
Copy link

Hi,
Thanks a bunch for working on this!

As other have mentioned, strftime and autopage features work well, I tried a few random variations (also with subnamespaces and stuff), and Dokuwiki did what I expected it to do.

What did not work is combining the parametric names with pagetemplates:

{{NEWPAGE>@NS:@INPUT#pagetemplates:example1,pagetemplates:example2}}

will use the correct templates, but place the new page in ns:input, instead of the current namespace with the given input.

@dregad
Copy link
Owner Author

dregad commented Nov 13, 2024

Thanks for testing @WetenSchaap

What did not work is combining the parametric names with pagetemplates:

{{NEWPAGE>@NS:@INPUT#pagetemplates:example1,pagetemplates:example2}}

will use the correct templates, but place the new page in ns:input, instead of the current namespace with the given input.

Is this the actual, exact markup ? If so can you please try with @NS@:@INPUT@ ?

@WetenSchaap
Copy link

WetenSchaap commented Nov 13, 2024

Oops, yes, made a typo there. Sorry! Don't know why the @ got lost.

With the correct syntax, everything works as expected.

@dregad dregad merged commit 4b4a3e9 into master Nov 16, 2024
@Whyglobaleyes
Copy link

Whyglobaleyes commented Nov 17, 2024

Brilliant, @dregad

Many thanks for finishing and finalising the features. Makes my DW a whole lot more comfortable and I'm sure it'll be enjoyed by many other people to o.

bw
ygi

@dregad
Copy link
Owner Author

dregad commented Nov 20, 2024

@WetenSchaap many thanks for your sponsorship ❤️ ! I must say, that was a very unexpected and pleasant surprise, the first time in so many years of open-source contributions and support that this actually happens. I'll drink a 🍺 to your health !

@Whyglobaleyes thanks for the feedback.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

{{NEWPAGE>foo:@INPUT@:start}} syntax does not work (Jackrum, current versions)
6 participants