Writing Ruby Pages
CoreServer has explicit support for Ruby scripts as pages. They are a little different than the ERB-parsed RHTML pages.
CORESERVER SCRIPTING BASICS
First, every Ruby script will be passed into memory using the "load" statement. This is like "require" but executes the script every time ti's loaded. That way, there's no threat of scripts messing with each other's variables or functions.
Second, every script needs to have at least one function: the "execute" function. Its only parameter is a hash that CoreServer will pass to it. Let's talk about that hash. It has at least two variables in it, and up to three. The two required variables:
* :session => the session your script should .print and .puts to
* :get => hash of GET variables passed to your script (at least includes "url" => filename)
It might have one more:
* :post => hash of POST variables, if there are any
So, here's what a basic script should at least include:
## DEMO.RB
def execute(data)
get = data[:get] # Ease-of-use
session = data[:session] # Same as above
post = data[:post] if (data[:post)
end
Thus, your code now can access GET variables through get["key"], POSTDATA through post["key"] (if it exists!), and the session through a variable of the same name.
Blueprint information
- Status:
- Not started
- Approver:
- None
- Priority:
- Undefined
- Drafter:
- None
- Direction:
- Approved
- Assignee:
- None
- Definition:
- Approved
- Series goal:
- None
- Implementation:
- Unknown
- Milestone target:
- None
- Started by
- Completed by