From b5b59781306aabf50b975c0b45dda0b110a8835c Mon Sep 17 00:00:00 2001 From: Tom Giannattasio Date: Fri, 17 Aug 2012 13:32:40 -0400 Subject: [PATCH 1/3] started styling attachments page --- lms/static/sass/course/wiki/_wiki.scss | 31 ++++ .../wiki/includes/anonymous_blocked.html | 13 ++ .../wiki/plugins/attachments/index.html | 132 ++++++++++++++++++ 3 files changed, 176 insertions(+) create mode 100644 lms/templates/wiki/includes/anonymous_blocked.html create mode 100644 lms/templates/wiki/plugins/attachments/index.html diff --git a/lms/static/sass/course/wiki/_wiki.scss b/lms/static/sass/course/wiki/_wiki.scss index 782792bbbb..bc2cc46700 100644 --- a/lms/static/sass/course/wiki/_wiki.scss +++ b/lms/static/sass/course/wiki/_wiki.scss @@ -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; + } + } + diff --git a/lms/templates/wiki/includes/anonymous_blocked.html b/lms/templates/wiki/includes/anonymous_blocked.html new file mode 100644 index 0000000000..264579130e --- /dev/null +++ b/lms/templates/wiki/includes/anonymous_blocked.html @@ -0,0 +1,13 @@ +{% load i18n %} +{% load url from future %} + +{% url 'wiki:signup' as signup_url %} +{% url 'wiki:login' as login_url %} +{% if login_url and signup_url %} + {% blocktrans %} + You need to log in or sign up to use this function. + {% endblocktrans %} +{% else %} + {% trans "You need to log in or sign up to use this function." %} +{% endif %} + diff --git a/lms/templates/wiki/plugins/attachments/index.html b/lms/templates/wiki/plugins/attachments/index.html new file mode 100644 index 0000000000..711f54a4af --- /dev/null +++ b/lms/templates/wiki/plugins/attachments/index.html @@ -0,0 +1,132 @@ +{% 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 %} +
+ + + + {% if article|can_write:user %} +
+
+
+ +
+
+ {% if anonymous_disallowed %} + {% include "wiki/includes/anonymous_blocked.html" %} + {% else %} +
+ {% wiki_form form %} + +
+ {% endif %} +
+
+ +
+
+
+
+ + +
+
+

{% 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." %}

+ +
+
+
+ +
+
+ {% endif %} + + + +
+

{% trans "The following files are available for this article. Copy the markdown tag to directly refer to a file from the article text." %}

+ {% for attachment in attachments %} + + + + + + + + + + + + + + + +
+

+ {{ attachment.current_revision.get_filename }} + {{ attachment.current_revision.created|naturaltime }} + {% if attachment.current_revision.deleted %} + {% trans "deleted" %} + {% endif %} +

+ {{ attachment.current_revision.description }} +
{% trans "Markdown tag" %}{% trans "Uploaded by" %}{% trans "Size" %} + {% if attachment|can_write:user %} +

+ {% if not attachment.current_revision.deleted %} + {% trans "Replace" %} + {% if attachment.article = article %} + {% trans "Delete" %} + {% else %} + {% trans "Detach" %} + {% endif %} + {% else %} + {% if attachment.current_revision.previous_revision.id %} +

+ {% csrf_token %} + +
+ {% endif %} + {% endif %} +

+ {% endif %} +

+ + + {% trans "File history" %} ({{ attachment.attachmentrevision_set.all.count }} {% trans "revisions" %}) + +

+
[attachment:{{ attachment.id }}] + {% 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 %} + {{ attachment.current_revision.get_size|filesizeformat }}
+ {% empty %} +

{% trans "There are no attachments for this article." %}

+ {% endfor %} +
+ + +
+ +{% endblock %} + From f67a3564664f69f85d7499eb5d67c171ec689eab Mon Sep 17 00:00:00 2001 From: Tom Giannattasio Date: Fri, 17 Aug 2012 14:14:07 -0400 Subject: [PATCH 2/3] added additional bootstrap js files --- lms/static/js/bootstrap-alert.js | 90 +++++++++++++++ lms/static/js/bootstrap-collapse.js | 157 ++++++++++++++++++++++++++ lms/static/js/bootstrap-transition.js | 61 ++++++++++ lms/templates/wiki/base.html | 5 +- 4 files changed, 312 insertions(+), 1 deletion(-) create mode 100644 lms/static/js/bootstrap-alert.js create mode 100644 lms/static/js/bootstrap-collapse.js create mode 100644 lms/static/js/bootstrap-transition.js diff --git a/lms/static/js/bootstrap-alert.js b/lms/static/js/bootstrap-alert.js new file mode 100644 index 0000000000..57890a9a28 --- /dev/null +++ b/lms/static/js/bootstrap-alert.js @@ -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); \ No newline at end of file diff --git a/lms/static/js/bootstrap-collapse.js b/lms/static/js/bootstrap-collapse.js new file mode 100644 index 0000000000..fbc915b9f9 --- /dev/null +++ b/lms/static/js/bootstrap-collapse.js @@ -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); \ No newline at end of file diff --git a/lms/static/js/bootstrap-transition.js b/lms/static/js/bootstrap-transition.js new file mode 100644 index 0000000000..534182622d --- /dev/null +++ b/lms/static/js/bootstrap-transition.js @@ -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); \ No newline at end of file diff --git a/lms/templates/wiki/base.html b/lms/templates/wiki/base.html index bb82f8f996..f2d48db8aa 100644 --- a/lms/templates/wiki/base.html +++ b/lms/templates/wiki/base.html @@ -5,7 +5,10 @@ {% block headextra %} {% compressed_css 'course' %} - + + + +