Restructure Elixir to avoid Python path hacks

* Move static files from http to a new directory
This commit is contained in:
Franciszek Stachura 2024-08-16 22:56:15 +02:00
parent 584c98686d
commit 9e18f26aeb
63 changed files with 90 additions and 109 deletions

0
elixir/__init__.py Executable file
View file

View file

@ -24,12 +24,7 @@ import falcon
from urllib import parse from urllib import parse
import sys import sys
ELIXIR_DIR = os.path.dirname(os.path.realpath(__file__)) + '/..' from .query import get_query
if ELIXIR_DIR not in sys.path:
sys.path = [ ELIXIR_DIR ] + sys.path
from query import get_query
class ApiIdentGetterResource: class ApiIdentGetterResource:
def on_get(self, req, resp, project, ident): def on_get(self, req, resp, project, ident):

View file

@ -25,13 +25,8 @@ from urllib import parse
from bsddb3.db import DB_SET_RANGE from bsddb3.db import DB_SET_RANGE
import falcon import falcon
ELIXIR_DIR = os.path.dirname(os.path.realpath(__file__)) + '/..' from .lib import autoBytes
from .query import get_query
if ELIXIR_DIR not in sys.path:
sys.path = [ ELIXIR_DIR ] + sys.path
from lib import autoBytes
from query import get_query
class AutocompleteResource: class AutocompleteResource:
def on_get(self, req, resp): def on_get(self, req, resp):

View file

@ -20,7 +20,7 @@
import bsddb3 import bsddb3
import re import re
from lib import autoBytes from .lib import autoBytes
import os import os
import os.path import os.path
import errno import errno

View file

View file

@ -1,5 +1,5 @@
import re import re
from filters.utils import Filter, FilterContext, decode_number, encode_number, filename_without_ext_matches from .utils import Filter, FilterContext, decode_number, encode_number, filename_without_ext_matches
# Filters for Config.in includes # Filters for Config.in includes
# source "path/file" # source "path/file"

2
http/filters/cppinc.py → elixir/filters/cppinc.py Normal file → Executable file
View file

@ -1,5 +1,5 @@
import re import re
from filters.utils import Filter, FilterContext, encode_number, decode_number, extension_matches from .utils import Filter, FilterContext, encode_number, decode_number, extension_matches
# Filters for cpp includes like these: # Filters for cpp includes like these:
# #include "file" # #include "file"

View file

@ -1,5 +1,5 @@
import re import re
from filters.utils import Filter, FilterContext, encode_number, decode_number, extension_matches from .utils import Filter, FilterContext, encode_number, decode_number, extension_matches
# Filters for cpp includes like these: # Filters for cpp includes like these:
# #include <file> # #include <file>

View file

@ -1,5 +1,5 @@
import re import re
from filters.utils import Filter, FilterContext, encode_number, decode_number, extension_matches from .utils import Filter, FilterContext, encode_number, decode_number, extension_matches
# Filter for kconfig identifier in defconfigs # Filter for kconfig identifier in defconfigs
# Replaces defconfig identifiers with links to definitions/references # Replaces defconfig identifiers with links to definitions/references

View file

@ -1,5 +1,5 @@
import re import re
from filters.utils import Filter, FilterContext, encode_number, decode_number, extension_matches from .utils import Filter, FilterContext, encode_number, decode_number, extension_matches
# Filter for DT compatible strings in code (C family) files # Filter for DT compatible strings in code (C family) files
# Finds assigments to properties and variables named 'compatible' and recognized by the Query.query('file') # Finds assigments to properties and variables named 'compatible' and recognized by the Query.query('file')

View file

@ -1,6 +1,6 @@
import re import re
from urllib.parse import quote from urllib.parse import quote
from filters.utils import Filter, FilterContext, encode_number, decode_number from .utils import Filter, FilterContext, encode_number, decode_number
# Filter for DT compatible strings in documentation (B family) files # Filter for DT compatible strings in documentation (B family) files
# syscon # syscon

View file

@ -1,5 +1,5 @@
import re import re
from filters.utils import Filter, FilterContext, encode_number, decode_number, extension_matches from .utils import Filter, FilterContext, encode_number, decode_number, extension_matches
# Filter for DT compatible strings in DTS (D family) files # Filter for DT compatible strings in DTS (D family) files
# compatible = "device" # compatible = "device"

2
http/filters/dtsi.py → elixir/filters/dtsi.py Normal file → Executable file
View file

@ -1,5 +1,5 @@
import re import re
from filters.utils import Filter, FilterContext, encode_number, decode_number, extension_matches from .utils import Filter, FilterContext, encode_number, decode_number, extension_matches
# Filters for dts includes as follows: # Filters for dts includes as follows:
# Replaces include directives in dts/dtsi files with links to source # Replaces include directives in dts/dtsi files with links to source

2
http/filters/ident.py → elixir/filters/ident.py Normal file → Executable file
View file

@ -1,5 +1,5 @@
import re import re
from filters.utils import Filter, FilterContext, encode_number, decode_number from .utils import Filter, FilterContext, encode_number, decode_number
# Filter for identifier links # Filter for identifier links
# Replaces identifiers marked by Query.query('file') with links to ident page. # Replaces identifiers marked by Query.query('file') with links to ident page.

2
http/filters/kconfig.py → elixir/filters/kconfig.py Normal file → Executable file
View file

@ -1,5 +1,5 @@
import re import re
from filters.utils import Filter, FilterContext, encode_number, decode_number, filename_without_ext_matches from .utils import Filter, FilterContext, encode_number, decode_number, filename_without_ext_matches
# Filters for Kconfig includes # Filters for Kconfig includes
# Replaces KConfig includes (source keyword) with links to included files # Replaces KConfig includes (source keyword) with links to included files

View file

@ -1,5 +1,5 @@
import re import re
from filters.utils import Filter, FilterContext, encode_number, decode_number from .utils import Filter, FilterContext, encode_number, decode_number
# Filter for kconfig identifier links # Filter for kconfig identifier links
# Replaces KConfig identifiers with links to definitions and references # Replaces KConfig identifiers with links to definitions and references

View file

@ -1,6 +1,6 @@
from os.path import dirname from os.path import dirname
import re import re
from filters.utils import Filter, FilterContext, decode_number, encode_number, filename_without_ext_matches from .utils import Filter, FilterContext, decode_number, encode_number, filename_without_ext_matches
# Filters for Makefile directory includes as follows: # Filters for Makefile directory includes as follows:
# obj-$(VALUE) += dir/ # obj-$(VALUE) += dir/

View file

@ -1,6 +1,6 @@
from os.path import dirname from os.path import dirname
import re import re
from filters.utils import Filter, FilterContext, decode_number, encode_number, filename_without_ext_matches from .utils import Filter, FilterContext, decode_number, encode_number, filename_without_ext_matches
# Filters for Makefile file includes like these: # Filters for Makefile file includes like these:
# dtb-y += file.dtb # dtb-y += file.dtb

View file

@ -1,6 +1,6 @@
from os.path import dirname from os.path import dirname
import re import re
from filters.utils import Filter, FilterContext, decode_number, encode_number, filename_without_ext_matches from .utils import Filter, FilterContext, decode_number, encode_number, filename_without_ext_matches
# Filters for files listed in Makefiles # Filters for files listed in Makefiles
# path/file # path/file

View file

@ -1,6 +1,6 @@
from os.path import dirname from os.path import dirname
import re import re
from filters.utils import Filter, FilterContext, decode_number, encode_number, filename_without_ext_matches from .utils import Filter, FilterContext, decode_number, encode_number, filename_without_ext_matches
# Filters for Makefile file includes like these: # Filters for Makefile file includes like these:
# file.o # file.o

View file

@ -1,5 +1,5 @@
import re import re
from filters.utils import Filter, FilterContext, decode_number, encode_number, filename_without_ext_matches from .utils import Filter, FilterContext, decode_number, encode_number, filename_without_ext_matches
# Filters for files listed in Makefiles using $(srctree) # Filters for files listed in Makefiles using $(srctree)
# $(srctree)/Makefile # $(srctree)/Makefile

View file

@ -1,6 +1,6 @@
from os.path import dirname from os.path import dirname
import re import re
from filters.utils import Filter, FilterContext, decode_number, encode_number, filename_without_ext_matches from .utils import Filter, FilterContext, decode_number, encode_number, filename_without_ext_matches
# Filters for Makefile directory includes as follows: # Filters for Makefile directory includes as follows:
# subdir-y += dir # subdir-y += dir

View file

2
http/filters/utils.py → elixir/filters/utils.py Normal file → Executable file
View file

@ -2,7 +2,7 @@ import re
import os import os
from dataclasses import dataclass from dataclasses import dataclass
from typing import Callable, List from typing import Callable, List
from query import Query from ..query import Query
# Context data used by Filters # Context data used by Filters
# tag: browsed version, unqoted # tag: browsed version, unqoted

View file

@ -20,7 +20,7 @@
import subprocess, os import subprocess, os
CURRENT_DIR = os.path.dirname(os.path.abspath(__file__)) CURRENT_DIR = os.path.abspath(os.path.dirname(os.path.abspath(__file__)) + '/..')
def script(*args, env=None): def script(*args, env=None):
args = (os.path.join(CURRENT_DIR, 'script.sh'),) + args args = (os.path.join(CURRENT_DIR, 'script.sh'),) + args

View file

@ -18,9 +18,9 @@
# You should have received a copy of the GNU Affero General Public License # You should have received a copy of the GNU Affero General Public License
# along with Elixir. If not, see <http://www.gnu.org/licenses/>. # along with Elixir. If not, see <http://www.gnu.org/licenses/>.
from lib import script, scriptLines, decode from .lib import script, scriptLines, decode
import lib from . import lib
import data from . import data
import os import os
from collections import OrderedDict from collections import OrderedDict
from urllib import parse from urllib import parse

View file

@ -28,23 +28,13 @@ from urllib import parse
import falcon import falcon
import jinja2 import jinja2
ELIXIR_DIR = os.path.dirname(os.path.realpath(__file__)) + '/..' from .lib import validFamily
from .query import Query, SymbolInstance
if ELIXIR_DIR not in sys.path: from .filters import get_filters
sys.path = [ ELIXIR_DIR ] + sys.path from .filters.utils import FilterContext
from .autocomplete import AutocompleteResource
HTTP_DIR = os.path.dirname(os.path.realpath(__file__)) from .api import ApiIdentGetterResource
from .query import get_query
if HTTP_DIR not in sys.path:
sys.path = [ HTTP_DIR ] + sys.path
from lib import validFamily
from query import Query, SymbolInstance
from filters import get_filters
from filters.utils import FilterContext
from autocomplete import AutocompleteResource
from api import ApiIdentGetterResource
from query import get_query
# Generated a Elixir error page # Generated a Elixir error page
def get_error_page(ctx, title, details=None): def get_error_page(ctx, title, details=None):

View file

@ -20,7 +20,7 @@
import re import re
from urllib import parse from urllib import parse
from lib import decode from elixir.lib import decode
class FindCompatibleDTS: class FindCompatibleDTS:
def __init__(self): def __init__(self):

View file

@ -1,39 +0,0 @@
/* ubuntu-regular - cyrillic_greek_latin_latin-ext_greek-ext_cyrillic-ext */
@font-face {
font-family: 'Ubuntu';
font-style: normal;
font-weight: 400;
src: url('/fonts/ubuntu/ubuntu-v14-cyrillic_greek_latin_latin-ext_greek-ext_cyrillic-ext-regular.eot'); /* IE9 Compat Modes */
src: local('Ubuntu Regular'), local('Ubuntu-Regular'),
url('/fonts/ubuntu/ubuntu-v14-cyrillic_greek_latin_latin-ext_greek-ext_cyrillic-ext-regular.eot?#iefix') format('embedded-opentype'), /* IE6-IE8 */
url('/fonts/ubuntu/ubuntu-v14-cyrillic_greek_latin_latin-ext_greek-ext_cyrillic-ext-regular.woff2') format('woff2'), /* Super Modern Browsers */
url('/fonts/ubuntu/ubuntu-v14-cyrillic_greek_latin_latin-ext_greek-ext_cyrillic-ext-regular.woff') format('woff'), /* Modern Browsers */
url('/fonts/ubuntu/ubuntu-v14-cyrillic_greek_latin_latin-ext_greek-ext_cyrillic-ext-regular.ttf') format('truetype'), /* Safari, Android, iOS */
url('/fonts/ubuntu/ubuntu-v14-cyrillic_greek_latin_latin-ext_greek-ext_cyrillic-ext-regular.svg#Ubuntu') format('svg'); /* Legacy iOS */
}
/* ubuntu-italic - cyrillic_greek_latin_latin-ext_greek-ext_cyrillic-ext */
@font-face {
font-family: 'Ubuntu';
font-style: italic;
font-weight: 400;
src: url('/fonts/ubuntu/ubuntu-v14-cyrillic_greek_latin_latin-ext_greek-ext_cyrillic-ext-italic.eot'); /* IE9 Compat Modes */
src: local('Ubuntu Italic'), local('Ubuntu-Italic'),
url('/fonts/ubuntu/ubuntu-v14-cyrillic_greek_latin_latin-ext_greek-ext_cyrillic-ext-italic.eot?#iefix') format('embedded-opentype'), /* IE6-IE8 */
url('/fonts/ubuntu/ubuntu-v14-cyrillic_greek_latin_latin-ext_greek-ext_cyrillic-ext-italic.woff2') format('woff2'), /* Super Modern Browsers */
url('/fonts/ubuntu/ubuntu-v14-cyrillic_greek_latin_latin-ext_greek-ext_cyrillic-ext-italic.woff') format('woff'), /* Modern Browsers */
url('/fonts/ubuntu/ubuntu-v14-cyrillic_greek_latin_latin-ext_greek-ext_cyrillic-ext-italic.ttf') format('truetype'), /* Safari, Android, iOS */
url('/fonts/ubuntu/ubuntu-v14-cyrillic_greek_latin_latin-ext_greek-ext_cyrillic-ext-italic.svg#Ubuntu') format('svg'); /* Legacy iOS */
}
/* ubuntu-700 - cyrillic_greek_latin_latin-ext_greek-ext_cyrillic-ext */
@font-face {
font-family: 'Ubuntu';
font-style: normal;
font-weight: 700;
src: url('/fonts/ubuntu/ubuntu-v14-cyrillic_greek_latin_latin-ext_greek-ext_cyrillic-ext-700.eot'); /* IE9 Compat Modes */
src: local('Ubuntu Bold'), local('Ubuntu-Bold'),
url('/fonts/ubuntu/ubuntu-v14-cyrillic_greek_latin_latin-ext_greek-ext_cyrillic-ext-700.eot?#iefix') format('embedded-opentype'), /* IE6-IE8 */
url('/fonts/ubuntu/ubuntu-v14-cyrillic_greek_latin_latin-ext_greek-ext_cyrillic-ext-700.woff2') format('woff2'), /* Super Modern Browsers */
url('/fonts/ubuntu/ubuntu-v14-cyrillic_greek_latin_latin-ext_greek-ext_cyrillic-ext-700.woff') format('woff'), /* Modern Browsers */
url('/fonts/ubuntu/ubuntu-v14-cyrillic_greek_latin_latin-ext_greek-ext_cyrillic-ext-700.ttf') format('truetype'), /* Safari, Android, iOS */
url('/fonts/ubuntu/ubuntu-v14-cyrillic_greek_latin_latin-ext_greek-ext_cyrillic-ext-700.svg#Ubuntu') format('svg'); /* Legacy iOS */
}

39
static/fonts.css Normal file
View file

@ -0,0 +1,39 @@
/* ubuntu-regular - cyrillic_greek_latin_latin-ext_greek-ext_cyrillic-ext */
@font-face {
font-family: 'Ubuntu';
font-style: normal;
font-weight: 400;
src: url('/static/fonts/ubuntu/ubuntu-v14-cyrillic_greek_latin_latin-ext_greek-ext_cyrillic-ext-regular.eot'); /* IE9 Compat Modes */
src: local('Ubuntu Regular'), local('Ubuntu-Regular'),
url('/static/fonts/ubuntu/ubuntu-v14-cyrillic_greek_latin_latin-ext_greek-ext_cyrillic-ext-regular.eot?#iefix') format('embedded-opentype'), /* IE6-IE8 */
url('/static/fonts/ubuntu/ubuntu-v14-cyrillic_greek_latin_latin-ext_greek-ext_cyrillic-ext-regular.woff2') format('woff2'), /* Super Modern Browsers */
url('/static/fonts/ubuntu/ubuntu-v14-cyrillic_greek_latin_latin-ext_greek-ext_cyrillic-ext-regular.woff') format('woff'), /* Modern Browsers */
url('/static/fonts/ubuntu/ubuntu-v14-cyrillic_greek_latin_latin-ext_greek-ext_cyrillic-ext-regular.ttf') format('truetype'), /* Safari, Android, iOS */
url('/static/fonts/ubuntu/ubuntu-v14-cyrillic_greek_latin_latin-ext_greek-ext_cyrillic-ext-regular.svg#Ubuntu') format('svg'); /* Legacy iOS */
}
/* ubuntu-italic - cyrillic_greek_latin_latin-ext_greek-ext_cyrillic-ext */
@font-face {
font-family: 'Ubuntu';
font-style: italic;
font-weight: 400;
src: url('/static/fonts/ubuntu/ubuntu-v14-cyrillic_greek_latin_latin-ext_greek-ext_cyrillic-ext-italic.eot'); /* IE9 Compat Modes */
src: local('Ubuntu Italic'), local('Ubuntu-Italic'),
url('/static/fonts/ubuntu/ubuntu-v14-cyrillic_greek_latin_latin-ext_greek-ext_cyrillic-ext-italic.eot?#iefix') format('embedded-opentype'), /* IE6-IE8 */
url('/static/fonts/ubuntu/ubuntu-v14-cyrillic_greek_latin_latin-ext_greek-ext_cyrillic-ext-italic.woff2') format('woff2'), /* Super Modern Browsers */
url('/static/fonts/ubuntu/ubuntu-v14-cyrillic_greek_latin_latin-ext_greek-ext_cyrillic-ext-italic.woff') format('woff'), /* Modern Browsers */
url('/static/fonts/ubuntu/ubuntu-v14-cyrillic_greek_latin_latin-ext_greek-ext_cyrillic-ext-italic.ttf') format('truetype'), /* Safari, Android, iOS */
url('/static/fonts/ubuntu/ubuntu-v14-cyrillic_greek_latin_latin-ext_greek-ext_cyrillic-ext-italic.svg#Ubuntu') format('svg'); /* Legacy iOS */
}
/* ubuntu-700 - cyrillic_greek_latin_latin-ext_greek-ext_cyrillic-ext */
@font-face {
font-family: 'Ubuntu';
font-style: normal;
font-weight: 700;
src: url('/static/fonts/ubuntu/ubuntu-v14-cyrillic_greek_latin_latin-ext_greek-ext_cyrillic-ext-700.eot'); /* IE9 Compat Modes */
src: local('Ubuntu Bold'), local('Ubuntu-Bold'),
url('/static/fonts/ubuntu/ubuntu-v14-cyrillic_greek_latin_latin-ext_greek-ext_cyrillic-ext-700.eot?#iefix') format('embedded-opentype'), /* IE6-IE8 */
url('/static/fonts/ubuntu/ubuntu-v14-cyrillic_greek_latin_latin-ext_greek-ext_cyrillic-ext-700.woff2') format('woff2'), /* Super Modern Browsers */
url('/static/fonts/ubuntu/ubuntu-v14-cyrillic_greek_latin_latin-ext_greek-ext_cyrillic-ext-700.woff') format('woff'), /* Modern Browsers */
url('/static/fonts/ubuntu/ubuntu-v14-cyrillic_greek_latin_latin-ext_greek-ext_cyrillic-ext-700.ttf') format('truetype'), /* Safari, Android, iOS */
url('/static/fonts/ubuntu/ubuntu-v14-cyrillic_greek_latin_latin-ext_greek-ext_cyrillic-ext-700.svg#Ubuntu') format('svg'); /* Legacy iOS */
}

View file

Before

Width:  |  Height:  |  Size: 4.7 KiB

After

Width:  |  Height:  |  Size: 4.7 KiB

View file

@ -1,7 +1,7 @@
.header { .header {
height: 200px; height: 200px;
background: #6D7DD2; background: #6D7DD2;
background-image: url('/img/2penguins.svg'); background-image: url('/static/img/2penguins.svg');
background-repeat: no-repeat; background-repeat: no-repeat;
background-size: 300px; background-size: 300px;
background-position: bottom -82px right; background-position: bottom -82px right;

View file

Before

Width:  |  Height:  |  Size: 2.4 KiB

After

Width:  |  Height:  |  Size: 2.4 KiB

View file

Before

Width:  |  Height:  |  Size: 283 B

After

Width:  |  Height:  |  Size: 283 B

View file

@ -288,7 +288,7 @@ h2 {
text-decoration: none; text-decoration: none;
background-color: #aaa; background-color: #aaa;
background-image: url("/img/arrow-dropdown-16.svg"); background-image: url("/static/img/arrow-dropdown-16.svg");
background-position: right 2px center; background-position: right 2px center;
background-repeat: no-repeat; background-repeat: no-repeat;
@ -810,8 +810,8 @@ h2 {
@font-face { @font-face {
font-family: "lxr"; font-family: "lxr";
src: url("/fonts/lxr.svg") format("svg"), src: url("/static/fonts/lxr.svg") format("svg"),
url("/fonts/lxr.ttf") format("truetype"); url("/static/fonts/lxr.ttf") format("truetype");
font-weight: normal; font-weight: normal;
font-style: normal; font-style: normal;
} }

View file

@ -12,9 +12,9 @@
<a class="message-link" target="_blank" href="https://bootlin.com/training/audio/"></a> <a class="message-link" target="_blank" href="https://bootlin.com/training/audio/"></a>
</div> </div>
<h1> <h1>
<object data="/images/bootlin-logo-white.svg" type="image/svg+xml"> <object data="/static/images/bootlin-logo-white.svg" type="image/svg+xml">
<!-- If the browser doesn't support SVG --> <!-- If the browser doesn't support SVG -->
<img src="/images/bootlin-logo-white.png" alt="Bootlin logo" /> <img src="/static/images/bootlin-logo-white.png" alt="Bootlin logo" />
</object> </object>
</h1> </h1>
<h2>Elixir Cross Referencer</h2> <h2>Elixir Cross Referencer</h2>

View file

@ -14,9 +14,9 @@
Elixir Cross Referencer - Explore source code in your browser - Particularly useful for the Linux kernel and other low-level projects in C/C++ (bootloaders, C libraries...) Elixir Cross Referencer - Explore source code in your browser - Particularly useful for the Linux kernel and other low-level projects in C/C++ (bootloaders, C libraries...)
{%- endblock %}"> {%- endblock %}">
<meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1" /> <meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1" />
<link rel="stylesheet" href="/style.css?v=7"> <link rel="stylesheet" href="/static/style.css?v=7">
<link rel="stylesheet" href="/banner.css"> <link rel="stylesheet" href="/static/banner.css">
<link rel="stylesheet" href="/autocomplete.css"> <link rel="stylesheet" href="/static/autocomplete.css">
<script>document.documentElement.className = 'js'</script> <script>document.documentElement.className = 'js'</script>
</head> </head>
<body> <body>
@ -48,8 +48,8 @@
<span class="poweredby">powered by <a target="_blank" href="https://github.com/bootlin/elixir">Elixir 2.2</a></span> <span class="poweredby">powered by <a target="_blank" href="https://github.com/bootlin/elixir">Elixir 2.2</a></span>
</footer> </footer>
</div> </div>
<script src="/script.js?v=5"></script> <script src="/static/script.js?v=5"></script>
<script src="/dynamic-references.js?v=4"></script> <script src="/static/dynamic-references.js?v=4"></script>
<script src="/autocomplete.js" project="{{ current_project }}"></script> <script src="/static/autocomplete.js" project="{{ current_project }}"></script>
</body> </body>
</html> </html>

View file

@ -25,10 +25,10 @@
from sys import argv from sys import argv
from threading import Thread, Lock, Event, Condition from threading import Thread, Lock, Event, Condition
import lib import elixir.lib as lib
from lib import script, scriptLines from elixir.lib import script, scriptLines
import data import elixir.data as data
from data import PathList from elixir.data import PathList
from find_compatible_dts import FindCompatibleDTS from find_compatible_dts import FindCompatibleDTS
verbose = False verbose = False

1
wsgi.py Executable file
View file

@ -0,0 +1 @@
from elixir.web import application