Browse Source

[enh] better highlighting

Adam Tauber 11 years ago
parent
commit
5d9d04a16e

+ 2
- 0
searx/static/css/style.css View File

48
 .right{float:right}
48
 .right{float:right}
49
 .invisible{display:none}
49
 .invisible{display:none}
50
 .left{float:left}
50
 .left{float:left}
51
+.highlight{color:#094089}
52
+.content .highlight{color:#000}
51
 .image_result{float:left;margin:10px 10px;position:relative;height:160px}.image_result img{border:0;height:160px}
53
 .image_result{float:left;margin:10px 10px;position:relative;height:160px}.image_result img{border:0;height:160px}
52
 .image_result p{margin:0;padding:0}.image_result p span a{display:none;color:#fff}
54
 .image_result p{margin:0;padding:0}.image_result p span a{display:none;color:#fff}
53
 .image_result p:hover span a{display:block;position:absolute;bottom:0;right:0;padding:4px;background-color:rgba(0,0,0,0.6);font-size:.7em}
55
 .image_result p:hover span a{display:block;position:absolute;bottom:0;right:0;padding:4px;background-color:rgba(0,0,0,0.6);font-size:.7em}

+ 2
- 1
searx/static/less/definitions.less View File

9
 @color-base: #3498DB;
9
 @color-base: #3498DB;
10
 @color-base-dark: #2980B9;
10
 @color-base-dark: #2980B9;
11
 @color-base-light: #ECF0F1;
11
 @color-base-light: #ECF0F1;
12
-
12
+@color-highlight: #094089;
13
+@color-black: #000000;
13
 
14
 
14
 /// General
15
 /// General
15
 
16
 

+ 8
- 0
searx/static/less/style.less View File

273
 	float: left;
273
 	float: left;
274
 }
274
 }
275
 
275
 
276
+.highlight {
277
+    color: @color-highlight;
278
+}
279
+
280
+.content .highlight {
281
+    color: @color-black;
282
+}
283
+
276
 .image_result {
284
 .image_result {
277
 	float: left;
285
 	float: left;
278
 	margin: 10px 10px;
286
 	margin: 10px 10px;

+ 2
- 2
searx/utils.py View File

28
     query = query.decode('utf-8')
28
     query = query.decode('utf-8')
29
     if content.lower().find(query.lower()) > -1:
29
     if content.lower().find(query.lower()) > -1:
30
         query_regex = u'({0})'.format(re.escape(query))
30
         query_regex = u'({0})'.format(re.escape(query))
31
-        content = re.sub(query_regex, '<b>\\1</b>', content, flags=re.I | re.U)
31
+        content = re.sub(query_regex, '<span class="highlight">\\1</span>', content, flags=re.I | re.U)
32
     else:
32
     else:
33
         regex_parts = []
33
         regex_parts = []
34
         for chunk in query.split():
34
         for chunk in query.split():
37
             else:
37
             else:
38
                 regex_parts.append(u'{0}'.format(re.escape(chunk)))
38
                 regex_parts.append(u'{0}'.format(re.escape(chunk)))
39
         query_regex = u'({0})'.format('|'.join(regex_parts))
39
         query_regex = u'({0})'.format('|'.join(regex_parts))
40
-        content = re.sub(query_regex, '<b>\\1</b>', content, flags=re.I | re.U)
40
+        content = re.sub(query_regex, '<span class="highlight">\\1</span>', content, flags=re.I | re.U)
41
 
41
 
42
     return content
42
     return content
43
 
43