-
Notifications
You must be signed in to change notification settings - Fork 72
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
Add external link icon (#136) #189
Conversation
About the FAIR pledge, yes that's a problem; not sure what the solution here is. About the Feedback on design: the external link icon should be of grey color (for de-emphasiz) and not of blue ($theme). Is there anyway we can generalize this to also implement (clickable) header anchors? eg: https://markkarpov.com/tutorial/megaparsec.html#controlling-backtracking-with-try It would need backend support, but assuming it exists ... |
Ok. If you want it grey, then we do not need all this mask trickery and we can just use an image with a fixed color.
I don't think CSS can be used for this. Without backend support one could add some JS that adds an anchor after each header once the page is loaded, but I wouldn't call this a pretty solution. However, if the following TODO in
I think that's a good idea. I know some Haskell, so I could help with this, but at the moment I don't have much free time. Where (in which modules) should this be implemented? I'm not familiar with the structure of emanote yet. |
bcd6ee7
to
4ca9a92
Compare
How about this?
Fixed this with JS that disables the icon if the
What do you think about also having a separate CSS file (or a set of files?) instead of putting the styles inside |
Sorry I let this slip my radar. |
I think I'd prefer the JS do the opposite. ie., start with no icon next to links, and have the JS add the icon to all text links (links with text, not image). It is safer approach, as we can't handle all edge cases.
Inline styles is fine for now. If they become huge, we can move it latter in a different PR. @kukimik The screenshot you pasted looks good. Once the JS thing is addressed, we can merge it (after I test it locally). |
On the other hand, with the current approach you can easily turn off the external link icon manually in a particular case by adding a class to a single link. With JS activating the icon this is, of course, also possible, but I think it gets a little bit more complicated. |
The generated site should work on browsers with JavaScript disabled. That's another -- and arguably the most important -- reason for the JS injecting icons after page load. |
4ca9a92
to
829c974
Compare
@srid Please have a look at this. The links containing an image in the link text are now recognized before HTML is generated, so no JavaScript is needed. I'm not sure if Perhaps the code in Sorry for taking so long. Family reasons. |
829c974
to
36241d6
Compare
What do you think: should the icons appear in the backlinks section? I also see I need to fix the colors to make them consistent with other icons around. |
I'll take a look later this week. Been busy. |
@kukimik Just took a look at this.
I can refactor the code latter. |
Behaviorally, the icon looks good to me (and selecting text doesn't select it anymore). Maybe it should be made smaller. What do you mean by "fix the colors"? |
I believe it's sufficient to add the
I disabled the icon if the link contains another link. I believe this should detect wikilinks. Am I missing something?
TBD
AFAIR this was an issue in #190, not here.
Made it a bit smaller.
I thought that the color for inactive icon should be lighter (like the color of the "Edit this page" icon), but I checked it and it doesn't look good - the icons are hardly visible. The current colors are ok. |
Okay, behaviourally things look good to me 👍🏿 Why do we need |
I'm not sure if I understand the question correctly. External links without an icon still need to behave like other external links (e.g. I see the following options to implement this:
There are some mixed solutions, but I don't find them very clean. If you find the first approach better, then I may rewrite it. It should be easy. |
The external links containing an image (or a wikilink) lose the
That's what I meant here:
On the other hand this made me think some more about my proposed solution and now I think that the following structure would be better:
This, together with an extra
I don't have such an example. That's why I said "probably this extra flexibility is not needed." |
Let's take a step back and flesh out the requirements first. Question 1: What are the specific Markdown snippets on which we do not want to add the external icon? So far, one has been identified:
Is there anything else? I'm not sure if we should bother with wiki-links since that is an absurd case (is there a legitimate reason for them?). Question 2: Why do we need more than one template class var, |
Actually, this is only valid if the image appears as a block element (as with the disaster girl, due to being the only element of a EDIT: But maybe the inline icon is undesirable even in inline images? |
I'm mostly envisioning a situation where the user doesn't have to override their .tpl - tweaking WithIcon/NoIcon just to workaround the external link icon behavior. It should do the "right" thing as default. |
Yea, this is really frustrating to think about without having specific and concrete examples. I'd suggest adding all those examples (including your "A link text containing some image ..." case) to Then defining the requirements becomes straightforward, and it is easy to talk about this from a common ground. |
a8949ee
to
0a34d85
Compare
This is going to be a heuristic. A better or worse one, but still. I don't believe we can cover all the usecases. I'm trying to illustrate this in the I also propose an implementation that I find satisfying. I think it's pleasantly symmetric and readable at the cost of slight redundance. No tests yet. I've not looked into this. |
I've noticed that I duplicate the |
@kukimik I'm happy with this PR. If you could add tests for |
be0dcc8
to
6c7fb14
Compare
Rebased to master to run treefmt using new Ormolu. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is ready to be merged! Just one thing I don't understand in base.tpl.
@srid Thanks for the final corrections. And for your guidance throughout the process. And for your patience - the PR was opened over a year ago! Glad to see it merged. |
This adds an icon to external links. I've checked it on Firefox 94.0 and Chromium 95.0.4638.69. Screenshots attached.
Mostly it looks ok, but look at the image (FAIR Pledge) at the bottom of the first screenshot: the icon is displayed in the next line.
So this is not quite ready to get merged. Do you have any ideas how to handle the image case? I'm not even sure about the expected behavior: should we also have an icon if the link content is just an image? What if it has some text but ends with an image?
I'd also like to know your opinion whether adding the
emanote-external
class to external links is the right way to go.