Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
APK Vitrine
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Max Rees
APK Vitrine
Commits
b619ec26
Commit
b619ec26
authored
Dec 25, 2020
by
Max Rees
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Change default section name in config
parent
4d94475e
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
21 additions
and
15 deletions
+21
-15
apkvitrine/__init__.py
apkvitrine/__init__.py
+3
-0
apkvitrine/cgi.py
apkvitrine/cgi.py
+17
-14
config.ini.in
config.ini.in
+1
-1
No files found.
apkvitrine/__init__.py
View file @
b619ec26
...
...
@@ -5,6 +5,8 @@ import collections # defaultdict
import
configparser
# ConfigParser
from
pathlib
import
Path
DEFAULT
=
"@default"
def
_config_map
(
s
):
d
=
{}
for
i
in
s
.
strip
().
splitlines
():
...
...
@@ -32,6 +34,7 @@ def _ConfigParser(**kwargs):
"map"
:
_config_map
,
"maplist"
:
_config_maplist
,
},
default_section
=
DEFAULT
,
**
kwargs
,
)
parser
.
BOOLEAN_STATES
=
{
"true"
:
True
,
"false"
:
False
}
...
...
apkvitrine/cgi.py
View file @
b619ec26
...
...
@@ -14,10 +14,12 @@ import cgitb # enable
cgitb
.
enable
()
import
jinja2
# Environment, FileSystemBytecodeCache, PackageLoader
# Markup
SRCDIR
=
Path
(
__file__
).
parent
.
parent
CACHE
=
Path
(
"/var/tmp/apkvitrine"
)
sys
.
path
.
insert
(
0
,
str
(
SRCDIR
))
import
apkvitrine
# DEFAULT
import
apkvitrine.models
# build_search, Pkg
ENV
=
jinja2
.
Environment
(
...
...
@@ -117,8 +119,7 @@ def pkg_versions(conf, db, pkgs):
return
versions
,
sorted
(
repos
),
sorted
(
arches
)
def
page_branches
(
path
,
_query
):
conf
=
apkvitrine
.
config
()
def
page_branches
(
conf
,
path
,
_query
):
branches
=
list
(
conf
.
sections
())
for
i
,
branch
in
enumerate
(
branches
):
...
...
@@ -128,18 +129,18 @@ def page_branches(path, _query):
branches
=
[
i
for
i
in
branches
if
i
]
ok
()
response
=
ENV
.
get_template
(
"branches.tmpl"
).
render
(
conf
=
conf
[
"DEFAULT"
],
conf
=
conf
[
apkvitrine
.
DEFAULT
],
branches
=
branches
,
)
print
(
response
)
save_cache
(
path
,
response
)
def
page_branch
(
path
,
query
):
def
page_branch
(
conf
,
path
,
query
):
branch
=
path
.
parts
[
0
]
db
=
init_db
(
branch
)
if
not
db
:
return
conf
=
apkvitrine
.
config
(
branch
)
conf
=
conf
[
branch
]
pkgs
=
pkg_paginate
(
conf
,
query
,
db
,
"""
SELECT * FROM packages
...
...
@@ -161,12 +162,12 @@ def page_branch(path, query):
print
(
response
)
save_cache
(
path
,
response
)
def
page_package
(
path
,
_query
):
def
page_package
(
conf
,
path
,
_query
):
branch
,
name
=
path
.
parts
db
=
init_db
(
branch
)
if
not
db
:
return
conf
=
apkvitrine
.
config
(
branch
)
conf
=
conf
[
branch
]
db
.
row_factory
=
apkvitrine
.
models
.
Pkg
.
factory
pkg
=
db
.
execute
(
"""
...
...
@@ -213,12 +214,12 @@ _BORING_TOGGLES = (
"sort"
,
)
def
page_search
(
path
,
query
):
def
page_search
(
conf
,
path
,
query
):
branch
=
path
.
parts
[
0
]
db
=
init_db
(
branch
)
if
not
db
:
return
conf
=
apkvitrine
.
config
(
branch
)
conf
=
conf
[
branch
]
maints
=
set
(
db
.
execute
(
"""
SELECT DISTINCT(maintainer) FROM packages
...
...
@@ -269,8 +270,8 @@ def page_search(path, query):
if
not
searched
:
save_cache
(
path
,
response
)
def
page_home
(
_path
,
_query
):
conf
=
apkvitrine
.
config
(
"DEFAULT"
)
def
page_home
(
conf
,
_path
,
_query
):
conf
=
conf
[
apkvitrine
.
DEFAULT
]
location
=
ENV
.
globals
[
"base"
]
+
"/"
+
conf
[
"default_version"
]
response
(
http
.
HTTPStatus
.
TEMPORARY_REDIRECT
,
...
...
@@ -280,7 +281,7 @@ def page_home(_path, _query):
ROUTES
=
{
"-/versions"
:
page_branches
,
"*/-/search"
:
page_search
,
"*/*/*"
:
lambda
_path
,
_query
:
notfound
(),
"*/*/*"
:
lambda
_
conf
,
_
path
,
_query
:
notfound
(),
"*/*"
:
page_package
,
"*"
:
page_branch
,
"."
:
page_home
,
...
...
@@ -307,13 +308,15 @@ if __name__ == "__main__":
ok
(
headers
=
{
"X-Sendfile"
:
cache
})
sys
.
exit
(
0
)
conf
=
apkvitrine
.
config
()
for
route
,
handler
in
ROUTES
.
items
():
if
route
==
"."
:
if
route
==
str
(
path
):
handler
(
path
,
query
)
handler
(
conf
,
path
,
query
)
break
elif
path
.
match
(
route
):
handler
(
path
,
query
)
handler
(
conf
,
path
,
query
)
break
else
:
notfound
()
config.ini.in
View file @
b619ec26
[
DEFAULT
]
[
@default
]
; =========================================================
; *****************
; * Main settings *
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment