Changeset - 9deb6f1d5b90
[Not reviewed]
default
1 1 3
Marcin Kuzminski - 16 years ago 2010-05-03 21:59:01
marcin@python-works.com
Implemented file history.
4 files changed with 96 insertions and 87 deletions:
0 comments (0 inline, 0 general)
pylons_app/controllers/files.py
Show inline comments
 
@@ -22,4 +22,18 @@ class FilesController(BaseController):
 
        
 
        c.files_list = c.changeset.get_node(f_path)
 
        
 
        return render('/files.html')
 
        c.file_history = self._get_history(repo, c.files_list, f_path)
 
        return render('files/files.html')
 

	
 

	
 
    def _get_history(self, repo, node, f_path):
 
        from vcs.nodes import NodeKind
 
        if not node.kind is NodeKind.FILE:
 
            return []
 
        changesets = list(node.history)
 
        changesets.reverse()
 
        hist_l = []
 
        for chs in changesets:
 
            n_desc = 'r%s:%s' % (chs.revision, chs._short)
 
            hist_l.append((chs._short, n_desc,))
 
        return hist_l
pylons_app/templates/files/files.html
Show inline comments
 
file renamed from pylons_app/templates/files.html to pylons_app/templates/files/files.html
 
<%inherit file="base/base.html"/>
 
<%inherit file="/base/base.html"/>
 

	
 
<%def name="title()">
 
    ${_('Repository managment')}
 
@@ -28,93 +28,11 @@
 

	
 
    <h2 class="no-link no-border">${_('Files')}</h2>
 
	<div id="files_data">
 
		<h2>${_('File')}: ${h.files_breadcrumbs(c.repo_name,c.cur_rev,c.files_list.path)}</h2>
 
		<h2>${_('Location')}: ${h.files_breadcrumbs(c.repo_name,c.cur_rev,c.files_list.path)}</h2>
 
		%if c.files_list.is_dir():
 
        <table class="code-browser">
 
            <thead>
 
                <tr>
 
                    <th class="width-50 lefted">${_('Name')}</th>
 
                    <th class="width-10 righted">${_('Size')}</th>
 
                    <th class="width-10 righted">${_('Revision')}</th>
 
                    <th class="width-15 righted">${_('Last modified')}</th>
 
                    <th class="width-15 righted">${_('Last commiter')}</th>
 
                </tr>
 
            </thead>
 
            	<tr>
 
            		% if c.files_list.parent:
 
	            		<td>
 
	            			${h.link_to('..',h.url('files_home',repo_name=c.repo_name,revision=c.cur_rev,f_path=c.files_list.parent),class_="browser-dir")}
 
	            		</td>
 
	            		<td></td>
 
	            		<td></td>
 
	            		<td></td>
 
	            		<td></td>
 
            		%endif
 
            	</tr>
 
					<%def name="file_class(node)">
 
						%if node.is_file():
 
							<%return "browser-file" %>
 
				<%include file='files_browser.html'/>
 
						%else:
 
							<%return "browser-dir"%>
 
						%endif
 
					</%def>
 
			
 

	
 
	            %for cnt,node in enumerate(c.files_list):
 
					<tr class="parity${cnt%2}">
 
	
 
	                    <td>
 
							${h.link_to(node.name,h.url('files_home',repo_name=c.repo_name,revision=c.cur_rev,f_path=node.path),class_=file_class(node))}
 
	                    </td>
 
	                    <td>
 
	                        %if node.is_file():
 
	                    		${h.filesizeformat(node.size)}
 
	                    	%endif
 
	                    </td>
 
	                    <td>
 
	                    	%if node.is_file():
 
	                    		${node.last_changeset.revision}
 
	                    	%endif
 
	                    </td>
 
	                    <td>
 
	                    	%if node.is_file():
 
	                    		${node.last_changeset.date}
 
	                    	%endif
 
	                    </td>
 
	                    <td>
 
	                    	%if node.is_file():
 
	                    		${node.last_changeset.author}
 
	                    	%endif                    
 
	                    	
 
	                    </td>
 
					</tr>
 
				%endfor
 
			</table>
 
			%else:
 
			<table class="info-table">
 
				<tr>
 
					<td>r70:17ecc1c97401</td>
 
					<td>374 loc</td>
 
					<td>12.5 KB</td>
 
					<td>
 
						<a href="/marcinkuzminski/vcs/history/vcs/backends/hg.py">history</a> / 
 
						<a href="/marcinkuzminski/vcs/annotate/17ecc1c97401/vcs/backends/hg.py">annotate</a> / 
 
						<a href="/marcinkuzminski/vcs/raw/17ecc1c97401/vcs/backends/hg.py">raw</a> / 
 
						<form class="source-view-form" method="get" action="/marcinkuzminski/vcs/diff/vcs/backends/hg.py">
 
							
 
							<input type="hidden" value="17ecc1c97401" name="diff2">
 
								<select class="smaller" name="diff1">
 
									<option>history</option>							
 
								</select>
 
								<input type="submit" class="smaller" value="diff">
 
							
 
						</form>
 
					</td>
 
				</tr>
 
			</table>			
 
				<div id="body" class="codeblock">
 
				${h.pygmentize(c.files_list.content,linenos=True,anchorlinenos=True,cssclass="code-highlight")}
 
				</div>				
 
				<%include file='files_source.html'/>			
 
			%endif
 
	</div>
 
</%def>    
 
\ No newline at end of file
pylons_app/templates/files/files_browser.html
Show inline comments
 
new file 100644
 
<%def name="file_class(node)">
 
	%if node.is_file():
 
		<%return "browser-file" %>
 
	%else:
 
		<%return "browser-dir"%>
 
	%endif
 
</%def>
 
		
 
<table class="code-browser">
 
         <thead>
 
             <tr>
 
                 <th class="width-50 lefted">${_('Name')}</th>
 
                 <th class="width-10 righted">${_('Size')}</th>
 
                 <th class="width-10 righted">${_('Revision')}</th>
 
                 <th class="width-15 righted">${_('Last modified')}</th>
 
                 <th class="width-15 righted">${_('Last commiter')}</th>
 
             </tr>
 
         </thead>
 
         	<tr>
 
         		% if c.files_list.parent:
 
          		<td>
 
          			${h.link_to('..',h.url('files_home',repo_name=c.repo_name,revision=c.cur_rev,f_path=c.files_list.parent),class_="browser-dir")}
 
          		</td>
 
          		<td></td>
 
          		<td></td>
 
          		<td></td>
 
          		<td></td>
 
         		%endif
 
         	</tr>
 
    %for cnt,node in enumerate(c.files_list):
 
		<tr class="parity${cnt%2}">
 
             <td>
 
				${h.link_to(node.name,h.url('files_home',repo_name=c.repo_name,revision=c.cur_rev,f_path=node.path),class_=file_class(node))}
 
             </td>
 
             <td>
 
                %if node.is_file():
 
             		${h.filesizeformat(node.size)}
 
             	%endif
 
             </td>
 
             <td>
 
             	%if node.is_file():
 
             		${node.last_changeset.revision}
 
             	%endif
 
             </td>
 
             <td>
 
             	%if node.is_file():
 
             		${node.last_changeset.date}
 
             	%endif
 
             </td>
 
             <td>
 
             	%if node.is_file():
 
             		${node.last_changeset.author}
 
             	%endif                    
 
             </td>
 
		</tr>
 
	%endfor
 
</table>
 
\ No newline at end of file
pylons_app/templates/files/files_source.html
Show inline comments
 
new file 100644
 
<dl class="overview">
 
	<dt>${_('Revision')}</dt>
 
	<dd>r${c.files_list.changeset.revision}:${c.files_list.changeset._short}</dd>
 
	<dt>${_('Size')}</dt>
 
	<dd>${h.filesizeformat(c.files_list.size)}</dd>
 
	<dt>${_('Options')}</dt>
 
	<dd>history  / annotate  / raw  </dd>
 
	<dt>${_('History')}</dt>
 
	<dd>
 
		${h.form(h.url.current())}
 
		${h.hidden('diff2',c.files_list.changeset._short)}
 
		${h.select('diff1','',c.file_history)}
 
		${h.submit('diff','diff')}
 
		${h.end_form()}
 
	</dd>
 
					
 
</dl>		
 
<div id="body" class="codeblock">
 
	${h.pygmentize(c.files_list.content,linenos=True,anchorlinenos=True,cssclass="code-highlight")}
 
</div>
 
\ No newline at end of file
0 comments (0 inline, 0 general)