Skip to content

Commit

Permalink
Update starlight and sync files with sailor
Browse files Browse the repository at this point in the history
  • Loading branch information
Etiene committed Feb 15, 2016
1 parent 99d0134 commit d566a8c
Show file tree
Hide file tree
Showing 15 changed files with 57 additions and 234 deletions.
158 changes: 0 additions & 158 deletions js/starlight/DOMAPI.js

This file was deleted.

1 change: 0 additions & 1 deletion js/starlight/DOMAPI.min.js

This file was deleted.

30 changes: 0 additions & 30 deletions js/starlight/babel.min.js

This file was deleted.

29 changes: 29 additions & 0 deletions js/starlight/browser.5.8.34.min.js

Large diffs are not rendered by default.

24 changes: 0 additions & 24 deletions js/starlight/latclient.js

This file was deleted.

1 change: 0 additions & 1 deletion js/starlight/parser.min.js

This file was deleted.

2 changes: 2 additions & 0 deletions js/starlight/starlight.js

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion js/starlight/starlight.min.js

This file was deleted.

2 changes: 1 addition & 1 deletion lua/latclient.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
--[[
Lua@Client 0.3.2
Lua@Client 0.4
Lua Pages Template Preprocessor Extension
Copyright (c) 2014-2015 Felipe Daragon
Expand Down
2 changes: 1 addition & 1 deletion lua/latclient/common.lua
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,4 @@ function M.js_string_escape(s)

end

return M
return M
2 changes: 1 addition & 1 deletion lua/latclient/conf.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ local conf = {
}
}

return conf
return conf
2 changes: 1 addition & 1 deletion lua/latclient/lp_handler.lua
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ function provide_file(r)
local conf = require "latclient.conf"
local vm = require("latclient."..conf.lua_at_client.vm)
return vm.handle(r)
end
end
2 changes: 1 addition & 1 deletion lua/latclient/lua51js.lua
Original file line number Diff line number Diff line change
Expand Up @@ -72,4 +72,4 @@ function M.cgilua_exit(path,filename)
end
end

return M
return M
3 changes: 2 additions & 1 deletion lua/latclient/moonshine.lua
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ local M = {
}

local common = require "latclient.common"
local loadstring = loadstring or load

function M.get_header(s)
if M.js_served == false then
Expand Down Expand Up @@ -49,4 +50,4 @@ function M.get_modules(s)
return modules
end

return M
return M
32 changes: 19 additions & 13 deletions lua/latclient/starlight.lua
Original file line number Diff line number Diff line change
Expand Up @@ -13,26 +13,36 @@ function M.get_header(s)
if M.js_served == false then
M.js_served = true
local header = [[
<script src="{url}/starlight/starlight.min.js"></script>
<script src="{url}/starlight/parser.min.js"></script>
<script src="{url}/starlight/babel.min.js"></script>
<script src="{url}/starlight/DOMAPI.min.js"></script>
<script src="{url}/starlight/latclient.js"></script>
<!-- While target browsers don't support ES6 natively, include Babel parser -->
<script src="{url}/starlight/browser.5.8.34.min.js"></script>
<script src="{url}/starlight/starlight.js" data-run-script-tags></script>
<!-- Starlight! -->
]]
header = string.gsub(header, "{url}", M.js_url)
s = header..s
s = s..header
end
return s
end


function M.get_client_js(s)
local modules = M.get_modules(s)
s = common.js_string_escape(s)
s = '<script>'..modules..'(starlight.parser.parse('..s..'))();</script>'
s = modules..M.wrap_code(s)
return M.get_header(s)
end

function M.wrap_code(s,module_name)
local mod = module_name and table.concat{'data-modname="',module_name,'"'} or ''

return table.concat({
'<script type="application/x-lua"',
mod,
'>',
s,
'</script>'
}, '\n')
end


function M.get_modules(s)
local modules = ""
Expand All @@ -43,11 +53,7 @@ function M.get_modules(s)
local file = io.open(module_file,'r')
local file_str = file:read("*a")
file:close()
local lua_code = "rawset(package.preload, '" .. name.. [[', function(...) ]]
.. file_str ..
[[ end)]]
lua_code = common.js_string_escape(lua_code)
modules = modules .. '(starlight.parser.parse('..lua_code..'))(); '
modules = modules..M.wrap_code(file_str,name)
M.modules_served[name] = true
end
end
Expand Down

0 comments on commit d566a8c

Please sign in to comment.