1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-09-25 14:50:29 +00:00

improve diff related code

This commit is contained in:
lins05
2012-10-20 11:48:19 +08:00
parent 4bb5cb2582
commit 5545afe6d7
5 changed files with 49 additions and 31 deletions

View File

@@ -928,7 +928,9 @@ ul.with-bg li {
color:#666; color:#666;
margin-left:5px; margin-left:5px;
} }
.lsch, .lsch-encrypted, .file-diff { .lsch,
.lsch-encrypted,
.file-diff {
font-size:12px; font-size:12px;
font-weight:normal; font-weight:normal;
color:#666; color:#666;
@@ -1383,13 +1385,27 @@ ul.with-bg li {
/* text file diff */ /* text file diff */
div.diff-desc { margin: 10px 0; } div.diff-desc { margin: 10px 0; }
div.diff-desc p { margin: 10px 0; } div.diff-desc p { margin: 10px 0; }
#text-diff-output table { margin-top: 20px; border: 1px solid gray; }
#text-diff-output thead { border: 1px solid gray; }
#text-diff-output th { background-color: #EED; text-align: center; }
#text-diff-output th, #text-diff-output td { border-bottom: none; }
#text-diff-output tr.hl { background-color: #afcde8; }/*highlight*/
.diff_header { background-color: #EED; text-align: center; } #text-diff-output table {
.diff_add { background-color: #DFD; } margin-top: 20px;
.diff_sub { background-color: #FDD; } border: 1px solid gray;
.diff_chg { background-color: #FD8; } }
#text-diff-output tr th {
background-color: #EED;
text-align: center;
}
#text-diff-output th,
#text-diff-output td {
border-bottom: none;
}
#text-diff-output tr.hl {
background-color: #afcde8; /*highlight*/
}
.diff-header {
background-color: #EED;
text-align: center;
}
.diff-add { background-color: #DFD; }
.diff-sub { background-color: #FDD; }
.diff-chg { background-color: #FD8; }

View File

@@ -82,7 +82,8 @@
{% if not view_history %} {% if not view_history %}
<div id="file-commit-info"> <div id="file-commit-info">
<div class="latest-commit ovhd"> <div class="latest-commit ovhd">
<p class="latest-commit-info fleft">{% avatar latest_contributor 20 %} <a href="{% url 'user_profile' latest_contributor %}" class="name">{{ latest_contributor|email2nickname }}</a> <span class="time">{{ last_modified|translate_commit_time}}</span><span> 做了最新修改</span> <p class="latest-commit-info fleft">
{% avatar latest_contributor 20 %} <a href="{% url 'user_profile' latest_contributor %}" class="name">{{ latest_contributor|email2nickname }}</a> <span class="time">{{ last_modified|translate_commit_time}}</span><span> 做了最新修改</span>
{% if filetype == 'Text' or filetype == 'Markdown' %} {% if filetype == 'Text' or filetype == 'Markdown' %}
{% if last_commit_id %} {% if last_commit_id %}
<span><a class="file-diff" href="{% url 'text_diff' repo.id %}?p={{path|urlencode}}&commit={{last_commit_id}}">详情</a></span> <span><a class="file-diff" href="{% url 'text_diff' repo.id %}?p={{path|urlencode}}&commit={{last_commit_id}}">详情</a></span>

View File

@@ -14,6 +14,3 @@
{% if filetype == 'Markdown' %} {% if filetype == 'Markdown' %}
<script type="text/javascript" src="{{MEDIA_URL}}js/showdown.js"></script> <script type="text/javascript" src="{{MEDIA_URL}}js/showdown.js"></script>
{% endif %} {% endif %}
{% if filetype == 'Text' or filetype == 'Markdown' %}
{% endif %}

View File

@@ -3,7 +3,7 @@
{% load url from future %} {% load url from future %}
{% block main_panel %} {% block main_panel %}
<h2>文件修改详情</h2> <h3>文件修改详情</h3>
<div class="diff-desc"> <div class="diff-desc">
<p class="path"> <p class="path">
文件路径: 文件路径:
@@ -23,16 +23,14 @@
</div> </div>
{% else %} {% else %}
<div id="text-diff-output"> <div id="text-diff-output">
<table rules="group"> <table>
<thead> <tr>
<th width="3%"></th> <th width="3%"></th>
<th width="47%"> 修改前 </th> <th width="47%"> 修改前 </th>
<th width="3%"></th> <th width="3%"></th>
<th width="47%"> 修改后 </th> <th width="47%"> 修改后 </th>
</thead> </tr>
<tbody>
{{ diff_result_table|safe }} {{ diff_result_table|safe }}
</tbody>
</table> </table>
</div> </div>
{% endif %} {% endif %}

View File

@@ -1875,17 +1875,21 @@ class HtmlDiff(object):
cls = '' cls = ''
if '\0+' in text: if '\0+' in text:
cls = 'diff_add' cls = 'diff-add'
elif '\0-' in text: elif '\0-' in text:
cls = 'diff_sub' cls = 'diff-sub'
elif '\0^' in text: elif '\0^' in text:
cls = 'diff_chg' cls = 'diff-chg'
text = text.replace('\0+', '').replace('\0-', ''). \
replace('\0^', '').replace('\1', ''). \
replace('\t','&nbsp;')
if cls: if cls:
return '<td class="diff_header">%s</td><td class=%s>%s</td>' \ return '<td class="diff-header">%s</td><td class=%s>%s</td>' \
% (linenum,cls,text) % (linenum,cls,text)
else: else:
return '<td class="diff_header">%s</td><td>%s</td>' \ return '<td class="diff-header">%s</td><td>%s</td>' \
% (linenum,text) % (linenum,text)
def _make_prefix(self): def _make_prefix(self):
@@ -2004,11 +2008,13 @@ class HtmlDiff(object):
data_rows = ''.join(s) data_rows = ''.join(s)
return data_rows.replace('\0+',''). \ return data_rows
replace('\0-',''). \
replace('\0^',''). \ # return data_rows.replace('\0+',''). \
replace('\1',''). \ # replace('\0-',''). \
replace('\t','&nbsp;') # replace('\0^',''). \
# replace('\1',''). \
# replace('\t','&nbsp;')
del re del re