Giter VIP home page Giter VIP logo

orbit's Introduction

Orbit 2.2.3
http://keplerproject.github.com/orbit

Orbit is an MVC web framework for Lua. The design is inspired by lightweight
Ruby frameworks such as Camping. It completely abandons the CGILua model
of "scripts" in favor of applications, where each Orbit application can fit
in a single file, but you can split it into multiple files if you want.
All Orbit applications follow the WSAPI protocol, so they currently work with
Xavante, CGI and Fastcgi. It includes a launcher that makes it easy to launch
a Xavante instance for development.

History
* Version 2.2.3 (16/Jul/2015)
  Fixed model:save() when using Postgres. The 'id' was being set to "NULL" and that violates the primary key constraint.
  NOT 5.2 compliant

* Version 2.2.2 (10/Sep/2014)
  Added the ability to specify the offset in a model. This is useful for implimenting pagination.
  NOT 5.2 compliant

* Version 2.2.1 (12/Jan/2014)
  bugfix release for Lua 5.1
  NOT 5.2 compliant
  documentation corrections
  support for Wsapi 1.6 and other dependency modules that no longer use "module"
  additional orbit model datatypes: real, float, timestamp, numeric
  MIME type application/json included

* Version 2.2.0 (31/Mar/2010)
  Reparse response to resume the dispatcher
  better parser for orbit.model conditions, fixes parsing bugs
  orbit launcher has parameters to control logging and port
  op.cgi/op.fcgi launchers have the same parameters as wsapi.cgi/wsapi.fcgi
  Optional Sinatra-like (http://www.sinatrarb.com/) route parser, using LPEG
  Pluggable route parsers (route patterns can be strings or objects that answer to :match)

* Version 2.1.0 (29/Oct/2009)
  better decoupling of orbit and orbit.model
  support for anything with a match method as patterns
  new options for orbit.model finders: distinct, fields
  count option for orbit.model now limits number of rows in the SQL
  logging of queries in orbit.model
  overhaul of the "orbit" script: better options, --help, sets application path
  content_type method in the web object to set content type
  support for PUT and DELETE (methods `dispatch_put` and `dispatch_delete`)
  orbit.model.recycle(*conn_builder*, *timeout*) function, to make a connection that automatically reopens after a certain time
  more samples in the samples folder
  added a "higher-order" $if to Orbit Pages

* Version 2.0.2 (10/Mar/2009)
  url-decodes path captures (suggested by Ignacio Burgueno on a Jul 24 email to the Kepler list)
  added tutorial and new examples
  fixed escape.string
  web:delete_cookie receives a path parameter in order to correctly remove the cookie. Bug report and patch by Ignacio Burgueño
  stripping UTF-8 BOM from templates read from disk
  removing SoLazer files in order to make the Orbit package smaller
  added alternate name for integer (int)
  better error reporting for missing escape and convert functions
  removed toboolean
  fixed bugs 13451 and 25418: setting status 500 on application errors not throwing an error if file not exists when invalidating
  cache

* Version 2.0.1 (10/Jun/2008): bug-fix release, fixed bug in Orbit pages' redirect function (thanks for Ignacio Burgueño for finding the bug)

* Version 2.0 (06/Jun/2008): Complete rewrite of Orbit

* Version 1.0: Initial release, obsolete

Download and Installation

The easiest way to download and install Orbit is via LuaRocks. You can install Orbit
with a simple command:

luarocks install orbit

Go to the path where LuaRocks put Orbit to see the sample apps and this documentation.
LuaRocks will automatically fetch and install any dependencies you don't already have.

To run the supplied example, go to the samples/hello directory
of this distribution and do:

orbit hello.lua

After the server is running go to your web browser. Some sample
urls for hello.lua:

http://127.0.0.1:8080/ will show "Hello World!"
http://127.0.0.1:8080/say/foo will show "Hello foo!"
http://127.0.0.1:8080/anythingelse will show "Not found!"

For more information please check http://keplerproject.github.com/orbit

orbit's People

Contributors

avlubimov avatar hishamhm avatar ignacio avatar jairojair avatar kognix avatar mascarenhas avatar msadegh avatar petsagouris avatar rjpcomputing 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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

orbit's Issues

test_routes.lua fails with lpeg > 0.10

test_routes.lua fails at line 126 with:
attempt to index local 't' (a nil value)

Believe this is due to the period in the match pattern which behaves differently in later versions of lpeg.

cookies table is empty although cookies are sent

Hello,

I'm trying to sent a cookie to an orbit app but it doesn't seem to make its way to the web.cookies table. The cookie is named 'bmaleticket' and from the request as well as from prettyprinting 'web' it seems to be ok.

I'm using orbit:
2.2.2-1 (installed) - /usr/local/lib/luarocks/rocks

and lua:
Lua 5.1.4 Copyright (C) 1994-2008 Lua.org, PUC-Rio

Here is the whole 'web' table pretty printed:

{
GET =
{
},
POST =
{
post_data = "",
},
cookies =
{
},
delete_cookie = function: 0x1084270,
doc_root = "/home/nando/src/bMale",
headers =
{
["Content-Type"] = "text/html",
},
input =
{
},
method = "get",
path_info = "/get",
path_translated = "/home/nando/src/bMale/bmale.lua",
prefix = "/bmale.lua",
real_path = "/home/nando/src/bMale",
response = "",
script_name = "/bmale.lua",
set_cookie = function: 0x10a6650,
status = "200 Ok",
vars =
{
APP_PATH = "/home/nando/src/bMale",
CONTENT_LENGTH = "",
CONTENT_TYPE = "",
DOCUMENT_ROOT = "/home/nando/src/bMale",
HTTP_COOKIE = "bmaleticket=c6f1eadc%2D34cb%2D4c4c%2Dcce8%2Ddf7f932946dd; BOS_Locale=en",
PATH_INFO = "/get",
PATH_TRANSLATED = "/home/nando/src/bMale/bmale.lua",
QUERY_STRING = "",
REQUEST_METHOD = "GET",
SCRIPT_NAME = "/bmale.lua",
error =
{
write = function: 0xe42fb0,
},
input =
{
read = function: 0xe43060,
},
},
}

Error in orbit.model reference manual (or code)?

Just when we hoped we were ready to release...!

I was inspired by the discussion on pull request #26 and various preferences for quotations vs. apostrophes to denote literal expressions. It prompted me to run some detailed tests on orbit.model to see if the code still held up in either case, since as we know SQL has its own established standards for delimiters.

The last orbit.model example in the reference is:
books:find_all_by_author_or_author{ "John Doe", "Jane Doe", order = "year_pub asc" }

Having created a suitable "books" table in a sqlite3 DB I found that this last example fails...

lua: /usr/local/share/lua/5.1/orbit/model.lua:226: attempt to index field '?' (a nil value)
stack traceback:
    /usr/local/share/lua/5.1/orbit/model.lua:226: in function 'parse_condition'
    /usr/local/share/lua/5.1/orbit/model.lua:258: in function 'build_query_by'

A quick look at parse_condition and the SQL concatenation in build_query_by suggests that we only support "x_and_y" clauses, not "x_or_y", in the method name.

i.e. The following works as expected:
books:find_all_by_author_and_year_pub{ "Jane Doe", 1996 }

I've never noticed this before (perhaps because I'm not a big fan of Rails ActiveRecord and haven't much used these constructs), but suggest that before releasing we either fix the code or... (easier) just the example in the reference manual ;-)

And if we're being strict about punctuation, the manual should read:
à la Rails instead of a la Rails :-)

P.S. I'll gladly share the test table once I've extracted it to a separate database file.

Cheers

add support for lua 5.2, 5.3 and above

orbit works in lua 5.1.5, but is broken in 5.2 and above (such as 5.2.4 and 5.3.5)

when I try to use orbit in 5.2, an exception is thrown

lua: /usr/share/lua/5.3/orbit.lua:9: attempt to call a nil value (local 'setfenv')
stack traceback:
	/usr/share/lua/5.3/orbit.lua:9: in main chunk
	[C]: in function 'require'
...

the line of code in question is

9: setfenv(1, _G)

related info:

Add DATE support to orbits model

Hi All,
Using orbit to develop a small wiki-type application,
I was given an error whenver I tried to parse something with the DATE field.
It did not have a parser for it. So I edited orbit/model.lua, and basically copied the datetime function.
Here is a diff, if you are interested in adding support for DATE:

98a99,102
> function convert.date(v)
> 	local year, month, day = string.match(v, "(%d+)%-(%d+)%-(%d+)")
> 	return os.time({year=tonumber(year), month=tonumber(month), day=tonumber(day)})
> end
153a158,161
> 
> function escape.date(v)
> 	return "'" .. os.date("%Y-%m-%d", v) .. "'"
> end

I had a few concerns about it.

  1. There is no difference between date and datetime in lua, this could possibly lead to bugs in programs that rely on a time (Since it would be noon, but are only given a date. Hopefully the developer would be aware of that though.
  2. Is it possible to use datetime for date? I tried, but I get the following:
/usr/share/lua/5.1/orbit/model.lua:93: field 'day' missing in date table

This seems to be because of the expression you use to find date. it is (%d+)%-(%d+)%-(%d+) (%d+):(%d+):(%d+)
This means that the day will not be matched for type date, since it does not follow a space. I don't know if you would prefer modifying the expression, or adding a separate function.

Either way, we would want a different function for escape.date.
Is there any reason DATE is not supported? Or is it just waiting for someone to bake support in?

Let me know what you guys think. If you want, I can fork and do a PR, but I don't speak git very well.
Happy new year!

Adapt Makefile to directory structure

The installation process fails, because the Makefile is missing sub-directories from the tree:

cp src/orbit/model.lua $(LUA_DIR)/orbit
cp src/orbit/cache.lua $(LUA_DIR)/orbit
cp src/orbit/pages.lua $(LUA_DIR)/orbit
cp src/orbit/ophandler.lua $(LUA_DIR)/orbit
mkdir -p $(BIN_DIR)
cp src/launchers/orbit $(BIN_DIR)

Notice the added sub-directories 'orbit' and 'launcher', which are missing.

Orbit not compatible with LPEG 0.10

LPEG 0.10 began to allow underscores in RE identifiers, changing the meaning of [%w_] which is used in Orbit1, which means a new install of orbit from luarocks currently does not work. Simple fix, otherwise I'd attach a patch :)

Impossible to retrieve number of rows in model table

It seems to me that counting the number of model instances can only be achieved through find_all() and the # operator. This is inefficient...

The Orbit tutorial uses a dedicated field in the "post" model to know how many "comment"s are associated with it, but that doesn't feel right (or even repeatable in other cases where a condition should be passed to a_model:find_all()).

Going through the current code for build_query() I don't think I can add this feature easily.

Rockspecs out of sync

The rockspec on the main Luarocks repository is 2.2.0-2 which doesn't exist here on Github. It pulls a tarball dated 2010 which lacks some important bugfixes.
Also it has wsapi-xavante as a dependency - this should be wsapi since Orbit can run with other webservers.
Please update :)

Lua 5.2 compatiblity

Though orbit works quite well with Lua 5.2, I discovered a problem with the xpcalls in orbit.lua:540:

    local ok, response = xpcall(function () 
                  return handler(web, unpack(captures)) 
                end, debug.traceback)

Via WSAPI, xpcall is used via coxpcall and therefore debug.traceback will be called with two string parameters.

This is a problem because in 5.1 debug.traceback([msg]) accepts one string argument and so the second argument is omitted BUT in Lua 5.2 we have debug.traceback ([thread,] [message [, level]]). Since levelneeds to be an integer, an error is raised (expected number instead of string).

For the sake of compatibility, I suggest the following easy fix:

    local ok, response = xpcall(function () 
                  return handler(web, unpack(captures)) 
                end, function(msg) return debug.traceback(msg) end))

Hope that helps.

Orbit don't handle OPTIONS request method

When trying to request a PUT method, before the PUT itself the browser start a preflight negotiation with an OPTIONS request, but Orbit respond it with a 500 Internal Error status code instead of 404 or 200.

Publish 2.2.1 on luarocks?

The latest rock I see is orbit 2.2.0-2, which doesn't work due to the module changes in the dependencies.

Support offset in models

Please add support for offset to the available options passed in a model. This is used often to support pagination.

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.