Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/pages.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ jobs:
- run: rm package.json pnpm-lock.yaml

- name: Publish to Cloudflare Pages
if: "github.repository_owner == 'NuschtOS'"
if: github.event_name == 'push'
uses: cloudflare/wrangler-action@v4
with:
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
Expand Down
2 changes: 1 addition & 1 deletion nix/frontend.nix
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ stdenv.mkDerivation (finalAttrs: {
strictDeps = true;

postPatch = ''
substituteInPlace src/index.html \
substituteInPlace src/index.html public/opensearch-options.xml public/opensearch-packages.xml \
--replace-fail '##TITLE##' ${lib.escapeShellArg config.title}

# remove development files
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"@angular/common": "^22.0.0",
"@angular/compiler": "^22.0.0",
"@angular/core": "^22.0.0",
"@angular/cdk": "^22.0.0",
"@angular/forms": "^22.0.0",
"@angular/platform-browser": "^22.0.0",
"@angular/router": "^22.0.0",
Expand Down
8 changes: 8 additions & 0 deletions public/opensearch-options.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<OpenSearchDescription xmlns="http://a9.com/-/spec/opensearch/1.1/">
<ShortName>##TITLE## - Options</ShortName>
<Description>##TITLE## options search</Description>
<InputEncoding>UTF-8</InputEncoding>
<Image width="16" height="16" type="image/x-icon">favicon.ico</Image>
<Url type="text/html" template="./options?query={searchTerms}" />
</OpenSearchDescription>
8 changes: 8 additions & 0 deletions public/opensearch-packages.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<OpenSearchDescription xmlns="http://a9.com/-/spec/opensearch/1.1/">
<ShortName>##TITLE## - Packages</ShortName>
<Description>##TITLE## packages search</Description>
<InputEncoding>UTF-8</InputEncoding>
<Image width="16" height="16" type="image/x-icon">favicon.ico</Image>
<Url type="text/html" template="./packages?query={searchTerms}" />
</OpenSearchDescription>
18 changes: 18 additions & 0 deletions src/app/core/opensearch-link.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { CONFIG } from './config.domain';

export type OpenSearchType = 'options' | 'packages';

export function setOpenSearchLink(document: Document, type: OpenSearchType): void {
const existing = document.head.querySelector<HTMLLinkElement>('link[data-nuschtos-opensearch]');
const link = existing ?? document.head.appendChild(document.createElement('link'));

link.rel = 'search';
link.type = 'application/opensearchdescription+xml';
link.dataset['nuschtosOpensearch'] = 'true';
link.title = `${CONFIG.title} ${type === 'options' ? 'Options' : 'Packages'} Search`;
link.href = `${CONFIG.baseHref}opensearch-${type}.xml`;
}

export function clearOpenSearchLink(document: Document): void {
document.head.querySelector<HTMLLinkElement>('link[data-nuschtos-opensearch]')?.remove();
}
8 changes: 6 additions & 2 deletions src/app/pages/options/options-page.component.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import { ChangeDetectionStrategy, Component, Inject, LOCALE_ID, OnDestroy } from '@angular/core';
import { CONFIG } from '../../core/config.domain';
import { DOCUMENT } from '@angular/common';
import { OptionComponent } from '../../core/components/option/option.component';
import { OptionsService } from '../../core/data/options.service';
import { OptionsSearchComponent } from '../../core/components/search/search.component';
import { RouterLink } from '@angular/router';
import { AsyncPipe, DecimalPipe, formatNumber } from '@angular/common';
import { AsyncPipe, formatNumber } from '@angular/common';
import { BehaviorSubject, Subject, takeUntil } from 'rxjs';
import { clearOpenSearchLink, setOpenSearchLink } from '../../core/opensearch-link';

@Component({
selector: 'app-options',
Expand All @@ -27,15 +28,18 @@ export class OptionsPageComponent implements OnDestroy {

constructor(
protected readonly searchService: OptionsService,
@Inject(DOCUMENT) private readonly document: Document,
@Inject(LOCALE_ID) private readonly locale: string
) {
setOpenSearchLink(this.document, 'options');
this.searchService.getIndexSize()
.pipe(takeUntil(this.destroy$))
.subscribe(size => {
this.searchLabel$.next(`Search ${formatNumber(size ?? 0, this.locale)} options`);
});
}
ngOnDestroy(): void {
clearOpenSearchLink(this.document);
this.destroy$.next();
this.destroy$.complete();
}
Expand Down
5 changes: 5 additions & 0 deletions src/app/pages/packages/packages-page.component.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import { ChangeDetectionStrategy, Component, Inject, LOCALE_ID, OnDestroy } from '@angular/core';
import { DOCUMENT } from '@angular/common';
import { PackagesSearchComponent } from '../../core/components/search/search.component';
import { PackagesService } from '../../core/data/packages.service';
import { PackageComponent } from "../../core/components/package/package.component";
import { AsyncPipe, formatNumber } from '@angular/common';
import { BehaviorSubject, Subject, takeUntil } from 'rxjs';
import { clearOpenSearchLink, setOpenSearchLink } from '../../core/opensearch-link';

@Component({
selector: 'app-packages-page.component',
Expand All @@ -23,15 +25,18 @@ export class PackagesPageComponent implements OnDestroy {

constructor(
protected readonly searchService: PackagesService,
@Inject(DOCUMENT) private readonly document: Document,
@Inject(LOCALE_ID) private readonly locale: string
) {
setOpenSearchLink(this.document, 'packages');
this.searchService.getIndexSize()
.pipe(takeUntil(this.destroy$))
.subscribe(size => {
this.searchLabel$.next(`Search ${formatNumber(size ?? 0, this.locale)} packages`);
});
}
ngOnDestroy(): void {
clearOpenSearchLink(this.document);
this.destroy$.next();
this.destroy$.complete();
}
Expand Down