From b833a5ce69028de5b3fd413153cde4afe64162e8 Mon Sep 17 00:00:00 2001 From: Tom Willemse Date: Wed, 20 Aug 2014 23:46:21 +0200 Subject: [PATCH] Update Conkeror config --- conkeror/.conkerorrc/content-delay.js | 49 ++++++++++ conkeror/.conkerorrc/firebug.js | 12 +++ conkeror/.conkerorrc/init.js | 115 +++++++++++++++++++----- conkeror/.conkerorrc/page-modes/jira.js | 16 ++++ 4 files changed, 171 insertions(+), 21 deletions(-) create mode 100644 conkeror/.conkerorrc/content-delay.js create mode 100644 conkeror/.conkerorrc/firebug.js create mode 100644 conkeror/.conkerorrc/page-modes/jira.js diff --git a/conkeror/.conkerorrc/content-delay.js b/conkeror/.conkerorrc/content-delay.js new file mode 100644 index 0000000..7999090 --- /dev/null +++ b/conkeror/.conkerorrc/content-delay.js @@ -0,0 +1,49 @@ +/* + +This script is a hack that provides delayed loading for content buffers. +The initial url of a buffer will not be loaded until that buffer is +switched to. Precaution is taken that the buffer's display_uri_string +returns the delayed url, not about:blank, so things like tabs and sessions +will still work properly. + +*/ + +function content_delay (spec) { + this.delayed_load = spec; +} + +function content_delay_init (b) { + if (b != b.window.buffers.current && + b instanceof content_buffer && + b.opener instanceof session_token) + { + b.load = content_delay; + b.__defineGetter__("display_uri_string", + function () { + if (this.delayed_load) { + if (this.delayed_load instanceof load_spec) + return load_spec_uri_string(this.delayed_load); + return this.delayed_load; + } + if (this._display_uri) + return this._display_uri; + if (this.current_uri) + return this.current_uri.spec; + return ""; + }); + } +} + +function content_delay_do_initial_load (b) { + if (b.hasOwnProperty("load")) { + delete b.load; + if (b.hasOwnProperty("delayed_load")) { + b.load(b.delayed_load); + delete b.delayed_load; + } + } +} + +add_hook("create_buffer_early_hook", content_delay_init); + +add_hook("select_buffer_hook", content_delay_do_initial_load); diff --git a/conkeror/.conkerorrc/firebug.js b/conkeror/.conkerorrc/firebug.js new file mode 100644 index 0000000..a194c40 --- /dev/null +++ b/conkeror/.conkerorrc/firebug.js @@ -0,0 +1,12 @@ +define_variable("firebug_url", + "http://getfirebug.com/releases/lite/1.2/firebug-lite-compressed.js"); + +function firebug (I) { + var doc = I.buffer.document; + var script = doc.createElement('script'); + script.setAttribute('type', 'text/javascript'); + script.setAttribute('src', firebug_url); + script.setAttribute('onload', 'firebug.init();'); + doc.body.appendChild(script); +} +interactive("firebug", "open firebug lite", firebug); diff --git a/conkeror/.conkerorrc/init.js b/conkeror/.conkerorrc/init.js index 96e712c..d4fd48d 100644 --- a/conkeror/.conkerorrc/init.js +++ b/conkeror/.conkerorrc/init.js @@ -1,17 +1,20 @@ require("content-policy.js"); require("favicon"); require("session"); +require("github"); +require("reddit"); load_paths.push("file:///usr/local/clark/share/conkeror/modules/"); load_paths.push("file:///home/slash/projects/cdispass/"); load_paths.push("file:///home/slash/.conkerorrc/site-js/"); load_paths.push("file:///home/slash/.conkerorrc/clark-conkeror/"); +load_paths.push("file:///home/slash/.conkerorrc/page-modes/"); theme_load_paths.push("/home/slash/.conkerorrc/themes/"); opensearch_load_paths.push(make_file("/home/slash/.conkerorrc/search-engines/")); require("clark"); require("cdispass"); -require("quickdispatch"); +require("jira"); define_browser_object_class( "history-url", null, @@ -27,16 +30,7 @@ define_browser_object_class( function ext_title_format(window) { return '(' + get_current_profile() +') ' - + window.buffers.current.description; -} - -function oni_add_sheet(css) { - let (sheet = get_home_directory()) { - sheet.append(".conkerorrc"); - sheet.append("styles"); - sheet.append(css); - register_user_stylesheet(make_uri(sheet)); - }; + + window.buffers.current.title; } function oni_before_quit_func() { @@ -188,13 +182,11 @@ session_auto_save_auto_load = true; define_key(content_buffer_form_keymap, "C-g", "unfocus"); define_key(content_buffer_normal_keymap, "C-x C-b", "switch-to-buffer"); -define_key(content_buffer_normal_keymap, "C-x C-f", "clark-find-url-new-buffer"); define_key(content_buffer_normal_keymap, "C-y", "paste-url-new-buffer"); define_key(content_buffer_normal_keymap, "H", "find-url-from-history"); define_key(content_buffer_normal_keymap, "b", clark_keymap); -define_key(content_buffer_normal_keymap, "g", "clark-find-url"); define_key(content_buffer_normal_keymap, "h", "find-url-from-history-new-buffer"); -define_key(content_buffer_text_keymap, "C-c d", "dispass-and-submit"); +define_key(content_buffer_text_keymap, "C-c d", "dispass"); define_key(default_base_keymap, "C-x f", "follow-new-buffer"); add_hook("before_quit_hook", oni_before_quit_func); @@ -216,17 +208,26 @@ external_content_handlers.set( "libreoffice" ); +function read_url_duckduckbang_handler(input) +{ + var m = /^!/.test(input); + + if (m) + return "https://duckduckgo.com/?q=" + encodeURIComponent(input); + return null; +} + var gh_url = "http://github.com/"; function read_url_github_repo_command_handler(input) { var m = /^gh\s+(\S+\/\S+)(?:\s+(\#\d+|\@\S+|issues|pulls|wiki|graphs|network|admin)(?:\s+(\#\d+|new))?)?$/.exec(input); if (m) { - repo_url = gh_url + m[1] + "/"; + var repo_url = gh_url + m[1] + "/"; switch (m[2]) { case "issues": - issues_url = repo_url + m[2] + "/"; + var issues_url = repo_url + m[2] + "/"; if (m[3]) { if (m[3][0] == '#') @@ -268,7 +269,7 @@ function read_url_github_command_handler(input) } read_url_handler_list = [read_url_github_command_handler, - read_url_qd_handler]; + read_url_duckduckbang_handler]; // Mozrepl let (mozrepl_init = get_home_directory()) { @@ -288,7 +289,7 @@ register_user_stylesheet( escape( "@namespace url(\"http://www.w3.org/1999/xhtml\");\n" + "span.__conkeror_hint {\n" + - " font-family: \"Envy Code R\" !important;\n" + + " font-family: \"Fantasque Sans Mono\" !important;\n" + " font-size: 12px !important;\n" + " line-height: 12px !important;\n" + " padding: 0 2px !important;\n" + @@ -296,6 +297,78 @@ register_user_stylesheet( ) ); -oni_add_sheet("github.css"); -oni_add_sheet("help.css"); -oni_add_sheet("git-scm.css"); +interactive("scuttle-post", + "bookmark the page via scuttle", + function (I) { + check_buffer(I.buffer, content_buffer); + let posturl = 'https://ryuslash.org/scuttle/api/posts_add.php?&url=' + + encodeURIComponent( + load_spec_uri_string( + load_spec(I.buffer.top_frame))) + + '&description=' + + encodeURIComponent( + yield I.minibuffer.read( + $prompt = "name (required): ", + $initial_value = I.buffer.title)) + + '&tags=' + + encodeURIComponent( + yield I.minibuffer.read( + $prompt = "tags (space delimited): ")) + + '&extended=' + + encodeURIComponent( + yield I.minibuffer.read( + $prompt = "extended description: ")); + + try { + var content = yield send_http_request( + load_spec({uri: posturl})); + I.window.minibuffer.message(content.responseText); + } catch (e) { } + }); + +interactive("scuttle-post-link", + "bookmark the link via scuttle", + function (I) { + var bo = yield read_browser_object(I); + var mylink = load_spec_uri_string( + load_spec(encodeURIComponent(bo))); + check_buffer(I.buffer, content_buffer); + let postlinkurl = 'https://ryuslash.org/scuttle/api/posts_add.php?&url=' + + mylink + + '&description=' + + encodeURIComponent( + yield I.minibuffer.read( + $prompt = "name (required): ", + $initial_value = bo.textContent)) + + '&tags=' + + encodeURIComponent( + yield I.minibuffer.read( + $prompt = "tags (space delimited): ")) + + '&extended=' + + encodeURIComponent( + yield I.minibuffer.read( + $prompt = "extended description: ")); + + try { + var content = yield send_http_request( + load_spec({uri: postlinkurl})); + I.window.minibuffer.message(content.responseText); + } catch (e) { } + }, $browser_object = browser_object_links); + +define_key(default_global_keymap, "p", "scuttle-post"); +define_key(default_global_keymap, "P", "scuttle-post-link"); + +// define_webjump("scuttle", "https://ryuslash.org/scuttle/search.php?p=%s&chk=&context=userposts%7Cthomas&fr=del_icio_us&lc="); + +// Bring back the spellchecking! +session_pref("layout.spellcheckDefault", 1); + +// Set cookie behaviour to only accept cookies from the originating +// server and cookie lifetime to expire at the end of each session. +session_pref("network.cookie.cookieBehavior", 1); +session_pref("network.cookie.lifetimePolicy", 2); + +// Please don't track me, for whatever that's worth. +session_pref("privacy.donottrackheader.enabled", true); +session_pref("privacy.donottrackheader.value", 1); diff --git a/conkeror/.conkerorrc/page-modes/jira.js b/conkeror/.conkerorrc/page-modes/jira.js new file mode 100644 index 0000000..f2d70c3 --- /dev/null +++ b/conkeror/.conkerorrc/page-modes/jira.js @@ -0,0 +1,16 @@ +define_keymap("jira_keymap", $display_name="jira"); + +define_key(jira_keymap, "1", null, $fallthrough); +define_key(jira_keymap, "2", null, $fallthrough); +define_key(jira_keymap, "3", null, $fallthrough); + +define_keymaps_page_mode("jira-mode", + build_url_regexp($domain = /.*\.atlassian/, + $tlds=["net"]), + { normal: jira_keymap }, + $display_name = "Jira", + $doc="A page mode for Jira."); + +page_mode_activate(jira_mode); + +provide("jira");