minify + fix lzwfs ui bug

This commit is contained in:
kepler155c@gmail.com
2019-11-07 22:49:59 -07:00
parent db31a0e5de
commit 3255a5a670
5 changed files with 2985 additions and 6 deletions

View File

@@ -38,7 +38,7 @@ local tab = UI.Tab {
disableHeader = true, disableHeader = true,
columns = { { key = 'value' } }, columns = { { key = 'value' } },
autospace = true, autospace = true,
sortColumn = 'index', sortColumn = 'value',
help = 'double-click to remove', help = 'double-click to remove',
accelerators = { accelerators = {
delete = 'remove', delete = 'remove',
@@ -54,8 +54,8 @@ local tab = UI.Tab {
function tab:enable() function tab:enable()
self.grid.values = { } self.grid.values = { }
for k,v in ipairs(config.filters or { }) do for _,v in ipairs(config.filters or { }) do
table.insert(self.grid.values, { index = k, value = v }) table.insert(self.grid.values, { value = v })
end end
self.grid:update() self.grid:update()
UI.Tab.enable(self) UI.Tab.enable(self)
@@ -68,7 +68,6 @@ local function rewriteFiles(p)
end end
else else
local function recurse(path) local function recurse(path)
_G._syslog('rewriting: ' .. path)
if fs.isDir(path) then if fs.isDir(path) then
for _, v in pairs(fs.listEx(path)) do for _, v in pairs(fs.listEx(path)) do
if not v.isReadOnly then if not v.isReadOnly then
@@ -88,7 +87,6 @@ end
function tab:eventHandler(event) function tab:eventHandler(event)
if event.type == 'add_path' then if event.type == 'add_path' then
table.insert(self.grid.values, { table.insert(self.grid.values, {
index = #self.grid.values + 1,
value = self.entry.value, value = self.entry.value,
}) })
self.entry:reset() self.entry:reset()
@@ -100,7 +98,7 @@ function tab:eventHandler(event)
elseif event.type == 'grid_select' or event.type == 'remove' then elseif event.type == 'grid_select' or event.type == 'remove' then
local selected = self.grid:getSelected() local selected = self.grid:getSelected()
if selected then if selected then
table.remove(self.grid.values, selected.index) Util.removeByValue(self.grid.values, selected)
self.grid:update() self.grid:update()
self.grid:draw() self.grid:draw()
end end

6
minify/.package Normal file
View File

@@ -0,0 +1,6 @@
{
title = 'Lua minification',
repository = 'kepler155c/opus-apps/{{OPUS_BRANCH}}/minify',
description = [[ Minifies Lua files ]],
license = 'MIT',
}

2949
minify/minify.lua Normal file

File diff suppressed because it is too large Load Diff

25
minify/minifyDir.lua Normal file
View File

@@ -0,0 +1,25 @@
local fs = _G.fs
local shell = _ENV.shell
local function recurse(path)
if fs.isDir(path) then
for _, v in pairs(fs.listEx(path)) do
if not v.isReadOnly then
recurse(fs.combine(path, v.name))
end
end
elseif path:match('%.lua$') and not fs.isReadOnly(path) then
local sz = fs.getSize(path)
shell.run('packages/minify/minify.lua minify ' .. path)
print(string.format('%s : %.2f%%', path, (sz - fs.getSize(path)) / sz * 100))
end
end
local path = ({ ... })[1] or error('Syntax: minifyDir PATH')
path = fs.combine(path, '')
if not fs.isDir(path) then
error('Invalid path')
end
recurse(path)

View File

@@ -13,6 +13,7 @@
[ 'milo' ] = 'https://raw.githubusercontent.com/kepler155c/opus-apps/develop-1.8/milo/.package', [ 'milo' ] = 'https://raw.githubusercontent.com/kepler155c/opus-apps/develop-1.8/milo/.package',
[ 'miloApps' ] = 'https://raw.githubusercontent.com/kepler155c/opus-apps/develop-1.8/miloApps/.package', [ 'miloApps' ] = 'https://raw.githubusercontent.com/kepler155c/opus-apps/develop-1.8/miloApps/.package',
[ 'miners' ] = 'https://raw.githubusercontent.com/kepler155c/opus-apps/develop-1.8/miners/.package', [ 'miners' ] = 'https://raw.githubusercontent.com/kepler155c/opus-apps/develop-1.8/miners/.package',
[ 'minify' ] = 'https://raw.githubusercontent.com/kepler155c/opus-apps/develop-1.8/minify/.package',
[ 'monitor' ] = 'https://raw.githubusercontent.com/kepler155c/opus-apps/develop-1.8/monitor/.package', [ 'monitor' ] = 'https://raw.githubusercontent.com/kepler155c/opus-apps/develop-1.8/monitor/.package',
[ 'neural' ] = 'https://raw.githubusercontent.com/kepler155c/opus-apps/develop-1.8/neural/.package', [ 'neural' ] = 'https://raw.githubusercontent.com/kepler155c/opus-apps/develop-1.8/neural/.package',
-- [ 'pickup' ] = 'https://raw.githubusercontent.com/kepler155c/opus-apps/develop-1.8/pickup/.package', -- [ 'pickup' ] = 'https://raw.githubusercontent.com/kepler155c/opus-apps/develop-1.8/pickup/.package',