I evaluate at the moment grav, whether I can use it for my specific case or not.
My requirement is the following:
I have generated documentation html files with doxygen. These files contain HTML.
Now when a user calls: www.MyDomain.com/doc/api-1-0-0/classes.html
I need to load the file called “classes.html” and embed it’s content into my base website template.
Is this possible with grav, when yes, how?
try to see the “page-inject plugin”, which includes a grav page within another page, I think you can easly modify it to include your html page.
The thing is, I have to load the file content of the html page depending on the provided URL.
E.g.: www.MyDomain.com/doc/api-1-0-0/classes.html I have to load 'doc/api-1-0-0/classes.html’
On this page I have other links, which then have to load on request.
Can I do this with grav?
You can do anything But it might be a little work.
2 options off the top of my head:
Ensure your Grav page structure mimics the HTML structure, and going to any
.html page will automatically just work for a Grav page.
If you have a custom Grav page structure, you would probably need to write a custom plugin with some regex to search replace the URLs into your custom Grav structure.
I don’t know what you mean with page structure of grav.
I think 1) cannot work, because I want to embed the content of the HTML file into my website. e.g.
I think it can be only done via a plugin, but I have to be able to retrieve the URL and depending on the URL I load a file and it render it into the page.
Well i would suggest having those files locally somewhere, rather than remotely… it would be quite slow to get a remote file for every page. Like I said, a plugin might be needed but all it would have to do is load the .html file and inject that in the page. Easy enough in Grav.
Regarding page structure, read the docs on folders for more info.
What do you mean with remote? The files will be of course located on the same server somewhere in the page structure of grav (maybe under 03.doc/version-1-2-3/).
We are speaking of maybe 200 HTML files. These will be placed under one folder, e.g. “version-1-2-3”
Here is an example: http://image.diku.dk/shark/doxygen_pages/html/classes.html
Then speed shouldn’t be a huge issue. I think i’ve provided enough information to get you started. It should be 100% possible. Short of actually doing all the work for you and testing it, the rest is on your shoulders Good luck!
Can you give me a hint, which hook I have to implement and how I get the current URL to load the file content?
I have looked into this plugin: https://github.com/getgrav/grav-plugin-page-inject/blob/develop/page-inject.php
The event you have overwritten:
public function onPageContentRaw(Event $event)
does not contain the current URL.
Reading this thread, it appears that Grav won’t do this “as is” and is going to take a certain level of customization to get it done. Plug-ins are not real hard, if you have some PHP development experience - at least a little. Do you?
My first approach was, using the file-content plugin, and forwarding the URL to the plugin.
However, Grav try’s to load immediately the file, which is of course not an md file…
Here is my folder structure:
How to load the myHTML.html file and embed its raw content in the rendered grav page of ‘default.md’?
So I get my main navigation menu and below the file content of myHTML.html.
The user URL to enter this page would be: www.mySite.com/doc/myHTML.html
Which file does Grav load immediately? For a user going to
www.mySite.com/doc, Grav will use the file
www.mySite.com/doc/default.md to open and render the template named default.html.twig.
when I load this URL:
www.mySite.com/doc/myHTML.html grav will load the error.html.twig
Which is of course not what I want.
If you point your browser to
www.mySite.com/doc, Grav will use the Markdown file it finds there (
default.md) as the page and render it with the template
So the code to include
myHTML.html needs to be in the template. Don’t navigate directly to the HTML file.
but this is the requirement, the URL has to be
Within the loaded html, there are of course more links, which then has to be loaded too.
I don’t know how to do that. I suppose custom code could be written to change the way Grav routes pages. At least the way I understand that Grav routes pages.