From 7764a1a6f8effff01f7f3b5599fe1b48362a1372 Mon Sep 17 00:00:00 2001 From: David Adam Date: Sun, 5 Oct 2014 12:19:57 +0800 Subject: web_config: add support for viewing abbreviations Add a new tab which lists the current abbreviations defined, by wrapping the `abbr` command. Work on #731. --- share/tools/web_config/index.html | 1 + share/tools/web_config/js/app.js | 4 ++++ share/tools/web_config/js/controllers.js | 10 ++++++++++ share/tools/web_config/js/filters.js | 17 +++++++++++++++++ share/tools/web_config/partials/abbreviations.html | 12 ++++++++++++ share/tools/web_config/webconfig.py | 13 ++++++++++++- 6 files changed, 56 insertions(+), 1 deletion(-) create mode 100644 share/tools/web_config/partials/abbreviations.html (limited to 'share') diff --git a/share/tools/web_config/index.html b/share/tools/web_config/index.html index 8173238d..222ddfaf 100644 --- a/share/tools/web_config/index.html +++ b/share/tools/web_config/index.html @@ -24,6 +24,7 @@
variables
history
bindings
+
abbreviations
diff --git a/share/tools/web_config/js/app.js b/share/tools/web_config/js/app.js index 296a11c1..6c573389 100644 --- a/share/tools/web_config/js/app.js +++ b/share/tools/web_config/js/app.js @@ -27,6 +27,10 @@ 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 cc4452b5..65489cfd 100644 --- a/share/tools/web_config/js/controllers.js +++ b/share/tools/web_config/js/controllers.js @@ -284,3 +284,13 @@ controllers.controller("bindingsController", function($scope, $http) { $scope.fetchBindings(); }); + +controllers.controller("abbreviationsController", function($scope, $http) { + $scope.abbreviations = []; + $scope.fetchAbbreviations = function() { + $http.get("abbreviations/").success(function(data, status, headers, config) { + $scope.abbreviations = data; + })}; + + $scope.fetchAbbreviations(); +}); \ No newline at end of file diff --git a/share/tools/web_config/js/filters.js b/share/tools/web_config/js/filters.js index f8c00766..b5580f2d 100644 --- a/share/tools/web_config/js/filters.js +++ b/share/tools/web_config/js/filters.js @@ -33,3 +33,20 @@ 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(i=0; i + +
+ + + + + + + + +
{{ abbreviation.word }}{{ abbreviation.phrase }}
diff --git a/share/tools/web_config/webconfig.py b/share/tools/web_config/webconfig.py index bfdd20d9..57e0ad90 100755 --- a/share/tools/web_config/webconfig.py +++ b/share/tools/web_config/webconfig.py @@ -682,6 +682,15 @@ class FishConfigHTTPRequestHandler(SimpleHTTPServer.SimpleHTTPRequestHandler): result.extend([r for r in sample_results if r]) return result + def do_get_abbreviations(self): + out, err = run_fish_cmd('abbr -s') + lines = (x for x in out.rstrip().split('\n')) + # Turn the output into something we can use + abbrout = (line[len('abbr -a '):].strip('\'') for line in lines) + abbrs = (x.split('=') for x in abbrout) + result = [{'word': x, 'phrase': y} for x, y in abbrs] + return result + def secure_startswith(self, haystack, needle): if len(haystack) < len(needle): return False @@ -731,6 +740,8 @@ 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) @@ -887,7 +898,7 @@ if PORT > 9000: # Just look at the first letter initial_tab = '' if len(sys.argv) > 1: - for tab in ['functions', 'prompt', 'colors', 'variables', 'history', 'bindings']: + for tab in ['functions', 'prompt', 'colors', 'variables', 'history', 'bindings', 'abbreviations']: if tab.startswith(sys.argv[1]): initial_tab = '#' + tab break -- cgit v1.2.3