Skip to content

Instantly share code, notes, and snippets.

@NateFerrero
Last active December 15, 2015 14:58
Show Gist options
  • Save NateFerrero/5278145 to your computer and use it in GitHub Desktop.
Save NateFerrero/5278145 to your computer and use it in GitHub Desktop.
A 10-line SimplifiedPHP File storage blog engine. No line over 80 characters.
t: 'textarea', dir: 'data/', ext: '.txt', f: Request.form, ? Request.method = {
"POST": File(dir (f.slug) ext).write(f.text), Router.redirect('?')}
'<h1>My SimplifiedPHP Blog</h1><form action="?"><h5>New Post:</h5>Post slug:
<input name="slug" /><br/><'t' name="text" cols=60 rows=20></'t'><br/>
<input type="submit" /></form><hr/>'.print, slug: Request.args.slug, ? slug = {
Void: Directory(dir).each{'<a href="?slug=' Path(it).name '">' \
File(it).string.lines[0] '</a><br/>'.print}
*: {'<a href="?">&lauqo; All Posts</a>'.print
File(dir post ext).string.lines.each ? key = {0: '<h2>' it '</h2>'.print
*: '<p>' it '</p>'.print}}}
/**
* Configuration
*/
dir: 'data/'
ext: '.txt'
? Request.method = {
"POST": {
File(dir (Request.form.slug) ext).write(Request.form.text)
Router.redirect('?')
}
}
"""<h1>My SimplifiedPHP Blog</h1>
<form action="?">
<h5>New Post:</h5>
Post slug: <input name="slug" /><br/>
<textarea name="text" cols=60 rows=20></textarea><br/>
<input type="submit" />
</form>
<hr/>""".print
? Request.args.slug = {
Void: {
Directory(dir).each{
'<a href="?slug=' Path(it).name '">' File(it).string.lines[0] '</a><br/>'.print
}
}
*: {
'<a href="?">&lauqo; All Posts</a>'.print
File(dir post ext).string.lines.each ? key = {
0: '<h2>' it '</h2>'.print
*: '<p>' it '</p>'.print
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment