1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-05-12 18:05:05 +00:00

[cleanup] removed unused code/file for seafile-docs, repo history, ma… ()

* [cleanup] removed unused code/file for seafile-docs, repo history, markdown file view

* [cleanup] removed unused css/js/image files
This commit is contained in:
llj 2019-12-11 15:50:04 +08:00 committed by Daniel Pan
parent d137c49184
commit 18ffe249d7
13 changed files with 0 additions and 2254 deletions

View File

@ -1,65 +0,0 @@
#main {
padding:0;
}
#view-hd,
#shared-file-view-hd,
#view-path-op,
#file-op {
width:950px;
margin:0 auto;
}
#view-hd,
#shared-file-view-hd {
margin-top:4px;
flex-shrink:0;
}
#file-op .avatar {
vertical-align:middle;
border-radius:1000px;
}
#file-op .time {
color:#666;
margin:0 2px 0 8px;
}
#file-op .file-diff {
font-size:100%;
}
#file-view {
padding:30px 0 15px;
background:#f4f4f4;
border:1px solid #ededed;
margin-top:12px;
}
#md-view,
.CodeMirror,
#file-view-tip {
border:1px solid #ccc;
margin:0 auto;
box-shadow:0 0 6px #ccc;
}
#md-view {
min-height:400px;
}
#md-view img {
max-width: 100%;
}
.CodeMirror {
color:#000;
width:950px;
background:#fff;
margin-bottom:40px;
}
#file-view .CodeMirror-scroll {
min-height:400px;
}
#file-star {
vertical-align:middle;
margin-left:3px;
color:#999;
}
.file-path {
margin: 0 0 9px;
}
.history-file-path {
margin:.5em 0 0;
}

View File

@ -1,40 +0,0 @@
/*
* This file is for print.
* */
blockquote {
border:none; /* overrides bootstrap */
}
.article blockquote {
color:#555;
border-color:#ccc;
}
/* file view */
#view-hd,
#view-path-op,
#file-op,
#file-enc-cont,
#side-toolbar {
display:none;
}
#file-view {
padding:0;
background:none;
border:none;
margin:0;
}
/* markdown */
#md-view {
border:none;
min-height:0;
}
/* pdf, doc */
.page-container {
border:none;
}
.pdf2html-toolbar {
display:none;
}

Binary file not shown.

Before

(image error) Size: 5.9 KiB

Binary file not shown.

Before

(image error) Size: 368 B

File diff suppressed because one or more lines are too long

View File

@ -724,15 +724,6 @@ ENABLE_WIKI = True
# Enable 'repo snapshot label' feature
ENABLE_REPO_SNAPSHOT_LABEL = False
############################
# Settings for SeafileDocs #
############################
if os.environ.get('SEAFILE_DOCS', None):
LOGO_PATH = 'img/seafile-docs-logo.png'
LOGO_WIDTH = ''
ENABLE_WIKI = True
d = os.path.dirname
EVENTS_CONFIG_FILE = os.environ.get(
'EVENTS_CONFIG_FILE',

View File

@ -1,193 +0,0 @@
{% extends "base_wide_page.html" %}
{% load seahub_tags avatar_tags i18n %}
{% load staticfiles %}
{% block sub_title %}{% trans "History" %} - {% endblock %}
{% block extra_style %}
<link rel="stylesheet" type="text/css" href="{% static "css/select2-3.5.2.css" %}" />
<link rel="stylesheet" type="text/css" href="{% static "css/select2.custom.css" %}" />
<style type="text/css">
.go-back { top:-3px; }
</style>
{% endblock %}
{% block wide_page_content %}
<h2>{% blocktrans with repo_name=repo.props.name %}<span class="op-target">{{repo_name}}</span> Modification History{% endblocktrans %}</h2>
{% if referer %}
<a href="#" class="go-back" title="{% trans "Back" %}">
<span class="icon-chevron-left"></span>
</a>
{% endif %}
{% if user_perm == 'rw' %}
<p class="tip">{% trans "Tip: a snapshot will be generated after modification, which records the library state after the modification."%}</p>
{% endif %}
<table class="commit-list">
<tr>
{% if show_label %}
<th width="43%">{% trans "Description" %}</th>
<th width="12%">{% trans "Time" %}</th>
<th width="9%">{% trans "Modifier" %}</th>
<th width="12%">{% trans "Device" %} / {% trans "Version" %}</th>
<th width="12%">{% trans "Labels" %}</th>
<th width="12%">{% trans "Operations" %}</th>
{% else %}
<th width="43%">{% trans "Description" %}</th>
<th width="15%">{% trans "Time" %}</th>
<th width="15%">{% trans "Modifier" %}</th>
<th width="15%">{% trans "Device" %} / {% trans "Version" %}</th>
<th width="12%">{% trans "Operations" %}</th>
{% endif %}
</tr>
{% for commit in commits %}
{% if commit.show %}
<tr>
<td>
{{ commit.props.desc|translate_commit_desc }}
{% if page_next or not forloop.last %}
<a class="lsch" href="#" data-url="{% url 'repo_history_changes' repo.id %}?commit_id={{ commit.id }}" data-time="{{ commit.props.ctime|tsstr_sec }}">{% trans "Details"%}</a>
{% endif %}
</td>
<td>{{ commit.ctime|translate_seahub_time }}</td>
<td>
{% if commit.creator_name %}
{% if not commit.second_parent_id %}
<a href="{% url 'user_profile' commit.creator_name %}" class="vam">{{ commit.creator_name|email2nickname }}</a>
{% else %}
{% trans "None"%}
{% endif %}
{% else %}
{% trans "Unknown"%}
{% endif %}
</td>
<td>
{% if commit.client_version %}
{{ commit.device_name }} / {{ commit.client_version }}
{% else %}
API / --
{% endif %}
</td>
{% if show_label %}
<td data-id="{{ commit.id }}">
{% for label in commit.labels %}
<span class="cur-tag">{{ label }}</span>
{% endfor %}
{% if user_perm == 'rw' %}
<span class="sf2-icon-edit label-edit-icon op-icon vh" title="{% trans "Edit" %}"></span>
{% endif %}
</td>
{% endif %}
<td>
{% if user_perm == 'rw' %}
{% if forloop.first and current_page == 1 %}
<span class="op vh">{% trans "Current Version" %}</span>
{% else %}
<a href="{% url 'repo_history_view' repo.id %}?commit_id={{ commit.id }}" class="op vh view-snapshot">{% trans "View Snapshot" %}</a>
{% endif %}
{% endif %}
</td>
</tr>
{% endif %}
{% endfor %}
</table>
<div id="paginator">
{% if current_page != 1 %}
<a href="?page={{ prev_page }}&referer={{referer|urlencode}}">{% trans "Previous"%}</a>
{% endif %}
{% if page_next %}
<a href="?page={{ next_page }}&referer={{referer|urlencode}}">{% trans "Next"%}</a>
{% endif %}
</div>
{% if show_label and user_perm == 'rw' %}
<form id="label-edit-form" action="" class="hide">
<h3 id="dialogTitle">{% trans "Edit labels" %}</h3>
<input type="hidden" name="labels" /><br />
<p class="error hide"></p>
<button type="submit" class="submit">{% trans "Submit" %}</button>
</form>
{% endif %}
{% endblock %}
{% block extra_script %}
<script type="text/javascript" src="{% static "scripts/lib/select2-3.5.2.js" %}"></script>
<script type="text/javascript">
{% include 'snippets/list_commit_detail.html' %}
$('.view-snapshot').each(function() {
$(this).attr('href', $(this).attr('href') + '&referer=' + encodeURIComponent(location.href));
});
{% if show_label and user_perm == 'rw' %}
$('.label-edit-icon').on('click', function() {
var $tr = $(this).parent();
var s2_tags = [];
$('.cur-tag', $tr).each(function(index, item) {
var label = $(item).text();
s2_tags.push({
'id': label,
'text': label
});
});
var $form = $('#label-edit-form');
$form.data('tr', $tr).modal({focus: false});
$('#simplemodal-container').css({'width':'auto', 'height':'auto'});
$('[name="labels"]')
.select2({
width: '280px',
tags: []
})
.select2('data', s2_tags);
});
$('#label-edit-form').on('submit', function() {
var $form = $(this);
var $input = $('[name="labels"]', $form);
var $error = $('.error', $form);
var $submit = $('[type="submit"]', $form);
var $tr = $form.data('tr');
var tags = $input.select2('val');
disable($submit);
$.ajax({
url: '{% url "api-v2.1-revision-tags-tagged-items" %}',
type: 'PUT',
cache: false,
dataType: 'json',
data: {
'repo_id': '{{repo.id}}',
'commit_id': $tr.attr('data-id'),
'tag_names': tags.join(',')
},
beforeSend: prepareCSRFToken,
success: function(data) {
var tags = data.revisionTags;
var str = '';
for (var i = 0, len = tags.length; i < len; i++) {
str += '<span class="cur-tag">' + HTMLescape(tags[i].tag) + '</span>';
}
$('.cur-tag', $tr).remove();
$tr.prepend(str);
$.modal.close();
feedback("{% trans "Successfully edited labels." %}", 'success');
},
error: function(xhr) {
var error_msg = prepareAjaxErrorMsg(xhr);
$error.html(error_msg).show();
enable($submit);
}
});
return false;
});
{% endif %}
{% include 'snippets/go_back_js.html' %}
</script>
{% endblock %}

View File

@ -1,664 +0,0 @@
{% extends 'base.html' %}
{% load seahub_tags avatar_tags i18n staticfiles %}
{% block sub_title %}{{filename}} - {% endblock %}
{% block viewport %}
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no" />
{% endblock %}
{% block extra_style %}
<link rel="stylesheet" type="text/css" href="{{ MEDIA_URL }}css/file_view_extra.css" />
<style type="text/css">
#view-hd {
width:100%;
padding:0 15px 12px;
border-bottom:1px solid #c9c9c9;
display:flex;
justify-content:space-between;
flex-shrink:0;
}
#file-view {
border:none;
border-right:4px solid transparent;
margin-top:0;
}
#file-discussions {
width:400px;
}
</style>
{% endblock %}
{% block header_css_class %}hide{% endblock %}
{% block main_class %}ovhd d-flex fd-col{% endblock %}
{% block main_content %}
<div id="view-hd">
<div>
<h2 class="file-view-hd">
<span class="vam">{{ filename }}</span>
{% if is_starred %}
<a id="file-star" class="vam no-deco icon-star" href="#" title="{% trans "starred" %}" aria-label="{% trans "starred" %}"></a>
{% else %}
<a id="file-star" class="vam no-deco icon-star-empty" href="#" title="{% trans "unstarred" %}" aria-label="{% trans "unstarred" %}"></a>
{% endif %}
{% if is_pro %}
<img class="file-locked-icon cspt vam {% if not file_locked %}hide{% endif %}" width="16" src="{{ MEDIA_URL }}img/file-locked-32.png" alt="{% trans "locked" %}" title="{% trans "locked" %}" aria-label="{% trans "locked" %}" />
{% endif %}
</h2>
<div class="commit">
<a href="{% url 'user_profile' latest_contributor %}" class="name vam">{{ latest_contributor|email2nickname }}</a>
<span class="time vam">{{ last_modified|translate_seahub_time}}</span>
{% block update_detail %}
{% if last_commit_id %}
<span class="vam">{% trans "updated this file"%}.</span>
{% endif %}
{% endblock %}
</div>
</div>
<div id="file-view-op" class="sf-btn-group file-view-op">
</div>
</div>
<div class="d-flex flex-auto ovhd"> {# 'ovhd' is for Firefox #}
<div id="file-view" class="flex-1 ov-auto {% block file_view_extra_class %}{% endblock %}">
{% if err %}
<div id="file-view-tip">
{% if err != 'File preview unsupported' %}
<p class="error">{{ err }}</p>
{% else %}
<p>{% trans "Online view is not applicable to this file format" %}</p>
{% endif %}
<a href="?dl=1" class="sf-btn-link big-btn-link">{% trans "Download" %}</a>
{% if file_perm == 'rw' %}
{% if filetype == 'Document' or filetype == 'SpreadSheet' %}
<a class="open-via-client" href="seafile://openfile?repo_id={{repo.id}}&path={{path|urlencode}}">{% trans "Open via Client" %}</a>
<p class="tip">{% trans "Please install the desktop client to open file via client." %}</p>
{% endif %}
{% endif %}
</div>
{% else %}
{% block file_view %}{% endblock %}
{% endif %}
</div>
<div id="file-discussions" class="comments-panel" style="display:none;"></div>
</div>
<div id="side-toolbar">
<ul class="side-toolbar">
<li class="item hide" id="back-to-top" title="{% trans "Back to top" %}"><img src="{{MEDIA_URL}}img/top.png" alt="{% trans "top" %}" /></li>
</ul>
</div>
<script type="text/template" id="discussion-panel-tmpl">
<div class="comments-panel-hd file-discussions-hd ovhd">
<a href="#" title="{% trans "Close" %}" aria-label="{% trans "Close" %}" class="sf-popover-close js-close sf2-icon-x1 op-icon"></a>
<h3 class="comments-panel-title">{% trans "Comments" %}</h3>
</div>
<div class="comments-panel-con file-discussions-con">
<div class="loading-icon loading-tip"></div>
<ul class="file-discussion-list hide"></ul>
<p class="no-discussion-tip hide">{% trans "No comment yet." %}</p>
<p class="error hide"></p>
</div>
<div class="comments-panel-footer file-discussions-footer">
<form action="" method="post" class="msg-form">
<img src="{% avatar_url request.user 64 %}" alt="" width="32" height="32" class="avatar-circle fleft" />
<div class="msg-body">
<textarea name="message" placeholder="{% trans "Add a comment..." %}" title="{% trans "Add a comment..." %}" aria-label="{% trans "Add a comment..." %}" class="msg-input"></textarea>
<p class="error hide"></p>
<button type="submit" class="submit msg-submit">{% trans "Submit" %}</button>
</div>
</form>
</div>
</script>
<script type="text/template" id="discussion-tmpl">
<li class="msg ovhd">
<img src="<%= avatar_url %>" alt="" width="32" height="32" class="avatar-circle fleft" />
<div class="msg-body">
<div class="ovhd">
<a class="msg-username ellipsis" title="<%- user_name %>" href="<%= user_profile_url %>"><%- user_name %></a>
<span class="msg-time" title="<%- time %>"><%- time_from_now %></span>
<div class="msg-ops fright vh">
<a class="msg-op sf2-icon-reply op-icon js-reply-msg" title="{% trans "Reply" %}" aria-label="{% trans "Reply" %}" href="#" data-username="<%- user_name %>"></a>
<% if (can_delete_msg) { %>
<a class="msg-op sf2-icon-delete op-icon js-del-msg" title="{% trans "Delete" %}" aria-label="{% trans "Delete" %}" href="#" data-id="<%= id %>"></a>
<% } %>
</div>
</div>
<div class="msg-content"><%= content_marked %></div>
</div>
</li>
</script>
<script type="text/template" id="editor-tools-tmpl">
<a class="sf-btn-group-btn sf-btn-group-btn-first sf-btn-link op-icon sf2-icon-folder" href="{{ SITE_ROOT }}library/{{ repo.id }}/{{ repo.name|urlencode }}/{{ parent_dir|strip_slash|urlencode }}" title="{% trans "Open parent folder" %}"></a>
{% if not err and file_perm == 'rw' %}
{% if filetype == 'Document' or filetype == 'SpreadSheet' %}
<a class="sf-btn-group-btn sf-btn-link op-icon sf2-icon-monitor open-via-client" href="seafile://openfile?repo_id={{repo.id}}&path={{path|urlencode}}" title="{% trans "Open via Client" %}"></a>
{% endif %}
{% endif %}
{% if can_lock_unlock_file %}
{% if not file_locked %}
<button id="lock-file" class="sf-btn-group-btn op-icon sf2-icon-lock" title="{% trans "Lock" %}"></button>
<button id="unlock-file" class="sf-btn-group-btn op-icon sf2-icon-unlock hide" title="{% trans "Unlock" %}"></button>
{% elif locked_by_me %}
<button id="unlock-file" class="sf-btn-group-btn op-icon sf2-icon-unlock" title="{% trans "Unlock" %}"></button>
<button id="lock-file" class="sf-btn-group-btn op-icon sf2-icon-lock hide" title="{% trans "Lock" %}"></button>
{% endif %}
{% endif %}
{% if file_perm == 'rw' %}
<a class="sf-btn-group-btn sf-btn-link op-icon sf2-icon-clock" id="history" href="{% url 'file_revisions' repo.id %}?p={{ path|urlencode }}" title="{% trans "History" %}"></a>
{% endif %}
{% if request.user.is_authenticated and can_edit_file %}
{% block edit_file %}
{% endblock %}
{% endif %}
{% if can_download_file %}
<a class="sf-btn-group-btn sf-btn-link op-icon sf2-icon-download" href="?dl=1" id="download-file" title="{% trans "Download"%}"></a>
{% endif %}
{% if enable_file_comment %}
<button id="discuss" class="sf-btn-group-btn op-icon sf2-icon-msgs" title="{% trans "Comment" %}"></button>
{% endif %}
</script>
<script type="text/template" id="mobile-editor-tools-tmpl">
<a class="sf2-icon-more sf2-mobile-menu-toggle"></a>
<div class="sf-dropdown-menu sf2-mobile-menu">
<ul>
<li>
<a id="openParent" class="op openfolder" href="{{ SITE_ROOT }}library/{{ repo.id }}/{{ repo.name|urlencode }}/{{ parent_dir|strip_slash|urlencode }}" title="{% trans "Open parent folder" %}">{% trans "Open parent folder" %}</a>
</li>
{% if can_lock_unlock_file %}
{% if not file_locked %}
<li id="lock-file">
<a class="op lock-file" title="{% trans "Lock" %}">{% trans "Lock" %}</a>
</li>
<li id="unlock-file" class="hide">
<a class="op unlock-file" title="{% trans "Unlock" %}">{% trans "Unlock" %}</a>
</li>
{% elif locked_by_me %}
<li id="unlock-file">
<a class="op unlock-file" title="{% trans "Unlock" %}">{% trans "Unlock" %}</a>
</li>
<li id="lock-file" class="hide">
<a class="op lock-file" title="{% trans "Lock" %}">{% trans "Lock" %}</a>
</li>
{% endif %}
{% endif %}
{% if file_perm == 'rw' %}
<li>
<a id="history" class="op history" href="{% url 'file_revisions' repo.id %}?p={{ path|urlencode }}" title="{% trans "History" %}">{% trans "History" %}</a>
</li>
{% endif %}
{% if can_download_file %}
<li>
<a id="download-file" class="op download" href="?dl=1" title="{% trans "Download"%}">{% trans "Download"%}</a>
</li>
{% endif %}
</ul>
<div>
</script>
{% endblock %}
{% block extra_script %}
<script type="text/javascript" src="{% static "scripts/lib/underscore.js" %}"></script>
<script type="text/javascript" src="{% static "scripts/lib/moment-with-locales.min.js" %}"></script>
<script type="text/javascript" src="{% static "scripts/lib/marked.min.js" %}"></script>
{% if highlight_keyword %}
<script type="text/javascript" src="{{ MEDIA_URL }}js/findAndReplaceDOMText.js"></script>
{% endif %}
<script type="text/javascript">
// star file
$('#file-star').on('click', function() {
var op_icon = $(this), url_base;
url_base = '{% url "starredfiles" %}';
if (op_icon.hasClass('icon-star-empty')) {
// star the file
$.ajax({
url: url_base,
cache: false,
dataType: 'json',
type: 'POST',
beforeSend: prepareCSRFToken,
data: {
'repo_id': "{{ repo.id }}",
'p': "{{ path|escapejs }}"
},
success:function(data) {
op_icon.toggleClass('icon-star-empty icon-star');
},
error: ajaxErrorHandler
});
} else {
// unstar
$.ajax({
url: url_base + '?p=' + e("{{path|escapejs}}") + '&repo_id=' + "{{ repo.id }}",
cache: false,
dataType: 'json',
type: 'DELETE',
beforeSend: prepareCSRFToken,
success:function(data) {
op_icon.toggleClass('icon-star-empty icon-star');
},
error: ajaxErrorHandler
});
}
return false;
});
// set 'side toolbar' position
function setToolbarPos() {
var toolbar = $('#side-toolbar');
// set toolbar pos
toolbar.css({'top': ($(window).height() - toolbar.outerHeight())/2});
}
(function () {
var to_top = $('#back-to-top');
to_top.on('click', function() {
$(window).scrollTop(0);
});
$(window).on('scroll', function() {
if ($(window).scrollTop() > 0) {
to_top.show();
} else {
to_top.hide();
}
});
})();
$(window).on('load resize', setToolbarPos);
{% if highlight_keyword %}
var ref_list = document.referrer.split('?');
// referrer is 'search result' page, i.e, '{{SITE_ROOT}}search/?q=xx..'
if (ref_list.length > 1 && ref_list[0].indexOf('search') > 0) {
var search_params = ref_list[1].split('&');
var search_keyword = search_params[0].substr(2); // get 'xx' from 'q=xx'
var highlight_kw = function(hl_area) { // 'hl_area': a node
findAndReplaceDOMText(hl_area, {
find: new RegExp(search_keyword, 'gim'),
replace: function(portion, match) { // portion is a part of a match
var node = document.createElement('span');
node.style.background = '#ffe761';
node.innerHTML = portion.text; // portion is an object
return node;
}
});
};
}
$(window).on('load', function() {
if (highlight_kw) {
// hl kw in file title
highlight_kw($('.file-view-hd span')[0]);
// hl kw in file content
if ('{{filetype}}' == 'Markdown') {
highlight_kw($('#file-view')[0]);
}
if ('{{fileext}}' == 'text' || '{{fileext}}' == 'txt') {
setTimeout(function(){ highlight_kw($('.CodeMirror')[0]); }, 500);
}
}
});
{% endif %}
// file discussion
var fileDiscussions = {
$el: $('#file-discussions'),
tmpl: _.template($('#discussion-panel-tmpl').html()),
init: function() {
var _this = this;
this.setLocale();
// events
this.$el.on('click', '.js-close', function() {
_this.hide();
return false;
});
this.$el.on('mouseenter', '.msg', function() {
$(this).addClass('hl').find('.msg-ops').removeClass('vh');
});
this.$el.on('mouseleave', '.msg', function() {
$(this).removeClass('hl').find('.msg-ops').addClass('vh');
});
this.$el.on('click', '.js-reply-msg', function() {
_this.replyTo($(this).attr('data-username'));
return false;
});
this.$el.on('click', '.js-del-msg', function() {
_this.delOne({
id: $(this).attr('data-id'),
$el: $(this).closest('.msg')
});
return false;
});
this.$el.on('submit', '.msg-form', function() {
_this.formSubmit();
return false;
});
},
setLocale: function() {
var lang_code = '{{LANGUAGE_CODE}}';
var m_lang_code;
if (lang_code == 'en') {
m_lang_code = 'en-gb';
} else if (lang_code == 'es-ar' || lang_code == 'es-mx') {
m_lang_code = 'es';
} else {
m_lang_code = lang_code;
}
moment.locale(m_lang_code);
},
render: function () {
this.$el.html($(this.tmpl()));
this.$listContainer = $('.file-discussion-list', this.$el);
this.$emptyTip = $('.no-discussion-tip', this.$el);
this.$loadingTip = $('.loading-tip', this.$el);
this.$conError = $('.file-discussions-con .error', this.$el);
this.$msgInput = $('[name="message"]', this.$el);
},
collectionUrl: '{% url "api2-file-comments" repo.id %}?p='
+ e('{{path|escapejs}}') + '&avatar_size=64',
show: function() {
this.render();
this.$el.show();
// pdf file view with pdf.js; text file view; #file-view-tip
$('#pdf, .CodeMirror, #file-view-tip').css({'width':'auto', 'margin':'0 10px'});
// encoding selector
$('#file-enc-cont').css({'width': 'auto', 'margin-right':'10px'});
this.getContent();
},
hide: function() {
// pdf file view with pdf.js; text file view; #file-view-tip
// encoding selector
$('#pdf, .CodeMirror, #file-enc-cont, #file-view-tip').removeAttr('style');
this.$el.empty().hide();
},
getContent: function() {
var _this = this;
$.ajax({
url: this.collectionUrl,
type: 'GET',
cache: false,
dataType: 'json',
success: function(data) {
var comments = data.comments;
if (comments.length > 0) {
$(comments).each(function(index, item) {
_this.addOne(item);
});
_this.$listContainer.show();
_this.scrollConToBottom();
} else {
_this.$emptyTip.show();
}
},
error: function(xhr) {
var error_msg = prepareAjaxErrorMsg(xhr);
_this.$conError.html(error_msg).show();
},
complete: function() {
_this.$loadingTip.hide();
}
});
},
formSubmit: function() {
var _this = this;
var $formError = $('.msg-form .error', this.$el);
var $submitBtn = $('[type="submit"]', this.$el)
var msg = $.trim(this.$msgInput.val());
if (!msg) {
return false;
}
$formError.hide();
disable($submitBtn);
$.ajax({
url: this.collectionUrl,
type: 'POST',
cache: false,
dataType: 'json',
beforeSend: prepareCSRFToken,
data: {'comment': msg},
success: function(data) {
_this.$msgInput.val('');
_this.addOne(data);
if (_this.$emptyTip.is(':visible')) {
_this.$emptyTip.hide();
_this.$listContainer.show();
}
_this.scrollConToBottom();
},
error: function(xhr) {
var error_msg = prepareAjaxErrorMsg(xhr);
$formError.html(error_msg).show();
},
complete: function() {
enable($submitBtn);
}
});
},
itemTmpl: _.template($('#discussion-tmpl').html()),
addOne: function(obj) {
var can_delete_msg = false;
var is_repo_owner = {% if is_repo_owner %}true{% else %}false{% endif %};
if (is_repo_owner ||
obj.user_email == '{{request.user|escapejs}}') {
can_delete_msg = true;
}
var user_profile_url = '{{SITE_ROOT}}profile/' + encodeURIComponent(obj.user_email) + '/';
var m = moment(obj.created_at);
var data = $.extend({}, obj, {
'content_marked': marked(obj.comment, {
breaks: true,
sanitize: true
}),
'time': m.format('LLLL'),
'time_from_now': this.util_getRelativeTimeStr(m),
'can_delete_msg': can_delete_msg,
'user_profile_url': user_profile_url
});
var $item = $(this.itemTmpl(data));
this.$listContainer.append($item);
},
scrollConToBottom: function() {
var $el = $('.file-discussions-con', this.$el);
$el.scrollTop($el[0].scrollHeight - $el[0].clientHeight);
},
replyTo: function(to_user) {
var str = "@" + to_user + " ";
var $input = this.$msgInput.val(str);
setCaretPos($input[0], str.length);
$input.trigger('focus');
},
// delete a comment
delOne: function(item) { // item: {id:, $el:}
var _this = this;
$.ajax({
url: '{{SITE_ROOT}}api2/repos/{{repo.id}}/file/comments/' + item.id + '/',
type: 'delete',
cache: false,
beforeSend: prepareCSRFToken,
success: function() {
item.$el.remove();
if ($('.msg', _this.$el).length == 0) {
_this.$emptyTip.show();
_this.$listContainer.hide();
}
},
error: ajaxErrorHandler
});
},
util_getRelativeTimeStr: function(m) {
var now = new Date();
if (m - now > 0) {
return "{% trans "Just now" %}";
} else {
return m.fromNow();
}
}
};
// init
fileDiscussions.init();
$(document).on('keydown', function(e) {
// ESCAPE key pressed
if (e.which == 27) {
fileDiscussions.hide();
}
});
var DropDownMenu = {
$el: $("#file-view-op"),
$mobileTmp: _.template($("#mobile-editor-tools-tmpl").html()),
$deviceTmp: _.template($("#editor-tools-tmpl").html()),
init: function() {
var _this = this;
this.render();
window.onresize = function(){
_this.render();
}
},
render: function() {
var _this = this;
var template = $(window).width() > 992 ? this.$deviceTmp : this.$mobileTmp;
this.$el.html(template);
$('.sf-btn-group-btn:last', this.$el).addClass('sf-btn-group-btn-last');
//bind click event for the menu item;
{% if can_lock_unlock_file %}
// lock/unlock file
$('#lock-file, #unlock-file').on('click', function(event) {
var eventSource = this;
_this.clickToggleLock(eventSource);
})
{% endif %}
$('#discuss').on('click', function() {
_this.clickToCommet();
});
//if mobile : bind the popmenu event
if ($(".sf2-mobile-menu-toggle").length) {
$(".sf2-mobile-menu-toggle").on('click',function(){
var isDisplay = $('.sf2-mobile-menu').css('display') === "block" ? true : false;
if (isDisplay) {
_this.clickToClosePopMenu();
} else {
_this.clickToShowPopMenu();
}
return false;
})
$(document).on('click', function(e){
var target = e.target || event.srcElement;
var isDisplay = $('.sf2-mobile-menu').css('display') === "block" ? true : false;
if (!isDisplay) {
return true;
}
if (!$('.sf2-mobile-menu').is(target) &&
!$('.sf2-mobile-menu').find('*').is(target)) {
$('.sf2-mobile-menu').hide();
}
return true;
});
$("#download-file").on("click", function(){
_this.clickToClosePopMenu();
})
}
},
clickToggleLock: function(eventSource) {
this.clickToClosePopMenu();
var op = $(eventSource).attr('id') == 'lock-file' ? 'lock' : 'unlock',
path = '{{path|escapejs}}';
$.ajax({
url: '{% url 'api-v2.1-file-view' repo.id %}' + '?p=' + encodeURIComponent(path),
type: 'PUT',
dataType: 'json',
cache: false,
beforeSend: prepareCSRFToken,
data: {'operation': op},
success: function() {
$('#lock-file, #unlock-file, .file-locked-icon').toggleClass('hide');
},
error: ajaxErrorHandler
});
},
clickToCommet: function() {
if (fileDiscussions.$el.is(':visible')) {
fileDiscussions.hide();
} else {
fileDiscussions.show();
}
},
clickToClosePopMenu: function() {
$(".sf2-mobile-menu").hide();
},
clickToShowPopMenu: function() {
$(".sf2-mobile-menu").show();
}
}
DropDownMenu.init();
// for 'go back'
var $history = $('#history');
$history.attr('href', $history.attr('href') + '&referer=' + encodeURIComponent(location.href));
</script>
{% if enable_watermark %}
<script type="text/javascript" src="{{ MEDIA_URL }}js/watermark.js"></script>
<script type="text/javascript">{% include "snippets/add_watermark.html" %}</script>
{% endif %}
{% endblock %}

View File

@ -655,32 +655,6 @@ def view_lib_file(request, repo_id, path):
if filetype == MARKDOWN:
# get file size
if file_size > FILE_PREVIEW_MAX_SIZE:
error_msg = _('File size surpasses %s, can not be opened online.') % \
filesizeformat(FILE_PREVIEW_MAX_SIZE)
return_dict['err'] = error_msg
return render(request, 'view_file_base.html', return_dict)
file_enc = request.GET.get('file_enc', 'auto')
if file_enc not in FILE_ENCODING_LIST:
file_enc = 'auto'
error_msg, file_content, encoding = get_file_content(filetype,
inner_path, file_enc)
if error_msg:
return_dict['err'] = error_msg
return render(request, 'view_file_base.html', return_dict)
file_encoding_list = FILE_ENCODING_LIST
if encoding and encoding not in FILE_ENCODING_LIST:
file_encoding_list.append(encoding)
return_dict['file_enc'] = file_enc
return_dict['encoding'] = encoding
return_dict['file_encoding_list'] = file_encoding_list
mode = request.GET.get('mode', '')
is_draft = is_draft_file(repo.id, path)
@ -693,7 +667,6 @@ def view_lib_file(request, repo_id, path):
return_dict['protocol'] = request.is_secure() and 'https' or 'http'
return_dict['domain'] = get_current_site(request).domain
return_dict['file_content'] = convert_md_link(file_content, repo_id, username)
return_dict['serviceUrl'] = get_service_url().rstrip('/')
return_dict['language_code'] = get_language()
return_dict['mode'] = 'edit' if mode == 'edit' else 'viewer'
@ -711,10 +684,8 @@ def view_lib_file(request, repo_id, path):
can_edit_file = False
elif is_locked and not locked_by_me:
can_edit_file = False
return_dict['can_edit_file'] = can_edit_file
template = 'view_file_%s.html' % filetype.lower()
return render(request, template, return_dict)
elif filetype in (VIDEO, AUDIO, PDF, SVG):

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff