Last active
December 31, 2015 15:59
-
-
Save rgchris/8010425 to your computer and use it in GitHub Desktop.
Example controller per https://github.com/revault/desktop.rebol.info/pull/1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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