1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-09-16 07:08:55 +00:00

modified md file view, edit, preview;modified shared-file and history-file view for md & seaf

This commit is contained in:
llj
2012-11-28 15:24:11 +08:00
parent 20c467b0a8
commit fbd13ef381
5 changed files with 114 additions and 64 deletions

View File

@@ -0,0 +1,50 @@
#main {
width:100%;
}
#view-hd,
#view-path-op,
#file-op,
#sf-commit-op {
width:950px;
margin:0 auto;
}
#file-op {
padding:0;
border:0;
}
#file-op .avatar,
#file-op .name,
#file-op .time,
#file-op span {
vertical-align:middle;
}
#file-op .time {
color:#666;
margin:0 2px 0 8px;
}
#file-op .file-diff {
font-size:100%;
}
#file-op .contributors {
margin-left:8px;
}
#file {
padding:0;
background:#fff;
}
#file-view {
padding:30px 0 10px;
min-height:400px;
background:#f4f4f4;
border:1px solid #ededed;
margin-top:12px;
}
#sf,
#md-view {
width:624px;
padding:40px 96px;
border:1px solid #ccc;
margin:0 auto;
box-shadow:0 0 6px #ccc;
min-height:400px;
}

View File

@@ -40,14 +40,9 @@
background:#f4f4f4; background:#f4f4f4;
border-top:1px solid #ededed; border-top:1px solid #ededed;
} }
#md-view { #sf, #md-view {
width:690px;
}
#sf {
width:624px; width:624px;
padding:40px 96px; padding:40px 96px;
}
#sf, #md-view {
box-shadow:0 0 6px #ccc; box-shadow:0 0 6px #ccc;
min-height:400px; min-height:400px;
border:1px solid #ccc; border:1px solid #ccc;
@@ -61,7 +56,11 @@
z-index:1010;/*make seaf image show below path-op*/ z-index:1010;/*make seaf image show below path-op*/
} }
.CodeMirror { .CodeMirror {
{% if filetype == 'Markdown' %}
width:818px;
{% else %}
width:950px; width:950px;
{% endif %}
margin:0 auto; margin:0 auto;
box-shadow:0 0 6px #272822; box-shadow:0 0 6px #272822;
} }

View File

@@ -6,53 +6,8 @@
{% if filetype == 'Text' %} {% if filetype == 'Text' %}
<link rel="stylesheet" type="text/css" href="{{ MEDIA_URL }}codemirror/codemirror.css" /> <link rel="stylesheet" type="text/css" href="{{ MEDIA_URL }}codemirror/codemirror.css" />
{% endif %} {% endif %}
{% if filetype == 'Sf' %} {% if filetype == 'Sf' or filetype == 'Markdown' %}
<style type="text/css"> <link rel="stylesheet" type="text/css" href="{{ MEDIA_URL }}css/file_view_extra.css" />
#main {
width:100%;
}
#view-hd,
#view-path-op,
#file-op,
#sf-commit-op {
width:950px;
margin:0 auto;
}
#file-op {
padding:0;
border:0;
}
#file-op .avatar,
#file-op .name,
#file-op .time,
#file-op span {
vertical-align:middle;
}
#file-op .time {
color:#666;
margin:0 4px 0 8px;
}
#file-op .contributors {
margin-left:8px;
}
#file {
padding:0;
background:#fff;
}
#file-view {
background:#f4f4f4;
border-top:1px solid #ededed;
margin-top:12px;
}
#sf {
width:624px;
padding:40px 96px;
border:1px solid #ccc;
margin:30px auto 10px;
box-shadow:0 0 6px #ccc;
min-height:400px;
}
</style>
{% endif %} {% endif %}
{% endblock %} {% endblock %}
@@ -84,7 +39,15 @@
{% endif %} {% endif %}
</div> </div>
{% if filetype == 'Sf' or filetype == 'Markdown'%}
{% if view_history %}
<div id="view-path-op" class="hide">
{% else %}
<div id="view-path-op" class="w100 ovhd"> <div id="view-path-op" class="w100 ovhd">
{% endif %}
{% else %}
<div id="view-path-op" class="w100 ovhd">
{% endif %}
<p class="path fleft"> <p class="path fleft">
{% trans "Current Path: "%} {% trans "Current Path: "%}
@@ -130,12 +93,12 @@
{% endif %} {% endif %}
</div> </div>
{% if not view_history and filetype != 'Sf' %} {% if not view_history and filetype != 'Sf' and filetype != 'Markdown' %}
<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"> <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_seahub_time}}</span><span>{% trans "updated this file"%}</span> {% avatar latest_contributor 20 %} <a href="{% url 'user_profile' latest_contributor %}" class="name">{{ latest_contributor|email2nickname }}</a><span class="time">{{ last_modified|translate_seahub_time}}</span><span>{% trans "updated this file"%}</span>
{% if filetype == 'Text' or filetype == 'Markdown' %} {% if filetype == 'Text' %}
{% 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}}">{% trans "Detail"%}</a></span> <span><a class="file-diff" href="{% url 'text_diff' repo.id %}?p={{path|urlencode}}&commit={{last_commit_id}}">{% trans "Detail"%}</a></span>
{% endif %} {% endif %}
@@ -161,9 +124,19 @@
<div id="file-op"> <div id="file-op">
{% endif %} {% endif %}
{% if not view_history and filetype == 'Sf' %} {% if not view_history %}
{% if filetype == 'Sf' or filetype == 'Markdown' %}
<div class="commit fleft"> <div class="commit fleft">
{% avatar latest_contributor 20 %} <a href="{% url 'user_profile' latest_contributor %}" class="name">{{ latest_contributor|email2nickname }}</a><span class="time">{{ last_modified|translate_seahub_time}}</span><span>{% trans "updated this file"%}.</span> {% avatar latest_contributor 20 %} <a href="{% url 'user_profile' latest_contributor %}" class="name">{{ latest_contributor|email2nickname }}</a><span class="time">{{ last_modified|translate_seahub_time}}</span>
{% if filetype == 'Markdown' %}
{% if last_commit_id %}
<span>{% trans "updated this file"%}, <a class="file-diff" href="{% url 'text_diff' repo.id %}?p={{path|urlencode}}&commit={{last_commit_id}}">{% trans "Detail"%}</a>.</span>
{% endif %}
{% endif %}
{% if filetype == 'Sf' %}
<span>{% trans "updated this file"%}.</span>
{% endif %}
<span class="contributors">{% blocktrans count counter=contributors|length %}one contributor{% plural %} {{ counter }} contributors {% endblocktrans %}</span> <span class="contributors">{% blocktrans count counter=contributors|length %}one contributor{% plural %} {{ counter }} contributors {% endblocktrans %}</span>
{% for user in contributors %} {% for user in contributors %}
<a href="{% url 'user_profile' user %}" title="{{ user|email2nickname}}">{% avatar user 16 %}</a> <a href="{% url 'user_profile' user %}" title="{{ user|email2nickname}}">{% avatar user 16 %}</a>
@@ -173,6 +146,7 @@
<button data-url="{% url 'file_revisions' repo.id %}?p={{ path }}" class="history">{% trans "History"%}</button> <button data-url="{% url 'file_revisions' repo.id %}?p={{ path }}" class="history">{% trans "History"%}</button>
{% endif %} {% endif %}
{% endif %} {% endif %}
{% endif %}
{% if not view_history and request.user.is_authenticated %} {% if not view_history and request.user.is_authenticated %}
{% if filetype != 'Sf' %} {% if filetype != 'Sf' %}
@@ -199,7 +173,13 @@
{% endif %} {% endif %}
{% endifnotequal %} {% endifnotequal %}
{% else %} {% else %}
{% if filetype == 'Markdown' %}
<div id="md-view" class="article">
<p>{% trans "Loading..."%}</p> <p>{% trans "Loading..."%}</p>
</div>
{% else %}
<p>{% trans "Loading..."%}</p>
{% endif %}
{% endif %} {% endif %}
</div> </div>
</div> </div>
@@ -601,13 +581,16 @@ $('#back').click(function() {
{% endif %} {% endif %}
{% endif %} {% endif %}
{% if filetype == 'Sf' %} {% if filetype == 'Sf' or filetype == 'Markdown' %}
{% if not view_history %} {% if not view_history %}
$('#file-op .history').click(function () { $('#file-op .history').click(function () {
location.href = $(this).data('url'); location.href = $(this).data('url');
}); });
{% endif %}
$('#main-panel').css({'margin-bottom':0}); $('#main-panel').css({'margin-bottom':0});
{% else %}
$('.path').css('margin-top', '.5em');
$('#file-op').prepend($('.path'));
{% endif %}
{% endif %} {% endif %}
</script> </script>
{% endblock %} {% endblock %}

View File

@@ -101,7 +101,7 @@
{% endifnotequal %} {% endifnotequal %}
{% if err %} {% if err %}
$('#file-view').html('<p class="error">{{ err }}</p>').addClass('file-view-tip'); $('#file-view').html('<div id="md-view" class="article"><p class="error">{{ err }}</p></div>');
{% endif %} {% endif %}
{% endif %} {% endif %}

View File

@@ -2,21 +2,33 @@
{% load seahub_tags i18n %} {% load seahub_tags i18n %}
{% block extra_style %} {% block extra_style %}
{% if filetype == 'Text' %}
<link rel="stylesheet" type="text/css" href="{{ MEDIA_URL }}codemirror/codemirror.css" /> <link rel="stylesheet" type="text/css" href="{{ MEDIA_URL }}codemirror/codemirror.css" />
{% endif %}
{% if filetype == 'Sf' or filetype == 'Markdown' %}
<link rel="stylesheet" type="text/css" href="{{ MEDIA_URL }}css/file_view_extra.css" />
{% endif %}
{% endblock %} {% endblock %}
{% block main_panel %} {% block main_panel %}
<h2>{{ file_name }}</h2> <h2 id="view-hd">{{ file_name }}</h2>
{% if filetype != 'Markdown' and filetype != 'Sf' %}
<p class="file-share-from">{% trans "Shared by: " %}{{ username }}</p> <p class="file-share-from">{% trans "Shared by: " %}{{ username }}</p>
{% endif %}
<div id="file"> <div id="file">
{% if filetype == 'PDF' and not pdf_use_flas %} {% if filetype == 'PDF' and not pdf_use_flas %}
<div id="file-op" class="hide"> <div id="file-op" class="hide">
{% else %} {% else %}
<div id="file-op"> <div id="file-op">
{% endif %} {% endif %}
{% if filetype == 'Markdown' or filetype == 'Sf' %}
<p class="fleft">{% trans "Shared by: " %}{{ username }}</p>
{% endif %}
{% if filetype == 'Text' or filetype == 'Image' or filetype == 'SVG' or filetype == 'Markdown' %} {% if filetype == 'Text' or filetype == 'Image' or filetype == 'SVG' or filetype == 'Markdown' %}
<button data="{{ SITE_ROOT }}repo/{{ repo.id }}/{{ obj_id }}/?file_name={{ file_name }}&op=view&t={{ shared_token }}" id="view-original">{% trans "Raw" %}</button> <button data="{{ SITE_ROOT }}repo/{{ repo.id }}/{{ obj_id }}/?file_name={{ file_name }}&op=view&t={{ shared_token }}" id="view-original">{% trans "Raw" %}</button>
{% endif %} {% endif %}
<button data="{{ SITE_ROOT }}repo/{{ repo.id }}/{{ obj_id }}/?file_name={{ file_name }}&op=download&t={{ shared_token }}" id="download">{% trans "Download" %}</button> <button data="{{ SITE_ROOT }}repo/{{ repo.id }}/{{ obj_id }}/?file_name={{ file_name }}&op=download&t={{ shared_token }}" id="download">{% trans "Download" %}</button>
</div> </div>
<div id="file-view"> <div id="file-view">
@@ -25,12 +37,18 @@
{% if filetype == 'Text' %} {% if filetype == 'Text' %}
<textarea id="docu-view" class="vh">{{ file_content|escape }}</textarea> <textarea id="docu-view" class="vh">{{ file_content|escape }}</textarea>
{% else %} {% else %}
<div id="sf-view" class="article">{{ file_content|safe }}</div> <div id="sf" class="article">{{ file_content|safe }}</div>
{% endif %} {% endif %}
{% endifnotequal %} {% endifnotequal %}
{% else %}
{% if filetype == 'Markdown' %}
<div id="md-view" class="article">
<p>{% trans "Loading..."%}</p>
</div>
{% else %} {% else %}
<p>{% trans "Loading..." %}</p> <p>{% trans "Loading..." %}</p>
{% endif %} {% endif %}
{% endif %}
</div> </div>
</div> </div>
{% endblock %} {% endblock %}