Skip to content

Commit

Permalink
Make Lighttpd support work again
Browse files Browse the repository at this point in the history
  • Loading branch information
felipedaragon committed Sep 27, 2015
1 parent 2a9c049 commit e919052
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 15 deletions.
5 changes: 3 additions & 2 deletions src/remy.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
-- Remy 0.2.8
-- Remy 0.2.9
-- Copyright (c) 2014-2015 Felipe Daragon
-- License: MIT (http://opensource.org/licenses/mit-license.php)
--
Expand Down Expand Up @@ -133,7 +133,8 @@ function remy.detect(native_request)
if env["pLua-Version"] ~= nil then
mode = remy.MODE_MOD_PLUA
end
elseif package.loaded.lighty ~= nil then
-- Note: lighty is not a package so package.loaded.lighty ~= nil will not work
elseif lighty ~= nil then
mode = remy.MODE_LIGHTTPD
elseif native_request ~= nil and type(native_request.query_param) == "function" then
mode = remy.MODE_LWAN
Expand Down
3 changes: 2 additions & 1 deletion src/remy/mod_magnet.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@

local base64 = require "base64"
local remy = require "remy"
local lighty = require "lighty"
-- local lighty = require "lighty"
-- Note: lighty is not a package so require "lighty" will not work

local utils = {}

Expand Down
20 changes: 14 additions & 6 deletions src/sailor.lua
Original file line number Diff line number Diff line change
Expand Up @@ -56,15 +56,23 @@ function sailor.handle_request(r)
return sailor.route(page)
end

function sailor.get_filename_path(r)
local filename = r.uri:match( "([^/]+)$")
return r.filename:match("^@?(.-)/"..filename.."$")
end

-- Stores the path of the application in sailor.path
function sailor.set_application_path(r)
local dir = lfs.currentdir()

if dir == '/' or not dir then
local filename = r.uri:match( "([^/]+)$")
sailor.path = r.filename:match("^@?(.-)/"..filename.."$")
if sailor.remy_mode == remy.MODE_LIGHTTPD then
-- Ideally, this should not be needed (needs improvement/removal)
sailor.path = sailor.get_filename_path(r)
else
sailor.path = dir
local dir = lfs.currentdir()
if dir == '/' or not dir then
sailor.path = sailor.get_filename_path(r)
else
sailor.path = dir
end
end
end

Expand Down
10 changes: 7 additions & 3 deletions src/sailor/blank-app/index-magnet.lua
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
-- Alternative index for LightTPD's mod_magnet
if package.loaded.lighty ~= nil then
local lighty = require "lighty"
if lighty ~= nil then
-- Note: package.loaded.lighty ~= nil will not work because lighty is a
-- local variable and not a package
local docroot = lighty.env['physical.doc-root']
package.path = package.path..";"..docroot.."/../lib/lua/?.lua"
package.cpath = package.cpath..";"..docroot.."/../lib/clibs/?.dll"
package.path = package.path..";"..docroot.."/sailor/?.lua"


-- Makes lighty global so it can be accessed by Remy or controllers
_G["lighty"] = lighty
local sailor = require "sailor"
sailor.launch()
return sailor.r.status
end

10 changes: 7 additions & 3 deletions test/dev-app/index-magnet.lua
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
-- Alternative index for LightTPD's mod_magnet
if package.loaded.lighty ~= nil then
local lighty = require "lighty"
if lighty ~= nil then
-- Note: package.loaded.lighty ~= nil will not work because lighty is a
-- local variable and not a package
local docroot = lighty.env['physical.doc-root']
package.path = package.path..";"..docroot.."/../lib/lua/?.lua"
package.cpath = package.cpath..";"..docroot.."/../lib/clibs/?.dll"
package.path = package.path..";"..docroot.."/sailor/?.lua"


-- Makes lighty global so it can be accessed by Remy or controllers
_G["lighty"] = lighty
local sailor = require "sailor"
sailor.launch()
return sailor.r.status
end

0 comments on commit e919052

Please sign in to comment.