Skip to content

Commit

Permalink
Merge branch 'unstable'
Browse files Browse the repository at this point in the history
  • Loading branch information
mikedilger committed Oct 23, 2024
2 parents c39ff51 + 6165c9d commit 697734f
Show file tree
Hide file tree
Showing 25 changed files with 1,281 additions and 38 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 12 additions & 12 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion gossip-bin/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ humansize = "2.1"
image = { version = "0.25", features = [ "png", "jpeg" ] }
lazy_static = "1.5"
memoize = "0.4"
nostr-types = { git = "https://github.com/mikedilger/nostr-types", rev = "3613b32dcb501548525d1f01da04a131b6e18373", features = [ "speedy" ] }
nostr-types = { git = "https://github.com/mikedilger/nostr-types", rev = "a91f43081dd700fe2b47aa1ddfb533c9364dc553", features = [ "speedy" ] }
paste = "1.0"
qrcode = "0.14"
resvg = "0.35.0"
Expand Down
49 changes: 48 additions & 1 deletion gossip-bin/src/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ impl Command {
}
}

const COMMANDS: [Command; 44] = [
const COMMANDS: [Command; 45] = [
Command {
cmd: "oneshot",
usage_params: "{depends}",
Expand Down Expand Up @@ -85,6 +85,11 @@ const COMMANDS: [Command; 44] = [
usage_params: "<relayurl>",
desc: "Set a relay rank to 0 so it will never connect, and also hide form thie list. This is better than delete because deleted relays quickly come back with default settings."
},
Command {
cmd: "dump_handlers",
usage_params: "",
desc: "print all the web-based event handlers",
},
Command {
cmd: "events_of_kind",
usage_params: "<kind>",
Expand Down Expand Up @@ -275,6 +280,7 @@ pub fn handle_command(mut args: env::Args) -> Result<bool, Error> {
"delete_relay" => delete_relay(command, args)?,
"dpi" => override_dpi(command, args)?,
"disable_relay" => disable_relay(command, args)?,
"dump_handlers" => dump_handlers()?,
"events_of_kind" => events_of_kind(command, args)?,
"events_of_pubkey" => events_of_pubkey(command, args)?,
"events_of_pubkey_and_kind" => events_of_pubkey_and_kind(command, args)?,
Expand Down Expand Up @@ -741,6 +747,47 @@ pub fn disable_relay(cmd: Command, mut args: env::Args) -> Result<(), Error> {
Ok(())
}

pub fn dump_handlers() -> Result<(), Error> {
use gossip_lib::HandlersTable;

let mut last_kind = EventKind::Other(12345);

for (kind, handler_key, enabled, recommended) in
GLOBALS.db().read_all_configured_handlers()?.iter()
{
if *kind != last_kind {
println!("KIND={:?}", *kind);
last_kind = *kind;
}

if let Some(handler) = HandlersTable::read_record(handler_key.clone(), None)? {
let handler_url = if kind.is_parameterized_replaceable() {
if let Some(naddr_url) = &handler.naddr_url {
naddr_url.as_str()
} else {
"no web-naddr url provided"
}
} else {
if let Some(nevent_url) = &handler.nevent_url {
nevent_url.as_str()
} else {
"no web-nevent url provided"
}
};

println!(
" {:?} enabled={} recommended={} url={}",
handler.bestname(*kind),
*enabled,
*recommended,
handler_url
);
}
}

Ok(())
}

pub fn import_encrypted_private_key(cmd: Command, mut args: env::Args) -> Result<(), Error> {
let input = match args.next() {
Some(input) => input,
Expand Down
1 change: 0 additions & 1 deletion gossip-bin/src/notedata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,6 @@ impl NoteData {
EventKind::GiftWrap => ("".to_owned(), Some("DECRYPTION FAILED".to_owned())),
EventKind::ChannelMessage => (event.content.clone(), None),
EventKind::LiveChatMessage => (event.content.clone(), None),
EventKind::CommunityPost => (event.content.clone(), None),
EventKind::DraftLongFormContent => (event.content.clone(), None),
k => {
if k.is_feed_displayable() {
Expand Down
56 changes: 50 additions & 6 deletions gossip-bin/src/ui/feed/note/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1463,23 +1463,67 @@ fn note_actions(
)));
} // end Bookmark

// ---- Share ----
// ---- Open with ----
if !note.event.kind.is_direct_message_related() {
items.push(MoreMenuItem::Button(MoreMenuButton::new(
"Share via web",
let mut my_items: Vec<MoreMenuItem> = Vec::new();

// njump.me
my_items.push(MoreMenuItem::Button(MoreMenuButton::new(
"njump.me",
Box::new(|ui, _| {
let nevent = NEvent {
id: note.event.id,
relays: relays.clone(),
author: None,
kind: None,
};
ui.output_mut(|o| {
o.copied_text = format!("https://njump.me/{}", nevent.as_bech32_string())
let url = format!("https://njump.me/{}", nevent.as_bech32_string());
ui.ctx().open_url(egui::OpenUrl {
url: url.clone(),
new_tab: true,
});
}),
)));
} // end Share

if let Some(handlers) = GLOBALS.handlers.get(&note.event.kind) {
for (label, url) in handlers.value().iter() {
let url = if note.event.kind.is_parameterized_replaceable() {
let param = match note.event.parameter() {
Some(p) => p,
None => "".to_owned(),
};
let naddr = NAddr {
d: param,
relays: relays.clone(),
kind: note.event.kind,
author: note.event.pubkey,
};
url.as_str().replace("<bech32>", &naddr.as_bech32_string())
} else {
let nevent = NEvent {
id: note.event.id,
relays: relays.clone(),
author: Some(note.event.pubkey),
kind: Some(note.event.kind),
};
url.as_str().replace("<bech32>", &nevent.as_bech32_string())
};

my_items.push(MoreMenuItem::Button(MoreMenuButton::new(
label,
Box::new(move |ui, _app| {
ui.ctx().open_url(egui::OpenUrl { url, new_tab: true });
}),
)));
}
}

items.push(MoreMenuItem::SubMenu(MoreMenuSubMenu::new(
"Open with",
my_items,
&menu,
)))
} // Open with SubMenu

// ---- Copy ID SubMenu ----
{
Expand Down
Loading

0 comments on commit 697734f

Please sign in to comment.