Changeset - f905f45c457e
[Not reviewed]
default
1 5 0
Marcin Kuzminski - 16 years ago 2010-05-17 01:51:47
marcin@python-works.com
moved diff libs to vcs. updated htmls and css for diff and source
6 files changed with 21 insertions and 251 deletions:
0 comments (0 inline, 0 general)
pylons_app/controllers/files.py
Show inline comments
 
@@ -6,8 +6,7 @@ from pylons.controllers.util import abor
 
from pylons_app.lib.base import BaseController, render
 
from pylons_app.lib.utils import get_repo_slug
 
from pylons_app.model.hg_model import HgModel
 
from difflib import unified_diff
 
from pylons_app.lib.differ import render_udiff
 
from vcs.utils import diffs as differ
 
from vcs.exceptions import RepositoryError, ChangesetError
 
        
 
log = logging.getLogger(__name__)
 
@@ -83,21 +82,14 @@ class FilesController(BaseController):
 
        c.repo = hg_model.get_repo(c.repo_name)
 
        c.changeset_1 = c.repo.get_changeset(diff1)
 
        c.changeset_2 = c.repo.get_changeset(diff2)
 
        f1 = c.changeset_1.get_node(f_path)
 
        f2 = c.changeset_2.get_node(f_path)
 

	
 
        c.diff1 = 'r%s:%s' % (c.changeset_1.revision, c.changeset_1._short)
 
        c.diff2 = 'r%s:%s' % (c.changeset_2.revision, c.changeset_2._short)
 

	
 
        f_udiff = unified_diff(f1.content.splitlines(True),
 
                               f2.content.splitlines(True),
 
                               f1.name,
 
                               f2.name)
 
        
 
        
 
        c.diff_files = render_udiff(udiff=f_udiff, differ='difflib')
 
        print c.diff_files
 
        if len(c.diff_files) < 1:
 
            c.no_changes = True
 
        f_udiff = differ.get_udiff(c.changeset_1.get_node(f_path),
 
                            c.changeset_2.get_node(f_path))
 
        c.differ = differ.DiffProcessor(f_udiff)
 
        return render('files/file_diff.html')
 
    
 
    def _get_history(self, repo, node, f_path):
pylons_app/lib/differ.py
Show inline comments
 
deleted file
pylons_app/public/css/diff.css
Show inline comments
 
@@ -24,6 +24,14 @@ div.diffblock .code-body{
 

	
 
.code-difftable{
 
	border-collapse: collapse;
 
	width: 99%;
 
}
 
.code-difftable td:target *{
 
	background:  repeat scroll 0 0 #FFFFBE !important;
 
	text-decoration: underline;
 
}
 
.code-difftable .context{
 
	background:none repeat scroll 0 0 #DDE7EF;
 
}
 
.code-difftable .add{
 
	background:none repeat scroll 0 0 #DDFFDD;
pylons_app/public/css/pygments.css
Show inline comments
 
@@ -14,10 +14,14 @@ div.codeblock .code-header{
 
	color:blue;
 
	padding:10px 0 10px 0;
 
}
 
div.codeblock .code-header span{
 
div.codeblock .code-header .revision{
 
	margin-left:25px;
 
	font-weight: bold;
 
}
 
div.codeblock .code-header .commit{
 
	margin-left:25px;
 
	font-weight: normal;
 
}
 

	
 
.code-highlight {
 
    padding: 0px;
pylons_app/templates/files/file_diff.html
Show inline comments
 
@@ -34,25 +34,7 @@
 
 			%if c.no_changes:
 
            	${_('No changes')}
 
            %else:        
 
	            <table class='code-difftable'>
 
	            %for diff in c.diff_files:
 
		            %for x in diff['chunks']:
 
		                %for y in x:
 
		                    <tr class="line ${y['action']}">
 
		                        <td id="#${diff['filename']}_O${y['old_lineno']}" class="lineno old">
 
		                              <pre><a href="#${diff['filename']}_O${y['old_lineno']}">${y['old_lineno']}</a></pre>
 
		                        </td>		                    
 
		                        <td id="#${diff['filename']}_N${y['new_lineno']}"class="lineno new">
 
		                              <pre><a href="#${diff['filename']}_N${y['new_lineno']}">${y['new_lineno']}</a></pre>
 
		                        </td>                        
 
		                       <td class="code">
 
		                           <pre>${y['line']|n}</pre>
 
		                       </td>
 
		                    </tr>
 
		                %endfor$
 
		            %endfor
 
		        %endfor
 
	            </table>
 
				${c.differ.as_HTML()|n}
 
            %endif
 
	</div>
 
</div>
pylons_app/templates/files/files_source.html
Show inline comments
 
@@ -17,8 +17,8 @@
 
</dl>		
 
<div id="body" class="codeblock">
 
	<div class="code-header">
 
		<span>${c.files_list.name}@r${c.files_list.last_changeset.revision}:${c.files_list.last_changeset._short}</span>
 
		 <span style="font-size:70%">"${c.file_msg}"</span>
 
		<div class="revision">${c.files_list.name}@r${c.files_list.last_changeset.revision}:${c.files_list.last_changeset._short}</div>
 
		<div class="commit" style="font-size:70%">"${c.file_msg}"</div>
 
	</div>
 
	<div class="code-body">
 
		${h.pygmentize(c.files_list.content,linenos=True,anchorlinenos=True,cssclass="code-highlight")}
0 comments (0 inline, 0 general)