| 42 |
} |
} |
| 43 |
} elsif ($path =~ m#^/([0-9a-f]+)\.json$#) { |
} elsif ($path =~ m#^/([0-9a-f]+)\.json$#) { |
| 44 |
my $hash = $1; |
my $hash = $1; |
| 45 |
my ($is_pattern, $entry) = get_entry ($hash); |
my $entry = get_entry_or_fallback_entry ($hash); |
|
unless (defined $entry->{en}) { |
|
|
$entry = get_fallback_entry ($hash); |
|
|
} |
|
|
$entry->{tags} ||= [] if defined $entry->{en}; |
|
|
$entry->{isPattern} = 1 if $is_pattern; |
|
| 46 |
|
|
| 47 |
binmode STDOUT, ':encoding(utf-8)'; |
binmode STDOUT, ':encoding(utf-8)'; |
| 48 |
print "Content-Type: application/json\n\n"; |
print "Content-Type: application/json\n\n"; |
| 50 |
require JSON; |
require JSON; |
| 51 |
print scalar JSON::objToJson ($entry); |
print scalar JSON::objToJson ($entry); |
| 52 |
exit; |
exit; |
| 53 |
|
} elsif ($path eq '/updates.json') { |
| 54 |
|
my $updates = {}; |
| 55 |
|
for (get_modified_hashes ()) { |
| 56 |
|
$updates->{$_} = get_entry_or_fallback_entry ($_); |
| 57 |
|
} |
| 58 |
|
|
| 59 |
|
binmode STDOUT, ':encoding(utf-8)'; |
| 60 |
|
print "Content-Type: application/json\n\n"; |
| 61 |
|
|
| 62 |
|
require JSON; |
| 63 |
|
print scalar JSON::objToJson ($updates); |
| 64 |
|
exit; |
| 65 |
} |
} |
| 66 |
|
|
| 67 |
print q[Content-Type: text/plain ; charset=us-ascii |
print q[Content-Type: text/plain ; charset=us-ascii |