Add plugin path, separate search plugins
Added plugin path to Config, used to search for plugins. Moved search
plugins into their own directory, with a slightly different makefile.
Modified PluginManager to search for assemblies on the search path.
Search plugins have been modified to do proper url escaping (which,
incidentally, makes them even simpler).
public class Config {
public static List<string> ConfigPath;
public static string ConfigPathOut = null;
+ public static List<string> PluginPath;
public static Dictionary<string,string> Options;
public static Dictionary<string,Dictionary<string,string>> PluginOptions;
if (Directory.Exists(homepath))
ConfigPathOut = homepath;
}
+
+ // Set up PluginPath
+ PluginPath = new List<string>();
+ PluginPath.Add(Environment.GetEnvironmentVariable("WEBTHING_HOME") + "/plugins");
+ PluginPath.Add(Environment.GetEnvironmentVariable("WEBTHING_HOME") + "/searchplugins");
}
private static void ParseOption(string key, string val) {
CSFLAGS = -debug
references = -r:webkit-sharp.dll -pkg:gtk-sharp-2.0
-all: WebThingMain.exe plugins
+all: WebThingMain.exe plugins searchplugins
.PHONY: tags
tags:
plugins:
make -C plugins
.PHONY: plugins
+
+searchplugins:
+ make -C searchplugins
+.PHONY: searchplugins
}
public void LoadPlugin(string assemblyname) {
- Assembly a = Assembly.LoadFile(Environment.GetEnvironmentVariable("WEBTHING_HOME") + "/plugins/" + assemblyname + ".dll");
+ Assembly a = FindAssembly(assemblyname);
+ if (a == null) return;
Type[] types = a.GetTypes();
+
foreach (Type t in types) {
if (t.IsSubclassOf(typeof(WebThingPlugin))) {
if (Plugins.ContainsKey(t.FullName))
}
}
+ private Assembly FindAssembly(string assemblyname) {
+ foreach (string path in Config.PluginPath) {
+ try {
+ return Assembly.LoadFile(path + "/" + assemblyname + ".dll");
+ } catch {
+ }
+ }
+ Console.WriteLine("Could not find {0}", assemblyname);
+ return null;
+ }
+
public void WebViewSetup(WebView view) {
foreach (string key in PluginOrder) {
Plugins[key].InitWebView(view);
-using System;
-using bytex64.WebThing;
-using System.Text.RegularExpressions;
-
-public class GoogleSearch : WebThingPlugin, ISearchPlugin {
- public string SearchTransform(string search) {
- string[] words = Regex.Split(search, @"\s+");
- return String.Format("http://google.com/search?q={0}", String.Join("%20", words));
- }
-}
CSFLAGS = -debug
references = -r:../webkit-sharp.dll -pkg:gtk-sharp-2.0
-all: Vimish.dll FFNav.dll DefaultPage.dll LoadProgress.dll MiddleClickOpen.dll QuickSearch.dll Session.dll Fullscreen.dll GoogleSearch.dll WikipediaSearch.dll
+all: Vimish.dll FFNav.dll DefaultPage.dll LoadProgress.dll MiddleClickOpen.dll QuickSearch.dll Session.dll Fullscreen.dll
clean:
rm -f *.dll *.mdb *.so
- make -C SoupSettings clean
-
-.PHONY: SoupSettings.dll
-SoupSettings.dll:
- make -C SoupSettings
%.dll: %.cs ../WebThing.dll
gmcs $(CSFLAGS) $(references) -r:../WebThing.dll -target:library -out:$@ $<
-using System;
-using bytex64.WebThing;
-using System.Text.RegularExpressions;
-
-public class WikipediaSearch : WebThingPlugin, ISearchPlugin {
- public string SearchTransform(string search) {
- string[] words = Regex.Split(search, @"\s+");
- return String.Format("http://www.wikipedia.org/search-redirect.php?search={0}&language=en&go=Go", String.Join("%20", words));
- }
-}
+using System;
+using System.Web;
+using System.Text.RegularExpressions;
+using bytex64.WebThing;
+
+public class GoogleSearch : WebThingPlugin, ISearchPlugin {
+ public string SearchTransform(string search) {
+ return String.Format("http://google.com/search?q={0}", HttpUtility.UrlEncode(search));
+ }
+}
+CSFLAGS = -debug
+references = -r:../WebThing.dll -r:System.Web
+
+all: GoogleSearch.dll WikipediaSearch.dll
+
+clean:
+ rm -f *.dll *.mdb *.so
+
+%.dll: %.cs ../WebThing.dll
+ gmcs $(CSFLAGS) $(references) -target:library -out:$@ $<
+using System;
+using System.Web;
+using System.Text.RegularExpressions;
+using bytex64.WebThing;
+
+public class WikipediaSearch : WebThingPlugin, ISearchPlugin {
+ public string SearchTransform(string search) {
+ return String.Format("http://www.wikipedia.org/search-redirect.php?search={0}&language=en&go=Go", HttpUtility.UrlEncode(search));
+ }
+}