Add plugin marketplace routes

This commit is contained in:
2026-05-08 01:11:19 -04:00
parent a6077fa00a
commit b91f2c0ca1
7 changed files with 809 additions and 4 deletions
+17 -1
View File
@@ -1,4 +1,4 @@
use ely_domain::{BrowserTab, DomainError, UrlText};
use ely_domain::{BrowserTab, DomainError, PluginId, UrlText};
use url::Url;
use crate::CoreError;
@@ -22,6 +22,8 @@ fn internal_page_title(url: &str) -> Option<&'static str> {
"ely://history" => Some("History"),
"ely://archive" => Some("Archived Tabs"),
"ely://task-manager" => Some("Task Manager"),
"ely://plugins" => Some("Plugin Marketplace"),
url if plugin_detail_route_id(url).is_some() => Some("Plugin Details"),
"ely://about" => Some("About ELY Browser"),
"ely://settings" => Some("Settings"),
"ely://settings/plugins" => Some("Plugin Settings"),
@@ -103,6 +105,15 @@ pub(crate) fn task_manager_url() -> Result<UrlText, CoreError> {
internal_page_url("ely://task-manager")
}
pub(crate) fn plugins_url() -> Result<UrlText, CoreError> {
internal_page_url("ely://plugins")
}
pub(crate) fn plugin_detail_url(plugin_id: &PluginId) -> Result<UrlText, CoreError> {
let route = format!("ely://plugin/{}", plugin_id.as_str());
internal_page_url(&route)
}
pub(crate) fn about_url() -> Result<UrlText, CoreError> {
internal_page_url("ely://about")
}
@@ -142,3 +153,8 @@ fn settings_page_route(query: &str) -> Option<&'static str> {
fn internal_page_url(value: &str) -> Result<UrlText, CoreError> {
UrlText::parse(value).map_err(CoreError::from)
}
fn plugin_detail_route_id(url: &str) -> Option<&str> {
let plugin_id = url.strip_prefix("ely://plugin/")?;
(!plugin_id.is_empty() && !plugin_id.contains('/')).then_some(plugin_id)
}
+35 -2
View File
@@ -4,8 +4,9 @@ use crate::{
CoreError,
navigation::{
about_url, bookmarks_url, downloads_url, history_url, move_tab_space_name,
new_profile_name, new_space_name, reading_list_url, search_url, settings_page_url,
settings_url, space_icon, switch_profile_name, sync_status_url, task_manager_url,
new_profile_name, new_space_name, plugin_detail_url, plugins_url, reading_list_url,
search_url, settings_page_url, settings_url, space_icon, switch_profile_name,
sync_status_url, task_manager_url,
},
};
@@ -69,6 +70,12 @@ impl BrowserCore {
self.command_query.clear();
}
}
CommandIntent::ScopedSearch { scope: CommandScope::Plugins, query } => {
if let Some(url) = self.find_plugin_match(query)? {
self.open_tab(url);
self.command_query.clear();
}
}
CommandIntent::ScopedSearch { scope: CommandScope::Archive, query }
if self.restore_archived_tab_match(query)?.is_some() =>
{
@@ -130,6 +137,15 @@ impl BrowserCore {
self.open_tab(task_manager_url()?);
Ok(true)
}
"plugins"
| "open-plugins"
| "open plugins"
| "plugin-marketplace"
| "open-plugin-marketplace"
| "open plugin marketplace" => {
self.open_tab(plugins_url()?);
Ok(true)
}
"about" | "open-about" | "open about" => {
self.open_tab(about_url()?);
Ok(true)
@@ -186,4 +202,21 @@ impl BrowserCore {
.find(|profile| profile.name().to_lowercase().contains(&query))
.map(|profile| profile.id().clone())
}
fn find_plugin_match(&self, query: &str) -> Result<Option<ely_domain::UrlText>, CoreError> {
let query = query.trim().to_lowercase();
if query.is_empty() {
return Ok(None);
}
self.installed_plugins
.iter()
.find(|plugin| {
plugin.id().as_str().to_lowercase().contains(&query)
|| plugin.manifest().name().to_lowercase().contains(&query)
|| plugin.manifest().description().to_lowercase().contains(&query)
})
.map(|plugin| plugin_detail_url(plugin.id()))
.transpose()
}
}
+15
View File
@@ -96,6 +96,21 @@ fn open_task_manager_command_opens_task_manager_page() -> Result<(), Box<dyn Err
Ok(())
}
#[test]
fn open_plugins_command_opens_plugin_marketplace_page() -> Result<(), Box<dyn Error>> {
let mut core = BrowserCore::new(InitialBrowserConfig::ely_defaults()?)?;
core.set_command_query(">plugins");
let intent = core.submit_command()?;
let active_tab = core.active_tab()?;
assert_eq!(intent, Some(CommandIntent::Command("plugins".to_string())));
assert_eq!(active_tab.title(), "Plugin Marketplace");
assert_eq!(active_tab.url().as_str(), "ely://plugins");
assert_eq!(core.snapshot()?.command_query, "");
Ok(())
}
#[test]
fn open_about_command_opens_about_page() -> Result<(), Box<dyn Error>> {
let mut core = BrowserCore::new(InitialBrowserConfig::ely_defaults()?)?;
+43 -1
View File
@@ -1,7 +1,7 @@
use std::{error::Error, io};
use ely_browser_core::{BrowserCore, CoreError, InitialBrowserConfig, PluginAuditAction};
use ely_domain::{PluginId, PluginManifest};
use ely_domain::{CommandIntent, CommandScope, PluginId, PluginManifest};
#[test]
fn installs_standard_plugin_and_records_audit_event() -> Result<(), Box<dyn Error>> {
@@ -146,6 +146,48 @@ fn rejects_unknown_plugin_state_change() -> Result<(), Box<dyn Error>> {
Ok(())
}
#[test]
fn plugin_scoped_search_opens_installed_plugin_detail() -> Result<(), Box<dyn Error>> {
let mut core = BrowserCore::new(InitialBrowserConfig::ely_defaults()?)?;
core.install_plugin(plugin_manifest("com.elydora.reader", &["page:metadata"])?, false)?;
core.set_command_query("@plugins reader");
let intent = core.submit_command()?;
let active_tab = core.active_tab()?;
assert_eq!(
intent,
Some(CommandIntent::ScopedSearch {
scope: CommandScope::Plugins,
query: "reader".to_string()
})
);
assert_eq!(active_tab.title(), "Plugin Details");
assert_eq!(active_tab.url().as_str(), "ely://plugin/com.elydora.reader");
assert_eq!(core.snapshot()?.command_query, "");
Ok(())
}
#[test]
fn plugin_scoped_search_preserves_query_without_match() -> Result<(), Box<dyn Error>> {
let mut core = BrowserCore::new(InitialBrowserConfig::ely_defaults()?)?;
core.set_command_query("@plugins missing");
let intent = core.submit_command()?;
let active_tab = core.active_tab()?;
assert_eq!(
intent,
Some(CommandIntent::ScopedSearch {
scope: CommandScope::Plugins,
query: "missing".to_string()
})
);
assert_eq!(active_tab.url().as_str(), "ely://new-tab");
assert_eq!(core.snapshot()?.command_query, "@plugins missing");
Ok(())
}
fn install_error(
core: &mut BrowserCore,
manifest: PluginManifest,