Skip to content
This repository has been archived by the owner on May 16, 2020. It is now read-only.

Added scrollback support. Issue #249 #250

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions hacknight/forms/event.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# -*- coding: utf-8 -*-

import re
from flask import Markup
import wtforms
import wtforms.fields.html5
Expand Down Expand Up @@ -51,12 +52,26 @@ class EventForm(Form):
ticket_price = wtforms.TextField("Ticket price", description="Entry fee, if any, to be paid at the venue", validators=[wtforms.validators.length(max=250)])
maximum_participants = wtforms.IntegerField("Venue capacity", description="The number of people this venue can accommodate.", default=50, validators=[wtforms.validators.Required()])
website = wtforms.fields.html5.URLField("Website", description="Related Website (Optional)", validators=[wtforms.validators.Optional(), wtforms.validators.length(max=250), wtforms.validators.URL()])
irc_channel_url = wtforms.fields.html5.URLField("IRC Channel URL", description="IRC Channel for participants collaboration (Optional). E.G: irc://irc.freenode.net/#hasgeek", validators=[wtforms.validators.Optional(), wtforms.validators.length(max=250)])
status = wtforms.SelectField("Event status", description="Current status of this hacknight", coerce=int, choices=STATUS_CHOICES)

def validate_end_datetime(self, field):
if field.data < self.start_datetime.data:
raise wtforms.ValidationError(u"Your event can’t end before it starts.")

def validate_irc_channel_url(self, field):
pattern = "irc://irc\.([a-zA-Z0-9_-]{4,20})\.([a-zA-Z]{2,7})/([#a-zA-Z-_0-9]{2,20})"
"""
Above pattern will match following
irc://irc.freenode.net/#hasgeek
irc://irc.freenode.net/##hasgeek
irc://irc.freenode.net/##linux-india
irc://irc.free.net/##linux-india
irc://irc.fre23.net/##linux-india
"""
if not re.match(pattern, field.data):
raise wtforms.ValidationError(u"Invalid IRC Channel URL. E.G: irc://irc.freenode.net/#hasgeek")


class EmailEventParticipantsForm(Form):
pending_message = RichTextField("Pending Message", description="Message to be sent for pending participants. '*|FULLNAME|*' will be replaced with user's fullname.", validators=[wtforms.validators.Optional()], tinymce_options = {'convert_urls': False, 'remove_script_host': False})
Expand Down
1 change: 1 addition & 0 deletions hacknight/models/event.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ class Event(BaseScopedNameMixin, db.Model):
rejected_message_text = deferred(db.Column(db.UnicodeText, nullable=False, default=u''))
pending_message = deferred(db.Column(db.UnicodeText, nullable=False, default=u''))
pending_message_text = deferred(db.Column(db.UnicodeText, nullable=False, default=u''))
irc_channel_url = db.Column(db.Unicode(250), nullable=True)

__table_args__ = (db.UniqueConstraint('name', 'profile_id'),)

Expand Down
41 changes: 40 additions & 1 deletion hacknight/templates/event.html
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,11 @@ <h4 class="nav-header">Share</h4>
</li>
</ul>
</div>
{%- if event.irc_channel_url -%}
<div>
<a href="{{event.irc_channel_url}}" class="irc">Collaborate in IRC Channel</a>
</div>
{%- endif -%}
{% if event.sponsors %}
<hr class="clear-line">
<div class="sidebar-heading nav nav-list">
Expand Down Expand Up @@ -235,7 +240,41 @@ <h2>New project...</h2>
function onZoomend(){
map.setView(venue, map.getZoom());
};
{% endif %}
{% endif %}
//Scrollback
$(".irc").on('click', function(e){

var channel = "{{ event.irc_channel_url }}";
console.log(channel);
if (channel !== ""){

channel_name = channel.split("#");
name = channel_name[channel_name.length - 1];
console.log(name);
if (name){
if(window.scrollback) return true;

if ("{{ g.user }}"){
window.scrollback = {
streams:[name], theme: 'light', ticker: true, minimized: false, nickname: "{{g.user.username}}"
};
} else {
window.scrollback = {
streams:[channel_name], theme: 'light', ticker: true, minimized: false
};
}
/***** don't edit below *****/
console.log(window.scrollback);
(function(d, s, h, e){e=d.createElement(s);e.async=1;
e.src=h+'/client.min.js';scrollback.host=h;
d.getElementsByTagName(s)[0].parentNode.appendChild(e);}
(document,'script',location.protocol+'//scrollback.io'));

e.preventDefault();
return false;
}
}
});
});
</script>

Expand Down