Skip to content

Commit

Permalink
Load latclient settings from sailor.lua
Browse files Browse the repository at this point in the history
  • Loading branch information
felipedaragon committed Oct 9, 2015
1 parent f3e0f7e commit e1973ea
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 15 deletions.
13 changes: 8 additions & 5 deletions src/latclient.lua
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
--[[
Lua@Client 0.3.1
Lua@Client 0.3.2
Lua Pages Template Preprocessor Extension
Copyright (c) 2014-2015 Felipe Daragon
License: MIT
]]

local M = {}

local conf = require "latclient.conf"
local vm = require("latclient."..conf.lua_at_client.vm)
vm.js_url = conf.lua_at_client.vm_url or "./pub"

local M = {
conf = conf
}

function M.translate(src)
local vm = require("latclient."..conf.lua_at_client.vm)
vm.js_url = conf.lua_at_client.vm_url or "./pub"

-- Reset for persistent environments (like Lighttpd)
vm.js_served = false
vm.modules_served = {}
Expand Down
13 changes: 7 additions & 6 deletions src/latclient/conf.lua
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
-- Use the same config file as Sailor
require "conf.conf"
local conf = require "conf.conf"
if not conf.lua_at_client or not conf.lua_at_client.vm then
conf.lua_at_client = { vm = 'starlight'} -- default
end
local conf = {
lua_at_client = {
vm = "starlight", -- starlight is default. Other options are moonshine, lua51js and luavmjs.
vm_url = nil -- allows to set a custom URL for the VM JavaScript files.
}
}

return conf
4 changes: 4 additions & 0 deletions src/sailor.lua
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,11 @@ local sailor = {
_VERSION = "Sailor 0.4.11",
}

-- Loads Lua@client's settings from Sailor conf.
-- If lua_at_client table is missing, use default Lua@client settings
local lp = require "web_utils.lp_ex"
lp.lat.conf.lua_at_client = conf.lua_at_client or require "latclient.conf"

local lfs = require "lfs"
local open,assert,loadstring,setfenv,load,random = io.open,assert,loadstring,setfenv,load,math.random
local match,tostring,gsub = string.match,tostring,string.gsub
Expand Down
4 changes: 0 additions & 4 deletions src/web_utils/lp_ex.lua
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,6 @@ function M.translate (s)
end

function M.setoutfunc (f)
local conf = require "conf.conf"
local vm = require("latclient."..conf.lua_at_client.vm)
vm.js_served = false
vm.modules_served = {}
lp.setoutfunc(f)
end

Expand Down

0 comments on commit e1973ea

Please sign in to comment.