mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-03-10 09:16:53 +00:00
02_HTTPSRV: support tabletui (Forum #37232)
git-svn-id: https://svn.fhem.de/fhem/trunk@8933 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
959b4ab0ba
commit
14623e1910
@ -1,5 +1,6 @@
|
||||
# Add changes at the top of the list. Keep it in ASCII, and 80-char wide.
|
||||
# Do not insert empty lines here, update check depends on it.
|
||||
- feature: 02_HTTPSRV: support tabletui (Forum #37232)
|
||||
- bugfix: SOMFY: Only send stop if position changed
|
||||
improved timing for position update
|
||||
fix typos (go-my instead of go_my)
|
||||
|
@ -13,16 +13,27 @@ use warnings;
|
||||
use vars qw(%data);
|
||||
use HttpUtils;
|
||||
|
||||
my $HTTPSRV_matchlink = "^\/?(([^\/]*(\/[^\/]+)*)\/?)\$";
|
||||
|
||||
#########################
|
||||
sub
|
||||
HTTPSRV_addExtension($$$$) {
|
||||
my ($name,$func,$link,$friendlyname)= @_;
|
||||
|
||||
my $url = "/$link";
|
||||
Log3 $name, 3, "Registering HTTPSRV $name for URL $url...";
|
||||
|
||||
# do some cleanup on link/url
|
||||
# link should really show the link as expected to be called (might include trailing / but no leading /)
|
||||
# url should only contain the directory piece with a leading / but no trailing /
|
||||
# $1 is complete link without potentially leading /
|
||||
# $2 is complete link without potentially leading / and trailing /
|
||||
$link =~ /$HTTPSRV_matchlink/;
|
||||
|
||||
my $url = "/".$2;
|
||||
my $modlink = $1;
|
||||
|
||||
Log3 $name, 3, "Registering HTTPSRV $name for URL $url and assigned link $modlink ...";
|
||||
$data{FWEXT}{$url}{deviceName}= $name;
|
||||
$data{FWEXT}{$url}{FUNC} = $func;
|
||||
$data{FWEXT}{$url}{LINK} = $link;
|
||||
$data{FWEXT}{$url}{LINK} = $modlink;
|
||||
$data{FWEXT}{$url}{NAME} = $friendlyname;
|
||||
}
|
||||
|
||||
@ -30,7 +41,15 @@ sub
|
||||
HTTPSRV_removeExtension($) {
|
||||
my ($link)= @_;
|
||||
|
||||
my $url = "/$link";
|
||||
# do some cleanup on link/url
|
||||
# link should really show the link as expected to be called (might include trailing / but no leading /)
|
||||
# url should only contain the directory piece with a leading / but no trailing /
|
||||
# $1 is complete link without potentially leading /
|
||||
# $2 is complete link without potentially leading / and trailing /
|
||||
$link =~ /$HTTPSRV_matchlink/;
|
||||
|
||||
my $url = "/".$2;
|
||||
|
||||
my $name= $data{FWEXT}{$url}{deviceName};
|
||||
Log3 $name, 3, "Unregistering HTTPSRV $name for URL $url...";
|
||||
delete $data{FWEXT}{$url};
|
||||
@ -70,6 +89,8 @@ HTTPSRV_Define($$) {
|
||||
$hash->{fhem}{directory}= $directory;
|
||||
$hash->{fhem}{friendlyname}= $friendlyname;
|
||||
|
||||
Log3 $name, 3, "$name: new ext defined infix:$infix: dir:$directory:";
|
||||
|
||||
HTTPSRV_addExtension($name, "HTTPSRV_CGI", $infix, $friendlyname);
|
||||
|
||||
$hash->{STATE} = $name;
|
||||
@ -114,17 +135,26 @@ sub HTTPSRV_CGI() {
|
||||
|
||||
my ($request) = @_; # /$infix/filename
|
||||
|
||||
# Debug "request= $request";
|
||||
|
||||
# Match request first without trailing / in the link part
|
||||
if($request =~ m,^(/[^/]+)(/(.*)?)?$,) {
|
||||
my $link= $1;
|
||||
my $filename= $3;
|
||||
my $name;
|
||||
|
||||
# If FWEXT not found for this make a second try with a trailing slash in the link part
|
||||
if(! $data{FWEXT}{$link}) {
|
||||
$link = $link."/";
|
||||
return("text/plain; charset=utf-8", "Illegal request: $request") if(! $data{FWEXT}{$link});
|
||||
}
|
||||
|
||||
# get device name
|
||||
$name= $data{FWEXT}{$link}{deviceName} if($data{FWEXT}{$link});
|
||||
$name= $data{FWEXT}{$link}{deviceName};
|
||||
|
||||
#Debug "link= $link";
|
||||
#Debug "filename= $filename";
|
||||
#Debug "name= $name";
|
||||
# Debug "link= $link";
|
||||
# Debug "filename= $filename";
|
||||
# Debug "name= $name";
|
||||
|
||||
# return error if no such device
|
||||
return("text/plain; charset=utf-8", "No HTTPSRV device for $link") unless($name);
|
||||
@ -146,6 +176,7 @@ sub HTTPSRV_CGI() {
|
||||
|
||||
my $directory= $defs{$name}{fhem}{directory};
|
||||
$filename= "$directory/$filename";
|
||||
#Debug "read filename= $filename";
|
||||
my @contents;
|
||||
if(open(INPUTFILE, $filename)) {
|
||||
binmode(INPUTFILE);
|
||||
|
Loading…
x
Reference in New Issue
Block a user