Skip to content

Commit bdcdbbc

Browse files
authored
Merge pull request #5 from simple-repository/merge/internal-to-public
Merge the full history (warts and all), and move development of simple-repository-browser to github
2 parents 77f1942 + 7f9e11b commit bdcdbbc

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+460
-604
lines changed

.gitignore

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,20 @@
1+
simple_repository_browser/static_source/js/simple-repository-browser.project.js.LICENSE.txt
2+
simple_repository_browser/static_source/js/simple-repository-browser.core.js.LICENSE.txt
3+
simple_repository_browser/static_source/js/simple-repository-browser.core.js
4+
simple_repository_browser/static_source/js/simple-repository-browser.project.js
5+
6+
*/_version.py
7+
node_modules
18
*.egg-info
9+
venv
10+
*.sqlite
11+
cache
12+
logs
13+
14+
15+
__pycache__
16+
217
.idea
3-
simple_repository_browser/_version.py
4-
simple_repository_browser/static/js
5-
javascript/node_modules
18+
19+
build/
20+
dist/

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,4 @@ repos:
2525
- id: flake8
2626
args:
2727
- "--max-line-length=100"
28-
- '--ignore=E501,E226'
28+
- '--ignore=E501,E226,W503,E402'

javascript/scss/app.scss

Lines changed: 0 additions & 142 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
@import "variables";
2-
31
// Limit the width as seen on pypi.
42
$container-max-widths: (
53
sm: 540px,
@@ -10,143 +8,3 @@ $container-max-widths: (
108
);
119

1210
@import "~bootstrap/scss/bootstrap";
13-
14-
.top-nav {
15-
background: $base-color;
16-
}
17-
18-
.nav-link {
19-
color: white;
20-
}
21-
22-
.nav-link:hover, .nav-link:focus {
23-
color: white;
24-
}
25-
26-
.navbar-brand {
27-
font-size: xx-large;
28-
color: white;
29-
font-weight: bolder;
30-
}
31-
.navbar-brand:hover {
32-
text-decoration: none;
33-
color: white;
34-
}
35-
36-
.jumbo-banner {
37-
background: $base-color2;
38-
color: white;
39-
padding: 0px;
40-
margin: 0px;
41-
}
42-
43-
.jumbo-separator {
44-
background-color: #ececec;
45-
color: #464646;
46-
border-bottom: 1px solid #d3d3d3;
47-
padding: 1em;
48-
margin-bottom: 1em;
49-
}
50-
51-
52-
a:hover, a:visited, a:link, a:active
53-
{
54-
text-decoration: none;
55-
}
56-
57-
58-
.btn-link {
59-
text-decoration: none;
60-
}
61-
62-
nav a:hover {
63-
text-decoration: underline;
64-
}
65-
66-
.pip-command {
67-
font-family: Source Code Pro, monospace;
68-
font-weight: 500;
69-
font-size: 1.2rem;
70-
background-color: rgba(0, 0, 0, .15);
71-
padding: 8px;
72-
border: 1px dotted hsla(0, 0%, 100%, .4);
73-
line-height: 30px;
74-
white-space: nowrap; // Long pip commands shouldn't wrap
75-
}
76-
77-
.pip-command a, .pip-command a:hover {
78-
color: white;
79-
}
80-
81-
.listing-icon {
82-
padding: 0 1em 0 0.5em;
83-
}
84-
85-
footer {
86-
background-color: $base-color;
87-
color: white;
88-
padding: 2em;
89-
}
90-
91-
footer.text-muted.mt-auto {
92-
color: white !important;
93-
margin-top: 2em !important;
94-
}
95-
96-
.btn-primary, .btn-primary:hover, .btn-primary:active, .btn-primary:focus {
97-
background-color: $base-color;
98-
border-color: $base-color;
99-
box-shadow: none; // On focus otherwise
100-
}
101-
102-
dev#page-content a:hover {
103-
color: $base-color;
104-
}
105-
106-
107-
a.status-badge {
108-
font-weight: 400;
109-
line-height: 1.4;
110-
border: 1px solid hsla(0, 0%, 100%, .5);
111-
border-radius: 3px;
112-
box-sizing: border-box;
113-
display: inline-flex;
114-
font-size: .8rem;
115-
min-height: 40px;
116-
padding: 12px;
117-
color: #fff;
118-
}
119-
120-
a.status-badge--bad {
121-
background-color: #d52d40;
122-
}
123-
124-
a.status-badge--good {
125-
background-color: #148024;
126-
}
127-
128-
img {
129-
max-width: 100%;
130-
}
131-
132-
133-
.link-unstyled, .link-unstyled:link, .link-unstyled:hover {
134-
color: inherit;
135-
text-decoration: inherit;
136-
}
137-
138-
139-
.base-color {
140-
background: $base-color !important;
141-
color: white !important;
142-
}
143-
144-
.secondary-color {
145-
background: $base-color2 !important;
146-
color: white !important;
147-
}
148-
149-
150-
.m-1em {
151-
margin: 1em;
152-
}
Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,8 @@
1-
/*
2-
* Copyright (C) 2023, CERN
3-
* This software is distributed under the terms of the MIT
4-
* licence, copied verbatim in the file "LICENSE".
5-
* In applying this license, CERN does not waive the privileges and immunities
6-
* granted to it by virtue of its status as Intergovernmental Organization
7-
* or submit itself to any jurisdiction.
8-
*/
1+
import './scss/app.scss';
2+
3+
import 'popper.js'; // Needed for bootstrap tooltips.
94

105
import 'bootstrap';
116

12-
import './scss/app.scss';
7+
// Expose bootstrap, so that we can initiate some events with it (like enabling tooltips).
8+
window.bootstrap = require('bootstrap/dist/js/bootstrap.bundle.js');

javascript/simple-repository-browser.project.js

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,3 @@
1-
/*
2-
* Copyright (C) 2023, CERN
3-
* This software is distributed under the terms of the MIT
4-
* licence, copied verbatim in the file "LICENSE".
5-
* In applying this license, CERN does not waive the privileges and immunities
6-
* granted to it by virtue of its status as Intergovernmental Organization
7-
* or submit itself to any jurisdiction.
8-
*/
9-
101
import $ from 'jquery';
112
window.jQuery = $;
123
window.$ = $;

javascript/webpack.config.js

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,3 @@
1-
/*
2-
* Copyright (C) 2023, CERN
3-
* This software is distributed under the terms of the MIT
4-
* licence, copied verbatim in the file "LICENSE".
5-
* In applying this license, CERN does not waive the privileges and immunities
6-
* granted to it by virtue of its status as Intergovernmental Organization
7-
* or submit itself to any jurisdiction.
8-
*/
9-
101
const path = require('path');
112

123
module.exports = {
@@ -16,7 +7,7 @@ module.exports = {
167
},
178
output: {
189
filename: '[name]',
19-
path: path.resolve(__dirname, '../simple_repository_browser/static/js/')
10+
path: path.resolve(__dirname, '../simple_repository_browser/static_source/js/')
2011
},
2112
resolve: {
2213
extensions: [".ts", ".js"],

pyproject.toml

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,12 @@ dependencies = [
2929
"markupsafe",
3030
"packaging",
3131
"parsley",
32-
"pkginfo",
32+
"pkginfo>=1.12",
3333
"readme-renderer[md]",
34-
"simple-repository>=0.6",
34+
"simple-repository~=0.9",
3535
"uvicorn",
36+
"authlib",
37+
"starlette[full]",
3638
]
3739
readme = "README.md"
3840

@@ -50,14 +52,23 @@ dev = [
5052
[project.scripts]
5153
simple-repository-browser = "simple_repository_browser.__main__:main"
5254

53-
5455
[tool.setuptools_scm]
5556
version_file = "simple_repository_browser/_version.py"
5657

58+
[tool.isort]
59+
multi_line_output = 3
60+
include_trailing_comma = true
61+
force_grid_wrap = 0
62+
use_parentheses = true
63+
ensure_newline_before_comments = true
64+
line_length = 88
65+
force_sort_within_sections = true
66+
5767
[[tool.mypy.overrides]]
5868
module = [
5969
"diskcache",
6070
"parsley",
71+
"setuptools",
6172
]
6273
ignore_missing_imports = true
6374

setup.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import pathlib
2+
import sys
3+
4+
from setuptools import setup
5+
6+
sys.path.insert(0, 'simple_repository_browser')
7+
from _compile_static import compile_static_files # type: ignore[import-not-found]
8+
9+
root = pathlib.Path(__file__).parent
10+
11+
static_dir = root / 'simple_repository_browser' / 'static_source'
12+
dest = root / 'simple_repository_browser' / 'static'
13+
14+
compile_static_files(destination=dest, sources=[static_dir])
15+
16+
setup()

simple_repository_browser/__main__.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
import argparse
22
import logging
33
import os
4-
import typing
54
from pathlib import Path
5+
import typing
66

77
import uvicorn
8+
from uvicorn.config import LOGGING_CONFIG
89

910
from . import __version__
1011
from ._app import AppBuilder
@@ -47,10 +48,19 @@ def handler(args: typing.Any) -> None:
4748
browser_version=__version__,
4849
).create_app()
4950

51+
log_conf = LOGGING_CONFIG.copy()
52+
log_conf["formatters"]["default"]["fmt"] = "%(asctime)s [%(name)s] %(levelprefix)s %(message)s"
53+
log_conf["formatters"]["access"][
54+
"fmt"
55+
] = '%(asctime)s [%(name)s] %(levelprefix)s %(client_addr)s - "%(request_line)s" %(status_code)s'
56+
5057
uvicorn.run(
5158
app=app,
5259
host=args.host,
5360
port=args.port,
61+
proxy_headers=True,
62+
forwarded_allow_ips="*",
63+
log_config=log_conf,
5464
)
5565

5666

simple_repository_browser/_app.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import logging
2+
from pathlib import Path
23
import sqlite3
34
import typing
4-
from pathlib import Path
55
from urllib.parse import urlparse
66

77
import aiosqlite
@@ -107,7 +107,7 @@ async def catch_exceptions_middleware(request: fastapi.Request, call_next):
107107
return app
108108

109109
def create_view(self) -> view.View:
110-
return view.View(self.template_paths, self.browser_version)
110+
return view.View(self.template_paths, self.browser_version, static_files_path=self.static_files_path)
111111

112112
def create_crawler(self, http_client: httpx.AsyncClient, source: SimpleRepository) -> crawler.Crawler:
113113
return crawler.Crawler(

0 commit comments

Comments
 (0)