@@ -302,6 +302,37 @@ internal List<Result> Search(IEnumerable<Result> results, string searchName)
302
302
. ToList ( ) ;
303
303
}
304
304
305
+ internal List < Result > InstallFromWeb ( string url )
306
+ {
307
+ var fileName = url . Split ( "/" ) . Last ( ) ;
308
+ var filePath = Path . Combine ( DataLocation . PluginsDirectory , fileName ) ;
309
+ var plugin = new UserPlugin
310
+ {
311
+ ID = "" ,
312
+ Name = fileName . Split ( "." ) . First ( ) ,
313
+ Author = "N/A" ,
314
+ UrlDownload = url
315
+ } ;
316
+ var result = new Result
317
+ {
318
+ Title = $ "{ url } ",
319
+ SubTitle = $ "Download and Install from URL",
320
+ Action = e =>
321
+ {
322
+ if ( e . SpecialKeyState . CtrlPressed )
323
+ {
324
+ SearchWeb . NewTabInBrowser ( url ) ;
325
+ return ShouldHideWindow ;
326
+ }
327
+
328
+ Application . Current . MainWindow . Hide ( ) ;
329
+ _ = InstallOrUpdate ( plugin ) ;
330
+ return ShouldHideWindow ;
331
+ }
332
+ } ;
333
+ return new List < Result > { result } ;
334
+ }
335
+
305
336
internal async ValueTask < List < Result > > RequestInstallOrUpdate ( string searchName , CancellationToken token )
306
337
{
307
338
if ( ! PluginsManifest . UserPlugins . Any ( ) )
@@ -337,6 +368,10 @@ internal async ValueTask<List<Result>> RequestInstallOrUpdate(string searchName,
337
368
ContextData = x
338
369
} ) ;
339
370
371
+ if ( Uri . IsWellFormedUriString ( searchNameWithoutKeyword , UriKind . Absolute ) )
372
+ {
373
+ return InstallFromWeb ( searchNameWithoutKeyword ) ;
374
+ }
340
375
return Search ( results , searchNameWithoutKeyword ) ;
341
376
}
342
377
@@ -372,8 +407,8 @@ private void Install(UserPlugin plugin, string downloadedFilePath)
372
407
MessageBox . Show ( Context . API . GetTranslation ( "plugin_pluginsmanager_install_errormetadatafile" ) ) ;
373
408
return ;
374
409
}
375
-
376
- string newPluginPath = Path . Combine ( DataLocation . PluginsDirectory , $ " { plugin . Name } - { plugin . Version } " ) ;
410
+ var directory = String . IsNullOrEmpty ( plugin . Version ) ? $ " { plugin . Name } " : $ " { plugin . Name } - { plugin . Version } " ;
411
+ string newPluginPath = Path . Combine ( DataLocation . PluginsDirectory , directory ) ;
377
412
378
413
FilesFolders . CopyAll ( pluginFolderPath , newPluginPath ) ;
379
414
@@ -467,4 +502,4 @@ private List<Result> AutoCompleteReturnAllResults(string search, string hotkey,
467
502
return new List < Result > ( ) ;
468
503
}
469
504
}
470
- }
505
+ }
0 commit comments