]> jfr.im git - irc/quakenet/qwebirc.git/commitdiff
Add custom menu items.
authorChris Porter <redacted>
Wed, 26 Jul 2017 23:54:59 +0000 (00:54 +0100)
committerChris Porter <redacted>
Wed, 26 Jul 2017 23:54:59 +0000 (00:54 +0100)
bin/optionsgen.py
bin/pages.py
config.py.example
js/irc/commands.js
js/qwebircinterface.js
js/ui/baseui.js
js/ui/frontends/qui.js
js/ui/menuitems.js
js/ui/panes/help.js [deleted file]
js/ui/panes/privacypolicy.js [deleted file]
js/ui/panes/url.js [new file with mode: 0644]

index 2ae41272cb8c4f70ea0760255291b3514c778949..541ce1907a13c31215341fa149810c89e35c14ed 100644 (file)
@@ -10,7 +10,8 @@ def get_options():
     baseURL=config.BASE_URL,
     staticBaseURL=config.STATIC_BASE_URL,
     dynamicBaseURL=config.DYNAMIC_BASE_URL,
     baseURL=config.BASE_URL,
     staticBaseURL=config.STATIC_BASE_URL,
     dynamicBaseURL=config.DYNAMIC_BASE_URL,
-    validateNickname=False
+    validateNickname=False,
+    customMenuItems=[]
   )
   
   if hasattr(config, "NICKNAME_VALIDATE") and config.NICKNAME_VALIDATE:
   )
   
   if hasattr(config, "NICKNAME_VALIDATE") and config.NICKNAME_VALIDATE:
@@ -27,6 +28,9 @@ def get_options():
   if hasattr(config, "LOGO_URL"):
     options["logoURL"] = config.LOGO_URL
 
   if hasattr(config, "LOGO_URL"):
     options["logoURL"] = config.LOGO_URL
 
+  if hasattr(config, "CUSTOM_MENU_ITEMS"):
+    options["customMenuItems"] = config.CUSTOM_MENU_ITEMS
+
   if hasattr(config, "ACCOUNT_WHOIS_COMMAND") and config.ACCOUNT_WHOIS_COMMAND:
     options["accountWhoisCommand"] = config.ACCOUNT_WHOIS_COMMAND
 
   if hasattr(config, "ACCOUNT_WHOIS_COMMAND") and config.ACCOUNT_WHOIS_COMMAND:
     options["accountWhoisCommand"] = config.ACCOUNT_WHOIS_COMMAND
 
index aef9515f43e479a793f06c091131355576235b1a..b926b12a9061c9b3ea9ee1af0ed1e9a9783c0fe8 100644 (file)
@@ -1,6 +1,6 @@
 #!/usr/bin/env python
 IRC_BASE = ["ircconnection", "irclib", "numerics", "baseircclient", "irctracker", "commandparser", "commands", "ircclient", "commandhistory", "nicknamevalidator", "ignorecontroller"]
 #!/usr/bin/env python
 IRC_BASE = ["ircconnection", "irclib", "numerics", "baseircclient", "irctracker", "commandparser", "commands", "ircclient", "commandhistory", "nicknamevalidator", "ignorecontroller"]
-PANES = ["connect", "embed", "options", "about", "privacypolicy", "feedback", "help"]
+PANES = ["connect", "embed", "options", "about", "feedback", "url"]
 UI_BASE = ["menuitems", "baseui", "baseuiwindow", "colour", "url", "theme", "notifications", "tabcompleter", "style", "xdomain"]
 UI_BASE.extend(["panes/%s" % x for x in PANES])
 
 UI_BASE = ["menuitems", "baseui", "baseuiwindow", "colour", "url", "theme", "notifications", "tabcompleter", "style", "xdomain"]
 UI_BASE.extend(["panes/%s" % x for x in PANES])
 
index 03c3c738b06a06c76a6004441683515524a23d6b..e9eb6556fba0a720e7f5f6444215840257d713ea 100644 (file)
@@ -115,6 +115,13 @@ NETWORK_NAME = "FooNet"
 #ANALYTICS_HTML = """
 #"""
 
 #ANALYTICS_HTML = """
 #"""
 
+# OPTION: CUSTOM_MENU_ITEMS
+#         Adds custom URLs to the top left menu.
+#CUSTOM_MENU_ITEMS = [
+#  ["Help!", "http://www.my.help.site.example/"],
+#  ["Privacy policy", "http://www.privacy.policy.example/"],
+#]
+
 # OPTION: APP_TITLE
 #         The title of the application in the web browser.
 APP_TITLE = NETWORK_NAME + " Web IRC"
 # OPTION: APP_TITLE
 #         The title of the application in the web browser.
 APP_TITLE = NETWORK_NAME + " Web IRC"
@@ -280,11 +287,6 @@ DYNAMIC_BASE_URL = ""
 #         the system's default resolver(s).
 CONNECTION_RESOLVER = None
 
 #         the system's default resolver(s).
 CONNECTION_RESOLVER = None
 
-# OPTION: HELP_URL
-#         Shown to the user if they type /HELP or click on the Help!
-#         option in the user interface.
-HELP_URL = ""
-
 # OPTION: ACCOUNT_WHOIS_COMMAND
 #         Command sent when a username is clicked.
 #ACCOUNT_WHOIS_COMMAND = "/msg Q whois #"
 # OPTION: ACCOUNT_WHOIS_COMMAND
 #         Command sent when a username is clicked.
 #ACCOUNT_WHOIS_COMMAND = "/msg Q whois #"
index 5c16785e28485c8669743f9fc5aa97def5c08d12..43034bba3f4de6c1cb05669b4b59a881b4200b22 100644 (file)
@@ -9,7 +9,6 @@ qwebirc.irc.Commands = new Class({
       "MSG": "PRIVMSG",
       "Q": "QUERY",
       "BACK": "AWAY",
       "MSG": "PRIVMSG",
       "Q": "QUERY",
       "BACK": "AWAY",
-      "PRIVACY": "PRIVACYPOLICY",
       "HOP": "CYCLE",
       "": "SAY",
       "BLOCK": "IGNORE",
       "HOP": "CYCLE",
       "": "SAY",
       "BLOCK": "IGNORE",
@@ -126,9 +125,6 @@ qwebirc.irc.Commands = new Class({
   cmd_EMBED: [false, undefined, undefined, function(args) {
     this.newUIWindow("embeddedWindow");
   }],
   cmd_EMBED: [false, undefined, undefined, function(args) {
     this.newUIWindow("embeddedWindow");
   }],
-  cmd_PRIVACYPOLICY: [false, undefined, undefined, function(args) {
-    this.newUIWindow("privacyWindow");
-  }],
   cmd_ABOUT: [false, undefined, undefined, function(args) {
     this.newUIWindow("aboutWindow");
   }],
   cmd_ABOUT: [false, undefined, undefined, function(args) {
     this.newUIWindow("aboutWindow");
   }],
@@ -220,13 +216,6 @@ qwebirc.irc.Commands = new Class({
   cmd_AUTOJOIN: [false, undefined, undefined, function(args) {
     return ["JOIN", this.parentObject.options.autojoin];
   }],
   cmd_AUTOJOIN: [false, undefined, undefined, function(args) {
     return ["JOIN", this.parentObject.options.autojoin];
   }],
-  cmd_HELP: [false, 1, undefined, function(args) {
-    if(qwebirc.global.helpURL) {
-      this.newUIWindow("helpWindow");
-    } else {
-      this.send("HELP" + (args ? (" " + args[0]) : ""));
-    }
-  }],
   cmd_CLEAR: [false, undefined, undefined, function(args) {
     var w = this.getActiveWindow().lines;
     while(w.childNodes.length > 0)
   cmd_CLEAR: [false, undefined, undefined, function(args) {
     var w = this.getActiveWindow().lines;
     while(w.childNodes.length > 0)
index ccc584b00f009ec0d8d4759fd52a85c0651032fc..4655e0fc53470c49995d745f71eb72787bd81e74 100644 (file)
@@ -28,7 +28,6 @@ qwebirc.ui.Interface = new Class({
     tlightness: null,
     uiOptionsArg: null,
     nickValidation: null,
     tlightness: null,
     uiOptionsArg: null,
     nickValidation: null,
-    helpURL: null,
     dynamicBaseURL: "/",
     staticBaseURL: "/",
     cloak: false,
     dynamicBaseURL: "/",
     staticBaseURL: "/",
     cloak: false,
@@ -65,7 +64,6 @@ qwebirc.ui.Interface = new Class({
       dynamicBaseURL: options.dynamicBaseURL,
       staticBaseURL: options.staticBaseURL,
       baseURL: options.baseURL,
       dynamicBaseURL: options.dynamicBaseURL,
       staticBaseURL: options.staticBaseURL,
       baseURL: options.baseURL,
-      helpURL: options.helpURL,
       nicknameValidator: $defined(options.nickValidation) ? new qwebirc.irc.NicknameValidator(options.nickValidation) : new qwebirc.irc.DummyNicknameValidator()
     };
 
       nicknameValidator: $defined(options.nickValidation) ? new qwebirc.irc.NicknameValidator(options.nickValidation) : new qwebirc.irc.DummyNicknameValidator()
     };
 
index 86145c9eb020b9fe837b2f70fb65bc92aaecdb47..e0bf197390fc5c727bfb9eec2684841249cdc56c 100644 (file)
@@ -249,10 +249,11 @@ qwebirc.ui.BaseUI = new Class({
 
 qwebirc.ui.StandardUI = new Class({
   Extends: qwebirc.ui.BaseUI,
 
 qwebirc.ui.StandardUI = new Class({
   Extends: qwebirc.ui.BaseUI,
-  UICommands: qwebirc.ui.UI_COMMANDS,
   initialize: function(parentElement, windowClass, uiName, options) {
     this.parent(parentElement, windowClass, uiName, options);
 
   initialize: function(parentElement, windowClass, uiName, options) {
     this.parent(parentElement, windowClass, uiName, options);
 
+    this.UICommands = this.__build_menu_items(options);
+
     this.__styleValues = {hue: qwebirc.ui.DEFAULT_HUE, saturation: 0, lightness: 0, textHue: null, textSaturation: null, textLightness: null};
     if($defined(this.options.hue)) this.__styleValues.hue = this.options.hue;
     this.tabCompleter = new qwebirc.ui.TabCompleterFactory(this);
     this.__styleValues = {hue: qwebirc.ui.DEFAULT_HUE, saturation: 0, lightness: 0, textHue: null, textSaturation: null, textLightness: null};
     if($defined(this.options.hue)) this.__styleValues.hue = this.options.hue;
     this.tabCompleter = new qwebirc.ui.TabCompleterFactory(this);
@@ -274,6 +275,42 @@ qwebirc.ui.StandardUI = new Class({
 
     document.addEvent("keydown", this.__handleHotkey.bind(this));
   },
 
     document.addEvent("keydown", this.__handleHotkey.bind(this));
   },
+  __build_menu_items: function(options) {
+    var r = [];
+    var seenAbout = null;
+
+    for(var i=0;i<qwebirc.ui.UI_COMMANDS_P1.length;i++)
+      r.push([true, qwebirc.ui.UI_COMMANDS_P1[i]]);
+    for(var i=0;i<options.customMenuItems.length;i++)
+      r.push([false, options.customMenuItems[i]]);
+    for(var i=0;i<qwebirc.ui.UI_COMMANDS_P2.length;i++)
+      r.push([true, qwebirc.ui.UI_COMMANDS_P2[i]]);
+
+    var r2 = []
+    for(var i=0;i<r.length;i++) {
+      var preset = r[i][0], c = r[i][1];
+
+      if(c[0] == "About qwebirc") { /* HACK */
+        if(!preset) {
+          seenAbout = c;
+          continue;
+        } else if(seenAbout) {
+          c = seenAbout;
+          preset = false;
+        }
+      }
+
+      if(preset) {
+        r2.push([c[0], this[c[1] + "Window"].bind(this)]);
+      } else {
+        r2.push([c[0], (function(c) { return function() {
+          this.addCustomWindow(c[0], qwebirc.ui.URLPane, "urlpane", {url: c[1]});
+        }.bind(this); }).call(this, c)]);
+      }
+    }
+
+    return r2;
+  },
   __handleHotkey: function(x) {
     var success = false;
     if(!x.alt && !x.control && !x.shift && !x.meta) {
   __handleHotkey: function(x) {
     var success = false;
     if(!x.alt && !x.control && !x.shift && !x.meta) {
@@ -376,17 +413,11 @@ qwebirc.ui.StandardUI = new Class({
     this.addCustomWindow("Options", qwebirc.ui.OptionsPane, "optionspane", this.uiOptions);
   },
   aboutWindow: function() {
     this.addCustomWindow("Options", qwebirc.ui.OptionsPane, "optionspane", this.uiOptions);
   },
   aboutWindow: function() {
-    this.addCustomWindow("About", qwebirc.ui.AboutPane, "aboutpane", this.uiOptions);
-  },
-  privacyWindow: function() {
-    this.addCustomWindow("Privacy policy", qwebirc.ui.PrivacyPolicyPane, "privacypolicypane", this.uiOptions);
+    this.addCustomWindow("About qwebirc", qwebirc.ui.AboutPane, "aboutpane", this.uiOptions);
   },
   feedbackWindow: function() {
     this.addCustomWindow("Feedback", qwebirc.ui.FeedbackPane, "feedbackpane", this.uiOptions);
   },
   },
   feedbackWindow: function() {
     this.addCustomWindow("Feedback", qwebirc.ui.FeedbackPane, "feedbackpane", this.uiOptions);
   },
-  helpWindow: function() {
-    this.addCustomWindow("Help!", qwebirc.ui.HelpPane, "helppane", this.uiOptions);
-  },
   urlDispatcher: function(name, window) {
     if(name == "embedded")
       return ["a", this.embeddedWindow.bind(this)];
   urlDispatcher: function(name, window) {
     if(name == "embedded")
       return ["a", this.embeddedWindow.bind(this)];
index 8f23ecbf1c58dd62314a8f286438538b1c10d89e..eb71d79ec99bff881c8eb8a36431a72ae2456b89 100644 (file)
@@ -100,7 +100,7 @@ qwebirc.ui.QUI = new Class({
     
     this.UICommands.forEach(function(x) {
       var text = x[0];
     
     this.UICommands.forEach(function(x) {
       var text = x[0];
-      var fn = this[x[1] + "Window"].bind(this);
+      var fn = x[1];
       var e = new Element("a");
       e.addEvent("mousedown", function(e) { new Event(e).stop(); });
       e.addEvent("click", function() {
       var e = new Element("a");
       e.addEvent("mousedown", function(e) { new Event(e).stop(); });
       e.addEvent("click", function() {
@@ -141,7 +141,7 @@ qwebirc.ui.QUI = new Class({
     
     var inputbox = new Element("input");
     this.addEvent("signedOn", function() {
     
     var inputbox = new Element("input");
     this.addEvent("signedOn", function() {
-      inputbox.placeholder = "chat here! you can also use commands, like /JOIN or /HELP";
+      inputbox.placeholder = "chat here! you can also use commands, like /JOIN";
       var d = function() { inputbox.addClass("input-flash"); }.delay(250);
       var d = function() { inputbox.removeClass("input-flash"); }.delay(500);
       var d = function() { inputbox.addClass("input-flash"); }.delay(750);
       var d = function() { inputbox.addClass("input-flash"); }.delay(250);
       var d = function() { inputbox.removeClass("input-flash"); }.delay(500);
       var d = function() { inputbox.addClass("input-flash"); }.delay(750);
index 82ecb5f2653e80e57c9b0263d8f1202db36bdde9..cafd7a4651877da48c69f6f27db93c6a03a1e6db 100644 (file)
@@ -1,9 +1,10 @@
-qwebirc.ui.UI_COMMANDS = [
+qwebirc.ui.UI_COMMANDS_P1 = [
   ["Options", "options"],
   ["Options", "options"],
-  ["Add webchat to your site", "embedded"],
-  ["Privacy policy", "privacy"],
+  ["Add webchat to your site", "embedded"]
+];
+
+qwebirc.ui.UI_COMMANDS_P2 = [
   ["Feedback", "feedback"],
   ["Feedback", "feedback"],
-  ["Help!", "help"],
   ["About qwebirc", "about"]
 ];
 
   ["About qwebirc", "about"]
 ];
 
diff --git a/js/ui/panes/help.js b/js/ui/panes/help.js
deleted file mode 100644 (file)
index d70c534..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-qwebirc.ui.HelpPane = new Class({
-  Implements: [Events],
-  initialize: function(parent) {
-    if(qwebirc.global.helpURL) {
-      var element = new Element("iframe");
-      element.style.width = "100%";
-      element.style.height = "100%";
-      element.src = qwebirc.global.helpURL;
-      parent.appendChild(element);
-    } else {
-      parent.set("html", "<b>Sorry -- this network hasn't defined a help page!</b>");
-    }
-  }
-});
diff --git a/js/ui/panes/privacypolicy.js b/js/ui/panes/privacypolicy.js
deleted file mode 100644 (file)
index 648358d..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-qwebirc.ui.PrivacyPolicyPane = new Class({
-  Implements: [Events],
-  initialize: function(parent) {
-    var delayfn = function() { parent.set("html", "<div class=\"loading\">Loading. . .</div>"); };
-    var cb = delayfn.delay(500);
-    
-    var r = qwebirc.ui.RequestTransformHTML({url: qwebirc.global.staticBaseURL + "panes/privacypolicy.html", update: parent, onSuccess: function() {
-      $clear(cb);
-      
-      parent.getElement("input[class=close]").addEvent("click", function() {
-        this.fireEvent("close");
-      }.bind(this));
-    }.bind(this)});
-    r.get();
-  }
-});
diff --git a/js/ui/panes/url.js b/js/ui/panes/url.js
new file mode 100644 (file)
index 0000000..26fa003
--- /dev/null
@@ -0,0 +1,10 @@
+qwebirc.ui.URLPane = new Class({
+  Implements: [Events],
+  initialize: function(parent, options) {
+    var element = new Element("iframe");
+    element.style.width = "100%";
+    element.style.height = "100%";
+    element.src = options.url;
+    parent.appendChild(element);
+  }
+});