Skip to content

Instantly share code, notes, and snippets.

@onionhammer
Created December 6, 2013 01:29
Show Gist options
  • Save onionhammer/7817182 to your computer and use it in GitHub Desktop.
Save onionhammer/7817182 to your computer and use it in GitHub Desktop.
#! strip | stdtmpl
#from irc import TIRCMType
#from times import getTime
#import utilities, models
#
#proc logview(channel: TIRCChannel): string =
#result = ""
#
<ul class=logview>
#for message in channel.log:
#let time = message.time.formatJSON()
#let tooltip = message.time.formatDateString()
#var text = message.text
#let isAction = detectAction(message.sender, text)
#
#case message.msgType
#of MPrivMsg:
#var class = if isAction: "action" else: ""
<li class=$class data-timestamp="$time" title="$tooltip" data-type=$message.msgType>
#if not isAction:
<a class=user>$message.sender</a>
#end if
<div class=message>$text.htmlencode.detectLinks</div>
</li>
#of MTopic:
<li class=topic data-timestamp="$time" title="$tooltip" data-type=$message.msgType>
<div class=message>$message.sender.htmlencode changed the topic to: $text.htmlencode.detectLinks</div>
</li>
#of MJoin:
<li class=join data-timestamp="$time" title="$tooltip" data-type=$message.msgType>
<div class=message>$message.sender.htmlencode has joined</div>
</li>
#of MQuit:
<li class=part data-timestamp="$time" title="$tooltip" data-type=$message.msgType>
<div class=message>$message.sender.htmlencode has quit</div>
</li>
#of MPart:
<li class=part data-timestamp="$time" title="$tooltip" data-type=$message.msgType>
<div class=message>$message.sender.htmlencode has left</div>
</li>
#of MNumeric:
#if message.numeric == "372":
<li class=motd data-timestamp="$time" title="$tooltip" data-type=$message.msgType data-numeric=$message.numeric>
<div class=message>$text.htmlencode.detectLinks</div>
</li>
#end if
#else: nil
#end case
#end for
#let now = times.getTime()
#let nowTimestamp = now.formatJSON()
#let nowTooltip = now.formatDateString()
<li class=endlog data-timestamp="$nowTimestamp" title="$nowTooltip">
</ul>
#
#end proc
#
#
#proc users(channel: TIRCChannel): string =
#result = ""
#
<ul class=userlist>
#for user in channel.users:
#if user[0] in mod_types:
#var uname = user.substr(1)
<li><a class="user mod">$uname.htmlencode</a>
#else:
<li><a class=user>$user.htmlencode</a>
#end if
#end for
</ul>
#
#end proc
#
#
#proc view*(servers: openarray[TIRCServer], active: TIRCChannel, channelsOnly = false): string =
#result = ""
#
#for server in servers:
#for channel in server.channels:
#var activeCss = if active == channel: " active" else: ""
<div class="channel-display$activeCss"
data-channel="$channel.name"
data-server="$server.address">
#result.add(logview(channel))
#result.add(users(channel))
</div>
#end for
#end for
#
#if not channelsOnly:
#if active != nil:
#var disabled = if active.users.len == 0: "disabled" else: ""
<input id=chatbox maxlength=3500 $disabled>
#else:
<div class=pad>Welcome to IRCFamiliar</div>
<p>
If you are seeing this message, you likely have not configured
your settings.cfg file. Please follow the guide online!
<p>
#end if
#end if
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment