Work on CSS management
This commit is contained in:
		
							
								
								
									
										63
									
								
								display.py
									
									
									
									
									
								
							
							
						
						
									
										63
									
								
								display.py
									
									
									
									
									
								
							| @@ -60,45 +60,78 @@ class DisplayHTMLBlockTable(DisplayHTMLBlock): | |||||||
|         self.rows.append(listToStr(row)) |         self.rows.append(listToStr(row)) | ||||||
|         self.rows_cssclasses.append(['' for e in row]) |         self.rows_cssclasses.append(['' for e in row]) | ||||||
|  |  | ||||||
|     def getCellValue(row, col): |     def getCellValue(self, row, col): | ||||||
|         if row < 0 or col < 0 or\ |         if row < 0 or col < 0 or\ | ||||||
|            row >= len(self.rows) or col >= len(self.cols): |            row >= len(self.rows) or col >= len(self.cols): | ||||||
|             raise ValueError('Invalid indices') |             raise ValueError('Invalid indices %d,%d' % (row, col)) | ||||||
|  |  | ||||||
|         return self.rows[row][col] |         return self.rows[row][col] | ||||||
|  |  | ||||||
|     def setCellValue(row, col, value): |     def setCellValue(self, row, col, value): | ||||||
|         if row < 0 or col < 0 or\ |         if row < 0 or col < 0 or\ | ||||||
|            row >= len(self.rows) or col >= len(self.cols): |            row >= len(self.rows) or col >= len(self.cols): | ||||||
|             raise ValueError('Invalid indices') |             raise ValueError('Invalid indices %d,%d' % (row, col)) | ||||||
|  |  | ||||||
|         return self.rows[row][col] |         return self.rows[row][col] | ||||||
|  |  | ||||||
|     def setCellCSSClass(row, col, value): |     def setCellCSSClass(self, row, col, value): | ||||||
|         if row < 0 or col < 0 or\ |         if row < 0 or col < 0 or\ | ||||||
|            row >= len(self.rows) or col >= len(self.cols): |            row >= len(self.rows) or col >= len(self.cols): | ||||||
|             raise ValueError('Invalid indices') |             raise ValueError('Invalid indices %d,%d' % (row, col)) | ||||||
|  |  | ||||||
|         self.rows_cssclasses[row][col] = value |         self.rows_cssclasses[row][col] = value | ||||||
|  |  | ||||||
|     def setRowCSSClass(row, value): |     def getCellCSSClass(self, row, col): | ||||||
|  |         if row < 0 or col < 0 or\ | ||||||
|  |            row >= len(self.rows) or col >= len(self.cols): | ||||||
|  |             raise ValueError('Invalid indices %d,%d' % (row, col)) | ||||||
|  |  | ||||||
|  |         return self.rows_cssclasses[row][col] | ||||||
|  |  | ||||||
|  |     def getColCSSClass(self, col): | ||||||
|  |         if col < 0 or col >= len(self.cols): | ||||||
|  |             raise ValueError('Invalid indice %d' % (col)) | ||||||
|  |  | ||||||
|  |         return self.cols_cssclasses[col] | ||||||
|  |  | ||||||
|  |     def setRowCSSClass(self, row, value): | ||||||
|         if row < 0 or row >= len(self.rows): |         if row < 0 or row >= len(self.rows): | ||||||
|             raise ValueError('Invalid indice') |             raise ValueError('Invalid indice %d' % (row)) | ||||||
|  |  | ||||||
|         for i in range(0, self.rows_cssclasses[row]): |         for i in range(0, self.rows_cssclasses[row]): | ||||||
|             self.rows_cssclasses[row][i] = value |             self.rows_cssclasses[row][i] = value | ||||||
|  |  | ||||||
|  |     def setColCSSClass(self, col, value): | ||||||
|  |         if col < 0 or col >= len(self.cols): | ||||||
|  |             raise ValueError('Invalid indice %d' % (col)) | ||||||
|  |  | ||||||
|  |         self.cols_cssclasses[col] = value | ||||||
|  |  | ||||||
|  |     def setColsCSSClass(self, values): | ||||||
|  |         if len(values) != len(self.cols): | ||||||
|  |             raise ValueError('Invalid values size') | ||||||
|  |  | ||||||
|  |         self.cols_cssclasses = values | ||||||
|  |  | ||||||
|     def build(self, f): |     def build(self, f): | ||||||
|         if not self.html: |         if not self.html: | ||||||
|             html = '<table>' |             html = '<table>' | ||||||
|             html += '<tr>' |             if self.cols: | ||||||
|             for title in self.cols: |  | ||||||
|                 html += '<th>%s</th>' % (title) |  | ||||||
|             html += '</tr>' |  | ||||||
|             for row in self.rows: |  | ||||||
|                 html += '<tr>' |                 html += '<tr>' | ||||||
|                 for v in row: |                 for i in range (0, len(self.cols)): | ||||||
|                     html += '<td>%s</td>' % (v) |                     title = self.cols[i] | ||||||
|  |                     style = self.getColCSSClass(i) | ||||||
|  |                     if style: style = ' class="%s"' % (style) | ||||||
|  |                     html += '<th%s>%s</th>' % (style, title) | ||||||
|  |                 html += '</tr>' | ||||||
|  |             for i in range(0, len(self.rows)): | ||||||
|  |                 row = self.rows[i] | ||||||
|  |                 html += '<tr>' | ||||||
|  |                 for j in range(0, len(row)): | ||||||
|  |                     v = row[j] | ||||||
|  |                     style = self.getCellCSSClass(i, j) | ||||||
|  |                     if style: style = ' class="%s"' % (style) | ||||||
|  |                     html += '<td%s>%s</td>' % (style, v) | ||||||
|                 html += '</tr>' |                 html += '</tr>' | ||||||
|             html += '</table>' |             html += '</table>' | ||||||
|             self.html = html |             self.html = html | ||||||
|   | |||||||
							
								
								
									
										2
									
								
								iwla.py
									
									
									
									
									
								
							
							
						
						
									
										2
									
								
								iwla.py
									
									
									
									
									
								
							| @@ -232,7 +232,7 @@ class IWLA(object): | |||||||
|         page = DisplayHTMLPage(title, filename) |         page = DisplayHTMLPage(title, filename) | ||||||
|  |  | ||||||
|         days = DisplayHTMLBlockTable('By day', ['Day', 'Visits', 'Pages', 'Hits', 'Bandwidth', 'Not viewed Bandwidth']) |         days = DisplayHTMLBlockTable('By day', ['Day', 'Visits', 'Pages', 'Hits', 'Bandwidth', 'Not viewed Bandwidth']) | ||||||
|  |         days.setColsCSSClass(['', 'iwla_visit', 'iwla_page', 'iwla_hit', 'iwla_bandwith', 'iwla_bandwith']) | ||||||
|         keys = self.current_analysis['days_stats'].keys() |         keys = self.current_analysis['days_stats'].keys() | ||||||
|         keys.sort() |         keys.sort() | ||||||
|         nb_visits = 0 |         nb_visits = 0 | ||||||
|   | |||||||
| @@ -22,6 +22,8 @@ class IWLADisplayAllVisits(IPlugin): | |||||||
|  |  | ||||||
|         page = DisplayHTMLPage(title, path) |         page = DisplayHTMLPage(title, path) | ||||||
|         table = DisplayHTMLBlockTable('Last seen', ['Host', 'Pages', 'Hits', 'Bandwidth', 'Last seen']) |         table = DisplayHTMLBlockTable('Last seen', ['Host', 'Pages', 'Hits', 'Bandwidth', 'Last seen']) | ||||||
|  |         table.setColsCSSClass(['', 'iwla_page', 'iwla_hit', 'iwla_bandwith', '']) | ||||||
|  |          | ||||||
|         for super_hit in last_access: |         for super_hit in last_access: | ||||||
|             address = super_hit['remote_addr'] |             address = super_hit['remote_addr'] | ||||||
|             if display_visitor_ip and\ |             if display_visitor_ip and\ | ||||||
|   | |||||||
| @@ -40,6 +40,7 @@ class IWLADisplayReferers(IPlugin): | |||||||
|  |  | ||||||
|         page = DisplayHTMLPage(title, path) |         page = DisplayHTMLPage(title, path) | ||||||
|         table = DisplayHTMLBlockTable('Connexion from', ['Origin', 'Pages', 'Hits']) |         table = DisplayHTMLBlockTable('Connexion from', ['Origin', 'Pages', 'Hits']) | ||||||
|  |         table.setColsCSSClass(['', 'iwla_page', 'iwla_hit']) | ||||||
|  |  | ||||||
|         table.appendRow(['<b>Search Engine</b>', '', '']) |         table.appendRow(['<b>Search Engine</b>', '', '']) | ||||||
|         for r,_ in top_search_engine_referers: |         for r,_ in top_search_engine_referers: | ||||||
| @@ -67,6 +68,8 @@ class IWLADisplayReferers(IPlugin): | |||||||
|         title = '%s - %s' % ('Connexion from', link) |         title = '%s - %s' % ('Connexion from', link) | ||||||
|  |  | ||||||
|         table = DisplayHTMLBlockTable(title, ['Origin', 'Pages', 'Hits']) |         table = DisplayHTMLBlockTable(title, ['Origin', 'Pages', 'Hits']) | ||||||
|  |         table.setColsCSSClass(['', 'iwla_page', 'iwla_hit']) | ||||||
|  |  | ||||||
|         table.appendRow(['<b>Search Engine</b>', '', '']) |         table.appendRow(['<b>Search Engine</b>', '', '']) | ||||||
|         for r,_ in top_search_engine_referers[:10]: |         for r,_ in top_search_engine_referers[:10]: | ||||||
|             row = [r, search_engine_referers[r]['pages'], search_engine_referers[r]['hits']] |             row = [r, search_engine_referers[r]['pages'], search_engine_referers[r]['hits']] | ||||||
| @@ -92,6 +95,7 @@ class IWLADisplayReferers(IPlugin): | |||||||
|  |  | ||||||
|         page = DisplayHTMLPage(title, path) |         page = DisplayHTMLPage(title, path) | ||||||
|         table = DisplayHTMLBlockTable('Top key phrases', ['Key phrase', 'Search']) |         table = DisplayHTMLBlockTable('Top key phrases', ['Key phrase', 'Search']) | ||||||
|  |         table.setColsCSSClass(['', 'iwla_search']) | ||||||
|         for phrase in top_key_phrases: |         for phrase in top_key_phrases: | ||||||
|             table.appendRow([phrase[0], phrase[1]]) |             table.appendRow([phrase[0], phrase[1]]) | ||||||
|         page.appendBlock(table) |         page.appendBlock(table) | ||||||
| @@ -103,6 +107,7 @@ class IWLADisplayReferers(IPlugin): | |||||||
|         # Top key phrases in index |         # Top key phrases in index | ||||||
|         title = '%s - %s' % ('Top key phrases', link) |         title = '%s - %s' % ('Top key phrases', link) | ||||||
|         table = DisplayHTMLBlockTable(title, ['Key phrase', 'Search']) |         table = DisplayHTMLBlockTable(title, ['Key phrase', 'Search']) | ||||||
|  |         table.setColsCSSClass(['', 'iwla_search']) | ||||||
|         for phrase in top_key_phrases[:10]: |         for phrase in top_key_phrases[:10]: | ||||||
|             table.appendRow([phrase[0], phrase[1]]) |             table.appendRow([phrase[0], phrase[1]]) | ||||||
|         index.appendBlock(table) |         index.appendBlock(table) | ||||||
|   | |||||||
| @@ -21,6 +21,7 @@ class IWLADisplayTopDownloads(IPlugin): | |||||||
|  |  | ||||||
|         page = DisplayHTMLPage(title, path) |         page = DisplayHTMLPage(title, path) | ||||||
|         table = DisplayHTMLBlockTable('All Downloads', ['URI', 'Hit']) |         table = DisplayHTMLBlockTable('All Downloads', ['URI', 'Hit']) | ||||||
|  |         table.setColsCSSClass(['', 'iwla_hit']) | ||||||
|         for (uri, entrance) in top_downloads: |         for (uri, entrance) in top_downloads: | ||||||
|             table.appendRow([uri, entrance]) |             table.appendRow([uri, entrance]) | ||||||
|         page.appendBlock(table) |         page.appendBlock(table) | ||||||
| @@ -34,6 +35,7 @@ class IWLADisplayTopDownloads(IPlugin): | |||||||
|         index = self.iwla.getDisplayIndex() |         index = self.iwla.getDisplayIndex() | ||||||
|          |          | ||||||
|         table = DisplayHTMLBlockTable(title, ['URI', 'Hits']) |         table = DisplayHTMLBlockTable(title, ['URI', 'Hits']) | ||||||
|  |         table.setColsCSSClass(['', 'iwla_hit']) | ||||||
|         for (uri, entrance) in top_downloads[:10]: |         for (uri, entrance) in top_downloads[:10]: | ||||||
|             table.appendRow([uri, entrance]) |             table.appendRow([uri, entrance]) | ||||||
|         index.appendBlock(table) |         index.appendBlock(table) | ||||||
|   | |||||||
| @@ -21,6 +21,7 @@ class IWLADisplayTopHits(IPlugin): | |||||||
|  |  | ||||||
|         page = DisplayHTMLPage(title, path) |         page = DisplayHTMLPage(title, path) | ||||||
|         table = DisplayHTMLBlockTable('All Hits', ['URI', 'Entrance'])         |         table = DisplayHTMLBlockTable('All Hits', ['URI', 'Entrance'])         | ||||||
|  |         table.setColsCSSClass(['', 'iwla_hit']) | ||||||
|         for (uri, entrance) in top_hits: |         for (uri, entrance) in top_hits: | ||||||
|             table.appendRow([uri, entrance]) |             table.appendRow([uri, entrance]) | ||||||
|         page.appendBlock(table) |         page.appendBlock(table) | ||||||
| @@ -34,6 +35,7 @@ class IWLADisplayTopHits(IPlugin): | |||||||
|         index = self.iwla.getDisplayIndex() |         index = self.iwla.getDisplayIndex() | ||||||
|          |          | ||||||
|         table = DisplayHTMLBlockTable(title, ['URI', 'Entrance'])         |         table = DisplayHTMLBlockTable(title, ['URI', 'Entrance'])         | ||||||
|  |         table.setColsCSSClass(['', 'iwla_hit']) | ||||||
|         for (uri, entrance) in top_hits[:10]: |         for (uri, entrance) in top_hits[:10]: | ||||||
|             table.appendRow([uri, entrance]) |             table.appendRow([uri, entrance]) | ||||||
|         index.appendBlock(table) |         index.appendBlock(table) | ||||||
|   | |||||||
| @@ -21,6 +21,7 @@ class IWLADisplayTopPages(IPlugin): | |||||||
|  |  | ||||||
|         page = DisplayHTMLPage(title, path) |         page = DisplayHTMLPage(title, path) | ||||||
|         table = DisplayHTMLBlockTable('All Pages', ['URI', 'Entrance']) |         table = DisplayHTMLBlockTable('All Pages', ['URI', 'Entrance']) | ||||||
|  |         table.setColsCSSClass(['', 'iwla_hit']) | ||||||
|         for (uri, entrance) in top_pages: |         for (uri, entrance) in top_pages: | ||||||
|             table.appendRow([uri, entrance]) |             table.appendRow([uri, entrance]) | ||||||
|         page.appendBlock(table) |         page.appendBlock(table) | ||||||
| @@ -34,6 +35,7 @@ class IWLADisplayTopPages(IPlugin): | |||||||
|         index = self.iwla.getDisplayIndex() |         index = self.iwla.getDisplayIndex() | ||||||
|          |          | ||||||
|         table = DisplayHTMLBlockTable(title, ['URI', 'Entrance']) |         table = DisplayHTMLBlockTable(title, ['URI', 'Entrance']) | ||||||
|  |         table.setColsCSSClass(['', 'iwla_hit']) | ||||||
|         for (uri, entrance) in top_pages[:10]: |         for (uri, entrance) in top_pages[:10]: | ||||||
|             table.appendRow([uri, entrance]) |             table.appendRow([uri, entrance]) | ||||||
|         index.appendBlock(table) |         index.appendBlock(table) | ||||||
|   | |||||||
| @@ -21,6 +21,7 @@ class IWLADisplayTopVisitors(IPlugin): | |||||||
|  |  | ||||||
|         index = self.iwla.getDisplayIndex() |         index = self.iwla.getDisplayIndex() | ||||||
|         table = DisplayHTMLBlockTable('Top visitors', ['Host', 'Pages', 'Hits', 'Bandwidth', 'Last seen']) |         table = DisplayHTMLBlockTable('Top visitors', ['Host', 'Pages', 'Hits', 'Bandwidth', 'Last seen']) | ||||||
|  |         table.setColsCSSClass(['', 'iwla_page', 'iwla_hit', 'iwla_bandwith', '']) | ||||||
|         for super_hit in top_visitors: |         for super_hit in top_visitors: | ||||||
|             address = super_hit['remote_addr'] |             address = super_hit['remote_addr'] | ||||||
|             if display_visitor_ip and\ |             if display_visitor_ip and\ | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user