! Copyright (C) 2025 Serre
! See https://factorcode.org/license.txt for BSD license.
USING: arrays assocs csv hashtables http.server.responses
io.encodings.utf8 io.files io.streams.string json kernel mirrors
namespaces sequences sets shuffle xml.writer ;
IN: erinnemori-2.utils
! Various utility words used around Erinnemori
: zip-pile ( paths values -- entries )
'[ utf8 file-contents [ read-row ] with-string-reader
_ swap zip ] map ;
: pfilter ( pile key value -- entries )
'[ _ of _ = ] filter ;
: pfilter* ( pile key value -- entry/f )
pfilter ?first ;
: pAt* ( value key pile -- entry/f )
spin pfilter* ;
: alphanumeric? ( string -- ? )
"1234567890qwertyuiopasdfghjklzxcvbnm"
"QWERTYUIOPASDFGHJKLZXCVBNM-_.~" append
without empty? ;
: xml>response ( xml -- response )
! { "textarea" "pre" "h1" } sensitive-tags
! [ pprint-xml>string ]
! with-variable
xml>string
<html-content> ;
: change-of* ( assoc key quot -- assoc )
dupdd swapd change-at ; inline