Compare commits

..

No commits in common. "edaf5f5c714fa73ef8b402b4d1fbd74db959299d" and "fdf16227d3c8aeadbd2859912b8d3886ef6c5f5b" have entirely different histories.

6 changed files with 23 additions and 48 deletions

View File

@ -1,4 +1,6 @@
RELAY_URLS=wss://nostr.kosmos.org,wss://nostr.x0f.org PORT=8000
BASE_URL=http://localhost:8000
HOME_RELAY_URL=wss://nostr.kosmos.org
LDAP_URL=ldap://10.1.1.116:389 LDAP_URL=ldap://10.1.1.116:389
LDAP_BIND_DN=uid=service,ou=kosmos.org,cn=applications,dc=kosmos,dc=org LDAP_BIND_DN=uid=service,ou=kosmos.org,cn=applications,dc=kosmos,dc=org
LDAP_PASSWORD=123456abcdef LDAP_PASSWORD=123456abcdef

View File

@ -108,8 +108,8 @@ main header .meta .name a {
text-decoration: none; text-decoration: none;
} }
main.profile-page { main .article-list .item {
margin-top: 6rem; margin-bottom: 3rem;
} }
main .article-list .item h3 { main .article-list .item h3 {
@ -120,16 +120,12 @@ main .article-list p {
margin-top: 0.5rem; margin-top: 0.5rem;
} }
main .article-list p.meta {
font-size: 1rem;
}
main article footer { main article footer {
margin-top: 5rem; margin-top: 5rem;
} }
.profile-page header { .profile-page .about {
margin-bottom: 2rem; margin-bottom: 3rem;
} }
/* Dropdown menu */ /* Dropdown menu */
@ -198,7 +194,7 @@ main article footer {
main { main {
max-width: 100%; max-width: 100%;
margin: 4rem 1rem 8rem 1rem !important; margin: 4rem 1rem 8rem 1rem;
} }
.profile-page h1 { .profile-page h1 {

View File

@ -10,18 +10,17 @@ let staticUsers;
try { try {
const yamlContent = await Deno.readTextFile(`${dirname}/users.yaml`); const yamlContent = await Deno.readTextFile(`${dirname}/users.yaml`);
staticUsers = parse(yamlContent); staticUsers = parse(yamlContent);
log(`Serving content for ${Object.keys(staticUsers).length} pubkeys from users.yaml`, "blue"); log("Static user config:", "blue");
log(Deno.inspect(staticUsers), "blue");
} catch { } catch {
staticUsers = {}; staticUsers = {};
log(`Could not find or parse a users.yaml config`, "yellow"); log(`Could not find or parse a "users.yaml" config`, "yellow");
} }
const relay_urls = Deno.env.get("RELAY_URLS")?.split(",");
const config = { const config = {
port: Deno.env.get("PORT") || 8000, port: Deno.env.get("PORT") || 8000,
base_url: Deno.env.get("BASE_URL") || `http://localhost:8000`, base_url: Deno.env.get("BASE_URL") || `http://localhost:8000`,
relay_urls, home_relay_url: Deno.env.get("HOME_RELAY_URL") || "",
staticUsers: staticUsers, staticUsers: staticUsers,
ldapEnabled: !!Deno.env.get("LDAP_URL"), ldapEnabled: !!Deno.env.get("LDAP_URL"),
ldap: { ldap: {
@ -32,22 +31,6 @@ const config = {
}, },
}; };
if (config.ldapEnabled && config.ldap.url) { log(`LDAP enabled: ${config.ldapEnabled}`, "blue");
log(`Serving content for pubkeys from ${config.ldap.url}`, "blue");
} else {
log(`LDAP not enabled`, "blue");
}
if (Object.keys(staticUsers).length === 0 && !config.ldapEnabled) {
log(`Neither static users nor LDAP configured. Nothing to serve.`);
Deno.exit(1);
}
if (config.relay_urls?.length > 0) {
log(`Relays: ${config.relay_urls.join(", ")}`, "green");
} else {
log(`No relays configured. Please add at least one relay to RELAY_URLS.`);
Deno.exit(1);
}
export default config; export default config;

View File

@ -1,7 +1,7 @@
{ {
"tasks": { "tasks": {
"dev": "deno run --allow-net --allow-read --allow-env --watch server.ts", "dev": "deno run server",
"server": "deno run --allow-net --allow-read --allow-env server.ts" "server": "deno run --allow-net --allow-read --allow-env --watch server.ts"
}, },
"imports": { "imports": {
"@deno/gfm": "jsr:@deno/gfm@^0.9.0", "@deno/gfm": "jsr:@deno/gfm@^0.9.0",

View File

@ -77,9 +77,7 @@ function articleListItemHtml(article: Article): string {
return ` return `
<div class="item"> <div class="item">
<h3><a href="/${article.naddr}">${article.title}</a></h3> <h3><a href="/${article.naddr}">${article.title}</a></h3>
<p class="meta"> <p>${formattedDate}</p>
${formattedDate}
</p>
</div> </div>
`; `;
} }
@ -113,6 +111,7 @@ export function profilePageHtml(profile: Profile, articles: Article[]): string {
<p class="about"> <p class="about">
${profile.about} ${profile.about}
</p> </p>
</p>
</div> </div>
</header> </header>
<section> <section>

View File

@ -1,4 +1,4 @@
import { NPool, NRelay1 } from "@nostrify/nostrify"; import { NRelay1 } from "@nostrify/nostrify";
import config from "./config.ts"; import config from "./config.ts";
export interface NEvent { export interface NEvent {
@ -11,18 +11,13 @@ export interface NEvent {
tags: Array<[string, string, string?]>; tags: Array<[string, string, string?]>;
} }
const relayPool = new NPool({ export const relay = new NRelay1(config.home_relay_url);
open: (url) => new NRelay1(url),
reqRouter: async (filters) => new Map(
config.relay_urls.map(url => [ url, filters ])
)
});
export async function fetchReplaceableEvent( export async function fetchReplaceableEvent(
pubkey: string, pubkey: string,
identifier: string, identifier: string,
) { ) {
let events = await relayPool.query([{ let events = await relay.query([{
authors: [pubkey], authors: [pubkey],
kinds: [30023], kinds: [30023],
"#d": [identifier], "#d": [identifier],
@ -32,7 +27,7 @@ export async function fetchReplaceableEvent(
if (events.length > 0) { if (events.length > 0) {
return events[0]; return events[0];
} else { } else {
events = await relayPool.query([{ events = await relay.query([{
authors: [pubkey], authors: [pubkey],
kinds: [30024], kinds: [30024],
"#d": [identifier], "#d": [identifier],
@ -44,7 +39,7 @@ export async function fetchReplaceableEvent(
} }
export async function fetchArticlesByAuthor(pubkey: string) { export async function fetchArticlesByAuthor(pubkey: string) {
const events = await relayPool.query([{ const events = await relay.query([{
authors: [pubkey], authors: [pubkey],
kinds: [30023], kinds: [30023],
limit: 10, limit: 10,
@ -54,7 +49,7 @@ export async function fetchArticlesByAuthor(pubkey: string) {
} }
export async function fetchProfileEvent(pubkey: string) { export async function fetchProfileEvent(pubkey: string) {
const events = await relayPool.query([{ const events = await relay.query([{
authors: [pubkey], authors: [pubkey],
kinds: [0], kinds: [0],
limit: 1, limit: 1,