From 4ceb497bfb720344e18435490d61207fc8024515 Mon Sep 17 00:00:00 2001 From: Fabian Boehm Date: Tue, 10 Jan 2023 17:19:20 +0100 Subject: [PATCH] webconfig: Remove the abbreviations tab Since the new expanded abbreviations in 3.6.0, abbr no longer accepts new universal variables. That means this tab is now non-functional (except that it could technically remove abbrs that were set in universal variables). Because making it work with the expanded abbreviations requires some awkwardness like a dedicated conf.d snippet (or writing into config.fish!), we simply remove it. --- share/tools/web_config/fishconfig.css | 13 ----- share/tools/web_config/index.html | 1 - share/tools/web_config/js/app.js | 4 -- share/tools/web_config/js/controllers.js | 46 ----------------- share/tools/web_config/js/filters.js | 17 ------- .../web_config/partials/abbreviations.html | 22 --------- share/tools/web_config/webconfig.py | 49 ------------------- 7 files changed, 152 deletions(-) delete mode 100644 share/tools/web_config/partials/abbreviations.html diff --git a/share/tools/web_config/fishconfig.css b/share/tools/web_config/fishconfig.css index 1660cf43b..195bf52b4 100644 --- a/share/tools/web_config/fishconfig.css +++ b/share/tools/web_config/fishconfig.css @@ -293,19 +293,6 @@ body { border-bottom: #444 dotted 1px; } -.abbreviation_actions { - width: 8em; - text-align: right; - border-bottom: #444 dotted 1px; -} - -.abbreviation_input { - height: 1.5em; - font: inherit; - padding: 3px; - margin: 0; -} - /* The CSS we apply when a table row is filtered */ .data_table_row_filtered { display: none; diff --git a/share/tools/web_config/index.html b/share/tools/web_config/index.html index 8d7aa3d72..64169c83b 100644 --- a/share/tools/web_config/index.html +++ b/share/tools/web_config/index.html @@ -27,7 +27,6 @@
variables
history
bindings
-
abbreviations
diff --git a/share/tools/web_config/js/app.js b/share/tools/web_config/js/app.js index b602a8cd0..b34822532 100644 --- a/share/tools/web_config/js/app.js +++ b/share/tools/web_config/js/app.js @@ -34,10 +34,6 @@ fishconfig.config( controller: "bindingsController", templateUrl: "partials/bindings.html" }) - .when("/abbreviations", { - controller: "abbreviationsController", - templateUrl: "partials/abbreviations.html" - }) .otherwise({ redirectTo: "/colors" }) diff --git a/share/tools/web_config/js/controllers.js b/share/tools/web_config/js/controllers.js index 958649cdf..f363f6f6d 100644 --- a/share/tools/web_config/js/controllers.js +++ b/share/tools/web_config/js/controllers.js @@ -395,49 +395,3 @@ controllers.controller("bindingsController", function($scope, $http) { $scope.fetchBindings(); }); - -controllers.controller("abbreviationsController", function($scope, $http) { - $scope.abbreviations = []; - $scope.addBlank = function() { - // Add blank entry if it is missing - var hasBlank = {hasBlank: false} - angular.forEach($scope.abbreviations, function(value, key) { - if (value.phrase === "" && value.word === "") { - this.hasBlank = true; - } - }, hasBlank); - if (!$scope.abbreviations) $scope.abbreviations = []; - if (! hasBlank.hasBlank) { - $scope.abbreviations.push({phrase: "", word: "", editable: true}) - } - } - $scope.fetchAbbreviations = function() { - $http.get("abbreviations/").then(function(arg) { - $scope.abbreviations = arg.data; - $scope.addBlank(); - })}; - - $scope.editAbbreviation = function(abbreviation) { - abbreviation.editable = true; - } - - $scope.saveAbbreviation = function(abbreviation) { - if (abbreviation.word && abbreviation.phrase) { - $http.post("save_abbreviation/", abbreviation).then(function(arg) { - abbreviation.editable = false; - $scope.addBlank(); - }); - } - }; - - $scope.removeAbbreviation = function(abbreviation) { - if (abbreviation.word) { - $http.post("remove_abbreviation/", abbreviation).then(function(arg) { - $scope.abbreviations.splice($scope.abbreviations.indexOf(abbreviation), 1); - $scope.addBlank(); - }); - } - }; - - $scope.fetchAbbreviations(); -}); diff --git a/share/tools/web_config/js/filters.js b/share/tools/web_config/js/filters.js index 073869550..5159faa28 100644 --- a/share/tools/web_config/js/filters.js +++ b/share/tools/web_config/js/filters.js @@ -41,20 +41,3 @@ filters.filter("filterBinding", function() { return result; } }); - -filters.filter("filterAbbreviations", function() { - return function(abbreviations, query) { - var result = [] - if (abbreviations == undefined) return result; - if (query == null) { return abbreviations}; - - for(var i=0; i - -
- - - - - - - - - -
- {{ abbreviation.word }} - - - {{ abbreviation.phrase }} - - - - Delete -
diff --git a/share/tools/web_config/webconfig.py b/share/tools/web_config/webconfig.py index a3d71472a..6739f6fad 100755 --- a/share/tools/web_config/webconfig.py +++ b/share/tools/web_config/webconfig.py @@ -1338,40 +1338,6 @@ class FishConfigHTTPRequestHandler(SimpleHTTPServer.SimpleHTTPRequestHandler): result.extend([self.read_one_sample_prompt(path) for path in paths]) return result - def do_get_abbreviations(self): - # Example abbreviation line: - # abbr -a -U -- ls 'ls -a' - result = [] - out, err = run_fish_cmd("abbr --show") - for line in out.rstrip().split("\n"): - if not line: - continue - _, abbr = line.split(" -- ", 1) - word, phrase = abbr.split(" ", 1) - result.append({"word": word, "phrase": phrase}) - return result - - def do_remove_abbreviation(self, abbreviation): - out, err = run_fish_cmd("abbr --erase %s" % abbreviation["word"]) - if err: - return err - else: - return None - - def do_save_abbreviation(self, abbreviation): - out, err = run_fish_cmd( - # Remove one layer of single-quotes because escape_fish_cmd adds them back. - "abbr --add %s %s" - % ( - escape_fish_cmd(strip_one_layer(abbreviation["word"], "'")), - escape_fish_cmd(strip_one_layer(abbreviation["phrase"], "'")), - ) - ) - if err: - return err - else: - return None - def secure_startswith(self, haystack, needle): if len(haystack) < len(needle): return False @@ -1453,8 +1419,6 @@ class FishConfigHTTPRequestHandler(SimpleHTTPServer.SimpleHTTPRequestHandler): output = self.do_get_color_for_variable(name) elif p == "/bindings/": output = self.do_get_bindings() - elif p == "/abbreviations/": - output = self.do_get_abbreviations() else: return SimpleHTTPServer.SimpleHTTPRequestHandler.do_GET(self) @@ -1577,18 +1541,6 @@ class FishConfigHTTPRequestHandler(SimpleHTTPServer.SimpleHTTPRequestHandler): output = ["OK"] else: output = ["Unable to set prompt"] - elif p == "/save_abbreviation/": - errmsg = self.do_save_abbreviation(postvars) - if errmsg: - output = [errmsg] - else: - output = ["OK"] - elif p == "/remove_abbreviation/": - errmsg = self.do_remove_abbreviation(postvars) - if errmsg: - output = [errmsg] - else: - output = ["OK"] else: return self.send_error(404) @@ -1701,7 +1653,6 @@ if len(sys.argv) > 1: "variables", "history", "bindings", - "abbreviations", ]: if tab.startswith(sys.argv[1]): initial_tab = "#!/" + tab