Skip to content

Commit

Permalink
Bugfixes, banner, styles, more configs
Browse files Browse the repository at this point in the history
  • Loading branch information
gzuuus committed Jun 30, 2023
1 parent a4e2d37 commit 679368b
Show file tree
Hide file tree
Showing 8 changed files with 97 additions and 62 deletions.
13 changes: 10 additions & 3 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,17 @@ REACT_APP_THEME_SELECTOR=true
#'true' if you want to show the 2140meetups section or 'false' to hide it.
REACT_APP_SHOW_MEETUPS=true
#ID de tu comunidad, puedes encontrar la id en la pagina de tu comunidad de 2140meetups.com, por ejemplo https://2140meetups.com/comunidad/5605/ donde la id seria '5605'
REACT_APP_COMUNITY_ID=5573
REACT_APP_COMUNITY_ID=5983

#Nostr settings
#Show nostr section 'true' or 'false'
REACT_APP_NOSTR_SHOW=true
#Show banner like background of the site 'true' or 'false'
REACT_APP_NOSTR_SHOW_BANNER=true
#Your nostr pubkey in npub/hex
REACT_APP_NOSTR_PUBKEY=npub1gzuushllat7pet0ccv9yuhygvc8ldeyhrgxuwg744dn5khnpk3gs3ea5ds
#Choose how many messages from your feed you want to display (recommended from 1 to 25)
REACT_APP_NOSTR_NOTES_TO_SHOW=10
REACT_APP_NOSTR_NOTES_TO_SHOW=1
#Choose witch client you want to use for see notes out linktr ["https://nostr.com/", "https://snort.social/e/", "https://nostr.band/", "https://iris.to/", "https://primal.net/thread/", "https://www.nostr.guru/e/"]
REACT_APP_NOSTR_OUTER_NOTES=https://nostr.com/
#Choose witch client you want to use for see profiles out linktr ["https://snort.social/p/", "https://nostr.band/", "https://iris.to/", "https://primal.net/profile/"]
Expand All @@ -29,4 +32,8 @@ REACT_APP_NOSTR_OUTER_HASHTAGS=https://snort.social/t/
#Choose witch client you want to use for see long content out linktr ["https://habla.news/a/", "https://nostr.com/"]
REACT_APP_NOSTR_OUTER_LONG=https://habla.news/a/
#Choose witch client you want to use for others to chat with you ["https://chat.punkhub.me/?dm=", "https://www.nostrchat.io/dm/"]
REACT_APP_NOSTR_OUTER_CHAT=https://chat.punkhub.me/?dm=
REACT_APP_NOSTR_OUTER_CHAT=https://chat.punkhub.me/?dm=

#Extra settings
#Show footer 'true' or 'false'
REACT_APP_NOSTR_SHOW_FOOTER=true
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2023 Linktr
Copyright (c) 2023 Gzuuus

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
5 changes: 0 additions & 5 deletions public/.well-know/nostr.json

This file was deleted.

8 changes: 5 additions & 3 deletions src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,6 @@ function App() {
{themeButtons}
</div>
)}
<div className='creditsContainer'>
<span><a href='https://github.com/gzuuus/linktr' target='_blank' rel='noreferrer'>Made with love by gzuuus 💜</a></span>
</div>
<GlobalStyles theme={themePicked} />
<div className='mainContainer'>
<img className='header-img' src={`./img/${process.env.REACT_APP_PFP}`} alt="pfp" />
Expand All @@ -62,6 +59,11 @@ function App() {
<Nostr/>
</div>
)}
{process.env.REACT_APP_NOSTR_SHOW_FOOTER === 'true' && (
<div className='creditsContainer'>
<span><a href='https://github.com/gzuuus/linktr' target='_blank' rel='noreferrer'>With 💜 by gzuuus </a></span>
</div>
)}
</div>
);
}
Expand Down
40 changes: 22 additions & 18 deletions src/components/EventListComponent.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ import NoteParserKind0 from "./NoteParserKind0.js";

function EventListComponent({ events }) {
const uniqueEvents = {};
const NOTES_TO_SHOW = parseInt(process.env.REACT_APP_NOSTR_NOTES_TO_SHOW);
let noteParserCount = 0; // Variable de conteo adicional

// Filtramos los eventos duplicados
events.forEach((event) => {
if (event.kind === 0) {
if (uniqueEvents[event.kind] === undefined) {
Expand All @@ -14,27 +15,30 @@ function EventListComponent({ events }) {
uniqueEvents[event.kind] = event;
}
} else {
uniqueEvents[event.id] = event;
if (noteParserCount < NOTES_TO_SHOW) { // Verificar si se ha alcanzado el límite de NOTES_TO_SHOW
uniqueEvents[event.id] = event;
noteParserCount++; // Incrementar el conteo
}
}
});

const uniqueEventsList = Object.values(uniqueEvents);
const eventList = uniqueEventsList.map((event, index) => {
return (
<div className="noteContainer" key={index}>
{event.kind === 0 ? (
<>
<NoteParserKind0 note={event} />
</>
) : (
<>
<NoteParser note={event} />
</>
)}
</div>
);
});
const eventList = uniqueEventsList.map((event, index) => {
return (
<div className="noteContainer" key={index}>
{event.kind === 0 ? (
<>
<NoteParserKind0 note={event} />
</>
) : (
<>
<NoteParser note={event} />
</>
)}
</div>
);
});

return (
<div>
{eventList}
Expand Down
21 changes: 8 additions & 13 deletions src/components/Nostr.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { NostrLogo } from "../graphics/index.js";

const Nostr = () => {
const [events, setEvents] = useState([]);
const [uniqueEvents, setUniqueEvents] = useState(new Set());
//const [uniqueEvents, setUniqueEvents] = useState(new Set());

const relayList = useMemo(() => [
"wss://nos.lol",
Expand All @@ -26,8 +26,6 @@ const Nostr = () => {
return process.env.REACT_APP_NOSTR_PUBKEY;
}
};


useEffect(() => {
const NOTES_TO_SHOW = parseInt(process.env.REACT_APP_NOSTR_NOTES_TO_SHOW);
const onLoad = () => {
Expand Down Expand Up @@ -61,7 +59,6 @@ const Nostr = () => {
{
kinds: [0],
authors: [getHexPubKey()],
limit:1,
},
{
kinds: [1],
Expand All @@ -71,11 +68,8 @@ const Nostr = () => {
],
userRelayList,
(event, isAfterEose, relayURL) => {
if (!uniqueEvents.has(event.id)) {
setUniqueEvents(new Set(uniqueEvents.add(event.id)));
setEvents(events =>
utils.insertEventIntoDescendingList(events, event))
}
setEvents(events =>
utils.insertEventIntoDescendingList(events, event))
//console.log(event, isAfterEose, relayURL);
},
undefined,
Expand All @@ -102,21 +96,22 @@ const Nostr = () => {
};

window.onload = onLoad;

return () => {
window.onload = null;
};
}, []);
}, [relayList]);
return (

<div>
<div>
<div className="nostrHeading">
<NostrLogo className="nostrLogo"/>
<h3>Nostr</h3>
</div>
<EventListComponent events={events} />
<button><a href={process.env.REACT_APP_NOSTR_OUTER_PROFILES+nip19.npubEncode(getHexPubKey())} target="_blank" rel="noreferrer">More...</a></button>
{parseInt(process.env.REACT_APP_NOSTR_NOTES_TO_SHOW) > 0 && (
<button><a href={ process.env.REACT_APP_NOSTR_OUTER_PROFILES + nip19.npubEncode(getHexPubKey()) } target="_blank" rel="noreferrer" > More... </a></button>
)}
</div>
</div>
);
Expand Down
44 changes: 30 additions & 14 deletions src/components/NoteParserKind0.js
Original file line number Diff line number Diff line change
@@ -1,27 +1,43 @@
import React from 'react'
import { nip19 } from "nostr-tools";
import { GoOut, LnIcon, GoChat} from "../graphics/index.js";
const NoteParserKind0 = ({note}) => {
const nPub=nip19.npubEncode(note.pubkey)
import React from 'react';
import { nip19 } from 'nostr-tools';
import { GoOut, LnIcon, GoChat } from '../graphics/index.js';

const NoteParserKind0 = ({ note }) => {
const SHOW_BANNER = process.env.REACT_APP_NOSTR_SHOW_BANNER;
const nPub = nip19.npubEncode(note.pubkey);
const contentObj = JSON.parse(note.content);
const { lud16, display_name, name, about, picture, banner } = contentObj;

return (
<div className='noteContainerKind0'>
{SHOW_BANNER !== 'true' ? (
<div className='bannerBackground' style={{ display: 'none' }}></div>
) : (
<div
className='bannerBackground'
style={{ backgroundImage: `linear-gradient(transparent, var(--background-color)), url(${banner})` }}
></div>
)}
<img className='nostr_pfp' src={picture} alt={display_name} />
<h2>{name}</h2>
<a href={process.env.REACT_APP_NOSTR_OUTER_PROFILES+nPub} target="_blank" rel="noreferrer" >
<code style={{ textDecoration: 'none' }}>{nPub.slice(0, 16)}...</code>
<a href={process.env.REACT_APP_NOSTR_OUTER_PROFILES + nPub} target='_blank' rel='noreferrer'>
<code style={{ textDecoration: 'none' }}>{nPub.slice(0, 16)}...</code>
</a>
<p>{about}</p>
<hr />
<div className='noteButtonBox'>
<a href={`lightning:${lud16}`} target="_blank" rel="noreferrer"><LnIcon className="svg-src"/></a>
<a href={process.env.REACT_APP_NOSTR_OUTER_CHAT+note.pubkey} target="_blank" rel="noreferrer"><GoChat className="svg-src"/></a>
<a href={process.env.REACT_APP_NOSTR_OUTER_PROFILES+nPub} target="_blank" rel="noreferrer"><GoOut className="svg-src"/></a>
<a href={`lightning:${lud16}`} target='_blank' rel='noreferrer'>
<LnIcon className='svg-src' />
</a>
<a href={process.env.REACT_APP_NOSTR_OUTER_CHAT + note.pubkey} target='_blank' rel='noreferrer'>
<GoChat className='svg-src' />
</a>
<a href={process.env.REACT_APP_NOSTR_OUTER_PROFILES + nPub} target='_blank' rel='noreferrer'>
<GoOut className='svg-src' />
</a>
</div>
</div>
)
}
);
};

export default NoteParserKind0
export default NoteParserKind0;
26 changes: 21 additions & 5 deletions src/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -261,10 +261,14 @@ div.message-kind0, div.message-kind1{
}
.creditsContainer {
position: fixed;
bottom: 10px;
right: 10px;
color: var(--accent-color) ;
opacity: 0.3;
color: var(--accent-color);
text-align: center;
background: var(--container-b-color);
padding: 15px;
border-radius: 0 var(--default-border-radius) 0 0;
bottom: 0;
left: 0;
opacity: 0.5;
}
.creditsContainer:hover {
opacity: 1;
Expand All @@ -273,6 +277,18 @@ div.message-kind0, div.message-kind1{
display: flex;
align-items: center;
justify-content: center;
margin-top: 15px;
}
.bannerBackground {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 50%;
background-size: cover;
background-position: center;
background-repeat: no-repeat;
z-index: -1;
}


Expand All @@ -283,7 +299,7 @@ div.message-kind0, div.message-kind1{
}
.mainDiv {
width: auto;
margin: 10px;
margin: 10px 10px 0px 10px;
}
.mainContainer {
background: var(--container-b-color);
Expand Down

0 comments on commit 679368b

Please sign in to comment.