bug 351817, support for pref based params, needs to display, too, bustage fix in l10n tool chain

This commit is contained in:
axel%pike.org 2006-09-12 06:54:52 +00:00
parent d0af9cd09f
commit f507686699
2 changed files with 37 additions and 9 deletions

View File

@ -166,11 +166,14 @@ class SearchTest(Base):
self.engine = {'urls':[]}
self.lNames = []
self.textField = None
self.content = ''
return
def endDocument(self):
self.engine['md5'] = self.md5.hexdigest()
return
def startElementNS(self, (ns, local), qname, attrs):
if self.textField:
logging.warning('Found Element, but expected CDATA.')
self.indent += ' '
if ns != u'http://www.mozilla.org/2006/browser/search/':
raise UserWarning, ('bad namespace: ' + ns)
@ -183,14 +186,17 @@ class SearchTest(Base):
self.update(qna[0] + qna[1] + attrs.getValueByQName(qna))
return
def endElementNS(self, (ns, local), qname):
if self.textField:
self.engine[self.textField] = self.content
self.textField = None
self.content = ''
self.lNames.pop()
self.indent = self.indent[0:-2]
def characters(self, content):
self.update(content)
if not self.textField:
return
self.engine[self.textField] = content
self.textField = None
self.content += content
def update(self, content):
self.md5.update(utf_8_encode(content)[0])
def openURL(self, attrs):
@ -205,14 +211,23 @@ class SearchTest(Base):
raise UserWarning, 'bad param'
return
def handleMozParam(self, attrs):
mp = None
try:
self.engine['urls'][-1]['MozParams'] = {
'name': attrs.getValueByQName(u'name'),
'condition': attrs.getValueByQName(u'condition'),
'trueValue': attrs.getValueByQName(u'trueValue'),
'falseValue': attrs.getValueByQName(u'falseValue')}
mp = { 'name': attrs.getValueByQName(u'name'),
'condition': attrs.getValueByQName(u'condition'),
'trueValue': attrs.getValueByQName(u'trueValue'),
'falseValue': attrs.getValueByQName(u'falseValue')}
except KeyError:
raise UserWarning, 'bad mozParam'
try:
mp = {'name': attrs.getValueByQName(u'name'),
'condition': attrs.getValueByQName(u'condition'),
'pref': attrs.getValueByQName(u'pref')}
except KeyError:
raise UserWarning, 'bad mozParam'
if self.engine['urls'][-1].has_key('MozParams'):
self.engine['urls'][-1]['MozParams'].append(mp)
else:
self.engine['urls'][-1]['MozParams'] = [mp]
return
def handleShortName(self, attrs):
self.textField = 'ShortName'

View File

@ -38,6 +38,9 @@
var searchController = {
__proto__: baseController,
get path() {
return 'results/' + this.tag + '/search-results.json';
},
beforeSelect: function() {
this.hashes = {};
searchView.setUpHandlers();
@ -55,6 +58,7 @@ var searchController = {
callback);
},
beforeUnSelect: function() {
this.hashes = {};
searchView.destroyHandlers();
},
showView: function(aClosure) {
@ -214,7 +218,16 @@ var searchView = {
sep = '&';
}
uc = uc.replace('{searchTerms}', q);
c += '<button onclick="window.open(this.textContent)">' + uc + '</button><br>';
var mpContent = '';
if (url.MozParams) {
for each (var mp in url.MozParams) {
// add at least the yahoo prefs
if (mp.condition == 'pref') {
mpContent += ', using pref ' + mp.name + '=' + mp.pref;
}
}
}
c += '<button onclick="window.open(this.textContent)">' + uc + '</button>' +mpContent+ '<br>';
len = len < c.length ? c.length : len;
}
this._dv.setBody(c);