Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Leonidas Spyropoulos
aurweb
Commits
748499bb
Commit
748499bb
authored
Jun 28, 2021
by
Leonidas Spyropoulos
Browse files
WIP2
Signed-off-by:
Leonidas Spyropoulos
<
artafinde@gmail.com
>
parent
aef76c98
Pipeline
#9154
passed with stage
in 3 minutes and 44 seconds
Changes
6
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
.gitignore
View file @
748499bb
...
...
@@ -23,3 +23,4 @@ fastapi_aw/
/build/
/dist/
/aurweb.egg-info/
venv
aurweb/routers/packages.py
View file @
748499bb
...
...
@@ -6,6 +6,7 @@ from fastapi.responses import HTMLResponse
from
aurweb
import
db
from
aurweb.models.package
import
Package
from
aurweb.models.package_base
import
PackageBase
from
aurweb.models.package_keyword
import
PackageKeyword
from
aurweb.templates
import
make_variable_context
,
render_template
router
=
APIRouter
()
...
...
@@ -54,3 +55,18 @@ async def package_single(request: Request, package: str,
context
[
"q"
]
=
'&'
.
join
([
f
"coff=
{
current_off
}
"
,
f
"poff=
{
past_off
}
"
])
return
render_template
(
request
,
"package/packages.html"
,
context
)
@
router
.
get
(
"/pkgbase/{package}"
)
async
def
package_base
(
request
:
Request
,
package
:
str
):
context
=
await
make_variable_context
(
request
,
"Packages"
)
packages
=
db
.
query
(
Package
).
join
(
PackageBase
).
filter
(
PackageBase
.
Name
==
package
).
outerjoin
(
PackageKeyword
)
if
not
packages
:
raise
HTTPException
(
status_code
=
int
(
HTTPStatus
.
NOT_FOUND
))
context
[
"pkgbase"
]
=
packages
.
first
().
PackageBase
context
[
"packages_count"
]
=
packages
.
count
()
context
[
"packages"
]
=
packages
.
all
()
return
render_template
(
request
,
"package/packages.html"
,
context
)
templates/package/packages.html
View file @
748499bb
...
...
@@ -5,15 +5,20 @@
{% include "partials/packages/search.html" %}
{% if pkglist %}
{% set off = current_off %}
{% set off_param = "coff" %}
{% set results = pkglist %}
{% set results_count = pkglist_count %}
{% set table_class = "pkglist-stats" %}
{% include "partials/packages/pkglist.html" %}
{% set off = current_off %}
{% set off_param = "coff" %}
{% set results = pkglist %}
{% set results_count = pkglist_count %}
{% set table_class = "pkglist-stats" %}
{% include "partials/packages/pkglist.html" %}
{% elif pkgbase %}
{% set results = pkgbase %}
{% set pkgbase_count = pkglist_count %}
{% set table_class = "pkglist-stats" %}
{% include "partials/packages/pkgbase.html" %}
{% else %}
{% set result = package %}
{% include "partials/packages/pkgdetails.html" %}
{% set result = package %}
{% include "partials/packages/pkgdetails.html" %}
{% endif %}
...
...
templates/partials/packages/package_actions.html
0 → 100644
View file @
748499bb
<!--
This partial requires pkgname to render
-->
<div
id=
"detailslinks"
class=
"listing"
>
<div
id=
"actionlist"
>
<h4>
Package Actions
</h4>
<ul
class=
"small"
>
<li>
<a
href=
"/cgit/aur.git/tree/PKGBUILD?h={{ pkgname }}"
>
View PKGBUILD
</a>
/
<a
href=
"/cgit/aur.git/log/?h={{ pkgname }}"
>
View Changes
</a>
</li>
<li><a
href=
"/cgit/aur.git/snapshot/{{ pkgname }}.tar.gz"
>
Download snapshot
</a>
<li><a
href=
"https://wiki.archlinux.org/title/Special:Search?search={{ pkgname }}"
>
Search wiki
</a></li>
<li><span
class=
"flagged"
></span></li>
<li><a
href=
"/pkgbase/{{ pkgname }}/flag/"
>
Flag package out-of-date
</a></li>
<li>
<form
action=
"/pkgbase/{{ pkgname }}/vote/"
method=
"post"
><input
type=
"submit"
class=
"button text-button"
name=
"do_Vote"
value=
"Vote for this package"
/></form>
</li>
<li>
<form
action=
"/pkgbase/{{ pkgname }}/unnotify/"
method=
"post"
><input
type=
"submit"
class=
"button text-button"
name=
"do_UnNotify"
value=
"Disable notifications"
/>
</form>
</li>
<li><a
href=
"/pkgbase/{{ pkgname }}/comaintainers/"
>
Manage Co-Maintainers
</a></li>
<li><span
class=
"flagged"
></span></li>
<li><a
href=
"/pkgbase/{{ pkgname }}/request/"
>
Submit Request
</a></li>
<li><a
href=
"/pkgbase/{{ pkgname }}/delete/"
>
Delete Package
</a></li>
<li><a
href=
"/pkgbase/{{ pkgname }}/merge/"
>
Merge Package
</a></li>
<li>
<form
action=
"/pkgbase/{{ pkgname }}/disown/"
method=
"post"
><input
type=
"submit"
class=
"button text-button"
name=
"do_Disown"
value=
"Disown Package"
/></form>
</li>
</ul>
</div>
</div>
templates/partials/packages/pkgbase.html
0 → 100644
View file @
748499bb
<div
id=
"pkgdetails"
class=
"box"
>
<h2>
Package Base Details: {{ pkgbase.Name }}
</h2>
{% set pkgname = "result.Name" %}
{% include "partials/packages/package_actions.html" %}
<table
id=
"pkginfo"
>
<tr>
<th>
Git Clone URL:
</th>
<td>
<a
class=
"copy"
href=
"https://localhost:8443/cgit/aur.git -b {{ pkgbase.Name }}"
>
https://localhost:8443/cgit/aur.git -b {{ pkgbase.Name }}
</a>
(read-only, click to copy)
{% if request.user.is_authenticated() and pkgbase.Maintainer.Username == request.user.Username %}
<br
/>
<a
class=
"copy"
href=
"ssh://aur@localhost:2222/{{ pkgbase.Name }}.git"
>
ssh://aur@localhost:2222/{{ pkgbase.Name }}.git
</a>
(click to copy)
{% endif %}
</td>
</tr>
<tr>
<th>
Keywords:
</th>
{% if request.user.is_authenticated() and pkgbase.Maintainer.Username == request.user.Username %}
<td>
<form
method=
"post"
action=
"/pkgbase/{{ pkgbase.Name }}/"
>
<div>
<input
type=
"hidden"
name=
"action"
value=
"do_SetKeywords"
/>
<input
type=
"text"
name=
"keywords"
value=
"{{ pkgbase.keywords | join(' ', attribute='Keyword') }}"
/>
<input
type=
"submit"
value=
"Update"
/>
</div>
</form>
</td>
{% else %}
<td>
{% for item in pkgbase.keywords %}
<a
class=
"keyword"
href=
"/packages/?K={{ item.Keyword }}&SB=p"
>
{{ item.Keyword }}
</a>
{% endfor %}
</td>
{% endif %}
</tr>
<tr>
<th>
Submitter:
</th>
<td>
{{ pkgbase.Submitter.Username | default("None") }}
</td>
</tr>
<tr>
<th>
Maintainer:
</th>
<td>
{{ pkgbase.Maintainer.Username | default("None") }}
</td>
</tr>
<tr>
<th>
Last Packager:
</th>
<td>
{{ pkgbase.Packager.Username | default("None") }}
</td>
</tr>
<tr>
<th>
Votes:
</th>
<td>
{{ pkgbase.NumVotes }}
</td>
</tr>
<tr>
<th>
Popularity:
</th>
<td>
{{ '%0.2f' % pkgbase.Popularity | float }}
</td>
</tr>
<tr>
{% set submitted = pkgbase.SubmittedTS | dt | as_timezone(timezone) %}
<th>
First Submitted:
</th>
<td>
{{ "%s" | tr | format(submitted.strftime("%Y-%m-%d %H:%M")) }}
</td>
</tr>
<tr>
<th>
Last Updated:
</th>
{% set updated = pkgbase.ModifiedTS | dt | as_timezone(timezone) %}
<td>
{{ "%s" | tr | format(updated.strftime("%Y-%m-%d %H:%M")) }}
</td>
</tr>
</table>
<div
id=
"metadata"
>
<div
id=
"pkgs"
class=
"listing"
>
<h3>
Packages ({{ packages_count }})
</h3>
<ul>
{% for result in packages %}
<li><a
href=
"/packages/{{ result.Name }}/"
title=
"View packages details for {{ result.Name }}"
>
{{ result.Name }}
</a></li>
{% endfor %}
</ul>
</div>
</div>
</div>
web/lib/DB.class.php
View file @
748499bb
...
...
@@ -20,15 +20,23 @@ class DB {
$backend
=
config_get
(
'database'
,
'backend'
);
$host
=
config_get
(
'database'
,
'host'
);
$socket
=
config_get
(
'database'
,
'socket'
);
$port
=
config_get
(
'database'
,
'port'
);
$name
=
config_get
(
'database'
,
'name'
);
$user
=
config_get
(
'database'
,
'user'
);
$password
=
config_get
(
'database'
,
'password'
);
if
(
$backend
==
"mysql"
)
{
$dsn
=
$backend
.
':host='
.
$host
.
';unix_socket='
.
$socket
.
';dbname='
.
$name
;
if
(
$port
!=
''
)
{
$dsn
=
$backend
.
':host='
.
$host
.
';port='
.
$port
.
';dbname='
.
$name
;
}
else
{
$dsn
=
$backend
.
':host='
.
$host
.
';unix_socket='
.
$socket
.
';dbname='
.
$name
;
}
self
::
$dbh
=
new
PDO
(
$dsn
,
$user
,
$password
);
self
::
$dbh
->
exec
(
"SET NAMES 'utf8' COLLATE 'utf8_general_ci';"
);
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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