Commit graph

109 commits

Author SHA1 Message Date
Franciszek Stachura
fc8106d520 web: Unify _link and _url variable suffixes 2025-02-14 12:50:29 +01:00
Franciszek Stachura
531529a182 web: Make "Go to home page" link to current version
If project and version is valid. Otherwise, redirect to latest or /.
2025-02-14 12:49:16 +01:00
Franciszek Stachura
2cf83f5f7b web: Add input reset button
I tried type="reset", but it reverts to initial value that is sometimes
set by the backend, instead of actually cleraing data.

https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/reset
2025-01-31 20:11:53 +01:00
Théo Lebrun
972fdd73e1 js: remove 301 redirect cache fix
This code was required because we messed-up in the past regarding
caching headers. This is not required anymore because the caching set
has expired, so no well behaving user-agent should have remains.

This represents something like 240k requests to the backend (not the
cache) over two weeks. Server load was minimal because generating those
responses is really fast.

Signed-off-by: Théo Lebrun <theo.lebrun@bootlin.com>
2025-01-03 11:33:30 +01:00
Franciszek Stachura
018677d1c5 banner: Add static/messages.json file listing banner texts 2024-12-04 11:18:53 +01:00
Franciszek Stachura
701d609c2a banner, js: Add dynamic message banner 2024-12-04 11:08:06 +01:00
James Raphael Tiovalen
f2146891c9 js: Highlight line of code when start == end
Enable code highlighting when there is only 1 selected line of code.

Signed-off-by: James Raphael Tiovalen <jamestiotio@gmail.com>
2024-11-12 10:18:17 +01:00
Théo Lebrun
4b3d35399d templates/header: update link to Bootlin's LinkedIn
Signed-off-by: Théo Lebrun <theo.lebrun@bootlin.com>
2024-11-08 18:14:34 +01:00
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
46254c4a90 web: Add error details for bug reports 2024-09-30 12:00:53 +02: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
Théo Lebrun
2eb21c82f6 web: templates/topbar: mark searchbar as required
Mark the searchbar as a required input. This avoids <Enter> on an empty
searchbar to send a "POST /$PROJECT/$VERSION/ident" with empty value,
which triggers an error.

This is made more frequent by the fact that the searchbar is
automatically focused. It also avoids implementing logic on the backend
to redirect to the previous page if an empty search was submitted.

Signed-off-by: Théo Lebrun <theo.lebrun@bootlin.com>
2024-09-27 17:27:25 +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
ec37680f04 web: Add ability to hide sidebar on desktop layout
The sidebar is hidden by default
2024-09-11 11:13:13 +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
f5c7c3c1ec templates: Remove png version of logo
Backwards compatibility for browsers without svg support (in this
version) causes the logo to unnecessarily flicker on navigation.

According to caniuse.com SVG in img elements is supported in browsers
used by 97.85% of users. https://caniuse.com/svg-img
Firefox introduced support in 2011, Chrome in 2013, Safari in 2015.
2024-09-09 16:33:12 +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
Théo Lebrun
ab9d776397 frontend: header: fix Bootlin logo paths and commit logo png+svg
Signed-off-by: Théo Lebrun <theo.lebrun@bootlin.com>
2024-08-27 15:50:08 +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
Michael Opdenacker
662482ebce Audio course course banner
Signed-off-by: Michael Opdenacker <michael.opdenacker@bootlin.com>
2024-08-05 14:20:10 +02:00
Franciszek Stachura
f5f49b6b39 Quick fix for searching identifiers with commas
Fixes #309, both manual search and display in search bar.
2024-08-02 13:43:14 +02:00
Franciszek Stachura
86af364b14 Generate pretty HTML for more errors 2024-07-31 11:33:53 +02:00
Franciszek Stachura
3d34855677 Make full width of directory entry in tree template clickable 2024-07-31 11:33:49 +02:00
Franciszek Stachura
decc2680b2 Move title generation to templates 2024-07-30 15:16:11 +02:00
Franciszek Stachura
8932f26a22 Move topbar family list to web.py 2024-07-30 15:16:07 +02:00
Franciszek Stachura
4c22738687 Move ident URL generation to web.py 2024-07-30 15:11:32 +02:00
Franciszek Stachura
5c92b378ea Create file URLs for tree in web.py 2024-07-30 14:10:51 +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
bf6f183189 Don't display size for directories
* Refactor projects list
2024-07-30 14:10:51 +02:00