Merge branch 'feature/bridger/new_wiki' of github.com:MITx/mitx into feature/bridger/new_wiki
Conflicts: lms/templates/wiki/base.html
This commit is contained in:
90
lms/static/js/bootstrap-alert.js
vendored
Normal file
90
lms/static/js/bootstrap-alert.js
vendored
Normal file
@@ -0,0 +1,90 @@
|
||||
/* ==========================================================
|
||||
* bootstrap-alert.js v2.0.4
|
||||
* http://twitter.github.com/bootstrap/javascript.html#alerts
|
||||
* ==========================================================
|
||||
* Copyright 2012 Twitter, Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
* ========================================================== */
|
||||
|
||||
|
||||
!function ($) {
|
||||
|
||||
"use strict"; // jshint ;_;
|
||||
|
||||
|
||||
/* ALERT CLASS DEFINITION
|
||||
* ====================== */
|
||||
|
||||
var dismiss = '[data-dismiss="alert"]'
|
||||
, Alert = function (el) {
|
||||
$(el).on('click', dismiss, this.close)
|
||||
}
|
||||
|
||||
Alert.prototype.close = function (e) {
|
||||
var $this = $(this)
|
||||
, selector = $this.attr('data-target')
|
||||
, $parent
|
||||
|
||||
if (!selector) {
|
||||
selector = $this.attr('href')
|
||||
selector = selector && selector.replace(/.*(?=#[^\s]*$)/, '') //strip for ie7
|
||||
}
|
||||
|
||||
$parent = $(selector)
|
||||
|
||||
e && e.preventDefault()
|
||||
|
||||
$parent.length || ($parent = $this.hasClass('alert') ? $this : $this.parent())
|
||||
|
||||
$parent.trigger(e = $.Event('close'))
|
||||
|
||||
if (e.isDefaultPrevented()) return
|
||||
|
||||
$parent.removeClass('in')
|
||||
|
||||
function removeElement() {
|
||||
$parent
|
||||
.trigger('closed')
|
||||
.remove()
|
||||
}
|
||||
|
||||
$.support.transition && $parent.hasClass('fade') ?
|
||||
$parent.on($.support.transition.end, removeElement) :
|
||||
removeElement()
|
||||
}
|
||||
|
||||
|
||||
/* ALERT PLUGIN DEFINITION
|
||||
* ======================= */
|
||||
|
||||
$.fn.alert = function (option) {
|
||||
return this.each(function () {
|
||||
var $this = $(this)
|
||||
, data = $this.data('alert')
|
||||
if (!data) $this.data('alert', (data = new Alert(this)))
|
||||
if (typeof option == 'string') data[option].call($this)
|
||||
})
|
||||
}
|
||||
|
||||
$.fn.alert.Constructor = Alert
|
||||
|
||||
|
||||
/* ALERT DATA-API
|
||||
* ============== */
|
||||
|
||||
$(function () {
|
||||
$('body').on('click.alert.data-api', dismiss, Alert.prototype.close)
|
||||
})
|
||||
|
||||
}(window.jQuery);
|
||||
157
lms/static/js/bootstrap-collapse.js
vendored
Normal file
157
lms/static/js/bootstrap-collapse.js
vendored
Normal file
@@ -0,0 +1,157 @@
|
||||
/* =============================================================
|
||||
* bootstrap-collapse.js v2.0.4
|
||||
* http://twitter.github.com/bootstrap/javascript.html#collapse
|
||||
* =============================================================
|
||||
* Copyright 2012 Twitter, Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
* ============================================================ */
|
||||
|
||||
|
||||
!function ($) {
|
||||
|
||||
"use strict"; // jshint ;_;
|
||||
|
||||
|
||||
/* COLLAPSE PUBLIC CLASS DEFINITION
|
||||
* ================================ */
|
||||
|
||||
var Collapse = function (element, options) {
|
||||
this.$element = $(element)
|
||||
this.options = $.extend({}, $.fn.collapse.defaults, options)
|
||||
|
||||
if (this.options.parent) {
|
||||
this.$parent = $(this.options.parent)
|
||||
}
|
||||
|
||||
this.options.toggle && this.toggle()
|
||||
}
|
||||
|
||||
Collapse.prototype = {
|
||||
|
||||
constructor: Collapse
|
||||
|
||||
, dimension: function () {
|
||||
var hasWidth = this.$element.hasClass('width')
|
||||
return hasWidth ? 'width' : 'height'
|
||||
}
|
||||
|
||||
, show: function () {
|
||||
var dimension
|
||||
, scroll
|
||||
, actives
|
||||
, hasData
|
||||
|
||||
if (this.transitioning) return
|
||||
|
||||
dimension = this.dimension()
|
||||
scroll = $.camelCase(['scroll', dimension].join('-'))
|
||||
actives = this.$parent && this.$parent.find('> .accordion-group > .in')
|
||||
|
||||
if (actives && actives.length) {
|
||||
hasData = actives.data('collapse')
|
||||
if (hasData && hasData.transitioning) return
|
||||
actives.collapse('hide')
|
||||
hasData || actives.data('collapse', null)
|
||||
}
|
||||
|
||||
this.$element[dimension](0)
|
||||
this.transition('addClass', $.Event('show'), 'shown')
|
||||
this.$element[dimension](this.$element[0][scroll])
|
||||
}
|
||||
|
||||
, hide: function () {
|
||||
var dimension
|
||||
if (this.transitioning) return
|
||||
dimension = this.dimension()
|
||||
this.reset(this.$element[dimension]())
|
||||
this.transition('removeClass', $.Event('hide'), 'hidden')
|
||||
this.$element[dimension](0)
|
||||
}
|
||||
|
||||
, reset: function (size) {
|
||||
var dimension = this.dimension()
|
||||
|
||||
this.$element
|
||||
.removeClass('collapse')
|
||||
[dimension](size || 'auto')
|
||||
[0].offsetWidth
|
||||
|
||||
this.$element[size !== null ? 'addClass' : 'removeClass']('collapse')
|
||||
|
||||
return this
|
||||
}
|
||||
|
||||
, transition: function (method, startEvent, completeEvent) {
|
||||
var that = this
|
||||
, complete = function () {
|
||||
if (startEvent.type == 'show') that.reset()
|
||||
that.transitioning = 0
|
||||
that.$element.trigger(completeEvent)
|
||||
}
|
||||
|
||||
this.$element.trigger(startEvent)
|
||||
|
||||
if (startEvent.isDefaultPrevented()) return
|
||||
|
||||
this.transitioning = 1
|
||||
|
||||
this.$element[method]('in')
|
||||
|
||||
$.support.transition && this.$element.hasClass('collapse') ?
|
||||
this.$element.one($.support.transition.end, complete) :
|
||||
complete()
|
||||
}
|
||||
|
||||
, toggle: function () {
|
||||
this[this.$element.hasClass('in') ? 'hide' : 'show']()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/* COLLAPSIBLE PLUGIN DEFINITION
|
||||
* ============================== */
|
||||
|
||||
$.fn.collapse = function (option) {
|
||||
return this.each(function () {
|
||||
var $this = $(this)
|
||||
, data = $this.data('collapse')
|
||||
, options = typeof option == 'object' && option
|
||||
if (!data) $this.data('collapse', (data = new Collapse(this, options)))
|
||||
if (typeof option == 'string') data[option]()
|
||||
})
|
||||
}
|
||||
|
||||
$.fn.collapse.defaults = {
|
||||
toggle: true
|
||||
}
|
||||
|
||||
$.fn.collapse.Constructor = Collapse
|
||||
|
||||
|
||||
/* COLLAPSIBLE DATA-API
|
||||
* ==================== */
|
||||
|
||||
$(function () {
|
||||
$('body').on('click.collapse.data-api', '[data-toggle=collapse]', function ( e ) {
|
||||
var $this = $(this), href
|
||||
, target = $this.attr('data-target')
|
||||
|| e.preventDefault()
|
||||
|| (href = $this.attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '') //strip for ie7
|
||||
, option = $(target).data('collapse') ? 'toggle' : $this.data()
|
||||
$(target).collapse(option)
|
||||
})
|
||||
})
|
||||
|
||||
}(window.jQuery);
|
||||
61
lms/static/js/bootstrap-transition.js
vendored
Normal file
61
lms/static/js/bootstrap-transition.js
vendored
Normal file
@@ -0,0 +1,61 @@
|
||||
/* ===================================================
|
||||
* bootstrap-transition.js v2.0.4
|
||||
* http://twitter.github.com/bootstrap/javascript.html#transitions
|
||||
* ===================================================
|
||||
* Copyright 2012 Twitter, Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
* ========================================================== */
|
||||
|
||||
|
||||
!function ($) {
|
||||
|
||||
$(function () {
|
||||
|
||||
"use strict"; // jshint ;_;
|
||||
|
||||
|
||||
/* CSS TRANSITION SUPPORT (http://www.modernizr.com/)
|
||||
* ======================================================= */
|
||||
|
||||
$.support.transition = (function () {
|
||||
|
||||
var transitionEnd = (function () {
|
||||
|
||||
var el = document.createElement('bootstrap')
|
||||
, transEndEventNames = {
|
||||
'WebkitTransition' : 'webkitTransitionEnd'
|
||||
, 'MozTransition' : 'transitionend'
|
||||
, 'OTransition' : 'oTransitionEnd'
|
||||
, 'msTransition' : 'MSTransitionEnd'
|
||||
, 'transition' : 'transitionend'
|
||||
}
|
||||
, name
|
||||
|
||||
for (name in transEndEventNames){
|
||||
if (el.style[name] !== undefined) {
|
||||
return transEndEventNames[name]
|
||||
}
|
||||
}
|
||||
|
||||
}())
|
||||
|
||||
return transitionEnd && {
|
||||
end: transitionEnd
|
||||
}
|
||||
|
||||
})()
|
||||
|
||||
})
|
||||
|
||||
}(window.jQuery);
|
||||
@@ -466,6 +466,15 @@ section.wiki {
|
||||
}
|
||||
}
|
||||
|
||||
.accordion small {
|
||||
font-size: 0.8em;
|
||||
color: #aaa;
|
||||
}
|
||||
|
||||
.accordion-toggle div {
|
||||
margin-top: 8px;
|
||||
}
|
||||
|
||||
.collapse {
|
||||
display: none;
|
||||
|
||||
@@ -474,6 +483,28 @@ section.wiki {
|
||||
}
|
||||
}
|
||||
|
||||
.diff-container {
|
||||
overflow-x: scroll;
|
||||
|
||||
table {
|
||||
min-width: 100%;
|
||||
}
|
||||
|
||||
th {
|
||||
font-family: $sans-serif;
|
||||
font-size: 0.7em;
|
||||
}
|
||||
|
||||
td {
|
||||
font-family: $monospace;
|
||||
}
|
||||
|
||||
.linenumber,
|
||||
.data {
|
||||
font-size: 0.75em;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -5,8 +5,10 @@
|
||||
|
||||
{% block headextra %}
|
||||
{% compressed_css 'course' %}
|
||||
<script src="{% static 'js/bootstrap-alert.js' %}"></script>
|
||||
<script src="{% static 'js/bootstrap-collapse.js' %}"></script>
|
||||
<script src="{% static 'js/bootstrap-modal.js' %}"></script>
|
||||
|
||||
<script src="{% static 'js/bootstrap.min.js' %}"></script>
|
||||
<script type="text/javascript">
|
||||
function ajaxError(){}
|
||||
|
||||
|
||||
13
lms/templates/wiki/includes/anonymous_blocked.html
Normal file
13
lms/templates/wiki/includes/anonymous_blocked.html
Normal file
@@ -0,0 +1,13 @@
|
||||
{% load i18n %}
|
||||
{% load url from future %}
|
||||
<em>
|
||||
{% url 'wiki:signup' as signup_url %}
|
||||
{% url 'wiki:login' as login_url %}
|
||||
{% if login_url and signup_url %}
|
||||
{% blocktrans %}
|
||||
You need to <a href="{{ login_url }}">log in</a> or <a href="{{ signup_url }}">sign up</a> to use this function.
|
||||
{% endblocktrans %}
|
||||
{% else %}
|
||||
{% trans "You need to log in or sign up to use this function." %}
|
||||
{% endif %}
|
||||
</em>
|
||||
156
lms/templates/wiki/plugins/attachments/index.html
Normal file
156
lms/templates/wiki/plugins/attachments/index.html
Normal file
@@ -0,0 +1,156 @@
|
||||
{% extends "wiki/article.html" %}
|
||||
{% load wiki_tags i18n humanize %}
|
||||
{% load url from future %}
|
||||
|
||||
{% block pagetitle %}{% trans "Attachments" %}: {{ article.current_revision.title }}{% endblock %}
|
||||
|
||||
{% block wiki_contents_tab %}
|
||||
<div class="row-fluid">
|
||||
|
||||
|
||||
|
||||
{% if article|can_write:user %}
|
||||
|
||||
|
||||
<a class="accordion-toggle btn" href="#collapse_upload" data-toggle="collapse">
|
||||
<span class="icon-upload"></span>{% trans "Upload new file" %}
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
<div class="modal hide fade" id="upload-modal">
|
||||
{% if anonymous_disallowed %}
|
||||
{% include "wiki/includes/anonymous_blocked.html" %}
|
||||
{% else %}
|
||||
<form method="POST" class="form-vertical" id="attachment_form" enctype="multipart/form-data">
|
||||
{% wiki_form form %}
|
||||
<button type="submit" name="save" value="1" class="btn btn-large">
|
||||
{% trans "Upload file" %}
|
||||
</button>
|
||||
</form>
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
<div class="span5" style="min-width: 330px;">
|
||||
<div class="accordion" id="accordion_upload">
|
||||
<div class="accordion-group">
|
||||
<div class="accordion-heading">
|
||||
<a class="accordion-toggle btn" href="#collapse_upload" data-toggle="collapse">
|
||||
<span class="icon-upload"></span>{% trans "Upload new file" %}
|
||||
</a>
|
||||
</div>
|
||||
<div id="collapse_upload" class="accordion-body collapse{% if form.errors %} in{% endif %}">
|
||||
<div class="accordion-inner">
|
||||
{% if anonymous_disallowed %}
|
||||
{% include "wiki/includes/anonymous_blocked.html" %}
|
||||
{% else %}
|
||||
<form method="POST" class="form-vertical" id="attachment_form" enctype="multipart/form-data">
|
||||
{% wiki_form form %}
|
||||
<button type="submit" name="save" value="1" class="btn btn-large">
|
||||
{% trans "Upload file" %}
|
||||
</button>
|
||||
</form>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<div class="accordion" id="accordion_add">
|
||||
<div class="accordion-group">
|
||||
<div class="accordion-heading">
|
||||
<a class="accordion-toggle btn" href="#collapse_add" data-toggle="collapse">
|
||||
<span class="icon-plus-sign"></span>{% trans "Search and add file" %}
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<div id="collapse_add" class="accordion-body collapse">
|
||||
<div class="accordion-inner">
|
||||
<p>{% trans "You can reuse files from other articles. These files are subject to updates on other articles which may or may not be a good thing." %}</p>
|
||||
<form method="GET" action="{% url 'wiki:attachments_search' path=urlpath.path article_id=article.id %}" class="form-search">
|
||||
{{ search_form.query }}
|
||||
<button class="btn btn-large">
|
||||
{% trans "Search files and articles" %}
|
||||
</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
|
||||
|
||||
<div class="span7">
|
||||
<p class="lead">{% trans "The following files are available for this article. Copy the markdown tag to directly refer to a file from the article text." %}</p>
|
||||
{% for attachment in attachments %}
|
||||
<table class="table table-bordered table-striped" style="width: 100%;">
|
||||
<tr>
|
||||
<td colspan="4">
|
||||
<h3>
|
||||
<a href="{% url 'wiki:attachments_download' path=urlpath.path article_id=article.id attachment_id=attachment.id %}">{{ attachment.current_revision.get_filename }}</a>
|
||||
<span class="badge">{{ attachment.current_revision.created|naturaltime }}</span>
|
||||
{% if attachment.current_revision.deleted %}
|
||||
<span class="badge badge-important">{% trans "deleted" %}</span>
|
||||
{% endif %}
|
||||
</h3>
|
||||
{{ attachment.current_revision.description }}
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>{% trans "Markdown tag" %}</th>
|
||||
<th>{% trans "Uploaded by" %}</th>
|
||||
<th>{% trans "Size" %}</th>
|
||||
<td style="text-align: right;" rowspan="2">
|
||||
{% if attachment|can_write:user %}
|
||||
<p>
|
||||
{% if not attachment.current_revision.deleted %}
|
||||
<a href="{% url 'wiki:attachments_replace' path=urlpath.path article_id=article.id attachment_id=attachment.id %}" class="btn">{% trans "Replace" %}</a>
|
||||
{% if attachment.article = article %}
|
||||
<a href="{% url 'wiki:attachments_delete' path=urlpath.path article_id=article.id attachment_id=attachment.id %}" class="btn">{% trans "Delete" %}</a>
|
||||
{% else %}
|
||||
<a href="{% url 'wiki:attachments_delete' path=urlpath.path article_id=article.id attachment_id=attachment.id %}" class="btn">{% trans "Detach" %}</a>
|
||||
{% endif %}
|
||||
{% else %}
|
||||
{% if attachment.current_revision.previous_revision.id %}
|
||||
<form method="POST" action="{% url 'wiki:attachments_revision_change' path=urlpath.path article_id=article.id attachment_id=attachment.id revision_id=attachment.current_revision.previous_revision.id %}">
|
||||
{% csrf_token %}
|
||||
<button class="btn">
|
||||
{% trans "Restore" %}
|
||||
</button>
|
||||
</form>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
</p>
|
||||
{% endif %}
|
||||
<p>
|
||||
<a href="{% url 'wiki:attachments_history' path=urlpath.path article_id=article.id attachment_id=attachment.id %}">
|
||||
<span class="icon-time"></span>
|
||||
{% trans "File history" %} ({{ attachment.attachmentrevision_set.all.count }} {% trans "revisions" %})
|
||||
</a>
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>[attachment:{{ attachment.id }}]</code></td>
|
||||
<td>
|
||||
{% if attachment.current_revision.user %}{{ attachment.current_revision.user }}{% else %}{% if user|is_moderator %}{{ attachment.current_revision.ip_address|default:"anonymous (IP not logged)" }}{% else %}{% trans "anonymous (IP logged)" %}{% endif %}{% endif %}
|
||||
</td>
|
||||
<td>{{ attachment.current_revision.get_size|filesizeformat }}</td>
|
||||
</tr>
|
||||
</table>
|
||||
{% empty %}
|
||||
<p style="margin-bottom: 20px;"><em>{% trans "There are no attachments for this article." %}</em></p>
|
||||
{% endfor %}
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
{% endblock %}
|
||||
|
||||
Reference in New Issue
Block a user