Rens Oliemans <[email protected]> writes: > Ihor Radchenko <[email protected]> writes: > >> Then, what about presenting two links in the static html file: >> alternative and original? JS may hide either for most users, while users >> with JS disabled will see both and can choose whichever they prefer to >> (or can) open. > > Consider the attached patches for Worg. I'm still learning (e)lisp, please > don't hesitate with feedback, either for details or higher level.
Thanks for your work! > I took a slightly different approach than suggested elsewhere in the thread > (replacing [[https://youtube.com/...]] links with [[youtube:...]]). Instead I > add an export hook that edits relevant links in the buffer before export based > on Rx. It seems a bit more hacky, but perhaps it only seems so since I'm not > that familiar with the Emacs way (editing buffers). It has the benefit of not > having to modify worg source, but doesn't overcome the same limitation > (publish.sh only looks at modified files). This approach makes good sense to me in terms of the discussion so far. Others will have better feedback on the code, but a couple of thoughts: - It would be good to have all this code together in one place in publish.sh (the add-hook line has strayed down), perhaps at the current end of the file - But in any case, perhaps an export filter added to `org-export-filter-link-functions' would be a slightly cleaner approach than an export hook that has to `org-element-map' over the links in the buffer? - What happens if retrieving the libredirect data fails for whatever reason? > I don't have a JS program that shows only one of the two options yet. > > You can try this version of worg on https://files.rensoliemans.nl/worg/, but I > promise nothing about keeping it up-to-date or reliably online, it's just to > see how these alternative links look. I think this looks nice. It offers more choice with little extra mess. We need to think about the description parts. See the Reddit link: Browse _Org-mode discussions on reddit.com_ _(original URL)_ Here it's actually the "(original URL)" link that points to reddit.com, while the link that seems to suggest it does, points to the alternative, which seems a bit confusing. It probably won't be the only link that refers to reddit.com, github.com or youtube.com in the description part. Should we just live with that, or should the code try to rewrite the description too (drop the ".com" bits)? Or perhaps we should we go the other way with something like Browse _Org-mode discussions on reddit.com_ _(libre-JS alternative)_ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^ original reddit.com URL redlib alternative but I struggle to find a short, meaningful formulation for the alternative link, while "original URL" is clear. > The links that I convert are: > - youtube.com / youtu.be > - [gist.]github.com. Excluding github.com/u/r/issues, since gothub does > not support issues. gothub also doesn't support pull requests, but Worg > does not link to a pull request page, so I ignored that. > - [old.]reddit.com > > There are a couple of known limitations: > - Some github gists automatically redirect appropriately (f.e., > https://gist.github.com/4343164 redirects to > https://gist.github.com/tonyday567/4343164). gothub only supports the > "complete" url (/user/gistid). Those gist urls aren't supported yet. > - github supports two way of forcing the "raw" file, via > raw.github.com/... and via github.com/...?raw=true, I currently only > convert the first one. > - github issues pages are not rewritten, see above. Thanks, this is a helpful overview. Regards, Christian
