build from poonam, and build the site somewhat correctly

This commit is contained in:
Anish Lakhwara 2022-04-13 19:05:05 +10:00
parent a50b56d7e4
commit d52b9ddd9d
7 changed files with 87 additions and 43 deletions

View file

@ -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('')

View file

@ -22,6 +22,8 @@ media="screen" title="no title" charset="utf-8">
<meta name="twitter:title" content="page_title | config.name_of_site">
<meta name="twitter:image" content="build_urlassets/social.png">
<meta name="twitter:image:alt" content="page_title | config.name_of_site">
<link rel="stylesheet" href="assets/main.css">
--!>
<link rel="apple-touch-icon" sizes="57x57" href="build_urlassets/apple-icon-57x57.png">
<link rel="apple-touch-icon" sizes="60x60" href="build_urlassets/apple-icon-60x60.png">
@ -40,7 +42,6 @@ media="screen" title="no title" charset="utf-8">
<meta name="msapplication-TileImage" content="build_urlassets/ms-icon-144x144.png">
<meta name="theme-color" content="#5927e0">
<link rel="canonical" href="{{build_url}}">
<link rel="stylesheet" href="assets/main.css">
</head>
<body class="flow-large container">

View file

@ -10,37 +10,38 @@
<meta property="og:description"
content="config.site_meta_description">
<meta property="og:site_name" content="{{config.name_of_site}}">
<meta property="og:url" content="build_url">
<meta property="og:image" content="build_urlassets/social.png">
<meta property="og:url" content="{{build_url}}">
<meta property="og:image" content="assets/social.png">
<meta property="og:image:height" content="300">
<meta property="og:image:width" content="300">
<meta property="og:image:type" content="image/jpeg">
<link rel="stylesheet" href="asset/style.css" type="text/css"
<link rel="stylesheet" href="assets/style.css" type="text/css"
media="screen" title="no title" charset="utf-8">
<!-- Mastodon stuff should go here
<meta name="twitter:site" content="config.twitter_name">
<meta name="twitter:title" content="page_title | config.name_of_site">
<meta name="twitter:image" content="build_urlassets/social.png">
<meta name="twitter:image" content="{{build_url}}assets/social.png">
<meta name="twitter:image:alt" content="page_title | config.name_of_site">
<link rel="stylesheet" href="assets/main.css" type="text/css">
--!>
<link rel="apple-touch-icon" sizes="57x57" href="build_urlassets/apple-icon-57x57.png">
<link rel="apple-touch-icon" sizes="60x60" href="build_urlassets/apple-icon-60x60.png">
<link rel="apple-touch-icon" sizes="72x72" href="build_urlassets/apple-icon-72x72.png">
<link rel="apple-touch-icon" sizes="76x76" href="build_urlassets/apple-icon-76x76.png">
<link rel="apple-touch-icon" sizes="114x114" href="build_urlassets/apple-icon-114x114.png">
<link rel="apple-touch-icon" sizes="120x120" href="build_urlassets/apple-icon-120x120.png">
<link rel="apple-touch-icon" sizes="144x144" href="build_urlassets/apple-icon-144x144.png">
<link rel="apple-touch-icon" sizes="152x152" href="build_urlassets/apple-icon-152x152.png">
<link rel="apple-touch-icon" sizes="180x180" href="build_urlassets/apple-icon-180x180.png">
<link rel="icon" type="image/png" sizes="192x192" href="build_urlassets/android-icon-192x192.png">
<link rel="icon" type="image/png" sizes="32x32" href="build_urlassets/favicon-32x32.png">
<link rel="icon" type="image/png" sizes="96x96" href="build_urlassets/favicon-96x96.png">
<link rel="icon" type="image/png" sizes="16x16" href="build_urlassets/favicon-16x16.png">
<link rel="apple-touch-icon" sizes="57x57" href="{{build_url}}assets/apple-icon-57x57.png">
<link rel="apple-touch-icon" sizes="60x60" href="{{build_url}}assets/apple-icon-60x60.png">
<link rel="apple-touch-icon" sizes="72x72" href="{{build_url}}assets/apple-icon-72x72.png">
<link rel="apple-touch-icon" sizes="76x76" href="{{build_url}}assets/apple-icon-76x76.png">
<link rel="apple-touch-icon" sizes="114x114" href="{{build_url}}assets/apple-icon-114x114.png">
<link rel="apple-touch-icon" sizes="120x120" href="{{build_url}}assets/apple-icon-120x120.png">
<link rel="apple-touch-icon" sizes="144x144" href="{{build_url}}assets/apple-icon-144x144.png">
<link rel="apple-touch-icon" sizes="152x152" href="{{build_url}}assets/apple-icon-152x152.png">
<link rel="apple-touch-icon" sizes="180x180" href="{{build_url}}assets/apple-icon-180x180.png">
<link rel="icon" type="image/png" sizes="192x192" href="{{build_url}}assets/android-icon-192x192.png">
<link rel="icon" type="image/png" sizes="32x32" href="{{build_url}}assets/favicon-32x32.png">
<link rel="icon" type="image/png" sizes="96x96" href="{{build_url}}assets/favicon-96x96.png">
<link rel="icon" type="image/png" sizes="16x16" href="{{build_url}}assets/favicon-16x16.png">
<meta name="msapplication-TileColor" content="#5927e0">
<meta name="msapplication-TileImage" content="build_urlassets/ms-icon-144x144.png">
<meta name="msapplication-TileImage" content="{{build_url}}assets/ms-icon-144x144.png">
<meta name="theme-color" content="#5927e0">
<link rel="canonical" href="{{build_url}}">
<link rel="stylesheet" href="assets/main.css">
</head>
<body class="flow-large container">

View file

@ -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

View file

@ -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"

View file

@ -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"
}
}
},

View file

@ -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";