From 27a254a27df47cac88ce8053b4efe575cf9c481e Mon Sep 17 00:00:00 2001 From: Soispha Date: Sat, 21 Oct 2023 22:30:59 +0200 Subject: feat(hm/conf/firefox): Use the policy.json file for configs --- hm/soispha/conf/firefox/config/bookmarks/lib.nix | 49 ++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 hm/soispha/conf/firefox/config/bookmarks/lib.nix (limited to 'hm/soispha/conf/firefox/config/bookmarks/lib.nix') diff --git a/hm/soispha/conf/firefox/config/bookmarks/lib.nix b/hm/soispha/conf/firefox/config/bookmarks/lib.nix new file mode 100644 index 00000000..d1d89dd2 --- /dev/null +++ b/hm/soispha/conf/firefox/config/bookmarks/lib.nix @@ -0,0 +1,49 @@ +{ + lib, + pkgs, +}: bookmarks: let + indent = level: + lib.concatStringsSep "" (map (lib.const " ") (lib.range 1 level)); + + bookmarkToHTML = indentLevel: bookmark: '' + ${indent indentLevel}
${lib.escapeXML bookmark.name}''; + + directoryToHTML = indentLevel: directory: '' + ${indent indentLevel}
${ + if directory.toolbar + then ''

Bookmarks Toolbar'' + else "

${lib.escapeXML directory.name}" + }

+ ${indent indentLevel}

+ ${allItemsToHTML (indentLevel + 1) directory.bookmarks} + ${indent indentLevel}

''; + + itemToHTMLOrRecurse = indentLevel: item: + if item ? "url" + then bookmarkToHTML indentLevel item + else directoryToHTML indentLevel item; + + allItemsToHTML = indentLevel: bookmarks: + lib.concatStringsSep "\n" + (map (itemToHTMLOrRecurse indentLevel) bookmarks); + + bookmarkEntries = allItemsToHTML 1 bookmarks; +in + pkgs.writeText "firefox-bookmarks.html" '' + + + + Bookmarks +

Bookmarks Menu

+ +

+

Bookmarks Toolbar

+

+ ${bookmarkEntries} +

+

+ '' -- cgit 1.4.1