Commit 748499bb authored by Leonidas Spyropoulos's avatar Leonidas Spyropoulos
Browse files
parent aef76c98
Pipeline #9154 passed with stage
in 3 minutes and 44 seconds
...@@ -23,3 +23,4 @@ fastapi_aw/ ...@@ -23,3 +23,4 @@ fastapi_aw/
/build/ /build/
/dist/ /dist/
/aurweb.egg-info/ /aurweb.egg-info/
venv
...@@ -6,6 +6,7 @@ from fastapi.responses import HTMLResponse ...@@ -6,6 +6,7 @@ from fastapi.responses import HTMLResponse
from aurweb import db from aurweb import db
from aurweb.models.package import Package from aurweb.models.package import Package
from aurweb.models.package_base import PackageBase from aurweb.models.package_base import PackageBase
from aurweb.models.package_keyword import PackageKeyword
from aurweb.templates import make_variable_context, render_template from aurweb.templates import make_variable_context, render_template
router = APIRouter() router = APIRouter()
...@@ -54,3 +55,18 @@ async def package_single(request: Request, package: str, ...@@ -54,3 +55,18 @@ async def package_single(request: Request, package: str,
context["q"] = '&'.join([f"coff={current_off}", f"poff={past_off}"]) context["q"] = '&'.join([f"coff={current_off}", f"poff={past_off}"])
return render_template(request, "package/packages.html", context) 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)
...@@ -5,15 +5,20 @@ ...@@ -5,15 +5,20 @@
{% include "partials/packages/search.html" %} {% include "partials/packages/search.html" %}
{% if pkglist %} {% if pkglist %}
{% set off = current_off %} {% set off = current_off %}
{% set off_param = "coff" %} {% set off_param = "coff" %}
{% set results = pkglist %} {% set results = pkglist %}
{% set results_count = pkglist_count %} {% set results_count = pkglist_count %}
{% set table_class = "pkglist-stats" %} {% set table_class = "pkglist-stats" %}
{% include "partials/packages/pkglist.html" %} {% 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 %} {% else %}
{% set result = package %} {% set result = package %}
{% include "partials/packages/pkgdetails.html" %} {% include "partials/packages/pkgdetails.html" %}
{% endif %} {% endif %}
......
<!--
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>
<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 }}&amp;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>
...@@ -20,15 +20,23 @@ class DB { ...@@ -20,15 +20,23 @@ class DB {
$backend = config_get('database', 'backend'); $backend = config_get('database', 'backend');
$host = config_get('database', 'host'); $host = config_get('database', 'host');
$socket = config_get('database', 'socket'); $socket = config_get('database', 'socket');
$port = config_get('database', 'port');
$name = config_get('database', 'name'); $name = config_get('database', 'name');
$user = config_get('database', 'user'); $user = config_get('database', 'user');
$password = config_get('database', 'password'); $password = config_get('database', 'password');
if ($backend == "mysql") { if ($backend == "mysql") {
if ($port != '') {
$dsn = $backend .
':host=' . $host .
';port=' . $port .
';dbname=' . $name;
} else {
$dsn = $backend . $dsn = $backend .
':host=' . $host . ':host=' . $host .
';unix_socket=' . $socket . ';unix_socket=' . $socket .
';dbname=' . $name; ';dbname=' . $name;
}
self::$dbh = new PDO($dsn, $user, $password); self::$dbh = new PDO($dsn, $user, $password);
self::$dbh->exec("SET NAMES 'utf8' COLLATE 'utf8_general_ci';"); self::$dbh->exec("SET NAMES 'utf8' COLLATE 'utf8_general_ci';");
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment