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_BIND_DN=uid=service,ou=kosmos.org,cn=applications,dc=kosmos,dc=org
LDAP_PASSWORD=123456abcdef

View File

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

View File

@ -10,18 +10,17 @@ let staticUsers;
try {
const yamlContent = await Deno.readTextFile(`${dirname}/users.yaml`);
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 {
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 = {
port: Deno.env.get("PORT") || 8000,
base_url: Deno.env.get("BASE_URL") || `http://localhost:8000`,
relay_urls,
home_relay_url: Deno.env.get("HOME_RELAY_URL") || "",
staticUsers: staticUsers,
ldapEnabled: !!Deno.env.get("LDAP_URL"),
ldap: {
@ -32,22 +31,6 @@ const config = {
},
};
if (config.ldapEnabled && config.ldap.url) {
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);
}
log(`LDAP enabled: ${config.ldapEnabled}`, "blue");
export default config;

View File

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

View File

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

View File

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