• This repository has been archived on 25/Dec/2020
  • Stars
    star
    119
  • Rank 291,619 (Top 6 %)
  • Language
    Ruby
  • License
    MIT License
  • Created over 15 years ago
  • Updated almost 4 years ago

Reviews

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

Repository Details

A high-level, light-weight web framework for Ruby with many ideas from Seaside.

Wee Web Framework

Copyright and License

Copyright (c) 2004-2020 by Michael Neumann ([email protected]).

Released under the terms of the MIT license.

Introduction

Wee is a light-weight, very high-level and modern web-framework that makes Web engineering easy. It mainly inherits many ideas and features from Seaside, but was written from scratch without ever looking at the Seaside (or any other) sources. All code was developed from ideas and lots of discussions with Avi Bryant.

Features

Reusable components

Wee has real components, which are like widgets in a GUI. Once written, you can use them everywhere. They are completely independent and do not interfere with other components. Components encapsulate state, a view and actions. Of course you can use an external model or use templates for rendering.

Backtracking

See the What is backtracking? section below. In short, backtracking lets the browser's back and forward-button play well together with your application.

Clean and concise

Wee is well thought out, is written in and supports clean and concise code. Furthermore I think most parts are now very well documented.

Templating-independent

Wee does not depend on a special templating-engine. You can use a different templating engine for each component if you want.

Powerful programmatic HTML generation

Wee ships with an easy to use and very powerful programmatic HTML-generation library. For example you can create a select list easily with this piece of code:

# select an object from these items
items = [1, 2, 3, 4]

# the labels shown to the user
labels = items.map {|i| i.to_s}

# render it
r.select_list(items).labels(labels).callback {|choosen| p choosen}

# render a multi-select list, with objects 2 and 4 selected
r.select_list(items).multi.labels(labels).selected([2,4])

The callback is called with the selected objects from the items array. Items can be any object, even whole components:

labels = ["msg1", "msg2"]
items = labels.collect {|m| MessageBox.new(m)}
r.select_list(items).labels(labels).callback {|choosen| call choosen.first} 

Observations and Limitations

  • Components are thread-safe by nature as a fresh components-tree is created for each session and requests inside a session are serialized.

What is backtracking?

If you want, you can make the back-button of your browser work correctly together with your web-application. Imagine you have a simple counter application, which shows the current count and two links inc and dec with which you can increase or decrease the current count. Starting with an inital count of 0 you increase the counter up to 8, then click three times the back button of your browser (now displays 5). Finally you decrease by one and your counter shows what you'd have expected: 4. In contrast, traditional web applications would have shown 7, because the back button usually does not trigger a HTTP request and as such the server-side state still has a value of 8 for the counter when the request to decrease comes in.

The solution to this problem is to take snapshots of the components state after an action is performed and restoring the state before peforming actions. Each action generates a new state, which is indicated by a so-called page-id within the URL.

Decorations

Decorations are used to modify the look and behaviour of a component without modifying the components tree itself. A component can have more than one decoration. Decorations are implemented as a linked list (Wee::Decoration#next points to the next decoration), starting at Wee::Component#decoration, which either points to the next decoration in the chain, or to itself.

The request/response cycle

The request/response cycle in Wee is actually split into two separate phases.

Render Phase

The rendering phase is assumed to be side-effect free! So, you as a programmer should take care to meet this assumption. Rendering is performed by method Wee::Component#render!.

Action Phase (Invoking Callbacks)

Possible sources for callbacks are links (anchors) and all kinds of form-elements like submit buttons, input-fields etc. There are two different kinds of callbacks:

  • Input callbacks (input-fields)

  • Action callbacks (anchor, submit-button)

The distinction between input and action callbacks is important, as action callbacks might depend on values of input-fields being assigned to instance variables of the controlling component. Hence, Wee first invokes all input callbacks before any action callback is triggered. Callback processing is performed by method Wee::Component#process_callbacks.

The result of the action phase is an updated components state. As such, a snapshot is taken of the new state and stored under a new page-id. Then, a redirect requests is sent back to the client, including this new page-id. The client automatically follows this redirect and triggers a render phase of the new page.

More Repositories

1

rust-msgpack

[DEPRECATED] msgpack.org implementation for Rust language. Please use https://github.com/3Hren/msgpack-rust
Rust
122
star
2

rust-redis

A Rust client/server library for Redis
Rust
51
star
3

postgres-pr

A pure-Ruby (pr) library for accessing PostgreSQL databases
Ruby
43
star
4

rust-toml

[DEPRECATED] A TOML configuration file parser for Rust
Rust
36
star
5

MessagePack

An alternative msgpack.org implementation for Ruby and C++ / msgpack.org[Ruby/C++]
C
24
star
6

rust-smtp

SMTP implementation for Rust
Rust
22
star
7

rubyjs

Ruby to Javascript Compiler
Ruby
20
star
8

matplotlib-rs

Uses rust-cpython to provide a convenient interface to Python's matplotlib from Rust
Rust
18
star
9

rust-sophia

Rust bindings for the Sophia[http://sphia.org/] embedded database system.
Rust
14
star
10

lindenmayer-system

L-Systems in Rust
Rust
13
star
11

munkres-rs

Kuhn-Munkres (aka Hungarian) algorithm for solving the Assignment Problem in O(n^3), written in Rust.
Rust
9
star
12

rust-markdown

A fast Markdown implementation for Rust
Rust
8
star
13

graph-layout-rs

Graph-Layouting Algorithms for Rust.
Rust
8
star
14

hypernsga

Evolutionary Hyper-cube based neural net optimization using NSGA2
Rust
7
star
15

turtle-graphics-rs

Turtle Graphics for Rust
Rust
6
star
16

graph-neighbor-matching

A graph similarity score using neighbor matching (for Rust)
Rust
6
star
17

rust-cross-dragonfly

Cross-compiling Rust to DragonFlyBSD
Shell
5
star
18

evo-rs

Evolutionary Algorithm Library for Rust
Rust
5
star
19

gml-rs

GML (Graph Modelling Language) loader for Rust
Rust
4
star
20

space-colonization-rs

Space-Colonization Algorithm in Rust
Rust
4
star
21

non-dominated-sort-rs

A fast non-dominated sort algorithm for obtaining the pareto fronts. Written in Rust.
Rust
3
star
22

errno-dragonfly-rs

Exposes errno functionality to stable Rust on DragonFlyBSD
Rust
3
star
23

asexp-rs

Advanced S-expression-like format
Rust
3
star
24

izhikevich-neurons

Modelling of Izhikevich neurons in Rust
Rust
3
star
25

evolvable-substrate-rs

Implementation of the Evolvable Substrate (ES) algorithm of ES-HyperNEAT in Rust
JavaScript
3
star
26

wof

Web Object Framework
3
star
27

cplus2ruby

Gluing C++ and Ruby together in an OO manner
2
star
28

wee-pm

A web-based presentation maker written using Wee
2
star
29

dhttpd

A fast HTTP server for the D language
D
2
star
30

ricoh-gr-iii-tools

Software support for Ricoh GR-III camera
Ruby
2
star
31

acyclic-network-rs

Construction and representation of acyclic networks (in Rust)
Rust
2
star
32

yinspire

An efficient spiking neural net simulator
C++
2
star
33

neat-rs

NEAT (NeuroEvolution of Augmented Topologies) implemented in Rust
Rust
2
star
34

sorted-vec-rs

A sorted vector (Rust)
Rust
1
star
35

mnist-handwritten-digits-rs

Rust library for reading the MNIST database of handwritten digits http://yann.lecun.com/exdb/mnist/
Rust
1
star
36

meda

Meta Data Description Framework for Ruby
Ruby
1
star
37

graph-generators-rs

Graph generator algorithms for Rust.
Rust
1
star
38

ruby-ploticus

Interface to ploticus to draw diagrams
Ruby
1
star
39

nsga2-rs

Implementation of NSGA-2 (Non-dominated Sorting 2)
Rust
1
star
40

graph-similarity-cmd

A command-line utility to compare two graphs and calculate a similarity measure
Rust
1
star
41

graph-annealing

Genetically evolves graphs towards a given target graph.
Rust
1
star
42

cryl

A web crawler in Ruby and Erlang
Erlang
1
star
43

dragmail

DragonFlyBSD mail server
1
star
44

rustjs

Experiment with compiling a subset of the Rust language to Javascript
1
star
45

dragonfly-rust-bootstrap

[DEPRECATED] Boostrapping the Rust compiler on DragonFlyBSD. Use rust-bootstrap-dragonfly instead.
Shell
1
star
46

expression-rs

Represenation of expression terms and conditions
Rust
1
star
47

sixo

SIxO motor-bike trip computer (clone from www.sixo.de - CVS)
C
1
star
48

evospinn

Biologically-inspired evolutionary Spiking Neural Net Simulator and Optimizer
Rust
1
star
49

closed01-rs

Closed01 provides checked floating point operations within the range [0,1]
Rust
1
star
50

expression-num-rs

Numerical expression implementation based on expression-rs
Rust
1
star
51

RecordModel

C++
1
star
52

dragonfly-live-gui

Scripts to build a DragonFly Live GUI image
Shell
1
star
53

dominance-ord-rs

Domination relation trait
Rust
1
star