Commit graph

68 commits

Author SHA1 Message Date
Franciszek Stachura
81a1116013 web: increment ?v= range link state fixes 2024-11-06 17:19:39 +01:00
Franciszek Stachura
305395e8e9 web: Link to current commit from the footer 2024-11-06 17:18:07 +01:00
Franciszek Stachura
cb28f73dbc web: Display Elixir commit hash in footer 2024-11-06 17:18:07 +01:00
Théo Lebrun
a776fff7ae static/style.css: update normalize.css from v7.0.0 to v8.0.1
Project homepage:
https://necolas.github.io/normalize.css/

Changelog:
https://github.com/necolas/normalize.css/blob/master/CHANGELOG.md

Signed-off-by: Théo Lebrun <theo.lebrun@bootlin.com>
2024-11-06 15:33:13 +01:00
Théo Lebrun
41de913669 templates/layout.html: add preload links for CSS resources
Tell to browsers the resources we will need, as soon as possible. This
means they do not need to fully download our CSS to know what they
should load next.

For some reason, crossorigin is required on fonts to avoid them being
loaded twice by Firefox.

Signed-off-by: Théo Lebrun <theo.lebrun@bootlin.com>
2024-11-06 15:06:11 +01:00
Théo Lebrun
6356cdc3c7 static: embed all CSS files into /static/style.css
Avoid many tiny requests. The issue is that browsers have a limited
amount of concurrent requests they can make. We do 19 for
loading /linux/v6.11.6/source. Reduce that to 14.

Signed-off-by: Théo Lebrun <theo.lebrun@bootlin.com>
2024-11-06 15:00:41 +01:00
Franciszek Stachura
4779965e0f Fix styles for latest version of Pygments
Pygments 2.12.0 slightly changed the order of HTML elements which
makes line numbers look weird with current CSS styles.

Quoting changelog:
> When linenos=table is used, the <table> itself is now wrapped
> with a <div class="highlight"> tag instead of placing it
> inside the <td class="code"> cell (#632.) With this change,
> the output matches the documented behavior.

https://pygments.org/docs/changelog/#version-2-12-0
Related issue: https://github.com/pygments/pygments/issues/632

This commit aims to fix this by further restricting CSS selectors
that selected everything under .highlight to only select source code
related elements - descendants of .code in the new layout.

This was also tested on Pygemnts 2.14.0, version currently packaged
for Debian Bookworm
https://packages.debian.org/bookworm/armel/python3-pygments
2024-11-05 23:20:51 +01:00
Franciszek Stachura
1762568c85 web: Meta descriptions improvements
* Make source tree descriptions shorter
* Make default title more descriptive
* Add a short summary of results to ident search description
2024-11-05 12:20:02 +01:00
Franciszek Stachura
5aca2d51e5 web: Improve error page
Add some useful links, including a link to a pre-filled bug report form
2024-09-30 12:00:53 +02:00
Théo Lebrun
60699c4155 web: templates/layout: add favicon <link> tag
For some reason, browsers do not automatically pick up the hosted
favicon.ico available on staging server. Add an explicit line to
describe the availability of /favicon.ico.

Signed-off-by: Théo Lebrun <theo.lebrun@bootlin.com>
2024-09-27 18:17:00 +02:00
Franciszek Stachura
4c0f2cf42b web: increment ?v= following script refactoring 2024-09-26 13:05:00 +02:00
Franciszek Stachura
f3d43c380b web: Fix sidebar state if page loaded as mobile
Fixes the following bug:

1. Make sure show-menu == true
2. Open page in mobile mode
3. Reisze to widescreen

Sidebar will be hidden until page is reloaded.
2024-09-20 15:24:59 +02:00
Franciszek Stachura
32141d8e96 web: Fix mobile sidebar close with backdrop click 2024-09-20 15:22:47 +02:00
Théo Lebrun
1aa74c4dc9 web: templates/layout.html: increment ?v= following range anchors fix
As usual, we must increment those version numbers when changes are made
to style.css and/or script.js. That purges the production cache.

Signed-off-by: Théo Lebrun <theo.lebrun@bootlin.com>
2024-09-20 14:35:17 +02:00
Franciszek Stachura
9a27c7ae20 autocomplete: Submit form on item selection 2024-09-13 11:22:28 +02:00
Théo Lebrun
713401cf95 web: templates/layout.html: increment ?v= following range anchors fix
As usual, we must increment those version numbers when changes are made
to style.css and/or script.js. That purges the production cache.

Signed-off-by: Théo Lebrun <theo.lebrun@bootlin.com>
2024-09-11 15:45:36 +02:00
Théo Lebrun
8059650f1e web: templates/layout.html: increment ?v= following range anchors
As usual, we must increment those version numbers when changes are made
to style.css and/or script.js. That purges the production cache.

Signed-off-by: Théo Lebrun <theo.lebrun@bootlin.com>
2024-09-11 11:49:45 +02:00
Théo Lebrun
378dcf7e49 web: templates/layout.html: increment ?v= following sidebar changes
As usual, we must increment those version numbers when changes are made
to style.css and/or script.js. That purges the production cache.

Signed-off-by: Théo Lebrun <theo.lebrun@bootlin.com>
2024-09-11 11:36:32 +02:00
Théo Lebrun
0b65c2c459 web: refactor showSidebar computation
The local storage API returns strings and has no way to set a default
value in case no value exists. We must therefore check for the "true"
string or the null value.

Let's extract it from the if boolean expression. We go from:

    if (isWidescreen && (showSidebar === "true" || showSidebar === null))

To:

    if (isWidescreen && showSidebar)

Signed-off-by: Théo Lebrun <theo.lebrun@bootlin.com>
2024-09-11 11:20:17 +02:00
Franciszek Stachura
0e9ff63c15 web: Save sidebar state in local storage 2024-09-11 11:13:16 +02:00
Franciszek Stachura
0fed56ea25 web: Move sidebar above content
...in layout to make it load before (potentially) long source or list
of identifiers.
Reduces chances of layout shifts during load of mentioned pages.
2024-09-11 11:13:10 +02:00
Franciszek Stachura
8c5e12fffd Add support for 'raw' parameter for source files
This parameter makes the server return a response with raw file
contents and headers that cause the browser to show a 'save as' dialog.

Regarding Content-Security-Policy:

https://www.w3.org/TR/CSP2/#sandbox-usage

> For example, a message board or email system might provide downloads of
> arbitrary attachments provided by other users. Attacks that rely on tricking
> a client into rendering one of these attachments could be mitigated by
> requesting that resources only be rendered in a very restrictive sandbox.
> Sending the sandbox directive with an empty value establishes such an
> environment:
>
> Content-Security-Policy: sandbox

https://www.w3.org/TR/CSP2/#directive-default-src

> Given this behavior, one good way of building a policy for a site would be to
> begin with a default-src of 'none', and to build up a policy from there that
> contains only those resource types which are actually in use for the page
> you’d like to protect. If you don’t use webfonts, for instance, there’s no
> reason to specify a source list for font-src; specifying only those resource
> types a page uses ensures that the possible attack surface for that page
> remains as small as possible.

https://cheatsheetseries.owasp.org/cheatsheets/Content_Security_Policy_Cheat_Sheet.html#defense-in-depth

> A strong CSP provides an effective second layer of protection against various
> types of vulnerabilities, especially XSS. Although CSP doesn't prevent web
> applications from containing vulnerabilities, it can make those
> vulnerabilities significantly more difficult for an attacker to exploit.

The idea is to prevent the browser from loading any external resources, if it
turned out it's possible to trick it into interpreting a file as HTML.
2024-09-05 14:12:53 +02:00
Franciszek Stachura
9e18f26aeb Restructure Elixir to avoid Python path hacks
* Move static files from http to a new directory
2024-08-27 11:33:18 +02:00
Franciszek Stachura
e8da1bf578 Reduce sidebar flashing on navigation
by moving some dynamic HTML generation to templates.
Also fixes no-js CSS a bit by hiding useless elements.
2024-08-20 14:32:52 +02:00
Franciszek Stachura
7d629429bf Generate different meta tag descriptions for different views
Added an ability to customize contents of meta description tag in
templates that inherit from layout. This replaces the default
description previously used in all views.
This change could help with SEO and missing descriptions in search
results (#167). It's based on advice from
https://developers.google.com/search/docs/appearance/snippet

> Create unique descriptions for each page on your site
> Programmatically generate descriptions

This is not guaranteed to fix the issue, search engines are opaque.

All custom descriptions start with "Elixir Cross Referencer - ".

Currently customized descriptions:
* source - path to the file, project name and version
* ident - name of the searched identifier, project name and version

Everything else uses the previous, default description.
2024-08-20 10:35:17 +02:00
Franciszek Stachura
0de9a05d1f Increase min-width for tablet mode
Nowadays smartphones are long but narrow. On many devices, the sidebar
is visible (and impossible to hide) in landscape mode.

Long term it would be better to implement sidebar hiding regardless of
device size, but that may require cookies - otherwise some people will
have to hide the sidebar manually on all links.
2024-08-19 17:30:29 +02:00
Franciszek Stachura
22296b6cf8 Fix incorrectly issued 301 redirects on latest for project roots
This commit adds a small piece of Javascript code to force browsers to forget
about incorrectly issued 301 redirects from "latest" versions.
This code only runs for root project paths (i.e. `/linux/v6.10.2/source`, but
not `/linux/v6.10.2/source/arch`) - other links with "latest" will remain
broken for people who visited them (at least until they clear their cache).
2024-08-06 12:47:40 +02:00
Franciszek Stachura
decc2680b2 Move title generation to templates 2024-07-30 15:16:11 +02:00
Franciszek Stachura
ee4ccdeb80 Provide base source and ident URLs for project and tag as variables 2024-07-30 14:10:51 +02:00
Franciszek Stachura
d107fa27aa Remove current_url template variable
Now that the base tag is gone it's not useful anymore

* Make line number links use relative paths
2024-07-30 14:10:51 +02:00
Franciszek Stachura
8cf71f5e62 Remove base tag and baseurl template variable 2024-07-30 14:10:51 +02:00
Franciszek Stachura
21802b3203 Make dynamic references popup use absolute paths 2024-07-30 14:10:51 +02:00
Franciszek Stachura
edce92a64c Make url in templates and web.py absolute
This is a step to removing the base tag. Once everything uses absolute
URLs, base tag will be removed and some URLs will be replaced
by relative URLs.
2024-07-30 14:10:51 +02:00
Franciszek Stachura
5c6e604b9b Generate links for versions sidebar outside of template context
* Replace url variable with current_url that contains the current
  absolute url. This gets us a little closer to getting rid of the base
  tag
2024-07-30 14:10:51 +02:00
Franciszek Stachura
dbc7191060 Change template variable names to be more descriptive 2024-07-30 14:10:51 +02:00
Franciszek Stachura
f08aeb7b76 Split layout into sidebar and topbar 2024-07-30 12:49:29 +02:00
Franciszek Stachura
36ae9046f4 Move ident template to a new file 2024-07-30 12:49:29 +02:00
Franciszek Stachura
aa5057264d Move ident page HTML generation to layout template 2024-07-30 12:49:29 +02:00
Franciszek Stachura
237b4bb549 Move breadcrumb links generation to layout template 2024-07-30 12:49:29 +02:00
Franciszek Stachura
126ddae515 Move generate_versions to layout template 2024-07-30 12:49:25 +02:00
Franciszek Stachura
cb093ba2a5 Show a loading indicator if API fetch takes more than 200 milliseconds 2023-12-18 11:41:24 +01:00
Franciszek Stachura
7c595fe883 Change style.css version to force stylesheet cache reload
Fix documentation links rendering
2023-12-18 11:24:37 +01:00
Franciszek Stachura
5871fa6dca Add dynamic references
Initial implementation of a new mode in which clicking on an
identifier creates a HTML popup instead of redirecting to a new page.

Skip popup if ctrl/shift/meta is held. Fix generateDocComments

Add ident css class to more ident links (docs, dtb, config...)

Make popup positioning more predicatble

* Attempt to move the popup if a part of it is rendered outside of the viewport
* Make popup full-width on smartphone/small tablet devices

Hide popup on escape click

Add "use strict" and fix undeclared variable errors
2023-12-15 09:00:18 +01:00
Michael Opdenacker
5d39bb2ffa Bump version to 2.2
Signed-off-by: Michael Opdenacker <michael.opdenacker@bootlin.com>
2023-05-15 15:40:49 +02:00
AlphaHot
09f37db41f
web : Add autofocus when entering a search 2020-08-19 14:57:59 +05:00
Michael Opdenacker
e8a82f675f Bump version to 2.1
Signed-off-by: Michael Opdenacker <michael.opdenacker@bootlin.com>
2020-06-22 06:49:37 +02:00
Michael Opdenacker
53c160b349 Expand "description" header for better search engine results
Signed-off-by: Michael Opdenacker <michael.opdenacker@bootlin.com>
2020-06-12 16:15:46 +02:00
Maxime Chretien
086250fb03 web : Add autocompletion for ident search bar
To do that we use a slightly modified version of the script found here:
https://github.com/autocompletejs/autocomplete.js/tree/2.7
This code is under MIT licence so it's compatible with Elixir's licence

The server answers requests from the script via a new interface:
https://elixir.bootlin.com/acp?q=<query>&f=<family>&p=<project>

And this is handled by autocomplete.py
The script creates and uses a tmp file to store idents for each project
in order to reduce the time needed to answer a request.

Signed-off-by: Maxime Chretien <maxime.chretien@bootlin.com>
2020-06-11 14:38:44 +02:00
Maxime Chretien
4dec3ee4e9 web : Add DT compatible strings support
Signed-off-by: Maxime Chretien <maxime.chretien@bootlin.com>
2020-06-08 15:37:59 +02:00
Maxime Chretien
5e287d9a7e templates/layout.html: Add tooltip on search select element
Signed-off-by: Maxime Chretien <maxime.chretien@bootlin.com>
2020-05-28 11:46:05 +02:00