aboutsummaryrefslogtreecommitdiffhomepage
path: root/share/tools/web_config
diff options
context:
space:
mode:
authorGravatar ridiculousfish <corydoras@ridiculousfish.com>2012-08-20 11:58:54 -0700
committerGravatar ridiculousfish <corydoras@ridiculousfish.com>2012-08-20 11:58:54 -0700
commit81f45208b0f57f9b146bc09814d80835002529b5 (patch)
tree8885ffb9d03a4c36326e2b6d8802357f63275c8e /share/tools/web_config
parent9145d053971e59c3a0413fd3be4f290db5fc8a00 (diff)
Make history deletion from web config work properly with Unicode under both Python2 and Python3
Make the filter search field hide properly in tabs where it's non-functional Fixes https://github.com/fish-shell/fish-shell/issues/265
Diffstat (limited to 'share/tools/web_config')
-rw-r--r--share/tools/web_config/index.html30
-rwxr-xr-xshare/tools/web_config/webconfig.py18
2 files changed, 37 insertions, 11 deletions
diff --git a/share/tools/web_config/index.html b/share/tools/web_config/index.html
index d29f179b..41c426f0 100644
--- a/share/tools/web_config/index.html
+++ b/share/tools/web_config/index.html
@@ -297,7 +297,11 @@ img.delete_icon {
bottom: 10px;
}
-.table_filter_text_box {
+#table_filter_text_box {
+
+}
+
+.filter_text_box {
width: 250px;
padding: 5 10 5 10;
background-color: #888;
@@ -478,8 +482,12 @@ function switch_tab(new_tab) {
$('#detail_colorpicker').hide()
$('#detail_function').hide()
$('#data_table').hide()
+ $('#table_filter_container').hide()
$('#data_table').empty()
+ /* Determine if we will want to show the data table (and associated filter box) */
+ var wants_data_table = false
+
/* Load something new */
if (new_tab == 'tab_colors') {
/* Keep track of whether this is the first element */
@@ -499,6 +507,7 @@ function switch_tab(new_tab) {
})
$('#detail_colorpicker').show()
$('#master_detail_table').show()
+ wants_data_table = false
} else if (new_tab == 'tab_functions') {
/* Keep track of whether this is the first element */
var first = true
@@ -512,6 +521,7 @@ function switch_tab(new_tab) {
})
$('#detail_function').show()
$('#master_detail_table').show()
+ wants_data_table = false
} else if (new_tab == 'tab_variables') {
run_get_request_with_bulk_handler('/variables/', function(json_contents){
var rows = new Array()
@@ -525,7 +535,7 @@ function switch_tab(new_tab) {
}
$('#data_table').append(rows.join(''))
})
- $('#data_table').show()
+ wants_data_table = true
} else if (new_tab == 'tab_history') {
// Clear the history map
history_element_map.length = 0
@@ -541,10 +551,20 @@ function switch_tab(new_tab) {
end = new Date().getTime()
//alert(rows.length + " rows in " + (end - start) + " msec")
})
- $('#data_table').show()
+ wants_data_table = true
} else {
alert("Unknown tab");
}
+
+ /* Show or hide the data table and its search field */
+ if (wants_data_table) {
+ $('#data_table').show()
+ $('#table_filter_container').show()
+ } else {
+ $('#data_table').hide()
+ $('#table_filter_container').hide()
+ }
+
return false
}
@@ -1141,7 +1161,7 @@ function populate_colorpicker_term256() {
/* Update the filter text box */
function update_table_filter_text_box(allow_transient_message) {
- var box = $('.table_filter_text_box')
+ var box = $('#table_filter_text_box')
var has_transient = box.hasClass('text_box_transient')
if (! allow_transient_message && has_transient) {
box.val('')
@@ -1240,7 +1260,7 @@ $(document).ready(function() {
</div>
<table id="data_table">
<div id="table_filter_container">
- <input type="text" class="table_filter_text_box text_box_transient" value="Filter" onInput="update_table_filter_text_box(false)" onFocus="update_table_filter_text_box(false)" onBlur="update_table_filter_text_box(true)">
+ <input type="text" id="table_filter_text_box" class="filter_text_box text_box_transient" value="Filter" onInput="update_table_filter_text_box(false)" onFocus="update_table_filter_text_box(false)" onBlur="update_table_filter_text_box(true)">
</div>
<tr><td>
</td></tr>
diff --git a/share/tools/web_config/webconfig.py b/share/tools/web_config/webconfig.py
index 7ed6d519..f7158131 100755
--- a/share/tools/web_config/webconfig.py
+++ b/share/tools/web_config/webconfig.py
@@ -7,6 +7,7 @@ IS_PY2 = sys.version_info[0] == 2
if IS_PY2:
import SimpleHTTPServer
import SocketServer
+ import urlparse
else:
import http.server as SimpleHTTPServer
import socketserver as SocketServer
@@ -17,10 +18,10 @@ import re, json, socket, os, sys, cgi, select, time
def run_fish_cmd(text):
from subprocess import PIPE
p = subprocess.Popen(["fish"], stdin=PIPE, stdout=PIPE, stderr=PIPE)
- if IS_PY2:
- out, err = p.communicate(text)
- else:
- out, err = p.communicate(bytes(text, 'utf-8'))
+ if not IS_PY2:
+ text = text.encode('utf-8')
+ out, err = p.communicate(text)
+ if not IS_PY2:
out = str(out, 'utf-8')
err = str(err, 'utf-8')
return(out, err)
@@ -292,7 +293,11 @@ class FishConfigHTTPRequestHandler(SimpleHTTPServer.SimpleHTTPRequestHandler):
length = int(self.headers.getheader('content-length'))
except AttributeError:
length = int(self.headers['content-length'])
- postvars = cgi.parse_qs(self.rfile.read(length), keep_blank_values=1)
+
+ # parse_qs borks if we give it a Unicode string in Python2.
+ url_str = self.rfile.read(length).decode('utf-8')
+ if IS_PY2: url_str = str(url_str)
+ postvars = cgi.parse_qs(url_str, keep_blank_values=1)
else:
postvars = {}
@@ -331,7 +336,8 @@ class FishConfigHTTPRequestHandler(SimpleHTTPServer.SimpleHTTPRequestHandler):
if what == None: #Will be None for python3
what = postvars.get(b'what')
what[0] = str(what[0]).lstrip("b'").rstrip("'")
- if self.do_delete_history_item(what[0]):
+ what = what[0] # It's a list!
+ if self.do_delete_history_item(what):
output = ["OK"]
else:
output = ["Unable to delete history item"]