function displayMessage(data, self_sent) {
var new_entry = document.createElement("div");
- var new_text = document.createTextNode(data);
var stream_metabox = document.getElementById("stream-metabox");
var should_scroll = false;
if(stream_metabox.scrollTop === (stream_metabox.scrollHeight
} else {
new_entry.setAttribute("class", "stream-entry");
}
- new_entry.appendChild(new_text);
+ new_entry.innerHTML = data;
document.getElementById("stream").appendChild(new_entry);
if (should_scroll) {
stream_metabox.scrollTop = stream_metabox.scrollHeight;
#:use-module (ice-9 receive)
#:use-module (oop goops)
+ ;; Formatting
+ #:use-module (sxml simple)
+
;; used by web server only
#:use-module (sxml simple)
#:use-module (web request)
(define* (nm-send-to-client-id nm message #:key client data)
"Send DATA to TO-CLIENT id"
+ (define formatted-data
+ (call-with-output-string
+ (lambda (p)
+ (sxml->xml data p))))
(define client-obj (hash-ref (nm-clients nm) client))
(match client-obj
(#f (throw 'no-such-client
"Asked to send data to client but that client doesn't exist"
#:client-id client
- #:data data))
+ #:data formatted-data))
(('socket . client-socket)
- (display data client-socket))
+ (display formatted-data client-socket))
(('websocket . ws-client-id)
- (<- (.web-server nm) 'ws-send ws-client-id data))))
+ (<- (.web-server nm) 'ws-send ws-client-id formatted-data))))
(define (nm-incoming-line-action nm message client-id line)
"Handle LINE coming in, probably from an external message handler,
(empty-command "go" 'cmd-go-where)
(loose-direct-command "go" 'cmd-go)
(greedy-command "say" 'cmd-say)
- (greedy-command "emote" 'cmd-emote)))
+ (greedy-command "\"" 'cmd-say)
+ (greedy-command "'" 'cmd-say)
+ (greedy-command "emote" 'cmd-emote)
+ (greedy-command "/me" 'cmd-emote)))
;; TODO: Subclass from container?
(define-class <room> (<gameobj>)
"Handle looking around the room"
;; Get the room text
(define room-text
- (format #f "**~a**\n~a\n"
- (slot-ref room 'name)
- (slot-ref room 'desc)))
+ `((strong "=> " ,(slot-ref room 'name) " <=")
+ (p ,(slot-ref room 'desc))))
;; Get a list of other things the player would see in the room
(define occupant-names-all
(define final-text
(if occupant-names-string
- (string-append room-text occupant-names-string)
+ `(,@room-text
+ (p (i ,occupant-names-string)))
room-text))
(<- player-id 'tell
(define player-name
(mbody-val (<-wait (message-from message) 'get-name)))
(define message-to-send
- (format #f "~a says: ~a\n" player-name phrase))
+ `((b "<" ,player-name ">") " " ,phrase))
(room-tell-room room message-to-send))
(define* (room-cmd-emote room message #:key phrase)
(define player-name
(mbody-val (<-wait (message-from message) 'get-name)))
(define message-to-send
- (format #f "* ~a ~a\n" player-name phrase))
+ `((b "* " ,player-name) " " ,phrase))
(room-tell-room room message-to-send))
(define* (room-announce-entrance room message #:key who-entered)