Fully rework display with CSS style inclusion
This commit is contained in:
		| @@ -42,6 +42,11 @@ class IWLADisplayAllVisits(IPlugin): | ||||
|         display.addPage(page) | ||||
|  | ||||
|         index = self.iwla.getDisplayIndex() | ||||
|         block = DisplayHTMLRawBlock() | ||||
|         block.setRawHTML('<a href=\'%s\'>All visits</a>' % (filename)) | ||||
|         index.appendBlock(block) | ||||
|         link = '<a href=\'%s\'>All visits</a>' % (filename) | ||||
|         block = index.getBlock('Top visitors') | ||||
|         if block: | ||||
|             block.setTitle('%s - %s' % (block.getTitle(), link)) | ||||
|         else: | ||||
|             block = DisplayHTMLRawBlock() | ||||
|             block.setRawHTML(link) | ||||
|             index.appendBlock(block) | ||||
|   | ||||
| @@ -29,29 +29,10 @@ class IWLADisplayReferers(IPlugin): | ||||
|         top_key_phrases = key_phrases.items() | ||||
|         top_key_phrases = sorted(top_key_phrases, key=lambda t: t[1], reverse=True) | ||||
|  | ||||
|         # Top referers in index | ||||
|         cur_time = self.iwla.getCurTime() | ||||
|         index = self.iwla.getDisplayIndex() | ||||
|  | ||||
|         table = DisplayHTMLBlockTable('Connexion from', ['Origin', 'Pages', 'Hits']) | ||||
|         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']] | ||||
|             table.appendRow(row) | ||||
|  | ||||
|         table.appendRow(['<b>External URL</b>', '', '']) | ||||
|         for r,_ in top_referers[:10]: | ||||
|             row = [r, referers[r]['pages'], referers[r]['hits']] | ||||
|             table.appendRow(row) | ||||
|  | ||||
|         table.appendRow(['<b>External URL (robot)</b>', '', '']) | ||||
|         for r,_ in top_robots_referers[:10]: | ||||
|             row = [r, robots_referers[r]['pages'], robots_referers[r]['hits']] | ||||
|             table.appendRow(row) | ||||
|  | ||||
|         index.appendBlock(table) | ||||
|  | ||||
|         # All referers in a file | ||||
|         cur_time = self.iwla.getCurTime() | ||||
|         title = time.strftime('Connexion from - %B %Y', cur_time) | ||||
|  | ||||
|         filename = 'referers.html' | ||||
| @@ -80,14 +61,27 @@ class IWLADisplayReferers(IPlugin): | ||||
|         display = self.iwla.getDisplay() | ||||
|         display.addPage(page) | ||||
|  | ||||
|         block = DisplayHTMLRawBlock() | ||||
|         block.setRawHTML('<a href=\'%s\'>All referers</a>' % (filename)) | ||||
|         index.appendBlock(block) | ||||
|         link = '<a href=\'%s\'>All referers</a>' % (filename) | ||||
|  | ||||
|         # Top referers in index | ||||
|         title = '%s - %s' % ('Connexion from', link) | ||||
|  | ||||
|         table = DisplayHTMLBlockTable(title, ['Origin', 'Pages', 'Hits']) | ||||
|         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']] | ||||
|             table.appendRow(row) | ||||
|  | ||||
|         table.appendRow(['<b>External URL</b>', '', '']) | ||||
|         for r,_ in top_referers[:10]: | ||||
|             row = [r, referers[r]['pages'], referers[r]['hits']] | ||||
|             table.appendRow(row) | ||||
|  | ||||
|         table.appendRow(['<b>External URL (robot)</b>', '', '']) | ||||
|         for r,_ in top_robots_referers[:10]: | ||||
|             row = [r, robots_referers[r]['pages'], robots_referers[r]['hits']] | ||||
|             table.appendRow(row) | ||||
|  | ||||
|         # Top key phrases in index | ||||
|         table = DisplayHTMLBlockTable('Top key phrases', ['Key phrase', 'Search']) | ||||
|         for phrase in top_key_phrases[:10]: | ||||
|             table.appendRow([phrase[0], phrase[1]]) | ||||
|         index.appendBlock(table) | ||||
|  | ||||
|         # All key phrases in a file | ||||
| @@ -104,6 +98,11 @@ class IWLADisplayReferers(IPlugin): | ||||
|                          | ||||
|         display.addPage(page) | ||||
|  | ||||
|         block = DisplayHTMLRawBlock() | ||||
|         block.setRawHTML('<a href=\'%s\'>All key phrases</a>' % (filename)) | ||||
|         index.appendBlock(block) | ||||
|         link = '<a href=\'%s\'>All key phrases</a>' % (filename) | ||||
|  | ||||
|         # Top key phrases in index | ||||
|         title = '%s - %s' % ('Top key phrases', link) | ||||
|         table = DisplayHTMLBlockTable(title, ['Key phrase', 'Search']) | ||||
|         for phrase in top_key_phrases[:10]: | ||||
|             table.appendRow([phrase[0], phrase[1]]) | ||||
|         index.appendBlock(table) | ||||
|   | ||||
| @@ -12,20 +12,12 @@ class IWLADisplayTopDownloads(IPlugin): | ||||
|  | ||||
|     def hook(self): | ||||
|         top_downloads = self.iwla.getMonthStats()['top_downloads'] | ||||
|  | ||||
|         top_downloads = sorted(top_downloads.items(), key=lambda t: t[1], reverse=True) | ||||
|  | ||||
|         index = self.iwla.getDisplayIndex() | ||||
|          | ||||
|         table = DisplayHTMLBlockTable('Top Downloads', ['URI', 'Hits'])         | ||||
|         for (uri, entrance) in top_downloads[:10]: | ||||
|             table.appendRow([uri, entrance]) | ||||
|         index.appendBlock(table) | ||||
|  | ||||
|         title = time.strftime('Top Downloads - %B %Y', self.iwla.getCurTime()) | ||||
|  | ||||
|         # All in a file | ||||
|         filename = 'top_downloads.html' | ||||
|         path = self.iwla.getCurDisplayPath(filename) | ||||
|         title = time.strftime('All Downloads - %B %Y', self.iwla.getCurTime()) | ||||
|  | ||||
|         page = DisplayHTMLPage(title, path) | ||||
|         table = DisplayHTMLBlockTable('All Downloads', ['URI', 'Hit'])         | ||||
| @@ -33,9 +25,15 @@ class IWLADisplayTopDownloads(IPlugin): | ||||
|             table.appendRow([uri, entrance]) | ||||
|         page.appendBlock(table) | ||||
|                          | ||||
|         display = self.iwla.getDisplay() | ||||
|         display.addPage(page) | ||||
|         self.iwla.getDisplay().addPage(page) | ||||
|  | ||||
|         block = DisplayHTMLRawBlock() | ||||
|         block.setRawHTML('<a href=\'%s\'>All Downloads</a>' % (filename)) | ||||
|         index.appendBlock(block) | ||||
|         link = '<a href=\'%s\'>All Downloads</a>' % (filename) | ||||
|         title = '%s - %s' % ('Top Downloads', link) | ||||
|  | ||||
|         # Top in index | ||||
|         index = self.iwla.getDisplayIndex() | ||||
|          | ||||
|         table = DisplayHTMLBlockTable(title, ['URI', 'Hits'])         | ||||
|         for (uri, entrance) in top_downloads[:10]: | ||||
|             table.appendRow([uri, entrance]) | ||||
|         index.appendBlock(table) | ||||
|   | ||||
| @@ -12,30 +12,28 @@ class IWLADisplayTopHits(IPlugin): | ||||
|  | ||||
|     def hook(self): | ||||
|         top_hits = self.iwla.getMonthStats()['top_hits'] | ||||
|  | ||||
|         top_hits = sorted(top_hits.items(), key=lambda t: t[1], reverse=True) | ||||
|  | ||||
|         index = self.iwla.getDisplayIndex() | ||||
|          | ||||
|         table = DisplayHTMLBlockTable('Top Hits', ['URI', 'Entrance'])         | ||||
|         for (uri, entrance) in top_hits[:10]: | ||||
|             table.appendRow([uri, entrance]) | ||||
|         index.appendBlock(table) | ||||
|  | ||||
|         # All in a file | ||||
|         title = time.strftime('All Hits - %B %Y', self.iwla.getCurTime()) | ||||
|  | ||||
|         filename = 'top_hits.html' | ||||
|         path = self.iwla.getCurDisplayPath(filename) | ||||
|  | ||||
|         page = DisplayHTMLPage(title, path) | ||||
|         table = DisplayHTMLBlockTable('Top Hits', ['URI', 'Entrance'])         | ||||
|         table = DisplayHTMLBlockTable('All Hits', ['URI', 'Entrance'])         | ||||
|         for (uri, entrance) in top_hits: | ||||
|             table.appendRow([uri, entrance]) | ||||
|         page.appendBlock(table) | ||||
|                          | ||||
|         display = self.iwla.getDisplay() | ||||
|         display.addPage(page) | ||||
|         self.iwla.getDisplay().addPage(page) | ||||
|  | ||||
|         block = DisplayHTMLRawBlock() | ||||
|         block.setRawHTML('<a href=\'%s\'>All hits</a>' % (filename)) | ||||
|         index.appendBlock(block) | ||||
|         link = '<a href=\'%s\'>All hits</a>' % (filename) | ||||
|         title = '%s - %s' % ('Top Hits', link) | ||||
|  | ||||
|         # Top in index | ||||
|         index = self.iwla.getDisplayIndex() | ||||
|          | ||||
|         table = DisplayHTMLBlockTable(title, ['URI', 'Entrance'])         | ||||
|         for (uri, entrance) in top_hits[:10]: | ||||
|             table.appendRow([uri, entrance]) | ||||
|         index.appendBlock(table) | ||||
|   | ||||
| @@ -12,30 +12,28 @@ class IWLADisplayTopPages(IPlugin): | ||||
|  | ||||
|     def hook(self): | ||||
|         top_pages = self.iwla.getMonthStats()['top_pages'] | ||||
|  | ||||
|         top_pages = sorted(top_pages.items(), key=lambda t: t[1], reverse=True) | ||||
|  | ||||
|         index = self.iwla.getDisplayIndex() | ||||
|          | ||||
|         table = DisplayHTMLBlockTable('Top Pages', ['URI', 'Entrance'])         | ||||
|         for (uri, entrance) in top_pages[:10]: | ||||
|             table.appendRow([uri, entrance]) | ||||
|         index.appendBlock(table) | ||||
|  | ||||
|         # All in a page | ||||
|         title = time.strftime('All Pages - %B %Y', self.iwla.getCurTime()) | ||||
|  | ||||
|         filename = 'top_pages.html' | ||||
|         path = self.iwla.getCurDisplayPath(filename) | ||||
|  | ||||
|         page = DisplayHTMLPage(title, path) | ||||
|         table = DisplayHTMLBlockTable('Top Pages', ['URI', 'Entrance'])         | ||||
|         table = DisplayHTMLBlockTable('All Pages', ['URI', 'Entrance'])         | ||||
|         for (uri, entrance) in top_pages: | ||||
|             table.appendRow([uri, entrance]) | ||||
|         page.appendBlock(table) | ||||
|                          | ||||
|         display = self.iwla.getDisplay() | ||||
|         display.addPage(page) | ||||
|         self.iwla.getDisplay().addPage(page) | ||||
|  | ||||
|         block = DisplayHTMLRawBlock() | ||||
|         block.setRawHTML('<a href=\'%s\'>All pages</a>' % (filename)) | ||||
|         index.appendBlock(block) | ||||
|         link = '<a href=\'%s\'>All pages</a>' % (filename) | ||||
|         title = '%s - %s' % ('Top Pages', link) | ||||
|  | ||||
|         # Top in index | ||||
|         index = self.iwla.getDisplayIndex() | ||||
|          | ||||
|         table = DisplayHTMLBlockTable(title, ['URI', 'Entrance'])         | ||||
|         for (uri, entrance) in top_pages[:10]: | ||||
|             table.appendRow([uri, entrance]) | ||||
|         index.appendBlock(table) | ||||
|   | ||||
		Reference in New Issue
	
	Block a user