|
@@ -54,6 +54,7 @@ def lang(ctx, value):
|
|
print(f"Not translated phrase: `{value}`")
|
|
print(f"Not translated phrase: `{value}`")
|
|
return value
|
|
return value
|
|
|
|
|
|
|
|
+
|
|
@contextfilter
|
|
@contextfilter
|
|
def lang_url(ctx, value):
|
|
def lang_url(ctx, value):
|
|
name, _ = splitext(ctx.name)
|
|
name, _ = splitext(ctx.name)
|
|
@@ -105,6 +106,7 @@ def compile(env, path, target):
|
|
with open(dst, 'w') as f:
|
|
with open(dst, 'w') as f:
|
|
f.write(output)
|
|
f.write(output)
|
|
|
|
|
|
|
|
+
|
|
def run(args):
|
|
def run(args):
|
|
# Load layout
|
|
# Load layout
|
|
file_loader = FileSystemLoader(args.source)
|
|
file_loader = FileSystemLoader(args.source)
|
|
@@ -121,7 +123,10 @@ def run(args):
|
|
if exists(args.target):
|
|
if exists(args.target):
|
|
rmtree(args.target)
|
|
rmtree(args.target)
|
|
|
|
|
|
- makedirs(args.target)
|
|
|
|
|
|
+ if exists('root'):
|
|
|
|
+ copytree('root', args.target)
|
|
|
|
+ else:
|
|
|
|
+ makedirs(args.target)
|
|
|
|
|
|
compile(env, path, args.target)
|
|
compile(env, path, args.target)
|
|
|
|
|
|
@@ -131,6 +136,7 @@ def run(args):
|
|
env.globals['lang'] = other_lang
|
|
env.globals['lang'] = other_lang
|
|
compile(env, path, args.target)
|
|
compile(env, path, args.target)
|
|
|
|
|
|
|
|
+
|
|
if __name__ == '__main__':
|
|
if __name__ == '__main__':
|
|
parser = argparse.ArgumentParser("Site generator")
|
|
parser = argparse.ArgumentParser("Site generator")
|
|
|
|
|