Euphoria MVC is a model-view-controller application framework for Euphoria.
This project is still in the very early stages of development. Things can and will break or change until we reach a stable release. Documentation is not yet complete. Please see CONTRIBUTING for details on how to submit bug reports, feature requests, or if you'd like to contribute to the project directly.
These modules are fairly mature and operational.
These modules function as-is but still need some improvements.
These modules are not yet stablized and are subject to change.
These modules are based on third-party libraries or services.
This example will use the built-in development server to quickly start your project.
Save this as templates/layout.html
.
<!DOCTYPE html>
<html>
<head>
<title>{{ title }}</title>
</head>
<body>
{% block content %}
{# your content will end up here #}
{% end block %}
</body>
</html>
Save this as templates/index.html
.
{% extends "layout.html" %}
{% block content %}
{# this will replace the block with
same name in the layout template #}
<h1>{{ title }}</h1>
<p>{{ message }}</p>
{# these are just comments, btw #}
{% end block %}
Save this as index.esp
.
#!/usr/local/bin/eui
include mvc/app.e
include mvc/server.e
include mvc/template.e
include std/map.e
function index( object request )
object response = map:new()
map:put( response, "title", "My First App" )
map:put( response, "message", "Hello, world!" )
return render_template( "index.html", response )
end function
app:route( "/", "index" )
-- "/" is the URL path, "index" is the name of the route
-- route() will find the matching routine automatically
server:start()
-- the server runs on http://localhost:5000/ by default
> eui index.esp
Open your web browser to your application URL at http://localhost:5000/
This example assumes you are running Apache 2.4 on Linux and that you've already got a basic working web server.
cd ~/Downloads
wget "https://sourceforge.net/projects/rapideuphoria/files/Euphoria/4.1.0-beta2/euphoria-4.1.0-Linux-x64-57179171dbed.tar.gz/download" -O euphoria-4.1.0-Linux-x64-57179171dbed.tar.gz
sudo tar xzf euphoria-4.1.0-Linux-x64-57179171dbed.tar.gz -C /usr/local/
cd /usr/local/bin/
sudo find /usr/local/euphoria-4.1.0-Linux-x64/bin/ -type f -executable -exec ln -vs {} \;
sudo git clone https://github.com/OpenEuphoria/euphoria-mvc /opt/OpenEuphoria/euphoria-mvc
sudo chown -vR www-root:www-root /opt/OpenEuphoria/euphoria-mvc
cd /var/www/html
printf "[all]\n-i /opt/OpenEuphoria/euphoria-mvc/include\n" | sudo tee eu.cfg
Move your index.esp
and other project files to this directory.
Tell Apache you want it to execute Euphoria scripts and use index.esp as the index. This would generally go into a <Directory>
directive in the site's configuration file, or directly into the local .htaccess
file.
# Add CGI handler for index.esp
AddHandler cgi-script .esp
DirectoryIndex index.esp
Options +ExecCGI
# Send all non-existant paths to index.esp
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.esp/$1 [L,NS]
You can also add a block like this to keep snoopers out of certain files:
<Files ~ ".(cfg|err|edb)$">
Deny from all
</Files>
Although the ideal solution would be to store sensitive data outside of your web root.
Change the last line of your application from server:start()
to app:run()
.
Then open your web browser to your web server's IP address or host name.