aboutsummaryrefslogtreecommitdiffhomepage
path: root/share
diff options
context:
space:
mode:
authorGravatar David Adam <zanchey@ucc.gu.uwa.edu.au>2014-10-05 12:19:57 +0800
committerGravatar David Adam <zanchey@ucc.gu.uwa.edu.au>2014-10-05 12:23:31 +0800
commit7764a1a6f8effff01f7f3b5599fe1b48362a1372 (patch)
treec26f8ddfb125325c223d0429e4fc70e6d1f3eb3d /share
parent980bf6e2f4f1d5b705f27a2fe1c902764c8177fe (diff)
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.
Diffstat (limited to 'share')
-rw-r--r--share/tools/web_config/index.html1
-rw-r--r--share/tools/web_config/js/app.js4
-rw-r--r--share/tools/web_config/js/controllers.js10
-rw-r--r--share/tools/web_config/js/filters.js17
-rw-r--r--share/tools/web_config/partials/abbreviations.html12
-rwxr-xr-xshare/tools/web_config/webconfig.py13
6 files changed, 56 insertions, 1 deletions
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 @@
<div ng-class="{'tab': true, 'selected_tab': currentTab == 'variables'}" id="tab_variables" ng-click="changeView('variables')">variables</div>
<div ng-class="{'tab': true, 'selected_tab': currentTab == 'history'}" id="tab_history" ng-click="changeView('history')">history</div>
<div ng-class="{'tab': true, 'selected_tab': currentTab == 'bindings'}" id="tab_bindings" ng-click="changeView('bindings')">bindings</div>
+ <div ng-class="{'tab': true, 'selected_tab': currentTab == 'abbreviations'}" id="tab_abbreviations" ng-click="changeView('abbreviations')">abbreviations</div>
</div>
<div id="tab_contents">
<ng-view></ng-view>
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<abbreviations.length; ++i) {
+ abbr = abbreviations[i];
+ if (abbr.word.toLowerCase().indexOf(query) != -1 || abbr.phrase.toLowerCase().indexOf(query.toLowerCase()) != -1) {
+ result.push(abbr);
+ }
+ }
+
+ return result;
+ }
+});
diff --git a/share/tools/web_config/partials/abbreviations.html b/share/tools/web_config/partials/abbreviations.html
new file mode 100644
index 00000000..563865a8
--- /dev/null
+++ b/share/tools/web_config/partials/abbreviations.html
@@ -0,0 +1,12 @@
+<div id="table_filter_container" style="display: block;">
+ <input id="table_filter_text_box" class="filter_text_box text_box_transient" placeholder="Filter" ng-model="query">
+</div>
+
+<table class="data_table">
+ <tbody>
+ <tr class="data_table_row" ng-repeat="abbreviation in abbreviations | filterAbbreviations:query">
+ <td ng-class="{ data_table_cell: true}" style="text-align: right; padding-right: 30px;" ng-click="abbreviation._is_selected = !abbreviation._is_selected">{{ abbreviation.word }}</td>
+ <td ng-class="{ data_table_cell: true}" style="text-align: left; padding-right: 30px;" ng-click="abbreviation._is_selected = !abbreviation._is_selected">{{ abbreviation.phrase }}</td>
+ </tr>
+ </tbody>
+</table>
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