Commit graph

786 commits

Author SHA1 Message Date
Franciszek Stachura
54bd3bc0a4 js: Refactor line range handling
Important changes that should make reading the diff easier:
* Script now only works on line numbers. Elements are queried when
  necessary
* handleLineRange was refactored into functions that only validate and
  return line number(s), it's now the callers responsibility to
  highlight the range
2024-11-06 17:19:11 +01:00
Franciszek Stachura
558f75e3f5 web: Parse range state from URL
Fixes #329
2024-11-06 17:19:11 +01:00
Franciszek Stachura
6b47af27a7 README, Dockerfile: Update to support version in footer 2024-11-06 17:18:07 +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
Louis Chauvet
18376d3f7b web: Display documentation before other things
The current order for displaying references is:

- [definitions] prototype, label, typedef, variable, struct, member,
  function
- documentation
- references

This order is not very practical when you are searching for information
about a symbol, as you often want to know if the symbol is documented.

By inverting the order and displaying the documentation first, the user
experience may be improved for finding the documentation. This should not
significantly change the UX for definitions, as there are already many
definitions, and you already have to search for what you want.
2024-11-06 17:17:00 +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
Théo Lebrun
d06c760b2a web: add handler for '/' URL
Previously, the web server was responsible for redirecting '/' to a
sensible URL. Most likely, the target URL was '/linux/latest/source'.
From there on, web did the redirect to the proper version.

Avoid a redirect by handling '/' directly from our application to the
correct version.

Signed-off-by: Théo Lebrun <theo.lebrun@bootlin.com>
2024-11-06 14:25:24 +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
3f6aa021a7 Improve tests
* Run pytest only for t, do not run tests for other libraries
* Add email and name git options to test repo init
* Change test repo permissions to avoid "dubious ownership" error
2024-11-05 12:20:02 +01:00
Théo Lebrun
c54a4c3dec data.py: simplify BsdDB.__init__() flags code logic
Signed-off-by: Théo Lebrun <theo.lebrun@bootlin.com>
2024-10-11 14:37:39 +02:00
Franciszek Stachura
0b8d735641 update: Make database usage thread safe
Current update script serializes database access using mutexes.
According to a user of Oracle support forums, this is not enough.

https://forums.oracle.com/ords/apexds/post/berkeley-db-file-corrupted-while-operating-for-hours-panic-4953
> if you are accessing the same database from multiple threads or
> multiple processes, they must share a cache (memory pool). In other
> words, it is not sufficient to just make sure no DB->put or DB->get
> operations are run simultaneously as you do with mutexes. Berkeley
> DB also maintains information about database files across calls in
> the cache, such as the list of free pages. If two threads accessing
> a database file have independent freelists, they will eventually
> both try to allocate the same page for different purposes, and the
> structure of the file will be compromised.

DB.open provides a flag that should be specified if database is to be
shared between threads

https://docs.oracle.com/cd/E17276_01/html/api_reference/C/dbopen.html

> DB_THREAD
> Cause the DB handle returned by DB->open() to be free-threaded; that
> is, concurrently usable by multiple threads in the address space.
> You should use this flag only in the absence of an encompassing
> environment.

While this probably won't solve all database concurrency issues (web
accessing the database during updates likely still will behave weird)
it could help with recent database corruption issues.

https://docs.oracle.com/cd/E17276_01/html/programmer_reference/program_mt.html

> The DB_THREAD flag must be specified to the DB_ENV->open() and
> DB->open() methods if the Berkeley DB handles returned by those
> interfaces will be used in the context of more than one thread.
> Setting the DB_THREAD flag inconsistently may result in database
> corruption.

> When using the non-cursor Berkeley DB calls to retrieve key/data
> items (for example, DB->get()), the memory to which the pointer
> stored into the Dbt refers is valid only until the next call using
> the DB handle returned by DB->open(). This includes any use of the
> returned DB handle, including by another thread within the process.
>
> For this reason, if the DB_THREAD handle was specified to the
> DB->open() method, either DB_DBT_MALLOC, DB_DBT_REALLOC or
> DB_DBT_USERMEM must be specified in the DBT when performing any
> non-cursor key or data retrieval.

It seems that bsddb3 sets appropriate flags in DBTs for us if DB_THREAD
is specified.

https://hg.jcea.es/pybsddb/file/tip/src/Module/berkeleydb.c#l2025

(ctrl+f for DB_THREAD)

I believe DBTs used in DB_put shouldn't require any extra flags because
the DBTs are only read by Berkeley DB (doesn't matter if they get
invalidated on the next call).
2024-10-11 11:44:45 +02:00
Théo Lebrun
55921f1957 utils/index-repository: support multiple remote URLs
Linux is the only currently supported project for which we want three
remote URLs; see index-all-repositories for the list.

We could optimise the fetching by doing a single fetch call to all
remotes at the same time using --jobs (or fetch.parallel config).

Signed-off-by: Théo Lebrun <theo.lebrun@bootlin.com>
2024-10-02 10:48:03 +02:00
Théo Lebrun
06d503e3d9 utils/index-repository: if $ELIXIR_THREADS is not passed, use nproc
Follow behavior of utils/index-all-repositories.

Signed-off-by: Théo Lebrun <theo.lebrun@bootlin.com>
2024-10-01 16:31:07 +02:00
Théo Lebrun
905e6ef657 utils/index-repository: pass $ELIXIR_THREADS to update.py
Follow behavior of utils/index-all-repositories.

Signed-off-by: Théo Lebrun <theo.lebrun@bootlin.com>
2024-10-01 16:27:10 +02:00
Théo Lebrun
1853abe7f9 README: fix docker image instructions
Two issues are fixed:

 - Initial `docker build` instructions fail because the Dockerfile path
   is wrong (elixir/Dockerfile versus elixir/docker/Dockerfile).

 - Indexing instructions are wrong because they do not use the
   virtualenv Python. It contains the installed packages, which we need
   for indexing. Issue appears as:

      ModuleNotFoundError: No module named 'bsddb3' (edited)

We also remove some common Docker knowledge (why we might want the
database to be coming from a mounted volume, rather than stored inside
the container).

Finally, we fix line widths but splitting commands into multiple lines.

Signed-off-by: Théo Lebrun <theo.lebrun@bootlin.com>
2024-10-01 16:03:24 +02:00
Franciszek Stachura
426fff2dc5 web: Fix identifier unquoting
to make DT compatibles work again...
2024-09-30 14:14:13 +02:00
Théo Lebrun
4aac8fc8dc web: error page: make Github issue TODO message more straight forward
We reword the TODO message. We put two newlines before and after the
triple dashes to avoid Markdown title formatting.

Signed-off-by: Théo Lebrun <theo.lebrun@bootlin.com>
2024-09-30 12:22:42 +02:00
Franciszek Stachura
46254c4a90 web: Add error details for bug reports 2024-09-30 12:00:53 +02:00
Franciszek Stachura
76d13c9193 web: Make GET /ident redirect to /source
Now making a GET to /project/version/ident will redirect to
/project/version/source.
Refreshing a page after making a request for an empty identifier won't
show 405 Method Not Allowed anymore.
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
Franciszek Stachura
e4b72b22ad web: Add breadcrubs to source 404 2024-09-30 12:00:53 +02:00
Franciszek Stachura
5b11f7b201 web: Add more context to error handling 2024-09-30 12:00:53 +02:00
Franciszek Stachura
36dd519b34 web: Move path parameter validation to resources 2024-09-30 12:00:53 +02:00
Théo Lebrun
e25b3d7c4b static: add /robots.txt
This is NOT being served by Elixir backend. The HTTP server in front
must serve it. Commit robots.txt to store the file somewhere.

Signed-off-by: Théo Lebrun <theo.lebrun@bootlin.com>
2024-09-27 18:19:11 +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
007248e61f web: static/img: commit favicon.ico
favicon.ico being served is not dependent on Elixir's configuration, but
on the front-facing server. Its config must be updated to serve the
favicon; this is why favicon.ico used to not be commited into the
repo.

Signed-off-by: Théo Lebrun <theo.lebrun@bootlin.com>
2024-09-27 17:48:34 +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
e8f8a2e7b4 js: Switch to strict mode in script.js
The script should be compatible with strict mode, and strict mode
prevents some annoying bugs. The most important, it prevents assigning
to an undeclared variable.

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Strict_mode
2024-09-26 13:05:00 +02:00
Franciszek Stachura
ef1b83ad75 js: Move minor fixes into functions
Move the following to new functions:
* anchor offset handler
* 301 fix
* autoscrolling prevention

Hookup onload handler with addEventListener.

About autoscrolling prevention:

I'm not sure if this is still relevant. I'm unable to trigger this
behavior. I think it could be related to a some kind of a Chrome bug.

https://forum.jquery.com/portal/en/community/topic/chrome-bug-or-how-do-i-prevent-a-form-field-to-scroll-the-container-when-focused
https://stackoverflow.com/questions/49318282/how-to-prevent-autoscroll-to-focused-input
2024-09-26 13:05:00 +02:00
Franciszek Stachura
2f7b56a4d8 js: Refactor go-to-top handler
href # doesn't work... probably because the wrapper
2024-09-26 13:05:00 +02:00
Franciszek Stachura
61ca8e19f2 js: Refactor sidebar hamburger button script
Move hamburger menu handlers to a new setup function, called from
onload.
2024-09-26 13:04:57 +02:00
Franciszek Stachura
e333b33364 js: Refactor versions tree expand/collapse script
Move versions tree handlers to a new setup function, called from
onload.
2024-09-26 12:48:34 +02:00
Franciszek Stachura
b9817c412b js: Refactor tags filter
Move tag filter setup into a new function, refactor related functions
to avoid global variables. Set up tags filter from onload handler.
2024-09-26 12:48:34 +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
c8d088834d web: Make mobile sidebar state separate
...from desktop sidebar state.

Fixes #331
2024-09-20 14:33:01 +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
Franciszek Stachura
b2c3ab73e9 web: Fix highlighting when second select is before first 2024-09-11 15:40:57 +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
Franciszek Stachura
30933fea6a web: Highlight whole lines of code 2024-09-11 11:48:27 +02:00
Franciszek Stachura
3b4bcd852a web: Add javascript based range links
Click line anchor and another line anchor holding shift to
make a link to a range.
2024-09-11 11:48:27 +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