changeset 942:32318ec7bfc1 beta

added branch/tag options to download links in summary
author Marcin Kuzminski <marcin@python-works.com>
date Thu, 13 Jan 2011 23:35:46 +0100
parents 442ccfe939d0
children 1f28cf5384bf
files rhodecode/controllers/files.py rhodecode/controllers/summary.py rhodecode/templates/summary/summary.html
diffstat 3 files changed, 75 insertions(+), 40 deletions(-) [+]
line wrap: on
line diff
--- a/rhodecode/controllers/files.py	Tue Jan 11 22:51:48 2011 +0100
+++ b/rhodecode/controllers/files.py	Thu Jan 13 23:35:46 2011 +0100
@@ -149,15 +149,23 @@
         return render('files/files_annotate.html')
 
     def archivefile(self, repo_name, fname):
-        info = fname.split('.')
-        revision, fileformat = info[0], '.' + '.'.join(info[1:])
         archive_specs = {
           '.tar.bz2': ('application/x-tar', 'tbz2'),
           '.tar.gz': ('application/x-tar', 'tgz'),
           '.zip': ('application/zip', 'zip'),
         }
+        
+        fileformat = None
+        revision = None
+        
+        for ext in archive_specs.keys():
+            archive_spec = fname.split(ext)
+            if len(archive_spec) == 2:
+                fileformat = archive_spec[1] or ext
+                revision = archive_spec[0]
+        
         if not archive_specs.has_key(fileformat):
-            return _('Unknown archive type %s') % fileformat
+            return _('Unknown archive type')
 
         repo = ScmModel().get_repo(repo_name)
 
--- a/rhodecode/controllers/summary.py	Tue Jan 11 22:51:48 2011 +0100
+++ b/rhodecode/controllers/summary.py	Thu Jan 13 23:35:46 2011 +0100
@@ -142,5 +142,27 @@
             c.trending_languages = json.dumps({})
             c.no_data = True
 
+        c.download_options = self._get_download_links(c.repo_info)
+
         return render('summary/summary.html')
 
+
+
+    def _get_download_links(self, repo):
+
+        download_l = []
+
+        branches_group = ([], _("Branches"))
+        tags_group = ([], _("Tags"))
+
+        for name, chs in c.repository_branches.items():
+            #chs = chs.split(':')[-1]
+            branches_group[0].append((chs, name),)
+        download_l.append(branches_group)
+
+        for name, chs in c.repository_tags.items():
+            #chs = chs.split(':')[-1]
+            tags_group[0].append((chs, name),)
+        download_l.append(tags_group)
+
+        return download_l
--- a/rhodecode/templates/summary/summary.html	Tue Jan 11 22:51:48 2011 +0100
+++ b/rhodecode/templates/summary/summary.html	Thu Jan 13 23:35:46 2011 +0100
@@ -119,9 +119,40 @@
 			      <label>${_('Trending source files')}:</label>
 			  </div>
 			  <div class="input-short">
-			    <div id="lang_stats">
-			    
-			    </div> 			  
+			    <div id="lang_stats"></div> 			   
+			  </div>
+			 </div>
+			 			
+			 <div class="field">
+			  <div class="label">
+			      <label>${_('Download')}:</label>
+			  </div>
+			  <div class="input-short">
+		        
+		        ${h.select('download_options','tip',c.download_options)}
+
+		        %for cnt,archive in enumerate(c.repo_info._get_archives()):
+		             %if cnt >=1:
+		             |
+		             %endif
+		             ${h.link_to(archive['type'],
+		                h.url('files_archive_home',repo_name=c.repo_info.name,
+		                fname='tip'+archive['extension']),class_="archive_icon")}
+		        %endfor
+			  </div>
+			 </div>
+			 
+			 <div class="field">
+			  <div class="label">
+			      <label>${_('Feeds')}:</label>
+			  </div>
+			  <div class="input-short">
+	            ${h.link_to(_('RSS'),h.url('rss_feed_home',repo_name=c.repo_info.name),class_='rss_icon')}
+	            ${h.link_to(_('Atom'),h.url('atom_feed_home',repo_name=c.repo_info.name),class_='atom_icon')}
+			  </div>
+			 </div>				 			 			 
+	  </div>		 
+	</div>
 			  	<script type="text/javascript">
 				  	YUE.onDOMReady(function(e){
 				  	    id = 'clone_url';
@@ -206,39 +237,13 @@
 			  			YUD.setStyle(YUD.get('code_stats_show_more'),
 			  					'display','none');
 			  		})
-			  		
-			  	</script>
- 
-			  </div>
-			 </div>
-			 			
-			 <div class="field">
-			  <div class="label">
-			      <label>${_('Download')}:</label>
-			  </div>
-			  <div class="input-short">
-		        %for cnt,archive in enumerate(c.repo_info._get_archives()):
-		             %if cnt >=1:
-		             |
-		             %endif
-		             ${h.link_to(c.repo_info.name+'.'+archive['type'],
-		                h.url('files_archive_home',repo_name=c.repo_info.name,
-		                fname='tip'+archive['extension']),class_="archive_icon")}
-		        %endfor
-			  </div>
-			 </div>
-			 
-			 <div class="field">
-			  <div class="label">
-			      <label>${_('Feeds')}:</label>
-			  </div>
-			  <div class="input-short">
-	            ${h.link_to(_('RSS'),h.url('rss_feed_home',repo_name=c.repo_info.name),class_='rss_icon')}
-	            ${h.link_to(_('Atom'),h.url('atom_feed_home',repo_name=c.repo_info.name),class_='atom_icon')}
-			  </div>
-			 </div>				 			 			 
-	  </div>		 
-	</div>				
+			  	
+                
+                YUE.on('download_options','change',function(e){
+                    var new_cs = e.target.options[e.target.selectedIndex].value;
+                })
+                	
+			  	</script>    				
 </div>
         
 <div class="box box-right"  style="min-height:455px">
@@ -644,4 +649,4 @@
     </div>      
 </div> 
 
-</%def>    
\ No newline at end of file
+</%def>