Skip to content

Instantly share code, notes, and snippets.

@rgchris
Last active December 31, 2015 15:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rgchris/8010425 to your computer and use it in GitHub Desktop.
Save rgchris/8010425 to your computer and use it in GitHub Desktop.
Rebol [
Title: "Add a Site"
Type: 'controller
File: %app/controllers/addsite.r
]
route () to submit [ ; where submit is %app/views/addsite/submit.html.rsp
get [] ; shows the form
put [
if verify [
submission: get-params/body 'site [
reject 400 "No New Site data"
]
submission: validate submission [
name: string! length is less-than 50
info: opt string! length is less-than 240
site: url!
][] ; doing nothing will show the form again
attempt [load/header submission/site][
reject 400 "Could not reach your site"
]
][
sites-list: read index: wrt://site/rebsite.r ; uses the internal wrt:// filesystem scheme
write index append sites-list join newline remold [
'folder submission/name submission/site 'icon 'site 'info submission/info
]
redirect-to %/show?http://desktop.rebol.info/rebsites.r
]
]
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment