Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lua 5.3 compatibility, fixed model and corrected table name #50

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion samples/blog/blog.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@ local orbit = require "orbit"
local orcache = require "orbit.cache"
local markdown = require "markdown"
local wsutil = require "wsapi.util"
local unpack = unpack or table.unpack

--
-- Declares that this is module is an Orbit app
--
local blog = setmetatable(orbit.new(), { __index = _G })
if _VERSION == "Lua 5.2" then
if _VERSION >= "Lua 5.2" then
_ENV = blog
else
setfenv(1, blog)
Expand Down
7 changes: 6 additions & 1 deletion samples/hello/hello.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,12 @@ local orbit = require "orbit"
-- Orbit applications are usually modules,
-- orbit.new does the necessary initialization

module("hello", package.seeall, orbit.new)
local hello = orbit.new()
if _VERSION >= "Lua 5.2" then
_ENV = hello
else
setfenv(1, hello)
end

-- These are the controllers, each receives a web object
-- that is the request/response, plus any extra captures from the
Expand Down
15 changes: 9 additions & 6 deletions samples/toycms/toycms.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,12 @@ local markdown = require "markdown"
local orcache = require "orbit.cache"
local cosmo = require "cosmo"
local wsutil = require "wsapi.util"
local unpack = unpack or table.unpack

local toycms = setmetatable(orbit.new(), { __index = _G })
if _VERSION == "Lua 5.2" then
local toycms = setmetatable(orbit.new("toycms"), { __index = _G })
toycms.cosmo = cosmo

if _VERSION >= "Lua 5.2" then
_ENV = toycms
else
setfenv(1, toycms)
Expand All @@ -25,10 +28,10 @@ mapper.conn = env:connect(unpack(database.conn_data))
mapper.driver = database.driver

models = {
post = toycms:model "toycms_post",
comment = toycms:model "toycms_comment",
section = toycms:model "toycms_section",
user = toycms:model "toycms_user"
post = toycms:model "post",
comment = toycms:model "comment",
section = toycms:model "section",
user = toycms:model "user"
}

cache = orcache.new(toycms, cache_path)
Expand Down
Loading