You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am trying to write a plugin implementing a new link:// handler, and I would like it to be relative to the page it appears in (e.g. link://foo/helloworld in page bar would not return the same URL as the same link in page baz). But I cannot achieve to get the current page in the foo_path method. Is this possible?
MWE
File foo.plugin:
[Core]
Name = foo
Module = foo
File foo.py:
#!/usr/bin/env pythonimportosfromnikola.plugin_categoriesimportTaskfromnikolaimportutilsclassFoo(Task):
name="foo"defset_site(self, site):
"""Set Nikola site."""site.register_path_handler('foo', self.foo_path)
returnsuper(Foo, self).set_site(site)
deffoo_path(self, name, lang):
# Here, I would like to get the current page name/path/URL.return ["FOO"]
defgen_tasks(self):
yieldself.group_task()
-- Louis
The text was updated successfully, but these errors were encountered:
Right now, there is no support. I’m not sure if this should be supported, since the existing path handlers are independent of the environment they’re in (except for language). What page-specific thing would be done in your links?
What page-specific thing would be done in your links?
When trying to put data in the same directories as pages (as discussed in #2266), I tried to make a attachment page handler, where link link://attachment/data.tar in page pages/foo.rst would return a link to pages/foo/data.tar.
A less specific answer is: I was trying to make link:// return relative links.
But (again, as discussed in #2266), it seems that I eventually do not need this.
Environment (if reporting a bug)
Python Version: Python 3.6.4
Nikola Version: 7.8.11
Operating System: Debian testing
Description:
I am trying to write a plugin implementing a new
link://
handler, and I would like it to be relative to the page it appears in (e.g.link://foo/helloworld
in pagebar
would not return the same URL as the same link in pagebaz
). But I cannot achieve to get the current page in thefoo_path
method. Is this possible?MWE
File
foo.plugin
:File
foo.py
:-- Louis
The text was updated successfully, but these errors were encountered: