mirror of https://github.com/reiseburo/offtopic
Allow the for grepping message bodies from the web frontend
Fixes #6 Fixes #8
This commit is contained in:
parent
493deb7ddf
commit
d998f4f8ca
|
@ -1,10 +1,18 @@
|
|||
{{> header}}
|
||||
|
||||
<div class="container">
|
||||
<div class="progress" style="width: 100px;">
|
||||
<div class="progress-bar progress-bar-striped" role="progressbar" aria-valuenow="100" aria-valuemin="0" aria-valuemax="100" style="width: 100%">
|
||||
<span class="sr-only">Loading..</span>
|
||||
</div>
|
||||
<div class="container">
|
||||
<div class="progress" style="width: 100px;">
|
||||
<div class="progress-bar progress-bar-striped" role="progressbar" aria-valuenow="100" aria-valuemin="0" aria-valuemax="100" style="width: 100%">
|
||||
<span class="sr-only">Loading..</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<form id="grep" role="form">
|
||||
<input id="grepfield" class="form-control" type="search" placeholder="grep for.." size="20"/>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="messages">
|
||||
|
@ -15,5 +23,13 @@
|
|||
<script src="/js/ws.js?1"></script>
|
||||
<script type="text/javascript">
|
||||
watchTopic("{{name}}");
|
||||
|
||||
$('#grep').submit(function(e) {
|
||||
if (window.ws) {
|
||||
window.ws.send($('#grepfield').val());
|
||||
}
|
||||
$('#grepfield').blur();
|
||||
e.preventDefault();
|
||||
});
|
||||
</script>
|
||||
{{> footer}}
|
||||
|
|
|
@ -44,16 +44,16 @@ ratpack {
|
|||
}
|
||||
|
||||
get('topics/:name/websocket') { ctx ->
|
||||
println "creating thingies"
|
||||
def client = new OfftopicClient(Configuration.instance)
|
||||
println "client: ${client}"
|
||||
def grepper = null
|
||||
|
||||
websocket(ctx) { ws ->
|
||||
println "Connected ${ws}"
|
||||
client.onMessageCallback = { m ->
|
||||
println "called back with ${m}"
|
||||
ws.send(groovy.json.JsonOutput.toJson(m))
|
||||
println "sent message"
|
||||
println "called back with ${m} (grep: ${grepper})"
|
||||
if ((grepper == null) || (m.raw =~ grepper)) {
|
||||
ws.send(groovy.json.JsonOutput.toJson(m))
|
||||
}
|
||||
}
|
||||
client.createSubscribersFor(pathTokens.name)
|
||||
print "subscribers created for ${pathTokens.name}"
|
||||
|
@ -63,7 +63,7 @@ ratpack {
|
|||
client.shutdown()
|
||||
}
|
||||
sock.onMessage { msg ->
|
||||
println "client sent ${msg}"
|
||||
grepper = msg.text
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue