13 Commits

Author SHA1 Message Date
3cdb4cbd67 Merge pull request 'feat(#14): Add packager to details page' (#21) from dev-0.1.4 into master
Reviewed-on: artixweb/artixweb_packages#21
Reviewed-by: nikolar <nikolar@artixlinux.org>
2024-06-24 21:50:00 +02:00
7cfa02ecbd chore: add comment for format_packager function 2024-06-20 17:37:42 -05:00
31e4580c91 feat(#14): Add packager to details page 2024-06-20 17:33:53 -05:00
5dac79b54a Back to development: 0.1.4 2024-06-20 17:30:50 -05:00
13fea4748e Merge pull request 'feat: ignore repo URL stored in database' (#19) from repo-url-fix into master
Reviewed-on: artixweb/artixweb_packages#19
2024-06-18 01:36:53 +02:00
84f51bd2f3 feat: ignore repo URL stored in database 2024-06-17 18:06:19 -05:00
9eec2a2671 Back to development: 0.1.3 2024-06-17 18:05:30 -05:00
8e0d076e67 Merge pull request 'fix(#13): Show empty results instead of 404' (#17) from no-results into master
Reviewed-on: artixweb/artixweb_packages#17
Reviewed-by: nikolar <nikolar@artixlinux.org>
2024-06-15 00:50:42 +02:00
31d3cb5f27 fix(#13): Show empty results instead of 404 2024-06-14 12:16:59 -05:00
a1e748c0a9 Merge pull request 'feat: allow user to choose how links behave' (#16) from remove-target-blank into master
Reviewed-on: artixweb/artixweb_packages#16
2024-06-14 00:46:09 +02:00
4f2c810a2f feat: allow user to choose how links behave 2024-06-13 17:43:18 -05:00
3ce6daea15 Merge pull request 'feat: drop universe, add gremlins repos' (#12) from repos-update into master
Reviewed-on: artixweb/artixweb_packages#12
Reviewed-by: artoo <artoo@artixlinux.org>
Reviewed-by: nikolar <nikolar@artixlinux.org>
2024-06-14 00:17:31 +02:00
16fd963c8d use printf instead of echo 2024-06-13 17:09:44 -05:00
8 changed files with 51 additions and 42 deletions

6
Cargo.lock generated
View File

@@ -410,7 +410,7 @@ dependencies = [
[[package]]
name = "artix-gitea"
version = "0.1.2"
version = "0.1.4"
dependencies = [
"actix-web",
"awc",
@@ -420,7 +420,7 @@ dependencies = [
[[package]]
name = "artix-pkglib"
version = "0.1.2"
version = "0.1.4"
dependencies = [
"alpm",
"alpm-utils",
@@ -430,7 +430,7 @@ dependencies = [
[[package]]
name = "artixweb_packages"
version = "0.1.2"
version = "0.1.4"
dependencies = [
"actix-files",
"actix-identity",

View File

@@ -46,11 +46,11 @@ RUN pacman -Sy --noconfirm postgresql-libs \
&& set -x \
&& pacman -Syu --noconfirm \
&& pacman -Scc --noconfirm \
&& printf "\n[lib32]\nInclude = /etc/pacman.d/mirrorlist" >> /etc/pacman.conf \
&& printf "\n[system-gremlins]\nInclude = /etc/pacman.d/mirrorlist" >> /etc/pacman.conf \
&& printf "\n[world-gremlins]\nInclude = /etc/pacman.d/mirrorlist" >> /etc/pacman.conf \
&& printf "\n[galaxy-gremlins]\nInclude = /etc/pacman.d/mirrorlist" >> /etc/pacman.conf \
&& printf "\n[lib32-gremlins]\nInclude = /etc/pacman.d/mirrorlist" >> /etc/pacman.conf \
&& printf "[lib32]\nInclude = /etc/pacman.d/mirrorlist\n" >> /etc/pacman.conf \
&& printf "[system-gremlins]\nInclude = /etc/pacman.d/mirrorlist\n" >> /etc/pacman.conf \
&& printf "[world-gremlins]\nInclude = /etc/pacman.d/mirrorlist\n" >> /etc/pacman.conf \
&& printf "[galaxy-gremlins]\nInclude = /etc/pacman.d/mirrorlist\n" >> /etc/pacman.conf \
&& printf "[lib32-gremlins]\nInclude = /etc/pacman.d/mirrorlist\n" >> /etc/pacman.conf \
&& pacman -Sy --noconfirm
WORKDIR /usr/share/artixweb_packages

View File

@@ -8,7 +8,7 @@ homepage = "https://packages.artixlinux.org"
keywords = ["artix", "packages", "gitea"]
license = "MIT OR Apache-2.0"
edition = "2021"
version = "0.1.2"
version = "0.1.4"
[lib]
name = "artix_gitea"

View File

@@ -8,7 +8,7 @@ homepage = "https://packages.artixlinux.org"
keywords = ["artix", "packages"]
license = "MIT OR Apache-2.0"
edition = "2021"
version = "0.1.2"
version = "0.1.4"
[lib]
name = "artix_pkglib"

View File

@@ -7,7 +7,7 @@ repository = "gitea.artixlinux.org/artix/artixweb_packages"
keywords = ["artix", "packages"]
license = "MIT OR Apache-2.0"
edition = "2021"
version = "0.1.2"
version = "0.1.4"
[[bin]]
name = "artixweb_packages"
@@ -15,8 +15,8 @@ test = false
bench = false
[dependencies]
artix-gitea = { path = "../artix-gitea", version = "=0.1.2" }
artix-pkglib = { path = "../artix-pkglib", version = "=0.1.2" }
artix-gitea = { path = "../artix-gitea", version = "=0.1.4" }
artix-pkglib = { path = "../artix-pkglib", version = "=0.1.4" }
actix-files = "0.6.0"
actix-identity = "0.4"

View File

@@ -121,33 +121,31 @@ pub async fn index(
repos.join(":")
};
let s = if let Ok(result) =
let mut s = PackagesNavigation {
user_email,
packages: Vec::new(),
repos,
total: 0,
query: query_url.join("&"),
total_pages: 1,
generation_time: 0,
offset,
limit
};
if let Ok(result) =
get_packages_inner(&repos_criteria, limit, offset, search_criteria, Some(&pool)).await
{
PackagesNavigation {
user_email,
packages: result.0,
repos,
total: result.1,
query: query_url.join("&"),
total_pages: if limit > 0 {
(result.1 as f64 / limit as f64).ceil() as usize
} else {
1
},
generation_time: start_time.elapsed().as_millis(),
offset,
limit,
}
.render()
.unwrap()
} else {
return Ok(HttpResponse::NotFound()
.content_type("text/html")
.body("<html><body>404 - Page Not Found!</body></html>"));
};
s.packages = result.0;
s.total = result.1;
s.total_pages = if limit > 0 {
(result.1 as f64 / limit as f64).ceil() as usize
} else {
1
};
}
s.generation_time = start_time.elapsed().as_millis();
Ok(HttpResponse::Ok().content_type("text/html").body(s))
Ok(HttpResponse::Ok().content_type("text/html").body(s.render().unwrap()))
}
#[allow(clippy::unnecessary_wraps)]

View File

@@ -110,6 +110,7 @@ pub(crate) struct ResponseDetail {
pub required_by: Vec<String>,
pub contents: Vec<String>,
pub maintainers: Vec<String>,
pub packaged_by: String,
pub flagged: bool,
pub flagged_on: i64,
pub flagged_by: Vec<String>,
@@ -457,7 +458,7 @@ pub(crate) async fn get_packages_details_inner(
.iter()
.map(std::string::ToString::to_string)
.collect(),
gitea_url: String::new(),
gitea_url: format!("{}/packages/{}", SETTINGS.gitea_url, pkg.name().to_string()),
dependencies: get_depends_from_package(
&handle,
pkg.arch().unwrap_or("any"),
@@ -506,6 +507,7 @@ pub(crate) async fn get_packages_details_inner(
pkg.replaces(),
&DependencyKind::Misc,
),
packaged_by: format_packager(pkg.packager().unwrap_or("").to_string()),
flagged: false,
flagged_on: 0,
flagged_by: Vec::new(),
@@ -517,7 +519,6 @@ pub(crate) async fn get_packages_details_inner(
web::block(move || get_package_metadata(&pkg_name_version, &pool)).await
{
result.last_updated = metadata.last_update.timestamp();
result.gitea_url = metadata.gitea_url;
result.flagged = metadata.flagged;
if let Some(flagged_on) = metadata.flag_on {
result.flagged_on = flagged_on.timestamp_millis();
@@ -566,6 +567,14 @@ pub(crate) async fn get_packages_details_inner(
Err(ArtixWebPackageError::NotFound)
}
// removes email address from the packager string
fn format_packager(mut input: String) -> String {
if let Some(pos) = input.find('<') {
input.truncate(pos - 1);
}
input
}
// adds package metadata into the local postgres database
fn add_package_metadata(metadata: &PackageMeta, pool: &web::Data<Pool>) {
use crate::schema::packages::dsl::packages;

View File

@@ -35,8 +35,8 @@
<h2>{{ pkg.package_name }}-{{ pkg.version }} {% if pkg.flagged %}(<span class="flagged">flagged</span>){% endif %}</h2>
<section role="action_panel" class="action_panel">
<h4>Actions Panel</h4>
<section role="action"><a href="{{ pkg.gitea_url }}" target="blank">View Package Sources</a></section>
<section role="action"><a href="{{ pkg.gitea_url }}/graph" target="blank">View Package Changes</a></section>
<section role="action"><a href="{{ pkg.gitea_url }}">View Package Sources</a></section>
<section role="action"><a href="{{ pkg.gitea_url }}/graph">View Package Changes</a></section>
{% if !pkg.flagged %}
<section role="action"><a href="/flag_package/{{ pkg.package_name }}/{{ pkg.version }}">Flag package out-of-date</a></section>
{% else %}
@@ -65,13 +65,15 @@
<section role="value">{{ pkg.replaces|provides_or_replaces }}</section>
{% endif %}
<section role="key">Upstream URL:</section>
<section role="value"><a href="{{ pkg.upstream_url }}" target="_blank">{{ pkg.upstream_url }}</a></section>
<section role="value"><a href="{{ pkg.upstream_url }}">{{ pkg.upstream_url }}</a></section>
<section role="key">Size:</section>
<section role="value">{{ pkg.size|human_readable }} MB</section>
<section role="key">Installed Size:</section>
<section role="value">{{ pkg.installed_size|human_readable }} MB</section>
<section role="key">Build Date:</section>
<section role="value">{{ pkg.build_date|show_date }}</section>
<section role="key">Packaged By:</section>
<section role="value">{{ pkg.packaged_by }}</section>
{% if pkg.flagged && !pkg.flagged_by.is_empty() %}
<section role="key">Flagged By:</section>
<section role="value">{{ pkg.flagged_by|join(", ") }}</section>