commit 054fda391e00e0791c5bd578bf0f5c86e17dca94 Author: b12f Date: Mon Nov 18 17:41:33 2024 +0100 Initial commit diff --git a/convert.ts b/convert.ts new file mode 100644 index 0000000..ab021b9 --- /dev/null +++ b/convert.ts @@ -0,0 +1,43 @@ +const decoder = new TextDecoder("utf-8"); +const data = await Deno.readFile("ical.ics"); +const text = decoder.decode(data); + +function chunk(str, size) { + const numChunks = Math.ceil(str.length / size) + const chunks = new Array(numChunks) + + for (let i = 0, o = 0; i < numChunks; ++i, o += size) { + chunks[i] = str.substr(o, size) + } + + return chunks +} + +const lines = text + .split('\r\n') + .reduce((newics, line) => { + if (line.startsWith(' ')) { + return newics + line.replace(/^ /, ''); + } + + return newics + '\n' + line; + }, "") + .split('\n') + .map(line => line + .replace(/
/g, '\\n') + .replace(/<[^>]*>/g, '') + .replace(/>\\;/g, '>') + .replace(/<\\;/g, '<') + .replace(/ \\;/g, ' ') + .replace(/&\\;/g, '&') + .replace(/"\\;/g, '"') + ) + .reduce((allLines, line) => [ + ...allLines, + chunk(line, 40).join('\r\n '), + ], []) + .join('\r\n'); + +console.log(lines); + + diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..be4bb98 --- /dev/null +++ b/flake.lock @@ -0,0 +1,58 @@ +{ + "nodes": { + "flake-parts": { + "inputs": { + "nixpkgs-lib": "nixpkgs-lib" + }, + "locked": { + "lastModified": 1717285511, + "narHash": "sha256-iKzJcpdXih14qYVcZ9QC9XuZYnPc6T8YImb6dX166kw=", + "owner": "hercules-ci", + "repo": "flake-parts", + "rev": "2a55567fcf15b1b1c7ed712a2c6fadaec7412ea8", + "type": "github" + }, + "original": { + "owner": "hercules-ci", + "repo": "flake-parts", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1717602782, + "narHash": "sha256-pL9jeus5QpX5R+9rsp3hhZ+uplVHscNJh8n8VpqscM0=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "e8057b67ebf307f01bdcc8fba94d94f75039d1f6", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs-lib": { + "locked": { + "lastModified": 1717284937, + "narHash": "sha256-lIbdfCsf8LMFloheeE6N31+BMIeixqyQWbSr2vk79EQ=", + "type": "tarball", + "url": "https://github.com/NixOS/nixpkgs/archive/eb9ceca17df2ea50a250b6b27f7bf6ab0186f198.tar.gz" + }, + "original": { + "type": "tarball", + "url": "https://github.com/NixOS/nixpkgs/archive/eb9ceca17df2ea50a250b6b27f7bf6ab0186f198.tar.gz" + } + }, + "root": { + "inputs": { + "flake-parts": "flake-parts", + "nixpkgs": "nixpkgs" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..cf62f7b --- /dev/null +++ b/flake.nix @@ -0,0 +1,27 @@ +{ + description = "pub.solar website"; + + inputs = { + nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; + flake-parts.url = "github:hercules-ci/flake-parts"; + }; + + outputs = inputs@{ self, ... }: + inputs.flake-parts.lib.mkFlake { inherit inputs; } { + systems = [ "x86_64-linux" "aarch64-linux" ]; + + perSystem = { system, pkgs, config, ... }: { + _module.args = { + inherit inputs; + pkgs = import inputs.nixpkgs { inherit system; }; + }; + + devShells.default = let + in pkgs.mkShell { + buildInputs = with pkgs; [ + deno + ]; + }; + }; + }; +}