first initial

This commit is contained in:
2025-03-31 21:54:29 +02:00
commit deee0d3737
33 changed files with 916 additions and 0 deletions

View File

@@ -0,0 +1,9 @@
Package: libsteffen-mojoplug-navhelper-perl
Version: 1.0
Section: perl
Priority: optional
Architecture: all
Depends: libsteffen-mojoplug-authorization-perl
Installed-Size: 94
Maintainer: Steffen Junge <Steffen.Junge@mlands.com>
Description: Bootstrap 4/5 Menu

View File

@@ -0,0 +1,27 @@
#!/bin/bash
script=`echo $0 | sed 's/^.*\///'`
echo "$script"
if [ -e ./$script ]; then
workdir=/tmp/$USER\_`pwd | sed 's/^.*\///'`
rm -Rf $workdir/*
mkdir -p $workdir
rsync -Cav ./DEBIAN $workdir/
rsync -Cav ./usr $workdir/
# Version in die startup app.pm eintragen
VER=`grep Version $workdir/DEBIAN/control | cut -d ' ' -f2`
sed -i "s@__VERSION__@$VER@g" $workdir/usr/share/perl5/steffen/MojoPlug/NavHelper.pm
echo "Version $VER"
chmod -R g-s $workdir
fakeroot dpkg-deb -b $workdir ./
echo "Installed-Size:"
du -h -k --max-depth=0 $workdir
else
echo Das Script $script muss im aktuellen Verzeichnis liegen!
echo Bitte dorthin wechseln und nochmal probieren.
fi

View File

@@ -0,0 +1,81 @@
package steffen::MojoPlug::NavHelper;
use Mojo::Base 'Mojolicious::Plugin';
our $VERSION = '__VERSION__';
# Navigation Helper für Bootstrap 4,5 navbar
#
# $self->plugin('steffen::MojoPlug::NavHelper' => { verbose => 0, bs => 5 });
#
# $menuitadmin = [
# {
# text => 'Admin Tools', icon => 'fas fa-tools', priv => 'itadmin',
# dropdown => [
# { icon => 'fas fa-file-code', text => 'Powershell Mitarbeiter in AD', href => '/rfs/get_psscript_noadlogin'},
# ]
# },
# ]
#
# in html.ep
# <ul class="navbar-nav">
# <%== nav( $menuitadmin) %>
# </ul>
#
# priv = Privilegienabfrage benötigt das Plugin Authorization dort ist has_priv integriert
# icon = ein css Klassenicon fontawesome funktioniert ganz gut
# navlinkclass = zusätzliche navlinkclasse zum markieren
# iconstyle = htmlstyle
# text = text des links
# textstyle = htmlstyle
# dropdown = Anfang eines Dropdowmenu
# href = Link wird im selben Fenster geöffnet
# xhref = Link wird auf in neuem Fenster geöffnet
# img = Bildurl
sub register {
my ($self, $app, $args) = @_;
my $verbose = $args->{verbose} || 0;
my $bs = $args->{bs} || 4; # oder 5
$app->helper(nav => sub {
my ($c, $nav) = @_;
my $html = '';
foreach my $i (@{$nav}) {
next if ($i->{priv} && ! $c->has_priv($i->{priv}));
if ($i->{dropdown}) {
$html .= '<li class="nav-item dropdown">';
$html .= sprintf('<a href="#" class="nav-link dropdown-toggle %s"', $i->{navlinkclass} ? $i->{navlinkclass} :'').( $bs == 5 ? 'data-bs-toggle' : 'data-toggle' ) .'="dropdown" role="button" aria-haspopup="true" aria-expanded="false">';
$html .= $i->{icon} ? sprintf('<span class="%s p%s-2" style="%s"></span>', $i->{icon}, ( $bs == 5 ? 'e' : 'r' ), ($i->{iconstyle} ? $i->{iconstyle} :'')) : '';
$html .= sprintf('<span style="%s">%s</span>', ($i->{textstyle} ? $i->{textstyle} :''), $i->{text});
$html .= '<span class="caret"></span></a> <ul class="dropdown-menu">';
foreach my $d (@{$i->{dropdown}}) {
next if ($d->{priv} && ! $c->has_priv($d->{priv}));
if ($d->{xhref} ) {
$html .= sprintf('<li><a target="blank" class="dropdown-item form-control" href="%s">', ( $d->{xhref} =~ /http/ ? $d->{xhref} : $c->url_for($d->{xhref}) ) );
} elsif ($d->{href} ) {
$html .= sprintf('<li><a class="dropdown-item form-control" href="%s">', ( $d->{href} =~ /http/ ? $d->{href} : $c->url_for($d->{href}) ) | '' );
}
$html .= $d->{icon} ? sprintf('<span class="%s" style="%s"></span>', $d->{icon}, ($d->{iconstyle} ? $d->{iconstyle} :'') ) : '';
$html .= $d->{img} ? sprintf('<img height="18px" src="%s">', ( $d->{img} =~ /http/ ? $d->{img} : $c->url_for($d->{img}) ) ) : '';
$html .= ( $bs == 5 ? '<span class="ps-2">' : '<span class="pl-2">' );
$html .= sprintf('<span style="%s">%s</span>', ($d->{textstyle} ? $d->{textstyle} :''), $d->{text});
$html .= '</span></a></li>';
}
$html .= '</ul></li> ';
} else {
$html .= sprintf('<li><a class="nav-link %s" href="%s">', $i->{navlinkclass} ? $i->{navlinkclass} :'', ( $i->{href} =~ /http/ ? $i->{href} : $c->url_for($i->{href}) ) );
$html .= $i->{img} ? sprintf('<img height="18px" src="%s">', ( $i->{img} =~ /http/ ? $i->{img} : $c->url_for($i->{img}) ) ) : '';
$html .= $i->{icon} ? sprintf('<span class="%s" style="%s"></span>', $i->{icon}, ($i->{iconstyle} ? $i->{iconstyle} :'')) : '';
$html .= ( $bs == 5 ? '<span class="ps-2">' : '<span class="pl-2">' );
$html .= sprintf('<span style="%s">%s</span>', ($i->{textstyle} ? $i->{textstyle} :''), $i->{text});
$html .= '</span></a></li>';
}
}
return $html;
});
$app->log->info(sprintf('REGISTERED: %s %s', __PACKAGE__, q$Revision: 411 $)) if $verbose;
}
1;