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

Source Link opened in the same tab #1678

Open
llmwesee opened this issue Jun 11, 2024 · 5 comments
Open

Source Link opened in the same tab #1678

llmwesee opened this issue Jun 11, 2024 · 5 comments

Comments

@llmwesee
Copy link

After got the answer and go to the source and hit the source link then it opened in the same tab instead of new tab. By looking the code, The link should open in the new tab always instead of same tab because we are targeting the blank. Then is it a Bug or something else?

def get_url(x, from_str=False, short_name=False, font_size=2):
    if not from_str:
        source = x.metadata['source']
    else:
        source = x
    if short_name:
        source_name = get_short_name(source)
    else:
        source_name = source
    if source.startswith('http://') or source.startswith('https://'):
        return """<font size="%s"><a href="%s" target="_blank"  rel="noopener noreferrer">%s</a></font>""" % (
            font_size, source, source_name)
    elif '<a href=' not in source:
        return """<font size="%s"><a href="file/%s" target="_blank"  rel="noopener noreferrer">%s</a></font>""" % (
            font_size, source, source_name)
    else:
        # already filled
        return source
@pseudotensor
Copy link
Collaborator

pseudotensor commented Jun 27, 2024

Sorry for delay.

I've never seen it open in same tab. For me a PDF link leads to downloading of the PDF.

For images, it opens in new tab always for me.

Just tried it again, seems all ok.

Can you give a specific document and question where there is an issue?

@llmwesee
Copy link
Author

I'm attaching the both PDF and also the screenshot for the reference.

Screencast.from.28-06-24.09.45.42.AM.IST.webm

2210.14699v2.pdf

@pseudotensor
Copy link
Collaborator

I see. It must be because for me it downloads the PDF in Ubuntu, but for you it is instead opening the PDF up. And you are using some modified code to get the correct page number, which is great.

@llmwesee
Copy link
Author

llmwesee commented Jul 4, 2024

Yep, I want to open the PDF up. And for get the correct page number it doesn't work on cases where PDFs are the scanned copies.

@Sivakajan-tech
Copy link
Contributor

Sivakajan-tech commented Oct 22, 2024

I would like to contribute to this issue.

Windows often requires file paths to be formatted differently. The path used is formatted correctly for Window. Using file:/// for better cross-platform support:

return """<font size="%s"><a href="file:///%s" target="_blank"  rel="noopener noreferrer">%s</a></font>""" % (

Fix#1882
Note the three slashes (file:///) in the link. This makes the link an absolute path which can be more reliable across different platforms.

Ref: https://stackoverflow.com/questions/25354048/difference-between-file-and-file

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

3 participants