Commit graph

81 commits

Author SHA1 Message Date
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
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
554bb11381 Refactor directory tree generation to use a namedtuple
* Fix #302 - Symlinks redirect to invalid paths (but only the directory
  tree part)
* Move more view-related logic to the template
2024-07-30 12:49:29 +02:00
Franciszek Stachura
f08aeb7b76 Split layout into sidebar and topbar 2024-07-30 12:49:29 +02:00
Franciszek Stachura
6e0a1ad64c Move source page generation to templates 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
Michael Opdenacker
cb5fc9fbdc Update default HTML banner
Signed-off-by: Michael Opdenacker <michael.opdenacker@bootlin.com>
2022-11-23 14:56:39 +01: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
Maxime Chretien
0385f29296 web.py/query.py: Add option to search identifiers in all families
Signed-off-by: Maxime Chretien <maxime.chretien@bootlin.com>
2020-05-28 11:37:17 +02:00
Michael Opdenacker
26dea97750 v2.0 release
Signed-off-by: Michael Opdenacker <michael.opdenacker@bootlin.com>
2020-05-27 09:07:35 +02:00
Maxime Chretien
962d6fb539 web interface: Add support for Kconfig and Devicetree idents
Keep old urls compatibility by settings family to C when nothing is
given.

Add a select element to select in which file family we want to search an
ident.

Update filters to support families and to handle Kconfig idents properly.

Signed-off-by: Maxime Chretien <maxime.chretien@bootlin.com>
2020-05-22 10:29:24 +02:00
Chris White
f112ab0826 Regularize whitespace; add editorconfig
- Change the few files that use leading tabs into leading spaces.
  This way they match the other files in the repo.
- Add an EditorConfig file so that supported editors will automatically
  use spaces instead of tabs.
- (Extra) Add some common editor backup-file extensions to .gitignore.
2020-03-21 08:58:43 -04:00