diff --git a/basant/build/kitaab.py b/basant/build/kitaab.py index 22280c8..9b30c51 100644 --- a/basant/build/kitaab.py +++ b/basant/build/kitaab.py @@ -214,12 +214,13 @@ def get_tags(page): def fix_images_urls(page): regex = r"\!\[.*\]\((.*)\)" matches = re.finditer(regex, page, re.MULTILINE) + media_folder = 'media/' # TODO bad hard code for matchNum, match in enumerate(matches, start=1): for groupNum in range(0, len(match.groups())): captured_group = match.group(groupNum + 1) if captured_group[:4] != "http": - full_url = build_url + config.medias_folder + captured_group + full_url = build_url + media_folder + captured_group page = page.replace(captured_group, full_url) return page @@ -303,8 +304,8 @@ def replacement_function(replace): line2 = lines[1].split(',') line1len = len(line1) line2len = len(line2) - first = line1[random.randrange(line1len)] - second = line2[random.randrange(line2len)] + first = line1[random.randrange(line1len)].strip('\n') + second = line2[random.randrange(line2len)].strip('\n') return first + ' ' + second @@ -535,8 +536,8 @@ def create_rss_feed(rss_entries, rss_template, rss_item_template, site_folder): entry_template = itemTemplate entry_template = entry_template.replace( 'rssItemTitle', rss_entry["title"]) - entry_template = entry_template.replace('rssItemUrl', build_url + - rss_entry["slug"]) + entry_template = entry_template.replace('rssItemUrl', build_url + + rss_entry["slug"]) entry_template = entry_template.replace( 'rssItemDate', rss_entry["iso_date"]) entry_template = entry_template.replace( diff --git a/basant/media/could.png b/basant/media/could.png new file mode 100644 index 0000000..f22853d Binary files /dev/null and b/basant/media/could.png differ diff --git a/basant/media/does.png b/basant/media/does.png new file mode 100644 index 0000000..e77cccd Binary files /dev/null and b/basant/media/does.png differ diff --git a/basant/media/everything.png b/basant/media/everything.png new file mode 100644 index 0000000..5c8030d Binary files /dev/null and b/basant/media/everything.png differ diff --git a/basant/media/rocks.jpg b/basant/media/rocks.jpg new file mode 100644 index 0000000..c350ae1 Binary files /dev/null and b/basant/media/rocks.jpg differ diff --git a/flake.lock b/flake.lock index 9c2b629..e9a6253 100644 --- a/flake.lock +++ b/flake.lock @@ -50,11 +50,11 @@ "nixpkgs": "nixpkgs_2" }, "locked": { - "lastModified": 1649943612, - "narHash": "sha256-SDpQSBgNkfpBCIFnwH7gtDi+Ip0/3QdlGmiumM6W5xA=", + "lastModified": 1650035341, + "narHash": "sha256-vYtvVKRIrdOrsPKr1oVrTj7wzBKeips698TTc/e6gk4=", "ref": "main", - "rev": "c18b26c49ece10fbd770d8422661c34363ecc199", - "revCount": 308, + "rev": "b6b97f649cd41a6dc19430e48a17fcb83a71f735", + "revCount": 324, "type": "git", "url": "ssh://gitea@git.sealight.xyz/aynish/kitaab" }, diff --git a/flake.nix b/flake.nix index 6b4825f..1d05963 100644 --- a/flake.nix +++ b/flake.nix @@ -59,35 +59,62 @@ ''; }; defaultPackage = self.packages.${system}.site; - #nixosModule = { options, lib, config, pkgs, ... }: - # let - # serverName = "anish.lakhwara.com"; - # webRoot = "/var/www/${serverName}"; - # serviceConfig = config.services."${serverName}"; - # options = { - # enable = lib.mkEnableOption "${serverName} service"; - # }; - # in - # { - # options.services.${serverName} = options; - # config = lib.mkIf serviceConfig.enable { - # systemd.services."source-${serverName}" = { - # description = '' - # https://${serverName} source - # ''; - # serviceConfig = { - # Type = "oneshot"; - # }; - # startAt = "*00:00:00"; - # path = with pkgs; [ nix gnutar gzip curl jq ]; - # script = '' - # set -ex + # Test container + nixosConfigurations.container = nixpkgs.lib.nixosSystem { + system = "x86_64-linux"; + modules = [ + self.nixosModule + ({ pkgs, ... }: { + # Only allow this to boot as a container + boot.isContainer = true; + networking.hostName = "basant"; + services."anish.lakhwara.com".enable = true; + }) + ]; + }; - # ln -sfT ${flake.packages.system.site} ${webRoot} - # ''; - # }; - # }; - # }; + # also need a module that refreshes this flake.lock, but maybe that shouldn't live here? + nixosModule = { options, lib, config, pkgs, ... }: + let + serverName = "anish.lakhwara.com"; + webRoot = "/var/www/${serverName}"; + + serviceConfig = config.services."${serverName}"; + options = { + enable = lib.mkEnableOption "${serverName} service"; + }; + in + { + options.services.${serverName} = options; + config = lib.mkIf serviceConfig.enable { + systemd.services."source-${serverName}" = { + description = '' + https://${serverName} source + ''; + wantedBy = [ "multi-user.target" ]; + serviceConfig = { + Type = "oneshot"; + DynamicUser = "yes"; + }; + startAt = "*00:00:00"; + path = with pkgs; [ nix gnutar gzip curl jq ] ++ [ self.packages.${system}.site ]; + script = '' + set -ex + + ln -sfT ${self.packages.${system}.site} ${webRoot} + ''; + }; + # Allow nginx through the firewall + networking.firewall.allowedTCPPorts = [ 80 ]; + services.nginx.enable = true; + services.nginx.virtualHosts.${serverName} = { + forceSSL = true; + enableACME = true; + locations."/" = { root = "${webRoot}"; }; + }; + + }; + }; }); }