logo

ap-client

Unnamed repository; edit this file 'description' to name the repository.
commit: 602ad2ecdfe40d03778887f666bfae5aa27146d1
Author: Haelwenn (lanodan) Monnier <contact@hacktivis.me>
Date:   Tue,  5 May 2020 03:58:32 +0200

Initial Commit

Diffstat:

Aap-represent.pl54++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 54 insertions(+), 0 deletions(-)

diff --git a/ap-represent.pl b/ap-represent.pl @@ -0,0 +1,54 @@ +#!/usr/bin/env perl +use strict; +use utf8; +no warnings; # Wide Character… + +use JSON::MaybeXS; +use Data::Dumper; + +my $json = JSON::MaybeXS->new(utf8 => 1, pretty => 1); + +sub print_object { + my $object = shift; + + printf '⇒ %s', $object->{"type"}; + printf ' <%s>', $object->{"id"} if $object->{"id"}; + printf ' “%s”', $object->{"name"} if $object->{"name"}; + printf ' @%s', $object->{"preferredUsername"} if $object->{"preferredUsername"}; + printf "\n"; + printf "URL: <%s>\n", $object->{"url"} if $object->{"url"}; + printf "Context: %s\n", $object->{"context"} if $object->{"context"}; + printf "Inbox: <%s>\n", $object->{"inbox"} if $object->{"inbox"}; + printf "Outbox: <%s>\n", $object->{"outbox"} if $object->{"outbox"}; + printf "Previous Page: <%s>\n", $object->{"prev"} if $object->{"prev"}; + printf "Next Page: <%s>\n", $object->{"next"} if $object->{"next"}; + printf "Published: %s\n", $object->{"published"} if $object->{"published"}; + printf "Updated: %s\n", $object->{"updated"} if $object->{"updated"}; + printf "Summary: %s\n", $object->{"summary"} if $object->{"summary"}; + printf "Content: %s\n", $object->{"content"} if $object->{"content"}; + if($object->{"object"}) { + printf "Object: "; + print_object($object->{"object"}); + } + if($object->{"tag"}) { + printf "Tags: "; + print_objects($object->{"tag"}); + } + if($object->{"attachment"}) { + printf "Attachments: "; + print_objects($object->{"attachment"}); + } +} + +sub print_objects { + my $objects = shift; + + printf "\n"; + foreach(@$objects) { + print_object($_); + } +} + +my $blob = $json->decode(<STDIN>); + +print_object($blob);