Skip to content

Commit

Permalink
warn: Reorganize messages object, should make it more clear to maintain
Browse files Browse the repository at this point in the history
Setting it up this way means there is even more of a difference between the scaled levels (level2, level4im, etc.) and singlenotice/singlewarning/custom,
but doing so should make it very straightforward to remove or add templates (pursuant to any discussion in #533).

The only change to the enduser is that this will now generate a submenu category for every grouping, even if there are no templates in that group at that level.  At the moment, this is only the `4im` level for the "Removal of deletion tags" category.  I'm not sure this is a bad thing.

One header was mistmatched ('other editors' versus 'other users'), resolves that.
  • Loading branch information
Amorymeltzer committed Apr 24, 2019
1 parent f11d797 commit d546c31
Show file tree
Hide file tree
Showing 2 changed files with 688 additions and 611 deletions.
61 changes: 61 additions & 0 deletions modules/procjson.pl
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
#!/usr/bin/env perl
# procjson.pl by Amory Meltzer

use strict;
use warnings;
use diagnostics;

my (%store,%catL);
my @cats;
my @levels = qw(1 2 3 4 4im);
my ($uw, $lvl, $lt) = (q{},q{},0);
my $cat = q{};

open my $in, '<', "$ARGV[0]" or die $1;
while (my $l = <$in>) {
chomp $l;
if ($l =~ /^\t\t\t"(uw-.+)(\d(?:im)?)": \{/) { # Level template
($uw,$lvl,$lt) = ($1,$2,$.);
push @{$catL{$cat}}, $uw;
} elsif ($l =~ /^\t\t"(.+)": \{/) { # Category
$cat = $1;
push @cats, $cat;
} elsif ($. == $lt+1) { # label
$store{$cat}{$uw}{$lvl}{label} = $l;
} elsif ($. == $lt+2) { # summary
$store{$cat}{$uw}{$lvl}{summary} = $l;
}
}
close $in or die $1;

# use Data::Dumper;
# print Dumper(%store);

# Uniqify
my %seen;
@cats = grep !$seen{$_}++, @cats;

# process outfile
open my $out, '>', 'out.json' or die $1;
print $out "\tlevels: {\n";
foreach my $group (@cats) {
print $out "\t\t\"$group\": {\n";
# Uniqify
my %seen2;
@{$catL{$group}} = grep !$seen{$_}++, @{$catL{$group}};
foreach my $temp (@{$catL{$group}}) {
print $out "\t\t\t\"$temp\": {\n";
foreach my $level (@levels) {
if ($store{$group}{$temp}{$level}) {
print $out "\t\t\t\tlevel$level: {\n";
print $out "\t$store{$group}{$temp}{$level}{label}\n";
print $out "\t$store{$group}{$temp}{$level}{summary}\n";
print $out "\t\t\t\t},\n";
}
}
print $out "\t\t\t},\n";
}
print $out "\t\t},";
}
print $out '},\n';
close $out or die $1;
Loading

0 comments on commit d546c31

Please sign in to comment.