A wiki in QM
REBOL [
Title: "Wiki Table"
Type: 'roughcut
]
record: make record [
title: does [get 'id]
populate: injects [
content: string! length is less-than 10'000
]
on-save: does [
set 'content sanitize get 'content
]
content: does [
any [
get 'content
rejoin ["!!!!!" title " does not exist!!!!!"]
]
]
rich-content: has [text] [
text: parse/all content "*"
rejoin map-each [txt lnk] text [
lnk: either lnk [
rejoin [{<a href="/wiki/show/} lnk {">} lnk </a>]
][""]
]
]
]
REBOL [
Title: "Quick Wiki Example"
Type: 'controller
Default: "show"
Template: %wiki.rsp
]
event "prepare" does [
select-new: [
page: select wiki 'new
page/set 'id id
]
]
action "show" [id: opt string! [some chars-f]] does [
id: any [id "Start"]
unless page: select wiki id :select-new
]
action "edit" [id: string! [some chars-f]] does [
unless page: select wiki id :select-new
]
action "store" [id: string! [some chars-f]] does [
unless page: select wiki id :select-new
either page/populate get-param 'page [
page/store
redirect-to join %/wiki/show/ page/title
][
render %edit.rsp
]
]
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en">
<title><%= page/title %></title>
</head>
<body>
<h1>Wiki!</h1>
<h2><%= page/title %></h2>
<hr />
<%= yield %>
<hr />
<p><%: a wiki/edit/(id) %>Edit</a></p>
</body>
</html>
<pre><%= page/rich-content %></pre>
<%: form wiki/store/(id) %><fieldset>
<legend>Edit "<%= page/title %>"</legend>
<table><tr>
<th><label for="page.content">Content</label></th>
<td><%: area page/content (page/content) 100x10 %></td>
</tr><tr>
<td></td>
<td><%: submit store "Store" %></td>
</tr></table>
</fieldset></form>