Improved README.md
This commit is contained in:
parent
097eaa0500
commit
872288f63b
2 changed files with 170 additions and 3 deletions
171
README.md
171
README.md
|
@ -1,6 +1,8 @@
|
||||||
# jcal unfucker
|
# jCal unfucker
|
||||||
|
|
||||||
This oneliner converts streaming optimised jCal format from [rfc7265](https://datatracker.ietf.org/doc/rfc7265/) into a developer frendly json structure.
|
This oneliner converts the streaming optimised jCal format known as [rfc7265](https://datatracker.ietf.org/doc/rfc7265/), into a developer frendly json structure.
|
||||||
|
|
||||||
|
This code was made in anger.
|
||||||
|
|
||||||
## The actual code
|
## The actual code
|
||||||
|
|
||||||
|
@ -12,3 +14,168 @@ This oneliner converts streaming optimised jCal format from [rfc7265](https://da
|
||||||
curl -sH 'Accept: application/calendar+json' https://cloud.kraut.space/remote.php/dav/public-calendars/2EkPGt3PF6WwYsA3\?export\&expand\=1\&start\=$(date -d '' +%s)\&end\=$(date -d 'next month' +%s) \
|
curl -sH 'Accept: application/calendar+json' https://cloud.kraut.space/remote.php/dav/public-calendars/2EkPGt3PF6WwYsA3\?export\&expand\=1\&start\=$(date -d '' +%s)\&end\=$(date -d 'next month' +%s) \
|
||||||
| jq '.[2]|map({_type:.[0]}+(.[1]|map({key:.[0],value:.[3]})|from_entries))'
|
| jq '.[2]|map({_type:.[0]}+(.[1]|map({key:.[0],value:.[3]})|from_entries))'
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## Okay, but why tho?
|
||||||
|
|
||||||
|
* OBJECTS WHERE NOT SUPPOSED TO BE STORED IN ARRAYS!
|
||||||
|
* Years of iCalendar, WebDAV and CalDAV, yet NO REAL WEB APIs!
|
||||||
|
* Wanted to hurt youself even more for some kicks? We had an rfc for that: [rfc7529](https://datatracker.ietf.org/doc/rfc7529/)
|
||||||
|
* "Yes, please store the components of the component in arrays of their array! Please fail silently with an empty array if request parameters where invalid." – Statements dreamed up by the uttlery Derenged
|
||||||
|
|
||||||
|
### On a more serious note
|
||||||
|
|
||||||
|
The jCal format may be great for transport and api stability. But if someone actual uses it without an api interface, you can expect bad code that references a lot of array indexes, resulting in unreadable code and longer debug times.
|
||||||
|
|
||||||
|
### Example of the jCal format
|
||||||
|
|
||||||
|
```json
|
||||||
|
[
|
||||||
|
"vcalendar",
|
||||||
|
[
|
||||||
|
[
|
||||||
|
"prodid",
|
||||||
|
{},
|
||||||
|
"text",
|
||||||
|
"-//Sabre//Sabre VObject 4.4.2//EN"
|
||||||
|
],
|
||||||
|
[
|
||||||
|
"calscale",
|
||||||
|
{},
|
||||||
|
"text",
|
||||||
|
"GREGORIAN"
|
||||||
|
],
|
||||||
|
[
|
||||||
|
"version",
|
||||||
|
{},
|
||||||
|
"text",
|
||||||
|
"2.0"
|
||||||
|
],
|
||||||
|
[
|
||||||
|
"x-wr-calname",
|
||||||
|
{},
|
||||||
|
"unknown",
|
||||||
|
"Events im KrautSpace (lbehm)"
|
||||||
|
],
|
||||||
|
[
|
||||||
|
"x-apple-calendar-color",
|
||||||
|
{},
|
||||||
|
"unknown",
|
||||||
|
"#9750A4"
|
||||||
|
],
|
||||||
|
[
|
||||||
|
"refresh-interval",
|
||||||
|
{},
|
||||||
|
"duration",
|
||||||
|
"PT4H"
|
||||||
|
],
|
||||||
|
[
|
||||||
|
"x-published-ttl",
|
||||||
|
{},
|
||||||
|
"unknown",
|
||||||
|
"PT4H"
|
||||||
|
]
|
||||||
|
],
|
||||||
|
[
|
||||||
|
[
|
||||||
|
"vevent",
|
||||||
|
[
|
||||||
|
[
|
||||||
|
"created",
|
||||||
|
{},
|
||||||
|
"date-time",
|
||||||
|
"2023-10-17T21:13:30Z"
|
||||||
|
],
|
||||||
|
[
|
||||||
|
"dtstamp",
|
||||||
|
{},
|
||||||
|
"date-time",
|
||||||
|
"2023-10-17T21:15:47Z"
|
||||||
|
],
|
||||||
|
[
|
||||||
|
"last-modified",
|
||||||
|
{},
|
||||||
|
"date-time",
|
||||||
|
"2023-10-17T21:15:47Z"
|
||||||
|
],
|
||||||
|
[
|
||||||
|
"sequence",
|
||||||
|
{},
|
||||||
|
"integer",
|
||||||
|
3
|
||||||
|
],
|
||||||
|
[
|
||||||
|
"uid",
|
||||||
|
{},
|
||||||
|
"text",
|
||||||
|
"0449bf5c-41c1-4868-9597-618a74f68377"
|
||||||
|
],
|
||||||
|
[
|
||||||
|
"dtstart",
|
||||||
|
{},
|
||||||
|
"date-time",
|
||||||
|
"2023-11-04T13:00:00Z"
|
||||||
|
],
|
||||||
|
[
|
||||||
|
"dtend",
|
||||||
|
{},
|
||||||
|
"date-time",
|
||||||
|
"2023-11-04T18:00:00Z"
|
||||||
|
],
|
||||||
|
[
|
||||||
|
"status",
|
||||||
|
{},
|
||||||
|
"text",
|
||||||
|
"CONFIRMED"
|
||||||
|
],
|
||||||
|
[
|
||||||
|
"summary",
|
||||||
|
{},
|
||||||
|
"text",
|
||||||
|
"Mitgliederversammlung"
|
||||||
|
],
|
||||||
|
[
|
||||||
|
"location",
|
||||||
|
{},
|
||||||
|
"text",
|
||||||
|
"Hackspace Jena e.V."
|
||||||
|
],
|
||||||
|
[
|
||||||
|
"color",
|
||||||
|
{},
|
||||||
|
"unknown",
|
||||||
|
"khaki"
|
||||||
|
],
|
||||||
|
[
|
||||||
|
"description",
|
||||||
|
{},
|
||||||
|
"text",
|
||||||
|
"Für weitere Informationen siehe: https://senf.kraut.space/t/einladung-zur-mitgliederversammlung-2023/205"
|
||||||
|
]
|
||||||
|
],
|
||||||
|
[]
|
||||||
|
]
|
||||||
|
]
|
||||||
|
]
|
||||||
|
```
|
||||||
|
|
||||||
|
### Output of this script for the example input
|
||||||
|
|
||||||
|
```json
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"_type": "vevent",
|
||||||
|
"created": "2023-10-17T21:13:30Z",
|
||||||
|
"dtstamp": "2023-10-17T21:15:47Z",
|
||||||
|
"last-modified": "2023-10-17T21:15:47Z",
|
||||||
|
"sequence": 3,
|
||||||
|
"uid": "0449bf5c-41c1-4868-9597-618a74f68377",
|
||||||
|
"dtstart": "2023-11-04T13:00:00Z",
|
||||||
|
"dtend": "2023-11-04T18:00:00Z",
|
||||||
|
"status": "CONFIRMED",
|
||||||
|
"summary": "Mitgliederversammlung",
|
||||||
|
"location": "Hackspace Jena e.V.",
|
||||||
|
"color": "khaki",
|
||||||
|
"description": "Für weitere Informationen siehe: https://senf.kraut.space/t/einladung-zur-mitgliederversammlung-2023/205"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
```
|
||||||
|
|
Loading…
Reference in a new issue