Giter Club home page Giter Club logo

beepbeep's Introduction

BeepBeep a simple web application for Erlang

BeepBeep is a simple Web Application framework for Erlang inspired by Rails and Merb. It follows the principle of convention over configuration – meaning if you follow the code structure layout and a few rules when building your app, it’ll require no extra work on you behalf to map Url requests to your Controllers and Views.

BeepBeep is built on MochiWeb and ErlyDTL, providing a super fast web server and the abiity to define your templates with the Django template language.

It looks like one of the many Google Groups I created for the project is finally available:
Google Group

Features

  • A script to generate a new web application (based on mochiweb’s approach)
  • Session Server to store your application state
  • Before filter on your controllers for things like authentication
  • Django templates for the view

Getting Started

  1. download the code
  2. CD into the beepbeep directory
  3. run make
  4. generate a new web application by running ./script/new_beep.erl YouAppName "DestinationDirectory

This will create a web app with everything you need. It includes a Sample controller (main_controller.erl).

To run the sample:

  1. cd into the new application’s directory you created above
  2. Run make to compile the new project
  3. Start the server: ./start-server.sh
  4. Open a browser and visit "http://localhost:8000

How it works:

You write a controller with a set of methods that look like this:


handle_request(Action,Params)

Where Action is a string that will match to the request in the Url.

And Params is an Array of optional parameters that will be passed to variables in your controller.

BeepBeep will automatically map Url requests to controller and functions (or actions). For example a request to “/hello/show” would map to the “hello_controller” and invoke the “handle_request(”show",[])" function.

Here’s an example:

 
%% hello_controller.erl
-module(hello_controller).

-export([handle_request/2, before_filter/0]).

%% Maps to http://localhost:8000/hello/show
handle_request("show",[]) ->
    {render, "hello/show.html",[{name,"BeepBeep"}]};

%% Maps to http://localhost:8000/hello/feed/2007
handle_request("feed",[Year]) ->
    %% Now Year contains the value 2007
    {render,"hello/feed.html",[{year,Year}]}.
  

%% Callback filter hook
before_filter(Params) ->
    ok.

 

From “handle_request” we return a tuple that tells the framework what view to use. Views are located in the views directory. In our example we’ll use the view located in the subdirectory “hello” and the file “show.html”

Here’s an example of the “show.html” template:


<h2>Hello from {{ name }} </h2>

Which will result in:


<h2>Hello from BeepBeep</h2>

The “name” key set in the controller is passed to the template and expanded using the Django format via erlyDTL.

This approach provides a clean separation of the erlang logic in the controller and the html code in the template.

You can also implement the before_filter to check requests before the matching “handle_request” is called. Filters that pass should simply return the atom ok, otherwise they should return one of the request responses such as {render…} or {redirect…"

For more information, see the documention and example blog app included with the source code. And there’s a small tutorial on the Wiki

beepbeep's People

Contributors

davebryson avatar strobe avatar tswicegood avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

beepbeep's Issues

blog example views error

In views "home/new.html" and "home/index.html",path of "flash.html" should be "../flash.html".

This causees erlydtl_compiler to fail,and I can't find any information to deal with this error.

Beepbeeop should log these info to console or log files.

Error on new_beepbeep.erl

Hi, I tried to create a new project but I got error like below:

escript: exception error: undefined function regexp:gsub/3
in function beepbeep_skel:skelcopy/4 (beepbeep_skel.erl, line 68)
in call from beepbeep_skel:skelcopy/2 (beepbeep_skel.erl, line 20)

Please help

The `mklink' Command

Hi, I have a question about creating new beepbeep apps.
My system runs in Windows XP with MinGW/MSYS, and it works
when calling ``./script/new_beep.erl MyApp /Path/To/Destination/ ''
but doesn't work completely when it calls`mklink' command.

I know beepbepp need run in Windows Vista. However, if the problem
is caused only by mklink' command, how does it work when calling command likemklink'?
Can you document some tips about what symbolic links between beep apps and header files
should be made while calling ./script/new_beep.erl? Thank you.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.