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
feat: canonically provide $ACT to javascript #2190
Conversation
It would be helpful if there were a reliable way to determine the current mode in javascript, for example if we only want to execute some javascript in `show` or `preview` modes. This writes the final mode to the JSINFO object right before it is written out as header, so we can hopefully capture the actual mode without an plugin changing it later on.
I'm not sure that setting the constants in template.php is the best place. However if we set them in doku.php, we have to duplicate it in lib/exe/mediamanager.php and lib/exe/detail.php, which is not ideal as well.
I have now added Thoughts? |
The shortcuts UHN and UHC are existing ones? I would prefer names that are more self-explaining... edit: better example: |
variable For including the JSINFO in the head as In Why do you consider moving it from |
This should make their purpose more obvious.
I renamed the fields. I don't want to move the place where the javascript variable |
json_encode is available natively since PHP 5.2
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
except for location/naming this looks fine to me
inc/template.php
Outdated
@@ -352,6 +351,20 @@ function tpl_metaheaders($alt = true) { | |||
return true; | |||
} | |||
|
|||
function _tpl_ensureJSINFO() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure if this should be in inc/template.php
and I'm also not so keen about the name. Maybe initJSInfo
or upgradeJSInfo
?
This is a more consistent place relative to pageinfo()
DOKU_UHC is still in use in dokuwiki js: https://github.com/splitbrain/dokuwiki/blob/65a6bb072adbc4fdbfd45391b93c089e18c997ac/lib/scripts/linkwiz.js#L230 |
It would be helpful if there were a reliable way to determine the current mode in javascript, for example, if we only want to execute some javascript in
show
orpreview
modes. This writes the final mode to the$JSINFO
object right before it is written out as a header, so we can hopefully capture the actual mode without a plugin changing it later on.To Do/Discuss
lib/exe/detail.php
as well. Which keys should be included?lib/exe/js.php
that might be suitable to be included inJSINFO
(see below). Which one should we include inJSINFO
and can we somehow show a deprecation notice if the old variables are used?https://github.com/splitbrain/dokuwiki/blob/479b8450994e5a47eff744c623b3ae14afcee19c/lib/exe/js.php#L94-L103