@@ -405,29 +405,28 @@ local function get_script_metadata(script)
405405
406406 log .msg (log .debug , " processing metatdata for " .. script )
407407
408- local description = nil
409- local metadata = nil
408+ local metadata_block = nil
409+ local metadata = {}
410410
411411 f = io.open (LUA_DIR .. PS .. script .. " .lua" )
412412 if f then
413413 -- slurp the file
414414 local content = f :read (" *all" )
415415 f :close ()
416416 -- grab the script_data.metadata table
417- description = string.match (content , " script_data%.metadata = %{\r ?\n (.-)\r ?\n %}" )
417+ metadata_block = string.match (content , " script_data%.metadata = %{\r ?\n (.-)\r ?\n %}" )
418418 else
419419 log .msg (log .error , " cant read from " .. script )
420420 end
421421
422- if description then
423- metadata = " "
424- -- format it into a string block for display
425- local lines = du .split (description , " \n " )
422+ if metadata_block then
423+ -- break up the lines into key value pairs
424+ local lines = du .split (metadata_block , " \n " )
426425 log .msg (log .debug , " got " .. # lines .. " lines" )
427- local first = 1
428426 for i = 1 , # lines do
429427 log .msg (log .debug , " splitting line " .. lines [i ])
430428 local parts = du .split (lines [i ], " = " )
429+ parts [1 ] = string_trim (parts [1 ])
431430 log .msg (log .debug , " got value " .. parts [1 ] .. " and data " .. parts [2 ])
432431 if string.match (parts [2 ], " %_%(" ) then
433432 parts [2 ] = _ (string_dequote (string_dei18n (parts [2 ])))
@@ -437,14 +436,15 @@ local function get_script_metadata(script)
437436 if string.match (parts [2 ], " ,$" ) then
438437 parts [2 ] = string_chop (parts [2 ])
439438 end
440- metadata = metadata .. string.format (" %s%-10s\t %s" , first and " " or " \n " , parts [1 ], parts [2 ])
441- first = nil
439+ log .msg (log .debug , " parts 1 is " .. parts [1 ] .. " and parts 2 is " .. parts [2 ])
440+ metadata [parts [1 ]] = parts [2 ]
441+ log .msg (log .debug , " metadata " .. parts [1 ] .. " is " .. metadata [parts [1 ]])
442442 end
443- log .msg (log .debug , " script data is \n " .. metadata )
443+ log .msg (log .debug , " script data found for " .. metadata [ " name " ] )
444444 end
445445
446446 restore_log_level (old_log_level )
447- return metadata
447+ return metadata_block and metadata or nil
448448end
449449
450450local function get_script_doc (script )
@@ -910,11 +910,11 @@ local function populate_buttons(folder, first, last)
910910 end
911911
912912 button .image = POWER_ICON
913- label .label = script .name
913+ label .label = script .metadata and script . metadata . name or script . name
914914 label .name = " pb_label"
915915 button .ellipsize = " end"
916916 button .sensitive = true
917- label .tooltip = script .metadata and script .metadata or script .doc
917+ label .tooltip = script .metadata and script .metadata . purpose or script .doc
918918
919919 button .clicked_callback = function (this )
920920 local cb_script = script
0 commit comments