Commit 6d581ea4 authored by Denis Salem's avatar Denis Salem
Browse files

fix minor bug, add templates deps to themes

parent 00d4d5b8
......@@ -21,7 +21,9 @@ from os.path import expanduser, isdir
from os import listdir
from setuptools import setup
dst_themes_path = expanduser('~')+"/.local/share/VenC/themes/"
homedir = expanduser('~')
dst_themes_path = homedir+"/.local/share/VenC/themes/"
src_themes_path = "share/themes/"
themes = listdir(src_themes_path)
......@@ -42,9 +44,10 @@ for theme in themes:
))
extra_files.append((expanduser('~')+"/.local/share/VenC/embed_providers/", ["share/embed_providers/oembed.json"]))
extra_files.append((expanduser('~')+"/.local/share/VenC/themes_assets", ["share/themes_assets/"+filename for filename in listdir("share/themes_assets")]) )
extra_files.append((expanduser('~')+"/.local/share/VenC/themes_includes", ["share/themes_includes/"+filename for filename in listdir("share/themes_includes")]) )
extra_files.append((homedir+"/.local/share/VenC/embed_providers/", ["share/embed_providers/oembed.json"]))
extra_files.append((homedir+"/.local/share/VenC/themes_assets", ["share/themes_assets/"+filename for filename in listdir("share/themes_assets")]) )
extra_files.append((homedir+"/.local/share/VenC/themes_includes", ["share/themes_includes/"+filename for filename in listdir("share/themes_includes")]) )
extra_files.append((homedir+"/.local/share/VenC/themes_templates", ["share/themes_templates/"+filename for filename in listdir("share/themes_templates")]) )
setup(
name='VenC',
......
......@@ -4,5 +4,5 @@ info:
override:
columns: 1
dependencies: ['VenC-Categories-0.0.0.js']
assets_dependencies: ['VenC-Categories-0.0.0.js']
......@@ -4,4 +4,4 @@ info:
override:
columns: 3
dependencies: ['VenC-Infinite-Scroll-1.1.0.js']
assets_dependencies: ['VenC-Infinite-Scroll-1.1.0.js']
authors: '.:GetBlogAuthors:.'
categories: ''
tags: ''
title: .:GetEntryTitle:.
---VENC-BEGIN-PREVIEW---
---VENC-END-PREVIEW---
This template is designed to work with defaults themes
The following will display aside if used with Academik theme. Otherwise,
it will be display below the current paragraphe.
.:SetStyle:: ::footnote:: A first footnote for the sake of the demonstration:.
You can go directly to [this](#footnote_1) second footnote by clicking the link.
Do not forget to add a line break so the parser will know that the footnote
is not part of this paragraphe
.:SetStyle::footnote_1::footnote::¹ The first argument is the css id name,
the second is the css class name:.
......@@ -72,7 +72,7 @@ def init_theme(argv):
theme_folder = os.path.expanduser("~")+"/.local/share/VenC/themes/"+argv[0]+"/"
else:
die(theme_doesnt_exists.format(argv[0]))
die(messages.theme_doesnt_exists.format(argv[0]))
if not os.path.isdir(theme_folder):
die(messages.file_not_found.format(theme_folder))
......
......@@ -71,7 +71,7 @@ def new_entry(argv):
entry["minute"] = raw_entry_date.minute
entry["date"] = raw_entry_date
entry_date = str(date.month)+'-'+str(date.day)+'-'+str(date.year)+'-'+str(date.hour)+'-'+str(date.minute)
entry_date = date.strftime("%m-%d-%Y-%H-%M")
output_filename = os.getcwd()+'/entries/'+str(entry["ID"])+"__"+entry_date+"__"+entry["title"].replace(' ','_')
stream = codecs.open(output_filename, 'w', encoding="utf-8")
......@@ -79,11 +79,26 @@ def new_entry(argv):
output = yaml.dump(content, default_flow_style=False, allow_unicode=True) + "---VENC-BEGIN-PREVIEW---\n---VENC-END-PREVIEW---\n"
else:
try:
output = open(os.getcwd()+'/templates/'+argv[1], 'r').read().replace(".:GetEntryTitle:.", argv[0])
except FileNotFoundError as e:
die(messages.file_not_found.format(os.getcwd()+"/templates/"+argv[1]))
found_template = False
templates_paths = [
os.getcwd()+'/templates/'+argv[1],
os.path.expanduser("~/.local/share/VenC/themes_templates/"+argv[1])
]
for template_path in templates_paths:
try:
output = open(template_path, 'r').read().replace(".:GetEntryTitle:.", argv[0])
found_template = True
break
except FileNotFoundError:
pass
except PermissionError:
die(messages.wrong_permissions.format(template_path))
if not found_template:
notify(messages.file_not_found.format(templates_paths[0]), color="RED")
die(messages.file_not_found.format(templates_paths[1]))
stream.write(output)
stream.close()
......
#! /usr/bin/env python3
# Copyright 2016, 2018 Denis Salem
# Copyright 2016, 2019 Denis Salem
#
# This file is part of VenC.
#
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment