Moving JS and CSS assets into a lua script, apart from:

1. looking silly
2. forbidding docs generation of all "*.lua" files
3. messing code stats
4. taking more resources at runtime (loading all in memory)

... works, but not for all types of files. If anyone knows a pure lua way
to encode PNG files.

But why not change the rules and decide that assets are OK in
/usr/local/share/lua/5.1 and find a way for luarocks to install them there
? Just decide on some sub-path in modules so these assets are easily
detected if there needs to be some house keeping...

Rubygems have not been rejected by the linux community because of this...
And the rule to keep things separate holds as long as they end up in *well
known paths* which is not the case for relocatable lua installations (which
is good).

Requiring a "post-install-fix" is even worse and is a no-go: move the
folder around and... "lub" breaks. No thanks.

Maybe this solution works (it has many of the above solution drawbacks
except messing with binary data) :

1. create an "assets" sub-module
2. copy all js, css, png files into the folder and rename them "*.lua" so
that luarocks can install them.
3. in assets, set package.loaded so that these files never get required or,
requiring them returns a table with the content.

Example of the assets module:
============ lub/assets.lua
local lib = {}
base = ... -- use debug library to get current script path's directory
lub.path <http://doc.lubyk.org/lub.html#path> does this for example.
local f = io.open(base .. '/assets/image1.lua', 'rb')
lib['image1'] = {data = f:read('*a')}
f:close()
-- not sure this line is needed
package.loaded.lub.assets = lib
return lib
============

But really, supporting assets along lua code is a much better solution.

Gaspard


On Tue, Apr 2, 2013 at 11:21 AM, steve donovan <steve.j.dono...@gmail.com>wrote:

> On Tue, Apr 2, 2013 at 11:15 AM, Gaspard Bucher <gasp...@teti.ch> wrote:
>
>> We could just do it like others do it: store assets besides script code.
>>
>
> I faced this issue with LDoc (which has templates and style sheets) and
> solved it by making them into Lua modules that just say 'return [['.  The
> alternative solution is to put them in the rock directory, and give module
> developers an easy way to find this.  The basic principle is that something
> like /usr/local/share/lua/5.1 is only meant for Lua files - each platform
> has their conventions, but Unix does like to keep similar animals in
> different enclosures, like any well-regulated zoo.
>
> We do need a aolution which doesn't distort a library's structure to match
> a particular packaging option. Peter D of LuaDist likes the idea of
> treating help files also as assets-as-Lua as well.
>
>
>
> ------------------------------------------------------------------------------
> Own the Future-Intel(R) Level Up Game Demo Contest 2013
> Rise to greatness in Intel's independent game demo contest. Compete
> for recognition, cash, and the chance to get your game on Steam.
> $5K grand prize plus 10 genre and skill prizes. Submit your demo
> by 6/6/13. http://altfarm.mediaplex.com/ad/ck/12124-176961-30367-2
> _______________________________________________
> Luarocks-developers mailing list
> Luarocks-developers@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/luarocks-developers
>
>


-- 

                                                               Gaspard
------------------------------------------------------------------------------
Own the Future-Intel(R) Level Up Game Demo Contest 2013
Rise to greatness in Intel's independent game demo contest. Compete 
for recognition, cash, and the chance to get your game on Steam. 
$5K grand prize plus 10 genre and skill prizes. Submit your demo 
by 6/6/13. http://altfarm.mediaplex.com/ad/ck/12124-176961-30367-2
_______________________________________________
Luarocks-developers mailing list
Luarocks-developers@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/luarocks-developers

Reply via email to