• This repository has been archived on 07/Nov/2018
  • Stars
    star
    138
  • Rank 264,508 (Top 6 %)
  • Language
    Erlang
  • License
    MIT License
  • Created almost 16 years ago
  • Updated about 14 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

BeepBeep is a simple web application framework for Mochiweb inspired by Rails and Merb

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

More Repositories

1

erlang_websocket

WebSocket Server and Client implementation in Erlang/Mochiweb
Erlang
84
star
2

py-abci

Build Tendermint blockchain applications in Python
Python
66
star
3

rinterface

Pure Ruby client that can talk (make rpc calls) to an Erlang node
Ruby
45
star
4

bftdb

Tendermint + Sqlite3 = BFT Database Replication
Go
38
star
5

py-tendermint

A Python microframework for building blockchain applications with Tendermint
Python
22
star
6

quorum-genesis

Simple utility to help create a genesis file for the Quorum permissioned blockchain
JavaScript
20
star
7

revmup

A smart-contract api and client for revm
Rust
18
star
8

mochiweb_scalaris

This is a simple example of how to provide an HTTP api to Scalaris via Mochiweb
Erlang
12
star
9

urkel

Go Implementation of an Urkel Tree
Go
8
star
10

rapido

đź’Ą A Rust framework for building Tendermint applications đź’Ą
Rust
6
star
11

menta

An SDK to build permissioned blockchain applications with Tendermint
Go
6
star
12

revm-python

Python API for smart-contracts and revm
Python
4
star
13

urkel-rs

Rust Implementation of an Urkel Tree
Rust
4
star
14

ethauth-js

Simple authentication tokens with Ethereum addresses
JavaScript
4
star
15

opencbdc-mvp

A super simplified version of opencbdc for learning and experimentation
Python
3
star
16

comfycouch

Simple CouchDB client for Elixir
Elixir
3
star
17

urkel-trie

Rust Implementation of an Urkel Tree
Rust
3
star
18

maptiler

Fork of MapTiler from Google Code
Python
3
star
19

sgl

An Erlang implementation of the Simple Grant Language
Erlang
3
star
20

revm-provider

A provider and contract API for Revm
Rust
2
star
21

elixir_milliseconds

Simple library to work with milliseconds
Elixir
2
star
22

rails_course

Content and code used for a 2 day Ruby on Rails course
Ruby
2
star
23

jython_esx_lib

Jython API for VMWare ESX Server
Python
2
star
24

jellyfish_merkle

Stand alone version of the Sparse Merkle Tree from the Libra project
Rust
1
star
25

libgdx-examples

My experimental code
Java
1
star
26

merkletree_stream

A streaming Merkle Tree indexed by a Flat Tree
Erlang
1
star
27

adhoc_network_simulator

A Simple AdHoc Network Simulator
Java
1
star
28

sparse-merkle-tree

Sparse Merkle Tree with Proofs
Python
1
star
29

worldwind_custom

WorldWind Android (custom)
Java
1
star
30

cita-trie-db

RocksDb storage implementation for the cita-trie merkle trie
Rust
1
star
31

elixir_jsonwebtoken

Simple Elixir library for signing and verifying JSON Web Tokens
Elixir
1
star