setup and fix basant with the changes to TagHelper

This commit is contained in:
Anish Lakhwara 2023-04-13 16:18:23 +10:00
parent 15db0ea5c1
commit 36e967f976
6 changed files with 33 additions and 44 deletions

View file

@ -1,5 +1,6 @@
from . import mistune
from basant.shared import TagHelper, config
from poonam import TagHelper
from basant.shared import config
from jinja2 import Environment, FileSystemLoader
import argparse
import glob
@ -57,7 +58,7 @@ def add_file_path(pages, root_dir):
def generate_index_pages(template=config.template_main, template_nav=config.template_nav, template_head=config.template_head):
template = template
all_tags = TagHelper.getAllTags()
all_tags = TagHelper.getAllTags(path=config.files_folder)
for index in all_tags.keys():
pages = all_tags[index]
pages = add_file_path(pages, config.files_folder)
@ -90,7 +91,7 @@ def generate_table_index(template=config.template_index, template_nav=config.tem
file_loader = FileSystemLoader('')
env = Environment(loader=file_loader)
template = env.get_template(template)
all_tags = TagHelper.getAllTags()
all_tags = TagHelper.getAllTags(path=config.files_folder)
parsed_set = {}
for k, v in all_tags.items():
parsed_set[k] = len(v)
@ -445,7 +446,10 @@ def create_entries(pages):
# Copy assets to production folder
def move_files(site_folder, path):
assets = os.listdir(path)
if 'basant/' in path:
to_copy_to = path.split("basant/")[1]
else:
to_copy_to = path
if assets:
for asset in assets:
asset = os.path.join(path, asset)

View file

@ -5,19 +5,11 @@
{% for entry in entries %}
<div style='overflow: hidden; display:flex; justify-content: space-between;position:relative'>
<h3 style='float:left;padding-right:150px'>
{% if title %}
<a href='{{entry['slug']}}'>{{entry["title"]}}</a>
{% else %}
<!--
TODO
Sometimes the entry doesn't output a title and I'm not entirely sure why
--!>
{% if entry['title']|length > 0 %}
{% if entry['title']|length > 1 %}
<a href='{{entry['file']}}.html'>{{entry["title"]}}</a>
{% else %}
<a href='{{entry['file']}}.html'>{{entry['file']}}</a>
{% endif %}
{% endif %}
</h3>
<p style='position:absolute;bottom:0;margin-left:29em'>{{entry['date']}}</p>
</div>

View file

@ -3,7 +3,6 @@ nav_tags = ['dev', 'way', 'recipe', 'ops', 'blog',
relative_build_url = ""
absolute_build_url = "https://anish.lakhwara.com/"
files_folder = 'public/'
_folder = 'public/'
build_folder = "output/"
assets_folder = "./basant/assets/"
medias_folder = "media/"

View file

@ -30,32 +30,19 @@
"type": "github"
}
},
"nixpkgs_2": {
"locked": {
"lastModified": 1662446902,
"narHash": "sha256-Dmsd3jSG2ldZUlhFaIwunqgMf14EEK7ylXpw+OPDLxE=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "3bfaf06b12253ddaafe64a67f4ed39b547d41667",
"type": "github"
},
"original": {
"owner": "nixos",
"repo": "nixpkgs",
"type": "github"
}
},
"poonam": {
"inputs": {
"nixpkgs": "nixpkgs_2",
"nixpkgs": [
"nixpkgs"
],
"vimwiki-cli": "vimwiki-cli"
},
"locked": {
"lastModified": 1680876003,
"narHash": "sha256-3aN6OSLrDpMHgViYr+C0qV7bVULpoN2vkcEdeKPq7B8=",
"lastModified": 1681309221,
"narHash": "sha256-iYin3deklQrF6Hjk8bPzlKleLtBk3QWLfJqWdcqFyAs=",
"ref": "main",
"rev": "65bb6b4d5f1f3e6f022b939b7feaf927c5c712cd",
"revCount": 588,
"rev": "543cbf2c0e3ab3f64738987d818982f1b7446098",
"revCount": 606,
"type": "git",
"url": "ssh://gitea@git.sealight.xyz/aynish/kitaab"
},

View file

@ -5,6 +5,7 @@
nixpkgs.url = "github:nixos/nixpkgs";
flake-utils.url = "github:numtide/flake-utils";
poonam.url = "git+ssh://gitea@git.sealight.xyz/aynish/kitaab?ref=main";
poonam.inputs.nixpkgs.follows = "nixpkgs";
};
outputs = { self, nixpkgs, flake-utils, poonam }:
@ -12,15 +13,19 @@
(system:
let
pkgs = nixpkgs.legacyPackages.${system};
my-python = pkgs.python3;
python-with-my-packages = my-python.withPackages (p: with p; [
my-python = pkgs.python39;
finalPython = my-python.override { packageOverrides = poonam.overlays.default; };
python-with-my-packages = finalPython.withPackages (p: with p; [
jinja2
click
pytest
poonam
python-ctags3
# other python packages you want in the devShell
]);
python-deps = with pkgs.python3Packages; [
python-deps = with finalPython.pkgs.pythonPackages; [
# Packages necessary at runtime to run build script
poonam
jinja2
python-ctags3
];
@ -31,17 +36,18 @@
python-with-my-packages
pkgs.pandoc
self.packages.x86_64-linux.basant
poonam.packages.${system}.poonam
];
shellHook = ''
# PYTHONPATH=${python-with-my-packages}/${python-with-my-packages.sitePackages}
# maybe set more env-vars
'';
};
packages.basant = pkgs.python3Packages.buildPythonPackage {
packages.basant = finalPython.pkgs.pythonPackages.buildPythonApplication {
pname = "basant";
src = ./.;
version = "0.1";
propagatedBuildInputs = [ python-deps ];
version = "0.2";
propagatedBuildInputs = [ poonam.packages.${system}.poonam python-deps ];
doCheck = false;
};
packages.site = pkgs.stdenv.mkDerivation {
@ -50,7 +56,7 @@
buildInputs = [ poonam.defaultPackage.${system} self.packages.${system}.basant ];
configurePhase = ''
cp -r ${poonam.defaultPackage.${system}}/public/ ./
cp -r ${poonam.defaultPackage.${system}}/assets/ ./
cp -r ${poonam.defaultPackage.${system}}/media/ ./
'';
buildPhase = ''
${self.packages.${system}.basant}/bin/main.py

View file

@ -2,8 +2,9 @@ from setuptools import setup, find_packages
setup(
name='basant',
version='0.1',
version='0.2',
author='Anish Lakhwara',
install_requires = [ "jinja2" ],
# TODO: broken because of import stuff, need to refactor app somehow
project_urls={"Source code": "https://git.sealight.xyz/aynish/basant"},
url="https://git.sealight.xyz/aynish/basant",