Skip to content
This repository has been archived by the owner on Aug 26, 2022. It is now read-only.

Commit

Permalink
Merge 7b41890 into 73cdf4f
Browse files Browse the repository at this point in the history
  • Loading branch information
darkwing committed Jun 10, 2015
2 parents 73cdf4f + 7b41890 commit 6397014
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 3 deletions.
6 changes: 4 additions & 2 deletions kuma/wiki/templates/wiki/document.html
Original file line number Diff line number Diff line change
Expand Up @@ -201,10 +201,8 @@ <h1>{{ document.title }}</h1>
</ul>
</div>
{% endif %}

</div>
{% endif %}

<!-- start the main content container -->
<div id="wiki-column-container" class="{% if show_right %}wiki-right-present{% else %}wiki-right-closed wiki-right-none{% endif %} {% if show_left %}wiki-left-present{% else %}wiki-left-closed wiki-left-none{% endif %}">

Expand Down Expand Up @@ -407,9 +405,13 @@ <h2 class="offscreen">{{ _('Document Tags and Contributors') }}</h2>
<menuitem data-action="{{ url('wiki.edit_document', document.full_path, locale=document.locale) }}" label="{{_('Edit page')}}"></menuitem>
<menuitem data-action="{{ url('wiki.document_revisions', document.full_path) }}" label="{{_('View page history')}}"></menuitem>
</menu>

{% endblock %}

{% block js %}
{% if waffle.flag('scrollback_widget') %}
{{ js('scrollback', async=True) }}
{% endif %}
<script type="text/javascript">
if(window.jQuery) jQuery('.from-search-toc').mozSearchResults('{{ search_url|safe }}');

Expand Down
9 changes: 8 additions & 1 deletion kuma/wiki/templates/wiki/includes/document_tag.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,14 @@
<strong>{{_('Tags:')}}</strong>&nbsp;
<ul class="tags tags-small">
{% for tag in tags %}
<li><a href="{{ url('wiki.tag', tag) }}">{{ tag }}</a></li>
<li><a href="{{ url('wiki.tag', tag) }}">{{ tag }}</a>
{% if waffle.flag('scrollback_widget') %}
{% set lower_name = tag.name.lower() %}
{% if settings.SCROLLBACK_ROOM_MAP[lower_name] %}
<button class="scrollback-button only-icon transparent" data-username="{{ request.user.username }}" data-room="{{ settings.SCROLLBACK_ROOM_MAP[lower_name] }}"><i class="icon-users" aria-hidden="true"></i><span>{{ _('Chat about {tag}')|f(tag=tag.name) }}</span></button>
{% endif %}
{% endif %}
</li>
{% endfor %}
</ul>
</div>
Expand Down
36 changes: 36 additions & 0 deletions media/js/libs/scrollback.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/* global document, window, setTimeout*/
/* exported addScrollback */

(function(win, doc, jQuery) {

// Open Scrollback upon button click
$('.scrollback-button').on('click', function() {
var $this = $(this);

addScrollback($this.attr('data-room'), $this.attr('data-username'));
});

// Functionality for opening the Scrollback widget
function addScrollback(roomName, suggestedNick) {

var host = 'https://scrollback.io/';

if(!win.scrollback) {
win.scrollback = {
room: roomName,
form: 'toast',
titlebarColor: '#00539f',
minimize: false,
nick: suggestedNick || 'guest'
};

$.getScript(host + 'client.min.js');
}
else {
$('.scrollback-stream').attr('src', function() {
return $(this).attr('src').replace(host, '') + roomName;
});
}
}

})(window, document, jQuery);
10 changes: 10 additions & 0 deletions settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -770,9 +770,19 @@ def JINJA_CONFIG():
'fontfaceobserver': (
'js/libs/fontfaceobserver/fontfaceobserver-standalone.js',
),
'scrollback': (
'js/libs/scrollback.js',
)
},
}

# Map wiki article tags to scrollback.io rooms
SCROLLBACK_ROOM_MAP = {
'mdn': 'mdn',
'css': 'mdn',
'javascript': 'mdn',
}

#
# Session cookies
SESSION_COOKIE_SECURE = True
Expand Down

0 comments on commit 6397014

Please sign in to comment.