keplerproject / orbit Goto Github PK
View Code? Open in Web Editor NEWOrbit is an MVC web framework for Lua.
Home Page: http://keplerproject.github.io/orbit/
Orbit is an MVC web framework for Lua.
Home Page: http://keplerproject.github.io/orbit/
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
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.
The project description still has a link to the luaforge site. It should be updated to point to http://keplerproject.github.io/orbit/
it's orbit dead?
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,
},
},
}
I'll make a fix for this right now.
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
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 Postgres support to orbit.model
In http://keplerproject.github.com/orbit/example.html you link to http://keplerproject.github.com/orbit/blog_config.lua, right above require "blog_config"
Foobar is a bug.
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.
/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!
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.
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 :)
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.
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 :)
There is no support for floating point numbers in Orbit's Model. Can it be added.
Right now the timestamp type is not supported by orbit.model. This would be nice to have.
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 level
needs 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.
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.
The latest rock I see is orbit 2.2.0-2, which doesn't work due to the module changes in the dependencies.
Please add support for offset to the available options passed in a model. This is used often to support pagination.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.