Skip to content

Commit

Permalink
Fix in-article links
Browse files Browse the repository at this point in the history
These got broken since they were linking to just the article file as if it were still in the same folder. Apparently we did test the image links, but not the article links.
  • Loading branch information
Ghostkeeper committed Feb 22, 2020
1 parent b7efda6 commit 3ef8779
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion CuraSettingsGuide.py
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ def isArticleFile(self, filename: str) -> bool:
:return: True if the file name is the file name of an existing article,
or False if it isn't.
"""
return os.path.exists(os.path.join(os.path.dirname(__file__), "resources", "articles", filename))
return os.path.exists(filename)

@pyqtProperty(QObject, constant=True)
def containerStack(self) -> Optional[ContainerStack]:
Expand Down
4 changes: 4 additions & 0 deletions QtMarkdownRenderer.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ def link(self, link, title, text):
"""
link = mistune.escape_link(link)
link_colour = UM.Qt.Bindings.Theme.Theme.getInstance().getColor("text_link").name()

if "://" not in link and link.endswith(".md"): # Link to a different article.
link = os.path.join(self._images_path, link)

if not title:
return "<a href=\"{link}\"><font color=\"{colour}\">{text}</font></a>".format(colour=link_colour, link=link, text=text)
title = mistune.escape(title, quote=True)
Expand Down
3 changes: 2 additions & 1 deletion resources/qml/ArticleText.qml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ Text {

onLinkActivated: {
if(manager.isArticleFile(link)) {
var article_id = link.replace(/\.[^/.]*$/, "")
var article_id = link.replace(/\.[^/.]*$/, "");
article_id = article_id.replace(/.*\//, "");
manager.setSelectedArticleId(article_id);
} else {
Qt.openUrlExternally(link);
Expand Down

0 comments on commit 3ef8779

Please sign in to comment.