GitXplorerGitXplorer
m

astley

public
13 stars
0 forks
0 issues

Commits

List of commits on branch master.
Unverified
bce2acf08932ac96d55ff0c4c0232ff41a622b19

Updated docs for new rack adapter and fixed formatting.

committed 15 years ago
Unverified
52791aac6e815f12da1961da98fc5a8325db0f74

Made a new Rack::Astley based on Rack::Legacy::Cgi.

committed 15 years ago
Unverified
61823d4dd938f2f0998e7407a732e060db915c43

Refactored hash iteration to be a little cleaner and not require an integer for loop. In theory I could probably extend this to also allow short-circuiting the loop rather than running down the whole list like it does currently.

committed 15 years ago
Unverified
2bdeefe15e206ff22f1058bc1d88d48829bef29a

Fixed indentation on astley rackup file.

committed 15 years ago
Unverified
34b3234c1efbe2a62a70b1d222398bc50b77f696

Introduced an init method which allowed auto-routing to go back in. If init returns 0 or does not exist astley will autoroute, any non-zero will suppress routing. This even makes routing suppression on unit testing cleaner cause we don't hinge on the CGI implementation.

committed 15 years ago
Unverified
b50a19199f23034cfaec9b91dcabf400769acab6

Updated demo to include a regular expression route. This required removing auto-routing, but I think have a way around it.

committed 15 years ago

README

The README file for this repository.

Astley

A web framework written in Bash. It's kinda like Sinatra, but only really enjoyable as a joke.

This project started with a vision and was spurred on by the support of good friends. Now it's reached the point where you might actually be able to do something with it. But probably not.

Really?

Seriously. Well maybe serious is the wrong word. Check it out for yourself. You can skip the apache config if you want and try it out using rack. Just do this:

gem install rack-legacy      # or sudo if you want
cd examples
rackup
open http://localhost:9292   # or however you open websites

Usage

Setup

So far this is all wired up through CGI. So you'll need something like this in your apache configuration:

<VirtualHost *:80>
  ServerName astley.local
  DocumentRoot "/path/to/astley/examples"
</VirtualHost>

And you'll probably want some of the magic included in examples/.htaccess to make URLs a little nicer.

Writing controller methods

Astley currently just tries to map REQUEST_METHOD and PATH_INFO to a command. This is usually a function, but a regular executable should work too. Of course, since the path maps directly to a command, you'll be limited to urls that are legal identifiers. Thankfully Bash supports most of the usual URL characters as identifiers.

So a GET request for "/" will map to the function get/. Or a POST to "/give/you/up" will try to call post/give/you/up.

Additionally you can prefix the function name with before_ or after_ (e.g., before_get/). I intended the before_ to be used to control how headers are sent out like status and content type. Not sure what after_ would do but it's there for sake of consistency.

See examples/index.cgi for some examples.

Rendering templates

You can also render templates using the "render" function. This takes a file path to a template as an argument like render "views/form.html". Templates are resolved as if they were inside double quoted strings, cause they are. So be careful to escape any usages of , backticks, $ and probably other characters, or you may end up with an error. And if you want to include any variables just use ${MYVAR} or you can use backticks to call functions. See examples examples/views/response.html

Security

If you're using Astley outside a friendly network your server has already been hacked. I haven't done any serious auditing yet, but I'm pretty sure this is dangerous since URLs will get arbitrarily mapped to executables if they exist. Scary? Good.

License

Astley is licensed under the MIT License. See LICENSE.txt for details.