diff --git a/basant/build/kitaab.py b/basant/build/kitaab.py index a59be40..2d2b47f 100644 --- a/basant/build/kitaab.py +++ b/basant/build/kitaab.py @@ -119,11 +119,11 @@ def generate_html_pages(site_folder, entries, template, sub_pages_list, template name_of_site="Kitaab", page_navigation=nav_html, page_title=entry['title'], build_url=entry['parent_text'], config=config) # Checking if content folder exists - folderExists = os.path.exists(site_folder+entry['folder']) + folderExists = os.path.exists(site_folder + entry['folder']) # If not, create it if config.flat_build == False: if not folderExists: - os.mkdir(site_folder+entry['folder']) + os.mkdir(site_folder + entry['folder']) # Write the HTML file slug_file = site_folder + entry['slug'] @@ -284,7 +284,7 @@ def replacement_function(replace): # TODO gross hardcoded lines = [] # this file should probably be an asset?? - with open('raw/210124-0033.wiki') as f: + with open(config.content_folder[0] + '210124-0033.wiki') as f: lines = f.readlines() lines = lines[-2:] line1 = lines[0].split(',') @@ -383,11 +383,12 @@ def create_entries(pages): # Copy assets to production folder def move_files(site_folder, path): assets = os.listdir(path) + to_copy_to = path.split("basant/")[1] if assets: for asset in assets: asset = os.path.join(path, asset) if os.path.isfile(asset): - shutil.copy(asset, site_folder+path) + shutil.copy(asset, site_folder + to_copy_to) else: print("No assets found!") @@ -443,7 +444,7 @@ def clean_path(path): # last_edit = str(subprocess.check_output('git log -1 --format="%ci" ' + path, shell=True)).replace("b'", "").replace("\\n'", '') # get last edited time from system try: - last_edit = os.path.getmtime('/home/anish/'+path) + last_edit = os.path.getmtime('/home/anish/' + path) last_edit_iso = datetime.fromtimestamp(last_edit) except ValueError: last_edit_iso = datetime.fromtimestamp(0) @@ -556,8 +557,8 @@ def generate_website(): shutil.rmtree(config.build_folder) # Make new folders - os.makedirs(config.build_folder + config.assets_folder) - os.makedirs(config.build_folder + config.medias_folder) + os.makedirs(config.build_folder + 'assets/') + os.makedirs(config.build_folder + 'media/') # Get main html template file_loader = FileSystemLoader('') diff --git a/basant/partial/index_table.html b/basant/partial/index_table.html index f7b2900..e244fb3 100644 --- a/basant/partial/index_table.html +++ b/basant/partial/index_table.html @@ -22,6 +22,8 @@ media="screen" title="no title" charset="utf-8"> + + --!> @@ -40,7 +42,6 @@ media="screen" title="no title" charset="utf-8"> - diff --git a/basant/partial/main.html b/basant/partial/main.html index fcb39e7..e232a7d 100644 --- a/basant/partial/main.html +++ b/basant/partial/main.html @@ -10,37 +10,38 @@ - - + + - - - - - - - - - - - - - - + + + + + + + + + + + + + - + - diff --git a/basant/shared/TagHelper.py b/basant/shared/TagHelper.py index b12e2b3..f4af00f 100644 --- a/basant/shared/TagHelper.py +++ b/basant/shared/TagHelper.py @@ -27,7 +27,7 @@ def untaggedFiles(AllFileList=getAllFiles()): return set.difference(AllFileList, doNotTakeFiles) -def loadTagFile(path=config.files_folder + '/.vimwiki_tags'): +def loadTagFile(path=config.files_folder + '.vimwiki_tags'): # Available file information keys: # opened - was the tag file successfully opened? # error_number - errno value when 'opened' is false diff --git a/basant/shared/config.py b/basant/shared/config.py index f7e1206..228d909 100644 --- a/basant/shared/config.py +++ b/basant/shared/config.py @@ -1,12 +1,12 @@ -content_folder = ['raw'] +content_folder = ['public/'] nav_tags = ['dev', 'way', 'recipe', 'ops', 'blog', 'rock', 'phil', 'story', 'blog', 'untagged'] relative_build_url = "" absolute_build_url = "https://anish.lakhwara.com/" -files_folder = '/home/anish/vimwiki2' +files_folder = 'public/' build_folder = "output/" -assets_folder = "./basant/assets/" -medias_folder = "./basant/media/" +assets_folder = "basant/assets/" +medias_folder = "basant/media/" raw_folder = "raw/" template_main = "./basant/partial/main.html" template_nav = "./basant/partial/nav.html" diff --git a/flake.lock b/flake.lock index 0769ede..a8eb15c 100644 --- a/flake.lock +++ b/flake.lock @@ -30,10 +30,45 @@ "type": "github" } }, + "nixpkgs_2": { + "locked": { + "lastModified": 1649667661, + "narHash": "sha256-9cbstidkXdAC3ZzokV6clgCoeLSbbs2tis9KFsqCzTM=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "a48aeae76ad50bb15ad9bda2cf51d7ae5c621853", + "type": "github" + }, + "original": { + "owner": "nixos", + "repo": "nixpkgs", + "type": "github" + } + }, + "poonam": { + "inputs": { + "nixpkgs": "nixpkgs_2" + }, + "locked": { + "lastModified": 1649834414, + "narHash": "sha256-Wu/PJQ+4KBL7GkAJWDLY6CG7n/GIP9keB1nLvFsEpAw=", + "ref": "main", + "rev": "5e217728465fdd0617c8496dd4059d631b7394ae", + "revCount": 302, + "type": "git", + "url": "ssh://gitea@git.sealight.xyz/aynish/kitaab" + }, + "original": { + "ref": "main", + "type": "git", + "url": "ssh://gitea@git.sealight.xyz/aynish/kitaab" + } + }, "root": { "inputs": { "flake-utils": "flake-utils", - "nixpkgs": "nixpkgs" + "nixpkgs": "nixpkgs", + "poonam": "poonam" } } }, diff --git a/flake.nix b/flake.nix index dec15ff..6b4825f 100644 --- a/flake.nix +++ b/flake.nix @@ -4,21 +4,24 @@ inputs = { nixpkgs.url = "github:nixos/nixpkgs"; flake-utils.url = "github:numtide/flake-utils"; + poonam.url = "git+ssh://gitea@git.sealight.xyz/aynish/kitaab?ref=main"; }; - outputs = { self, nixpkgs, flake-utils }: + outputs = { self, nixpkgs, flake-utils, poonam }: flake-utils.lib.eachDefaultSystem (system: let pkgs = nixpkgs.legacyPackages.${system}; my-python = pkgs.python3; python-with-my-packages = my-python.withPackages (p: with p; [ - icecream - python-ctags3 jinja2 click - pypandoc - # other python packages you want + # other python packages you want in the devShell ]); + python-deps = with pkgs.python3Packages; [ + # Packages necessary at runtime to run build script + jinja2 + python-ctags3 + ]; in { devShell = pkgs.mkShell { @@ -33,26 +36,29 @@ # maybe set more env-vars ''; }; - defaultPackage = pkgs.python3Packages.buildPythonPackage { - # We should probably only call grab from main.py here + packages.basant = pkgs.python3Packages.buildPythonPackage { pname = "basant"; src = ./.; version = "0.1"; - propagatedBuildInputs = [ python-with-my-packages ]; + propagatedBuildInputs = [ python-deps ]; doCheck = false; }; packages.site = pkgs.stdenv.mkDerivation { name = "anish-lakhwara-site"; src = ./.; - buildInputs = [ pkgs.python3 ]; + buildInputs = [ poonam.defaultPackage.${system} self.packages.${system}.basant ]; + configurePhase = '' + cp -r ${poonam.defaultPackage.${system}}/public/ ./ + ''; buildPhase = '' - ${self.defaultPackage.${system}}/bin/main.py + ${self.packages.${system}.basant}/bin/main.py ''; installPhase = '' mkdir -p $out cp -R output/* $out/ ''; }; + defaultPackage = self.packages.${system}.site; #nixosModule = { options, lib, config, pkgs, ... }: # let # serverName = "anish.lakhwara.com";