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

Unable to define the source_url base when the input source is a generated directory #458

Open
AlexITC opened this issue Nov 10, 2020 · 7 comments

Comments

@AlexITC
Copy link

AlexITC commented Nov 10, 2020

I'm using mdoc with paradox, which means that I set the paradox source to be from the mdoc output, specifically Compile / paradox / sourceDirectory := mdocOut.value.

Unfortunately, this means that I have dead-links on every page, because they link to the mdoc output directory instead of the proper source.

This is from the page footers with this content:

 The source code for this page can be found here. 

From my research, this gets rendered from the source_url variable, and I see no way to override this to the proper source, any hints appreciated.

@vincenzobaz
Copy link

I am having the same issue.
The url is accessed in themes/generic/src/main/assets/source.st which is used in themes/generic/src/main/assets/page.st.

I think that source_url is exposed to the template via the PageContents.getSource_url (imposed by PageTemplate.Contents).
getSource_url is based on GithubLink.href which uses GithubResolver.treeUrl defined in terms of GithubResolver.baseUrl that reads the github.base_url property.
Writer.Context is passed to the creation of GithubLink and its properties are used to initialize variables used in PropertyUrl.collect

Initally I thought that maybe this or this ++ could be responsible. If this is the case, both the properties passed to process and those coming from the page contain github.base_url and one is taken in favor of the other (as map keys must be unique).
pageProperties is used to build the Writer.Context which is then used to build a PageContents.

However if in my project sbt console I run show Paradox/paradoxProperties, github.base_url contains the correct address to the folder containing my md files. So a conflict is not the problem.

@AlexITC
Copy link
Author

AlexITC commented Jun 11, 2021

I forget to post that I found a way to solve this, the drawback is that it very simple and link sources from a single branch, it involves overriding the source url template, and a simple js to fix the source url.

src/main/paradox/_template/source.st:

<script type="text/javascript" src="$page.base$js/link_fix.js"></script>

$if(page.source_url)$
<div class="source-github">
The source code for this page can be found <a id="source-link" href="$page.source_url$">here</a>.
</div>
$endif$

<script type="text/javascript">jQuery(function(){sourceUrlFix('$page.source_url$')});</script>

src/main/paradox/_template/js/link_fix.js (this just creates a function to link the correct source:

function sourceUrlFix(sourceUrl) {
    // TODO: Use any branch instead of master
    $("#source-link").attr("href", sourceUrl.replace("tree/master/docs/target/mdoc", "tree/master/docs/src/main/paradox"))
}

@AlexITC AlexITC closed this as completed Jun 11, 2021
@julienrf
Copy link

Thanks for sharing your workaround @AlexITC! However, I think it would be better if we could fix the root cause of the problem instead. I think the issue should be re-opened.

@vincenzobaz
Copy link

I agree wtih @julienrf . I do not like this solution and I think the issue should be still be open.

It is not an easy fix but I think it is very important. Paradox is one of the very few resources allowing to create a site without relying on node, yarn, jekyll or ruby and having a broken link on each page does not look great.

@AlexITC AlexITC reopened this Jun 11, 2021
@AlexITC
Copy link
Author

AlexITC commented Jun 11, 2021

I know it is not an ideal workaround but at least, there is a way.

I'd have preferred to have a plugin option to either disable the generation, or to set the right source url.

@nafg
Copy link

nafg commented Jan 17, 2022

This is pretty important

@nafg
Copy link

nafg commented Jan 17, 2022

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

No branches or pull requests

4 participants