-
Notifications
You must be signed in to change notification settings - Fork 130
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #599 from hplato/ia7
Ia7 v1.2.301
- Loading branch information
Showing
29 changed files
with
2,052 additions
and
441 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
# Category = IA7 | ||
|
||
#@ IA7 v1.2 : This is a helper utility that can find and update collections.json files | ||
#@ if any structural changes are required. | ||
#@ | ||
#@ v1.2 - add in new login system id 700 | ||
|
||
my $ia7_coll_current_ver = 1.2; | ||
|
||
if ($Startup) { | ||
|
||
my @collection_files = ("$Pgm_Root/data/web/collections.json", | ||
"$config_parms{data_dir}/web/collections.json", | ||
"$config_parms{ia7_data_dir}/collections.json"); | ||
for my $file (@collection_files) { | ||
if (-e $file) { | ||
print_log "[IA7_Collection_Updater] : Checking $file to current version $ia7_coll_current_ver"; | ||
my $json_data; | ||
my $file_data; | ||
eval { | ||
$file_data = file_read($file); | ||
$json_data = decode_json($file_data); #HP, wrap this in eval to prevent MH crashes | ||
}; | ||
|
||
if ($@) { | ||
print_log "[IA7_Collection_Updater] : WARNING: decode_json failed for $file. Please check this file!"; | ||
} else { | ||
my $updated = 0; | ||
|
||
if ((! defined $json_data->{meta}->{version}) or ($json_data->{meta}->{version} < 1.2)) { #IA7 v1.2 required change | ||
$json_data->{700}->{user} = '$Authorized' unless (defined $json_data->{700}->{user}); | ||
my $found = 0; | ||
foreach my $i (@{$json_data->{500}->{children}}) { | ||
$found = 1 if ($i == 700); | ||
} | ||
push (@{$json_data->{500}->{children}},700) unless ($found); | ||
$json_data->{meta}->{version} = "1.2"; | ||
print_log "[IA7_Collection_Updater] : Checking $file to version $ia7_coll_current_ver"; | ||
$updated = 1; | ||
} | ||
if ($updated) { | ||
my $json_newdata = to_json($json_data, {utf8 => 1, pretty => 1}); | ||
my $backup_file = $file . ".v" . $version . ".backup"; | ||
file_write($backup_file,$file_data); | ||
print_log "[IA7_Collection_Updater] : Saved backup " . $file . ".v" . $version . ".backup"; | ||
file_write($file,$json_newdata); | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
# Category = IA7 | ||
|
||
#@ IA7 v1.1 : Enables speech notifications to browsers. | ||
#@ also includes some sample code of how to use other notifications | ||
|
||
if ($Startup or $Reload) { | ||
if (! defined $Info{IPAddress_local}) { | ||
print_log "json_server.pl: \$Info{IPAddress_local} not defined. Json speech disabled"; | ||
} else { | ||
print_log "IA7 Speech Notifications enabled"; | ||
&Speak_parms_add_hook(\&json_speech_enable); | ||
} | ||
} | ||
|
||
$v_ia7_test_sound = new Voice_Cmd ("Test playing a sound"); | ||
$v_ia7_test_banner = new Voice_Cmd("Test [blue,green,yellow,red] Banner Notification"); | ||
|
||
if (my $said = said $v_ia7_test_banner) { | ||
my %data; | ||
$data{text} = "This is a test of the IA7 notification"; | ||
$data{color} = $said; | ||
&json_notification("banner",{%data}); | ||
} | ||
|
||
if (said $v_ia7_test_sound) { | ||
my %data; | ||
$data{url} = "http://" . $Info{IPAddress_local} . ":" . $config_parms{http_port} . "/misc/tellme_welcome.wav"; | ||
&json_notification("sound",{%data}); | ||
} | ||
|
||
sub json_speech_enable { | ||
my ($parms) = @_; | ||
push @{$parms->{web_hook}},\&file_ready_for_ia7; | ||
} | ||
|
||
sub file_ready_for_ia7 { | ||
my (%parms) = @_; | ||
my %data; | ||
$data{mode} = $parms{mode}; | ||
$data{url} = "http://" . $Info{IPAddress_local} . ":" . $config_parms{http_port} . "/" . $parms{web_file}; | ||
$data{text} = $parms{raw_text}; | ||
$data{client} = $parms{requestor}; | ||
&json_notification("speech",{%data}); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.