Compare commits
4 Commits
fdf16227d3
...
edaf5f5c71
| Author | SHA1 | Date | |
|---|---|---|---|
| edaf5f5c71 | |||
| f15e845825 | |||
| 453a0f14d3 | |||
| 856b10358c |
@ -1,6 +1,4 @@
|
||||
PORT=8000
|
||||
BASE_URL=http://localhost:8000
|
||||
HOME_RELAY_URL=wss://nostr.kosmos.org
|
||||
RELAY_URLS=wss://nostr.kosmos.org,wss://nostr.x0f.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
|
||||
|
||||
@ -108,8 +108,8 @@ main header .meta .name a {
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
main .article-list .item {
|
||||
margin-bottom: 3rem;
|
||||
main.profile-page {
|
||||
margin-top: 6rem;
|
||||
}
|
||||
|
||||
main .article-list .item h3 {
|
||||
@ -120,12 +120,16 @@ main .article-list p {
|
||||
margin-top: 0.5rem;
|
||||
}
|
||||
|
||||
main .article-list p.meta {
|
||||
font-size: 1rem;
|
||||
}
|
||||
|
||||
main article footer {
|
||||
margin-top: 5rem;
|
||||
}
|
||||
|
||||
.profile-page .about {
|
||||
margin-bottom: 3rem;
|
||||
.profile-page header {
|
||||
margin-bottom: 2rem;
|
||||
}
|
||||
|
||||
/* Dropdown menu */
|
||||
@ -194,7 +198,7 @@ main article footer {
|
||||
|
||||
main {
|
||||
max-width: 100%;
|
||||
margin: 4rem 1rem 8rem 1rem;
|
||||
margin: 4rem 1rem 8rem 1rem !important;
|
||||
}
|
||||
|
||||
.profile-page h1 {
|
||||
|
||||
27
config.ts
27
config.ts
@ -10,17 +10,18 @@ let staticUsers;
|
||||
try {
|
||||
const yamlContent = await Deno.readTextFile(`${dirname}/users.yaml`);
|
||||
staticUsers = parse(yamlContent);
|
||||
log("Static user config:", "blue");
|
||||
log(Deno.inspect(staticUsers), "blue");
|
||||
log(`Serving content for ${Object.keys(staticUsers).length} pubkeys from users.yaml`, "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`,
|
||||
home_relay_url: Deno.env.get("HOME_RELAY_URL") || "",
|
||||
relay_urls,
|
||||
staticUsers: staticUsers,
|
||||
ldapEnabled: !!Deno.env.get("LDAP_URL"),
|
||||
ldap: {
|
||||
@ -31,6 +32,22 @@ const config = {
|
||||
},
|
||||
};
|
||||
|
||||
log(`LDAP enabled: ${config.ldapEnabled}`, "blue");
|
||||
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);
|
||||
}
|
||||
|
||||
export default config;
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
{
|
||||
"tasks": {
|
||||
"dev": "deno run server",
|
||||
"server": "deno run --allow-net --allow-read --allow-env --watch server.ts"
|
||||
"dev": "deno run --allow-net --allow-read --allow-env --watch server.ts",
|
||||
"server": "deno run --allow-net --allow-read --allow-env server.ts"
|
||||
},
|
||||
"imports": {
|
||||
"@deno/gfm": "jsr:@deno/gfm@^0.9.0",
|
||||
|
||||
5
html.ts
5
html.ts
@ -77,7 +77,9 @@ function articleListItemHtml(article: Article): string {
|
||||
return `
|
||||
<div class="item">
|
||||
<h3><a href="/${article.naddr}">${article.title}</a></h3>
|
||||
<p>${formattedDate}</p>
|
||||
<p class="meta">
|
||||
${formattedDate}
|
||||
</p>
|
||||
</div>
|
||||
`;
|
||||
}
|
||||
@ -111,7 +113,6 @@ export function profilePageHtml(profile: Profile, articles: Article[]): string {
|
||||
<p class="about">
|
||||
${profile.about}
|
||||
</p>
|
||||
</p>
|
||||
</div>
|
||||
</header>
|
||||
<section>
|
||||
|
||||
17
nostr.ts
17
nostr.ts
@ -1,4 +1,4 @@
|
||||
import { NRelay1 } from "@nostrify/nostrify";
|
||||
import { NPool, NRelay1 } from "@nostrify/nostrify";
|
||||
import config from "./config.ts";
|
||||
|
||||
export interface NEvent {
|
||||
@ -11,13 +11,18 @@ export interface NEvent {
|
||||
tags: Array<[string, string, string?]>;
|
||||
}
|
||||
|
||||
export const relay = new NRelay1(config.home_relay_url);
|
||||
const relayPool = new NPool({
|
||||
open: (url) => new NRelay1(url),
|
||||
reqRouter: async (filters) => new Map(
|
||||
config.relay_urls.map(url => [ url, filters ])
|
||||
)
|
||||
});
|
||||
|
||||
export async function fetchReplaceableEvent(
|
||||
pubkey: string,
|
||||
identifier: string,
|
||||
) {
|
||||
let events = await relay.query([{
|
||||
let events = await relayPool.query([{
|
||||
authors: [pubkey],
|
||||
kinds: [30023],
|
||||
"#d": [identifier],
|
||||
@ -27,7 +32,7 @@ export async function fetchReplaceableEvent(
|
||||
if (events.length > 0) {
|
||||
return events[0];
|
||||
} else {
|
||||
events = await relay.query([{
|
||||
events = await relayPool.query([{
|
||||
authors: [pubkey],
|
||||
kinds: [30024],
|
||||
"#d": [identifier],
|
||||
@ -39,7 +44,7 @@ export async function fetchReplaceableEvent(
|
||||
}
|
||||
|
||||
export async function fetchArticlesByAuthor(pubkey: string) {
|
||||
const events = await relay.query([{
|
||||
const events = await relayPool.query([{
|
||||
authors: [pubkey],
|
||||
kinds: [30023],
|
||||
limit: 10,
|
||||
@ -49,7 +54,7 @@ export async function fetchArticlesByAuthor(pubkey: string) {
|
||||
}
|
||||
|
||||
export async function fetchProfileEvent(pubkey: string) {
|
||||
const events = await relay.query([{
|
||||
const events = await relayPool.query([{
|
||||
authors: [pubkey],
|
||||
kinds: [0],
|
||||
limit: 1,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user