Merge pull request #54 from bigbluebutton/fix-chat-url

Fix for event urls and support for https
This commit is contained in:
Markos Calderon 2012-08-02 13:16:00 -07:00
commit 9b4a1b4815
4 changed files with 26 additions and 6 deletions

View File

@ -214,7 +214,9 @@
private function parseURLs(message:String):String{
var indexOfHTTP:Number = message.indexOf("http://");
var indexOfWWW:Number = message.indexOf("www.");
if (indexOfHTTP == -1 && indexOfWWW == -1) return message;
var indexOfHTTPS:Number = message.indexOf("https://");
if (indexOfHTTP == -1 && indexOfWWW == -1 && indexOfHTTPS == -1) return message;
var words:Array = message.split(" ");
var parsedString:String = "";
@ -223,6 +225,7 @@
var word:String = words[n] as String;
if (word.indexOf("http://") != -1) parsedString += '<a href="event:' + word + '"> <u>' + word + '</u></a> ';
else if (word.indexOf("www.") != -1) parsedString += '<a href="event:http://' + word + '"> <u>' + word + '</u></a> ';
else if (word.indexOf("https://") != -1) parsedString += '<a href="event:' + word + '"> <u>' + word + '</u></a> ';
else parsedString += word + ' ';
}
return parsedString;
@ -230,7 +233,8 @@
private function sendPublicChatMessage(message:String):void {
var publicEvent:SendPublicChatMessageEvent = new SendPublicChatMessageEvent(SendPublicChatMessageEvent.SEND_PUBLIC_CHAT_MESSAGE_EVENT);
publicEvent.message = parseURLs(cleanup(message));
//publicEvent.message = parseURLs(cleanup(message));
publicEvent.message = cleanup(message);
publicEvent.color = chatWindow.cmpColorPicker.selectedColor.toString();
publicEvent.time = currentTime();
publicEvent.language = ResourceUtil.getInstance().getCurrentLanguageCode().split("_")[0];
@ -244,7 +248,8 @@
private function sendPrivateChatMessage():void {
var privateEvent:SendPrivateChatMessageEvent = new SendPrivateChatMessageEvent(SendPrivateChatMessageEvent.SEND_PRIVATE_CHAT_MESSAGE_EVENT);
privateEvent.message = parseURLs(cleanup(chatWindow.txtMsg.text));
//privateEvent.message = parseURLs(cleanup(chatWindow.txtMsg.text));
privateEvent.message = cleanup(chatWindow.txtMsg.text);
privateEvent.toUser = chatTabs.selectedChild.name;
privateEvent.color = chatWindow.cmpColorPicker.selectedColor.toString();
privateEvent.time = currentTime();
@ -364,6 +369,9 @@
private function handlePublicChatMessageEvent(event:PublicChatMessageEvent):void {
LogUtil.debug("Got PublicChatMessageEvent from userid [ " + event.chatobj.userid + " ]");
if(event.chatobj.userid != "")
event.chatobj.message = parseURLs(event.chatobj.message);
showMessage(PUBLIC_CHAT_USERID, event.chatobj, autoTranslation);
if ((!this.focus) &&
(! UserManager.getInstance().getConference().amIThisUser(new Number(event.chatobj.userid))) &&
@ -378,6 +386,8 @@
if ((!this.focus) && (! UserManager.getInstance().getConference().amIThisUser(new Number(event.message.sender)))) {
ExternalInterface.call("startblink", ResourceUtil.getInstance().getString('bbb.chat.privateMsgAwaiting'), ResourceUtil.getInstance().getString('bbb.chat.privateMsgAwaiting2'));
}
if(event.message.chatobj.userid != "")
event.message.chatobj.message = parseURLs(event.message.chatobj.message);
showMessage(event.message.sender, event.message.chatobj, autoTranslation);
}

View File

@ -131,6 +131,16 @@ module BigBlueButton
stop_events << s
end
stop_events.sort {|a, b| a[:stop_timestamp] <=> b[:stop_timestamp]}
end
end
def self.linkify( text )
generic_URL_regexp = Regexp.new( '(^|[\n ])([\w]+?://[\w]+[^ \"\n\r\t<]*)', Regexp::MULTILINE | Regexp::IGNORECASE )
starts_with_www_regexp = Regexp.new( '(^|[\n ])((www)\.[^ \"\t\n\r<]*)', Regexp::MULTILINE | Regexp::IGNORECASE )
s = text.to_s
s.gsub!( generic_URL_regexp, '\1<a href="\2">\2</a>' )
s.gsub!( starts_with_www_regexp, '\1<a href="http://\2">\2</a>' )
s
end
end
end

View File

@ -490,7 +490,7 @@ def processChatMessages
$chat_events.each do |node|
chat_timestamp = node[:timestamp]
chat_sender = node.xpath(".//sender")[0].text()
chat_message = node.xpath(".//message")[0].text()
chat_message = BigBlueButton::Events.linkify(node.xpath(".//message")[0].text())
chat_start = (chat_timestamp.to_i - $meeting_start.to_i) / 1000
$xml.timeline(:in => chat_start, :direction => :down, :innerHTML => "<span><strong>#{chat_sender}:</strong> #{chat_message}</span>", :target => :chat )
end

View File

@ -117,7 +117,7 @@ if (playback == "slides")
chat_events.each do |node|
chat_timestamp = node['timestamp']
chat_sender = node.xpath(".//sender")[0].text()
chat_message = node.xpath(".//message")[0].text()
chat_message = BigBlueButton::Events.linkify(node.xpath(".//message")[0].text())
chat_start = (chat_timestamp.to_i - meeting_start.to_i) / 1000
xml.timeline(:in => chat_start, :direction => "down", :innerHTML => "<span><strong>#{chat_sender}:</strong> #{chat_message}</span>", :target => "chat" )
end