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_cssclasses.append(['' for e in row]) | ||||
|  | ||||
|     def getCellValue(row, col): | ||||
|     def getCellValue(self, row, col): | ||||
|         if row < 0 or col < 0 or\ | ||||
|            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] | ||||
|  | ||||
|     def setCellValue(row, col, value): | ||||
|     def setCellValue(self, row, col, value): | ||||
|         if row < 0 or col < 0 or\ | ||||
|            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] | ||||
|  | ||||
|     def setCellCSSClass(row, col, value): | ||||
|     def setCellCSSClass(self, row, col, value): | ||||
|         if row < 0 or col < 0 or\ | ||||
|            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 | ||||
|  | ||||
|     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): | ||||
|             raise ValueError('Invalid indice') | ||||
|             raise ValueError('Invalid indice %d' % (row)) | ||||
|  | ||||
|         for i in range(0, self.rows_cssclasses[row]): | ||||
|             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): | ||||
|         if not self.html: | ||||
|             html = '<table>' | ||||
|             html += '<tr>' | ||||
|             for title in self.cols: | ||||
|                 html += '<th>%s</th>' % (title) | ||||
|             html += '</tr>' | ||||
|             for row in self.rows: | ||||
|             if self.cols: | ||||
|                 html += '<tr>' | ||||
|                 for v in row: | ||||
|                     html += '<td>%s</td>' % (v) | ||||
|                 for i in range (0, len(self.cols)): | ||||
|                     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 += '</table>' | ||||
|             self.html = html | ||||
|   | ||||
							
								
								
									
										2
									
								
								iwla.py
									
									
									
									
									
								
							
							
						
						
									
										2
									
								
								iwla.py
									
									
									
									
									
								
							| @@ -232,7 +232,7 @@ class IWLA(object): | ||||
|         page = DisplayHTMLPage(title, filename) | ||||
|  | ||||
|         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.sort() | ||||
|         nb_visits = 0 | ||||
|   | ||||
| @@ -22,6 +22,8 @@ class IWLADisplayAllVisits(IPlugin): | ||||
|  | ||||
|         page = DisplayHTMLPage(title, path) | ||||
|         table = DisplayHTMLBlockTable('Last seen', ['Host', 'Pages', 'Hits', 'Bandwidth', 'Last seen']) | ||||
|         table.setColsCSSClass(['', 'iwla_page', 'iwla_hit', 'iwla_bandwith', '']) | ||||
|          | ||||
|         for super_hit in last_access: | ||||
|             address = super_hit['remote_addr'] | ||||
|             if display_visitor_ip and\ | ||||
|   | ||||
| @@ -40,6 +40,7 @@ class IWLADisplayReferers(IPlugin): | ||||
|  | ||||
|         page = DisplayHTMLPage(title, path) | ||||
|         table = DisplayHTMLBlockTable('Connexion from', ['Origin', 'Pages', 'Hits']) | ||||
|         table.setColsCSSClass(['', 'iwla_page', 'iwla_hit']) | ||||
|  | ||||
|         table.appendRow(['<b>Search Engine</b>', '', '']) | ||||
|         for r,_ in top_search_engine_referers: | ||||
| @@ -67,6 +68,8 @@ class IWLADisplayReferers(IPlugin): | ||||
|         title = '%s - %s' % ('Connexion from', link) | ||||
|  | ||||
|         table = DisplayHTMLBlockTable(title, ['Origin', 'Pages', 'Hits']) | ||||
|         table.setColsCSSClass(['', 'iwla_page', 'iwla_hit']) | ||||
|  | ||||
|         table.appendRow(['<b>Search Engine</b>', '', '']) | ||||
|         for r,_ in top_search_engine_referers[:10]: | ||||
|             row = [r, search_engine_referers[r]['pages'], search_engine_referers[r]['hits']] | ||||
| @@ -92,6 +95,7 @@ class IWLADisplayReferers(IPlugin): | ||||
|  | ||||
|         page = DisplayHTMLPage(title, path) | ||||
|         table = DisplayHTMLBlockTable('Top key phrases', ['Key phrase', 'Search']) | ||||
|         table.setColsCSSClass(['', 'iwla_search']) | ||||
|         for phrase in top_key_phrases: | ||||
|             table.appendRow([phrase[0], phrase[1]]) | ||||
|         page.appendBlock(table) | ||||
| @@ -103,6 +107,7 @@ class IWLADisplayReferers(IPlugin): | ||||
|         # Top key phrases in index | ||||
|         title = '%s - %s' % ('Top key phrases', link) | ||||
|         table = DisplayHTMLBlockTable(title, ['Key phrase', 'Search']) | ||||
|         table.setColsCSSClass(['', 'iwla_search']) | ||||
|         for phrase in top_key_phrases[:10]: | ||||
|             table.appendRow([phrase[0], phrase[1]]) | ||||
|         index.appendBlock(table) | ||||
|   | ||||
| @@ -21,6 +21,7 @@ class IWLADisplayTopDownloads(IPlugin): | ||||
|  | ||||
|         page = DisplayHTMLPage(title, path) | ||||
|         table = DisplayHTMLBlockTable('All Downloads', ['URI', 'Hit']) | ||||
|         table.setColsCSSClass(['', 'iwla_hit']) | ||||
|         for (uri, entrance) in top_downloads: | ||||
|             table.appendRow([uri, entrance]) | ||||
|         page.appendBlock(table) | ||||
| @@ -34,6 +35,7 @@ class IWLADisplayTopDownloads(IPlugin): | ||||
|         index = self.iwla.getDisplayIndex() | ||||
|          | ||||
|         table = DisplayHTMLBlockTable(title, ['URI', 'Hits']) | ||||
|         table.setColsCSSClass(['', 'iwla_hit']) | ||||
|         for (uri, entrance) in top_downloads[:10]: | ||||
|             table.appendRow([uri, entrance]) | ||||
|         index.appendBlock(table) | ||||
|   | ||||
| @@ -21,6 +21,7 @@ class IWLADisplayTopHits(IPlugin): | ||||
|  | ||||
|         page = DisplayHTMLPage(title, path) | ||||
|         table = DisplayHTMLBlockTable('All Hits', ['URI', 'Entrance'])         | ||||
|         table.setColsCSSClass(['', 'iwla_hit']) | ||||
|         for (uri, entrance) in top_hits: | ||||
|             table.appendRow([uri, entrance]) | ||||
|         page.appendBlock(table) | ||||
| @@ -34,6 +35,7 @@ class IWLADisplayTopHits(IPlugin): | ||||
|         index = self.iwla.getDisplayIndex() | ||||
|          | ||||
|         table = DisplayHTMLBlockTable(title, ['URI', 'Entrance'])         | ||||
|         table.setColsCSSClass(['', 'iwla_hit']) | ||||
|         for (uri, entrance) in top_hits[:10]: | ||||
|             table.appendRow([uri, entrance]) | ||||
|         index.appendBlock(table) | ||||
|   | ||||
| @@ -21,6 +21,7 @@ class IWLADisplayTopPages(IPlugin): | ||||
|  | ||||
|         page = DisplayHTMLPage(title, path) | ||||
|         table = DisplayHTMLBlockTable('All Pages', ['URI', 'Entrance']) | ||||
|         table.setColsCSSClass(['', 'iwla_hit']) | ||||
|         for (uri, entrance) in top_pages: | ||||
|             table.appendRow([uri, entrance]) | ||||
|         page.appendBlock(table) | ||||
| @@ -34,6 +35,7 @@ class IWLADisplayTopPages(IPlugin): | ||||
|         index = self.iwla.getDisplayIndex() | ||||
|          | ||||
|         table = DisplayHTMLBlockTable(title, ['URI', 'Entrance']) | ||||
|         table.setColsCSSClass(['', 'iwla_hit']) | ||||
|         for (uri, entrance) in top_pages[:10]: | ||||
|             table.appendRow([uri, entrance]) | ||||
|         index.appendBlock(table) | ||||
|   | ||||
| @@ -21,6 +21,7 @@ class IWLADisplayTopVisitors(IPlugin): | ||||
|  | ||||
|         index = self.iwla.getDisplayIndex() | ||||
|         table = DisplayHTMLBlockTable('Top visitors', ['Host', 'Pages', 'Hits', 'Bandwidth', 'Last seen']) | ||||
|         table.setColsCSSClass(['', 'iwla_page', 'iwla_hit', 'iwla_bandwith', '']) | ||||
|         for super_hit in top_visitors: | ||||
|             address = super_hit['remote_addr'] | ||||
|             if display_visitor_ip and\ | ||||
|   | ||||
		Reference in New Issue
	
	Block a user