gluon-core: make Lua files proper modules
This commit is contained in:
		
							parent
							
								
									bf7a2c974e
								
							
						
					
					
						commit
						ee307ec1de
					
				@ -6,4 +6,16 @@ local function loader()
 | 
				
			|||||||
end
 | 
					end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
-- setfenv doesn't work with Lua 5.2 anymore, but we're using 5.1
 | 
					-- setfenv doesn't work with Lua 5.2 anymore, but we're using 5.1
 | 
				
			||||||
return setfenv(assert(load(coroutine.wrap(loader), 'site.conf')), {})()
 | 
					local site_config = setfenv(assert(load(coroutine.wrap(loader), 'site.conf')), {})()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					local setmetatable = setmetatable
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					module 'gluon.site_config'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					setmetatable(_M,
 | 
				
			||||||
 | 
						{
 | 
				
			||||||
 | 
							__index = site_config,
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					return _M
 | 
				
			||||||
 | 
				
			|||||||
@ -17,11 +17,15 @@ local function set(_, name, val)
 | 
				
			|||||||
	f:close()
 | 
						f:close()
 | 
				
			||||||
end
 | 
					end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
local sysconfig = {}
 | 
					local setmetatable = setmetatable
 | 
				
			||||||
local mt = {
 | 
					 | 
				
			||||||
	__index = get,
 | 
					 | 
				
			||||||
	__newindex = set,
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
setmetatable(sysconfig, mt)
 | 
					module 'gluon.sysconfig'
 | 
				
			||||||
return sysconfig
 | 
					
 | 
				
			||||||
 | 
					setmetatable(_M,
 | 
				
			||||||
 | 
						{
 | 
				
			||||||
 | 
							__index = get,
 | 
				
			||||||
 | 
							__newindex = set,
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					return _M
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
		Reference in New Issue
	
	Block a user