# HG changeset patch # User Marcin Kuzminski # Date 2010-05-18 22:18:48 # Node ID 0f7f93df5802733a885f51eae77cf710643b325a # Parent 96285f905073f2b0bd16e922ebec7a3d7e1177a5 implemented rawdiff and diff download into diff view. Few css changes diff --git a/pylons_app/controllers/files.py b/pylons_app/controllers/files.py --- a/pylons_app/controllers/files.py +++ b/pylons_app/controllers/files.py @@ -65,8 +65,8 @@ class FilesController(BaseController): hg_model = HgModel() c.repo = hg_model.get_repo(c.repo_name) file_node = c.repo.get_changeset(revision).get_node(f_path) - response.headers['Content-type'] = file_node.mimetype - response.headers['Content-disposition'] = 'attachment; filename=%s' \ + response.content_type = file_node.mimetype + response.content_disposition = 'attachment; filename=%s' \ % f_path.split('/')[-1] return file_node.content @@ -77,6 +77,7 @@ class FilesController(BaseController): hg_model = HgModel() diff1 = request.GET.get('diff1') diff2 = request.GET.get('diff2') + c.action = action = request.GET.get('diff') c.no_changes = diff1 == diff2 c.f_path = f_path c.repo = hg_model.get_repo(c.repo_name) @@ -85,11 +86,23 @@ class FilesController(BaseController): 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 = differ.get_udiff(c.changeset_1.get_node(f_path), c.changeset_2.get_node(f_path)) - c.differ = differ.DiffProcessor(f_udiff) + + diff = differ.DiffProcessor(f_udiff) + + if action == 'download': + diff_name = '%s_vs_%s.diff' % (diff1, diff2) + response.content_type = 'text/plain' + response.content_disposition = 'attachment; filename=%s' \ + % diff_name + return diff.raw_diff() + + elif action == 'raw': + c.cur_diff = '
%s
' % diff.raw_diff() + elif action == 'diff': + c.cur_diff = diff.as_html() + return render('files/file_diff.html') def _get_history(self, repo, node, f_path): diff --git a/pylons_app/public/css/diff.css b/pylons_app/public/css/diff.css --- a/pylons_app/public/css/diff.css +++ b/pylons_app/public/css/diff.css @@ -14,13 +14,17 @@ div.diffblock .code-header{ color:blue; padding:10px 0 10px 0; } -div.diffblock .code-header span{ +div.diffblock .code-header div{ margin-left:25px; font-weight: bold; } div.diffblock .code-body{ background: #EEEEEE; } +div.diffblock pre.raw{ + background: #FFFFFF; + color:#000000; +} .code-difftable{ border-collapse: collapse; diff --git a/pylons_app/public/css/monoblue_custom.css b/pylons_app/public/css/monoblue_custom.css --- a/pylons_app/public/css/monoblue_custom.css +++ b/pylons_app/public/css/monoblue_custom.css @@ -12,7 +12,9 @@ a { a:HOVER{ text-decoration: underline; } -/*** end of Initial Settings ***/ /** common settings **/ +/*** end of Initial Settings ***/ + +/** common settings **/ div#main { padding: 5px; } @@ -381,76 +383,97 @@ p.files { /** end of file **/ /** changeset **/ -h3.changeset { - margin: 20px 0 5px 20px; - padding: 0 0 2px; - font-size: 1.6em; - border-bottom: dotted 1px #D5E1E6; -} -p.changeset-age { - position: relative; +.cs_files{ + border: 2px solid #CCCCCC; + width: 60%; + } - -p.changeset-age span { - position: absolute; - top: -25px; - right: 10px; - font-size: 1.4em; - color: #CCC; - font-weight: bold; - font-style: italic; +.cs_files .cs_added{ + background:#BBFFBB; } - -p.description { - margin: 10px 30px 0 30px; - padding: 10px; - border: solid 1px #CCC; - font-size: 1.2em; +.cs_files .cs_changed{ + background: #FFDD88; +} +.cs_files .cs_removed{ + background: #FF8888; } /** end of changeset **/ /** canvas **/ -div#wrapper { - position: relative; - font-size: 1.2em; -} - canvas { position: absolute; z-index: 5; top: -0.7em; } +#graph{ + overflow: hidden; -ul#nodebgs li.parity0 { - background: #F1F6F7; +} +#graph_nodes{ + width:160px; + float:left; } -ul#nodebgs li.parity1 { - background: #FFFFFF; +#graph_content{ + width:800px; + float:left; +} +#graph_content .container_header{ + border:1px solid #CCCCCC; + height:30px; + background: #EEEEEE; +} + + +#graph_content .container .wrapper{ + width: 600px; +} +#graph_content .container{ + border-bottom: 1px solid #CCCCCC; + border-left: 1px solid #CCCCCC; + border-right: 1px solid #CCCCCC; + height:120px; } -ul#graphnodes { - position: absolute; - z-index: 10; - top: 7px; - list-style: none inside none; +#graph_content .container .left{ + float:left; + width: 70%; + padding-left: 5px; } -ul#nodebgs { - list-style: none inside none; +#graph_content .container .right{ + float:right; + width: 25%; +} +#graph_content .container .left .date{ + font-weight:bold; +} +#graph_content .container .left .author{ + +} +#graph_content .container .left .message{ + font-size: 80%; } -ul#graphnodes li,ul#nodebgs li { - height: 39px; +.right .added,.changed,.removed{ + border:1px solid #DDDDDD; + display:block; + float:right; + font-size:0.75em; + text-align:center; + min-width:15px; } - -ul#graphnodes li .info { - display: block; - position: relative; +.right .added{ + background:#BBFFBB; } - +.right .changed{ + background: #FFDD88; +} +.right .removed{ + background: #FF8888; +} /** end of canvas **/ /* FILE BROWSER */ @@ -479,7 +502,8 @@ div.browserblock .browser-body{ } table.code-browser { - border-collapse:collapse; + border-collapse:collapse; + width: 100%; } table.code-browser tr{ margin:3px; @@ -491,6 +515,8 @@ table.code-browser thead th { font-size: 1.1em; font-weight: bold; text-align: center; + text-align: left; + padding-left: 10px; } table.code-browser tbody tr { diff --git a/pylons_app/templates/files/file_diff.html b/pylons_app/templates/files/file_diff.html --- a/pylons_app/templates/files/file_diff.html +++ b/pylons_app/templates/files/file_diff.html @@ -28,13 +28,22 @@
- ${h.link_to(c.f_path,h.url('files_home',repo_name=c.repo_name,revision=c.diff2.split(':')[1],f_path=c.f_path))} +
+ ${h.link_to(c.f_path,h.url('files_home',repo_name=c.repo_name, + revision=c.diff2.split(':')[1],f_path=c.f_path))} + » ${h.link_to(_('diff'), + h.url.current(diff2=c.diff2.split(':')[-1],diff1=c.diff1.split(':')[-1],diff='diff'))} + » ${h.link_to(_('raw diff'), + h.url.current(diff2=c.diff2.split(':')[-1],diff1=c.diff1.split(':')[-1],diff='raw'))} + » ${h.link_to(_('download diff'), + h.url.current(diff2=c.diff2.split(':')[-1],diff1=c.diff1.split(':')[-1],diff='download'))} +
%if c.no_changes: ${_('No changes')} %else: - ${c.differ.as_HTML()|n} + ${c.cur_diff|n} %endif