Changeset - 2a8bf2a3da98
[Not reviewed]
beta
0 2 0
Marcin Kuzminski - 14 years ago 2011-08-26 23:59:12
marcin@python-works.com
fixes #214 added support for downloading subrepos in download menu.
2 files changed with 21 insertions and 16 deletions:
0 comments (0 inline, 0 general)
rhodecode/controllers/files.py
Show inline comments
 
@@ -262,24 +262,25 @@ class FilesController(BaseRepoController
 
            return redirect(url('changeset_home',
 
                                repo_name=c.repo_name, revision='tip'))
 

	
 
        return render('files/files_edit.html')
 

	
 
    @HasRepoPermissionAnyDecorator('repository.read', 'repository.write',
 
                                   'repository.admin')
 
    def archivefile(self, repo_name, fname):
 

	
 
        fileformat = None
 
        revision = None
 
        ext = None
 
        subrepos = request.GET.get('subrepos') == 'true'
 

	
 
        for a_type, ext_data in ARCHIVE_SPECS.items():
 
            archive_spec = fname.split(ext_data[1])
 
            if len(archive_spec) == 2 and archive_spec[1] == '':
 
                fileformat = a_type or ext_data[1]
 
                revision = archive_spec[0]
 
                ext = ext_data[1]
 

	
 
        try:
 
            dbrepo = RepoModel().get_by_repo_name(repo_name)
 
            if dbrepo.enable_downloads is False:
 
                return _('downloads disabled')
 
@@ -291,25 +292,25 @@ class FilesController(BaseRepoController
 
        except EmptyRepositoryError:
 
            return _('Empty repository')
 
        except (ImproperArchiveTypeError, KeyError):
 
            return _('Unknown archive type')
 

	
 
        response.content_type = content_type
 
        response.content_disposition = 'attachment; filename=%s-%s%s' \
 
            % (repo_name, revision, ext)
 

	
 
        import tempfile
 
        archive = tempfile.mkstemp()[1]
 
        t = open(archive, 'wb')
 
        cs.fill_archive(stream=t, kind=fileformat)
 
        cs.fill_archive(stream=t, kind=fileformat, subrepos=subrepos)
 

	
 
        def get_chunked_archive(archive):
 
            stream = open(archive, 'rb')
 
            while True:
 
                data = stream.read(4096)
 
                if not data:
 
                    os.remove(archive)
 
                    break
 
                yield data
 

	
 
        return get_chunked_archive(archive)
 

	
rhodecode/templates/summary/summary.html
Show inline comments
 
@@ -155,24 +155,27 @@
 
                    %endif  		          
 
		        %else:
 
			        ${h.select('download_options',c.rhodecode_repo.get_changeset().raw_id,c.download_options)}
 
			        %for cnt,archive in enumerate(c.rhodecode_repo._get_archives()):
 
			             %if cnt >=1:
 
			             |
 
			             %endif
 
			             <span class="tooltip" title="${_('Download %s as %s') %('tip',archive['type'])}" 
 
			                  id="${archive['type']+'_link'}">${h.link_to(archive['type'],
 
			                h.url('files_archive_home',repo_name=c.dbrepo.repo_name,
 
			                fname='tip'+archive['extension']),class_="archive_icon")}</span>
 
			        %endfor
 
                    <span style="vertical-align: bottom">
 
                        <input id="archive_subrepos" type="checkbox" name="subrepos"/> <span class="tooltip" title="${_('Check this to download archive with subrepos')}" >${_('with subrepos')}</span>
 
                    </span>
 
			    %endif
 
			  </div>
 
			 </div>
 
			 
 
			 <div class="field">
 
			  <div class="label">
 
			      <label>${_('Feeds')}:</label>
 
			  </div>
 
			  <div class="input-short">
 
			   %if c.rhodecode_user.username != 'default':
 
	            ${h.link_to(_('RSS'),h.url('rss_feed_home',repo_name=c.dbrepo.repo_name,api_key=c.rhodecode_user.api_key),class_='rss_icon')}
 
	            ${h.link_to(_('Atom'),h.url('atom_feed_home',repo_name=c.dbrepo.repo_name,api_key=c.rhodecode_user.api_key),class_='atom_icon')}
 
@@ -269,45 +272,46 @@
 
  			tbl.appendChild(tr);
 
		}
 
  		YUD.get('lang_stats').appendChild(tbl);
 
  		YUE.on('code_stats_show_more','click',function(){
 
  			l = YUD.getElementsByClassName('stats_hidden')
 
  			for (e in l){
 
  			    YUD.setStyle(l[e],'display','');
 
  			};
 
  			YUD.setStyle(YUD.get('code_stats_show_more'),
 
  					'display','none');
 
  		})
 
  	
 
             
 
             YUE.on('download_options','change',function(e){
 
                 var new_cs = e.target.options[e.target.selectedIndex];
 
                 var tmpl_links = {}
 
                 %for cnt,archive in enumerate(c.rhodecode_repo._get_archives()):
 
                	 tmpl_links['${archive['type']}'] = '${h.link_to(archive['type'],
 
                        h.url('files_archive_home',repo_name=c.dbrepo.repo_name,
 
                        fname='__CS__'+archive['extension']),class_="archive_icon")}';
 
                 %endfor
 
                
 
             var tmpl_links = {}
 
              %for cnt,archive in enumerate(c.rhodecode_repo._get_archives()):
 
                tmpl_links['${archive['type']}'] = '${h.link_to(archive['type'],
 
                     h.url('files_archive_home',repo_name=c.dbrepo.repo_name,
 
                     fname='__CS__'+archive['extension'],subrepos='__SUB__'),class_="archive_icon")}';
 
              %endfor
 
              
 
             YUE.on(['download_options','archive_subrepos'],'change',function(e){
 
            	 var sm = YUD.get('download_options');
 
                 var new_cs = sm.options[sm.selectedIndex];
 
                 
 
                 for(k in tmpl_links){
 
                	 var s = YUD.get(k+'_link')
 
                	 var s = YUD.get(k+'_link');
 
                	 title_tmpl = "${_('Download %s as %s') % ('__CS_NAME__','__CS_EXT__')}";
 
                	 s.title = title_tmpl.replace('__CS_NAME__',new_cs.text);
 
                	 s.title = s.title.replace('__CS_EXT__',k);
 
                	 s.innerHTML = tmpl_links[k].replace('__CS__',new_cs.value);
 
                	 var url = tmpl_links[k].replace('__CS__',new_cs.value);
 
                	 var subrepos = YUD.get('archive_subrepos').checked
 
                	 url = url.replace('__SUB__',subrepos);
 
                	 s.innerHTML = url 
 
                 }
 
                 
 
             })
 
             	
 
             });
 
  	</script>    				
 
</div>
 
        
 
<div class="box box-right"  style="min-height:455px">
 
    <!-- box / title -->
 
    <div class="title">
 
        <h5>${_('Commit activity by day / author')}</h5>
 
    </div>
 
    
 
    <div class="graph">
 
         <div style="padding:0 10px 10px 15px;font-size: 1.2em;">
 
         %if c.no_data:
0 comments (0 inline, 0 general)