mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-05-04 22:19:38 +00:00
98_Installer: add maintainers to search results
git-svn-id: https://svn.fhem.de/fhem/trunk/fhem@18945 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
93c2a6f912
commit
8ab9a3a738
@ -246,12 +246,6 @@ sub Get($$@) {
|
|||||||
my $ret = CreateRawMetaJson( $hash, $cmd, $args[0] );
|
my $ret = CreateRawMetaJson( $hash, $cmd, $args[0] );
|
||||||
return $ret;
|
return $ret;
|
||||||
}
|
}
|
||||||
elsif ( lc($cmd) eq 'zzgetmaintainer.json' ) {
|
|
||||||
return "usage: $cmd MAINTAINER" if ( @args != 1 );
|
|
||||||
|
|
||||||
my $ret = CreateRawMaintainerJson( $hash, $cmd, $args[0] );
|
|
||||||
return $ret;
|
|
||||||
}
|
|
||||||
else {
|
else {
|
||||||
my @fhemModules;
|
my @fhemModules;
|
||||||
foreach ( sort { "\L$a" cmp "\L$b" } keys %modules ) {
|
foreach ( sort { "\L$a" cmp "\L$b" } keys %modules ) {
|
||||||
@ -259,23 +253,10 @@ sub Get($$@) {
|
|||||||
push @fhemModules, $_;
|
push @fhemModules, $_;
|
||||||
}
|
}
|
||||||
|
|
||||||
my @fhemMaintainers;
|
|
||||||
foreach ( keys %FHEM::Meta::maintainerModules ) {
|
|
||||||
push @fhemMaintainers, $_;
|
|
||||||
}
|
|
||||||
foreach ( keys %FHEM::Meta::maintainerPackages ) {
|
|
||||||
push @fhemMaintainers, $_;
|
|
||||||
}
|
|
||||||
foreach ( keys %FHEM::Meta::maintainerFile ) {
|
|
||||||
push @fhemMaintainers, $_;
|
|
||||||
}
|
|
||||||
|
|
||||||
my $list =
|
my $list =
|
||||||
'search'
|
'search'
|
||||||
. ' showModuleInfo:FHEM,'
|
. ' showModuleInfo:FHEM,'
|
||||||
. join( ',', @fhemModules )
|
. join( ',', @fhemModules )
|
||||||
. ' zzGetMaintainer.json:'
|
|
||||||
. join( ',', sort { "\L$a" cmp "\L$b" } __aUniq(@fhemMaintainers) )
|
|
||||||
. ' zzGetMETA.json:FHEM,'
|
. ' zzGetMETA.json:FHEM,'
|
||||||
. join( ',', @fhemModules );
|
. join( ',', @fhemModules );
|
||||||
|
|
||||||
@ -949,8 +930,8 @@ sub CreateSearchList ($$$) {
|
|||||||
|
|
||||||
# search for matching device
|
# search for matching device
|
||||||
my $foundDevices = 0;
|
my $foundDevices = 0;
|
||||||
my $linecount = 1;
|
my $linecount = 1;
|
||||||
foreach my $device ( sort keys %defs ) {
|
foreach my $device ( sort { "\L$a" cmp "\L$b" } keys %defs ) {
|
||||||
next
|
next
|
||||||
unless ( defined( $defs{$device}{TYPE} )
|
unless ( defined( $defs{$device}{TYPE} )
|
||||||
&& defined( $modules{ $defs{$device}{TYPE} } ) );
|
&& defined( $modules{ $defs{$device}{TYPE} } ) );
|
||||||
@ -1010,8 +991,8 @@ sub CreateSearchList ($$$) {
|
|||||||
|
|
||||||
# search for matching module
|
# search for matching module
|
||||||
my $foundModules = 0;
|
my $foundModules = 0;
|
||||||
$linecount = 1;
|
$linecount = 1;
|
||||||
foreach my $module ( sort keys %modules ) {
|
foreach my $module ( sort { "\L$a" cmp "\L$b" } keys %modules ) {
|
||||||
if ( $module =~ m/^.*$search.*$/i ) {
|
if ( $module =~ m/^.*$search.*$/i ) {
|
||||||
unless ($foundModules) {
|
unless ($foundModules) {
|
||||||
push @ret, '<h3>Modules</h3>' . $lb;
|
push @ret, '<h3>Modules</h3>' . $lb;
|
||||||
@ -1064,7 +1045,9 @@ sub CreateSearchList ($$$) {
|
|||||||
# search for matching keyword
|
# search for matching keyword
|
||||||
my $foundKeywords = 0;
|
my $foundKeywords = 0;
|
||||||
$linecount = 1;
|
$linecount = 1;
|
||||||
foreach my $keyword (%FHEM::Meta::keywords) {
|
foreach
|
||||||
|
my $keyword ( sort { "\L$a" cmp "\L$b" } keys %FHEM::Meta::keywords )
|
||||||
|
{
|
||||||
if ( $keyword =~ m/^.*$search.*$/i ) {
|
if ( $keyword =~ m/^.*$search.*$/i ) {
|
||||||
push @ret, '<h3>Keywords</h3>' unless ($foundKeywords);
|
push @ret, '<h3>Keywords</h3>' unless ($foundKeywords);
|
||||||
$found++;
|
$found++;
|
||||||
@ -1097,8 +1080,8 @@ sub CreateSearchList ($$$) {
|
|||||||
my $l = $linecount % 2 == 0 ? $rowOpenEven : $rowOpenOdd;
|
my $l = $linecount % 2 == 0 ? $rowOpenEven : $rowOpenOdd;
|
||||||
|
|
||||||
my $type = $mAttr;
|
my $type = $mAttr;
|
||||||
$type = 'Module' if ( $mAttr eq 'modules' );
|
$type = 'Module' if ( $mAttr eq 'modules' );
|
||||||
$type = 'Perl Package' if ( $mAttr eq 'packages' );
|
$type = 'Package' if ( $mAttr eq 'packages' );
|
||||||
|
|
||||||
FHEM::Meta::Load($item);
|
FHEM::Meta::Load($item);
|
||||||
|
|
||||||
@ -1138,6 +1121,107 @@ sub CreateSearchList ($$$) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# search for matching maintainer
|
||||||
|
my $foundMaintainers = 0;
|
||||||
|
my %maintainerInfo;
|
||||||
|
$linecount = 1;
|
||||||
|
foreach my $maintainer (
|
||||||
|
sort { "\L$a" cmp "\L$b" }
|
||||||
|
keys %FHEM::Meta::maintainerModules
|
||||||
|
)
|
||||||
|
{
|
||||||
|
if ( $maintainer =~ m/^.*$search.*$/i ) {
|
||||||
|
$maintainerInfo{$maintainer}{modules} =
|
||||||
|
$FHEM::Meta::maintainerModules{$maintainer};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
foreach my $maintainer (
|
||||||
|
sort { "\L$a" cmp "\L$b" }
|
||||||
|
keys %FHEM::Meta::maintainerPackages
|
||||||
|
)
|
||||||
|
{
|
||||||
|
if ( $maintainer =~ m/^.*$search.*$/i ) {
|
||||||
|
$maintainerInfo{$maintainer}{packages} =
|
||||||
|
$FHEM::Meta::maintainerPackages{$maintainer};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
foreach my $maintainer ( sort { "\L$a" cmp "\L$b" } keys %maintainerInfo ) {
|
||||||
|
next
|
||||||
|
unless ( defined( $maintainerInfo{$maintainer}{modules} )
|
||||||
|
|| defined( $maintainerInfo{$maintainer}{packages} ) );
|
||||||
|
|
||||||
|
unless ($foundMaintainers) {
|
||||||
|
push @ret, '<h3>Authors & Maintainers</h3>' . $lb;
|
||||||
|
push @ret, $tableOpen;
|
||||||
|
push @ret,
|
||||||
|
$colOpenMinWidth . $txtOpen . 'Author' . $txtClose . $colClose;
|
||||||
|
push @ret, $colOpen . $txtOpen . 'Modules' . $txtClose . $colClose;
|
||||||
|
push @ret, $colOpen . $txtOpen . 'Packages' . $txtClose . $colClose;
|
||||||
|
}
|
||||||
|
$found++;
|
||||||
|
$foundMaintainers++;
|
||||||
|
|
||||||
|
my $l = $linecount % 2 == 0 ? $rowOpenEven : $rowOpenOdd;
|
||||||
|
|
||||||
|
my $modules = '';
|
||||||
|
my $packages = '';
|
||||||
|
|
||||||
|
my $counter = 0;
|
||||||
|
foreach my $module ( sort { "\L$a" cmp "\L$b" }
|
||||||
|
@{ $maintainerInfo{$maintainer}{modules} } )
|
||||||
|
{
|
||||||
|
$modules .= $lb if ($counter);
|
||||||
|
$counter++;
|
||||||
|
|
||||||
|
if ($html) {
|
||||||
|
$modules .=
|
||||||
|
'<a href="/'
|
||||||
|
. $webname
|
||||||
|
. '?cmd=get '
|
||||||
|
. $hash->{NAME}
|
||||||
|
. ' showModuleInfo '
|
||||||
|
. $module
|
||||||
|
. $FW_CSRF . '">'
|
||||||
|
. $module . '</a>';
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$modules .= $module;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$counter = 0;
|
||||||
|
foreach my $package ( sort { "\L$a" cmp "\L$b" }
|
||||||
|
@{ $maintainerInfo{$maintainer}{packages} } )
|
||||||
|
{
|
||||||
|
$packages .= $lb if ($counter);
|
||||||
|
$counter++;
|
||||||
|
|
||||||
|
# if ($html) {
|
||||||
|
# $packages .=
|
||||||
|
# '<a href="/'
|
||||||
|
# . $webname
|
||||||
|
# . '?cmd=get '
|
||||||
|
# . $hash->{NAME}
|
||||||
|
# . ' showPackageInfo '
|
||||||
|
# . $package
|
||||||
|
# . $FW_CSRF . '">'
|
||||||
|
# . $package . '</a>';
|
||||||
|
# }
|
||||||
|
# else {
|
||||||
|
$packages .= $package;
|
||||||
|
# }
|
||||||
|
}
|
||||||
|
|
||||||
|
$l .= $colOpenMinWidth . $maintainer . $colClose;
|
||||||
|
$l .= $colOpen . $modules . $colClose;
|
||||||
|
$l .= $colOpen . $packages . $colClose;
|
||||||
|
|
||||||
|
$l .= $rowClose;
|
||||||
|
|
||||||
|
push @ret, $l;
|
||||||
|
$linecount++;
|
||||||
|
}
|
||||||
|
push @ret, $tableClose if ($foundMaintainers);
|
||||||
|
|
||||||
return $header . join( "\n", @ret ) . $footer;
|
return $header . join( "\n", @ret ) . $footer;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1369,7 +1453,7 @@ sub CreateMetadataList ($$$) {
|
|||||||
$copyWeb = $modMeta->{resources}{x_copyright}{web};
|
$copyWeb = $modMeta->{resources}{x_copyright}{web};
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( $html && $copyEmail ) {
|
if ( $html && $copyWeb ) {
|
||||||
$copyNameContact =
|
$copyNameContact =
|
||||||
'<a href="'
|
'<a href="'
|
||||||
. $copyWeb
|
. $copyWeb
|
||||||
@ -1787,7 +1871,6 @@ sub CreateMetadataList ($$$) {
|
|||||||
my $authorName;
|
my $authorName;
|
||||||
my $authorEditorOnly;
|
my $authorEditorOnly;
|
||||||
my $authorEmail;
|
my $authorEmail;
|
||||||
my $authorNameEmail;
|
|
||||||
|
|
||||||
if ( $_ =~
|
if ( $_ =~
|
||||||
m/^([^<>\n\r]+?)(?:\s+(\(last release only\)))?(?:\s+(?:<(.*)>))?$/
|
m/^([^<>\n\r]+?)(?:\s+(\(last release only\)))?(?:\s+(?:<(.*)>))?$/
|
||||||
@ -1798,12 +1881,7 @@ m/^([^<>\n\r]+?)(?:\s+(\(last release only\)))?(?:\s+(?:<(.*)>))?$/
|
|||||||
$authorEmail = $3;
|
$authorEmail = $3;
|
||||||
}
|
}
|
||||||
|
|
||||||
$authorNameEmail =
|
my $authorNameEmail = $authorName;
|
||||||
'<a href="mailto:'
|
|
||||||
. $authorEmail . '">'
|
|
||||||
. $authorName
|
|
||||||
. $authorEditorOnly . '</a>'
|
|
||||||
if ( $html && $authorEmail );
|
|
||||||
|
|
||||||
# add alias name if different
|
# add alias name if different
|
||||||
if ( defined( $modMeta->{x_fhem_maintainer} )
|
if ( defined( $modMeta->{x_fhem_maintainer} )
|
||||||
@ -1811,15 +1889,39 @@ m/^([^<>\n\r]+?)(?:\s+(\(last release only\)))?(?:\s+(?:<(.*)>))?$/
|
|||||||
&& @{ $modMeta->{x_fhem_maintainer} } > 0
|
&& @{ $modMeta->{x_fhem_maintainer} } > 0
|
||||||
&& $modMeta->{x_fhem_maintainer}[$counter] ne '' )
|
&& $modMeta->{x_fhem_maintainer}[$counter] ne '' )
|
||||||
{
|
{
|
||||||
$authorNameEmail = (
|
|
||||||
$authorNameEmail
|
my $alias = $modMeta->{x_fhem_maintainer}[$counter];
|
||||||
? $authorNameEmail
|
|
||||||
: $authorName
|
if ( $alias eq $authorName ) {
|
||||||
)
|
$authorNameEmail =
|
||||||
. ', alias '
|
'<a href="/'
|
||||||
. $modMeta->{x_fhem_maintainer}[$counter]
|
. $webname
|
||||||
if ( $modMeta->{x_fhem_maintainer}[$counter] ne
|
. '?cmd=get '
|
||||||
$authorName );
|
. $hash->{NAME}
|
||||||
|
. ' search '
|
||||||
|
. $alias
|
||||||
|
. $FW_CSRF . '">'
|
||||||
|
. $authorName . '</a>'
|
||||||
|
if ($html);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if ($html) {
|
||||||
|
$authorNameEmail =
|
||||||
|
$authorName
|
||||||
|
. ', alias <a href="/'
|
||||||
|
. $webname
|
||||||
|
. '?cmd=get '
|
||||||
|
. $hash->{NAME}
|
||||||
|
. ' search '
|
||||||
|
. $alias
|
||||||
|
. $FW_CSRF . '">'
|
||||||
|
. $alias . '</a>';
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$authorNameEmail =
|
||||||
|
$authorName . ', alias ' . $alias;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$l .= $lb if ($counter);
|
$l .= $lb if ($counter);
|
||||||
@ -2285,33 +2387,6 @@ sub CreateRawMetaJson ($$$) {
|
|||||||
return $j->encode( $modules{$modName}{META} );
|
return $j->encode( $modules{$modName}{META} );
|
||||||
}
|
}
|
||||||
|
|
||||||
sub CreateRawMaintainerJson ($$$) {
|
|
||||||
my ( $hash, $getCmd, $maintainer ) = @_;
|
|
||||||
my %ret = ();
|
|
||||||
|
|
||||||
$ret{fhem_modules} = $FHEM::Meta::maintainerModules{$maintainer}
|
|
||||||
if ( defined( $FHEM::Meta::maintainerModules{$maintainer} ) );
|
|
||||||
|
|
||||||
$ret{fhem_packages} = $FHEM::Meta::maintainerPackages{$maintainer}
|
|
||||||
if ( defined( $FHEM::Meta::maintainerPackages{$maintainer} ) );
|
|
||||||
|
|
||||||
$ret{fhem_files} = $FHEM::Meta::maintainerFile{$maintainer}
|
|
||||||
if ( defined( $FHEM::Meta::maintainerFile{$maintainer} ) );
|
|
||||||
|
|
||||||
if ( scalar keys %ret > 0 ) {
|
|
||||||
$ret{fhem_maintainer} = $maintainer;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
return '{}';
|
|
||||||
}
|
|
||||||
|
|
||||||
my $j = JSON->new;
|
|
||||||
$j->allow_nonref;
|
|
||||||
$j->canonical;
|
|
||||||
$j->pretty;
|
|
||||||
return $j->encode( \%ret );
|
|
||||||
}
|
|
||||||
|
|
||||||
# Checks whether a perl package is installed in the system
|
# Checks whether a perl package is installed in the system
|
||||||
sub __IsInstalledPerl($) {
|
sub __IsInstalledPerl($) {
|
||||||
return 0 unless ( __PACKAGE__ eq caller(0) );
|
return 0 unless ( __PACKAGE__ eq caller(0) );
|
||||||
|
Loading…
x
Reference in New Issue
Block a user