%dirpath() returns empty string on proxy

0 votes
asked Sep 20, 2019 in Question / help by Erik Bachmann (160 points)

I'm trying to include another file into a puml diagram on Github using

!include %dirpath()/alice-bob.iuml

but %dirpath() seem to return an empty string.

I've made an example using:

http://www.plantuml.com/plantuml/proxy?cache=no&fmt=svg&src=https://raw.githubusercontent.com/ClicketyClickDK/sandbox/master/plantuml/include/main.puml

https://raw.githubusercontent.com/ClicketyClickDK/sandbox/master/plantuml/include/main.puml

contains:

@startuml
title Generated %date() from [%dirpath()]
alice -> bob
note right
    Expected title
    "Generated 2019-09-xx@hh:mm from [https://raw.githubusercontent.com/Clicketyclick/sandboc/include/master/test/main.puml]
end note

!include %dirpath()/alice-bob.iuml
'!include https://raw.githubusercontent.com/ClicketyClickDK/sandbox/master/plantuml/include/alice-bob.iuml

@enduml

and alice-bob.iuml contains:

alice <-- bob: Included

The include using 

%dirpath()

fails while the full URL works fine.

How do I avoid inserting a hard coded url?

1 Answer

0 votes
answered Sep 20, 2019 by plantuml (294,960 points)

Well, maybe there is some confusion here.

dirpath%() return the path of the local file you are working on when running PlantUML locally (that is, from a local file system).
We should probably update the documentation about it.

When you are using PlantUML in cloud/internet context, the underlying library cannot exactly guess who is calling it.
So right now, you have to hardcoded the URL in your diagram.

However, your question makes sense.
I understand that you would like to be able to retrieve "https://raw.githubusercontent.com/ClicketyClickDK/sandbox/master/plantuml/include" somehow.

So we have to think about it, and to see if we could extend the behaviour of dirpath%() in some way.

However, the difficult part is the impact on tools that are linked with the PlantUML core library. This is because it will be the responsability of those tools to push the exact value of this context/dirpath string. So we have to find a clever way to do this transparently.

We'll keep you informed...

commented Sep 20, 2019 by Erik Bachmann (160 points)

Maybe the !includeurl() should be reintroduced for this - another function to get

window.location.href
...