KisssPM
  • Overview
  • Repository
  • Tickets
  • Statistics
  • Credits
  • Projects

Repository

In the ForgeTab, read the language from the config file

Parent commits : 86a365e5b06888cc68461474e919d6f28bb17c57,
Children commits : a5325de38b42f473325c420b07ad6730a1429367,

By Laurent Defert on 2015-03-14 11:50:52
In the ForgeTab, read the language from the config file

Required as the mimetype is not always precise.

Browse content
Difference with parent commit 86a365e5b06888cc68461474e919d6f28bb17c57
Files modified:
kissspm/tabs/forge.py
--- 
+++ 
@@ -68,24 +68,28 @@
             commit_stats.render_miniature_activity(img_path)
             img_url = '%s/activity_%i.png' % (self.name, no)
 
-            # Main mimetype
-            commit_stats._build_tree_stats(repo.repo['refs/heads/master'].tree)
-            mimetype = ''
+            # Project main language
+            if config.has_option('project', 'language'):
+                language =config.get('project', 'language')
+            else:
+                commit_stats._build_tree_stats(repo.repo['refs/heads/master'].tree)
+                mimetype = ''
 
-            mimecount = [(mime, count) for mime, count in commit_stats.mime_type_count.iteritems() if (mime.startswith('text/x-') or mime.startswith('application/x-'))]
-            mimecount.sort(key=lambda x: -x[1])
+                mimecount = [(mime, count) for mime, count in commit_stats.mime_type_count.iteritems() if (mime.startswith('text/x-') or mime.startswith('application/x-'))]
+                mimecount.sort(key=lambda x: -x[1])
 
-            # TODO: Count the number of lines to determine the mimetype
-            # as there is the same number of file with the same mimetype
-            # if len(mimecount) > 1 and mimecount[0][1] == mimecount[1][1]:
+                # TODO: Count the number of lines to determine the mimetype
+                # as there is the same number of file with the same mimetype
+                # if len(mimecount) > 1 and mimecount[0][1] == mimecount[1][1]:
 
-            if len(mimecount):
-                mimetype = mimecount[0][0]
+                if len(mimecount):
+                    mimetype = mimecount[0][0]
 
-            if mimetype.startswith('text/x-'):
-                mimetype = mimetype.replace('text/x-', '').title()
-            elif mimetype.startswith('application/x-'):
-                mimetype = mimetype.replace('application/x-', '').title()
+                if mimetype.startswith('text/x-'):
+                    mimetype = mimetype.replace('text/x-', '').title()
+                elif mimetype.startswith('application/x-'):
+                    mimetype = mimetype.replace('application/x-', '').title()
+                language = mimetype
 
             # Last modification date
             last_modified_time = datetime.fromtimestamp(repo.repo['refs/heads/master'].author_time)
@@ -100,7 +104,7 @@
                 'activity': img_url,
                 'last_modified': last_modified,
                 'last_modified_time': last_modified_time,
-                'mimetype': mimetype,
+                'language': language,
             })
         namespace['projects'].sort(key=lambda x: x['last_modified_time'])
         namespace['projects'].reverse()

share/themes/default/forge.html
--- 
+++ 
@@ -21,7 +21,7 @@
         #end if
         </td>
         <td><a href="$project.url"><b>$project.name</b></a></td>
-        <td>$project.mimetype</td>
+        <td>$project.language</td>
         <td>$project.last_modified</td>
         <td>
         #if $project.repository_url

Generated with KisssPM