Fli*_*imm 0 ubuntu-website manpage
Ubuntu 有一个网站,提供 Ubuntu 软件包附带的手册页(“manpage”)。例如,以下是 rsync 的联机帮助页:
| Ubuntu版本 | 链接到 rsync 联机帮助页 |
|---|---|
| Ubuntu 18.04 LTS(仿生) | https://manpages.ubuntu.com/manpages/bionic/en/man1/rsync.1.html |
| Ubuntu 20.04 LTS(焦点) | https://manpages.ubuntu.com/manpages/focal/en/man1/rsync.1.html |
| Ubuntu 21.10(顽皮) | https://manpages.ubuntu.com/manpages/impish/en/man1/rsync.1.html |
| Ubuntu 22.04 LTS(杰米) | https://manpages.ubuntu.com/manpages/jammy/en/man1/rsync.1.html |
| Ubuntu 22.10(动力学) | https://manpages.ubuntu.com/manpages/kinetic/en/man1/rsync.1.html |
我想创建一个指向 Ubuntu.com 上托管的 rsync 联机帮助页的链接,该链接会自动重定向到最新发布的 Ubuntu 版本,如下所示(注意这个stable词):
https://manpages.ubuntu.com/manpages/stable/en/man1/rsync.1.html
如果我单击该示例链接,它会将我重定向到最新的未发布版本的 Ubuntu(在编写 Ubuntu 22.10 时),而不是最新发布的 Ubuntu 版本(在编写 Ubuntu 22.04 LTS 时)。如何创建最新发布版本的链接?
用于此重定向的脚本不是很复杂。它只是从根据 Ubuntu 版本和联机帮助页部分生成的列表中选择最后一个链接,并将其发送到那里:
if matches > 0:
if "titles" in get and get["titles"].value == "404":
# If we were sent here by a 404-not-found, and we have at least one
# match, redirect the user to the last page in our list
html += "<script>location.replace('" + href_path + "');</script>"
else:
# Otherwise, a normal title search, display the title table
html += title_html
else:
# But if we do not find any matching titles, do a full text search
html += ("</div></div><section class='p-strip u-no-padding--top'>"
"<div class='row'><strong>No matching titles found - "
"Full text search results below</strong>")
Run Code Online (Sandbox Code Playgroud)
正如在代码中的其他地方可以看到的,它仅具有从发布代码名称(例如,jammy)到完整版本(22.04 LTS)的映射。任何地方都没有提到像stableor 之类的关键字或其他任何内容。latest
所以,不,这在当前系统中是不可能的。