mirror of
https://gitlab.com/octtspacc/staticoso
synced 2025-03-12 17:20:22 +01:00
Starting to code categories
This commit is contained in:
parent
2a1a55aa81
commit
de1ddc17ad
@ -15,7 +15,7 @@ Feel free to experiment with all of this stuff!
|
||||
- [pug-cli >= 1.0.0-alpha6](https://npmjs.com/package/pug-cli)
|
||||
|
||||
## Features roadmap
|
||||
- [-] Open Graph support
|
||||
- [ ] Open Graph support
|
||||
- [ ] Custom categories for blog posts
|
||||
- [x] Custom static page parts programmable by context
|
||||
- [x] Handle showing creation and modified date for posts
|
||||
|
@ -120,6 +120,7 @@ def PreProcessor(Path, SiteRoot):
|
||||
'HTMLTitle': '',
|
||||
'Description': '',
|
||||
'Image': '',
|
||||
'Categories': [],
|
||||
'CreatedOn': '',
|
||||
'EditedOn': '',
|
||||
'Order': None}
|
||||
@ -131,12 +132,15 @@ def PreProcessor(Path, SiteRoot):
|
||||
ItemText = '{}: '.format(Item)
|
||||
if lss.startswith(ItemText):
|
||||
Meta[Item] = lss[len(ItemText):]
|
||||
if lss.startswith('Background: '):
|
||||
Meta['Style'] += "#MainBox{Background:" + ls[len('// Background: '):] + ";} "
|
||||
if lss.startswith('Categories: '):
|
||||
for i in lss[len('Categories: '):].split(' '):
|
||||
Meta['Categories'] += [i]
|
||||
elif lss.startswith('Background: '):
|
||||
Meta['Style'] += "#MainBox{Background:" + lss[len('Background: '):] + ";} "
|
||||
elif lss.startswith('Style: '):
|
||||
Meta['Style'] += ls[len('// Style: '):] + ' '
|
||||
Meta['Style'] += lss[len('Style: '):] + ' '
|
||||
elif lss.startswith('Order: '):
|
||||
Meta['Order'] = int(ls[len('// Order: '):])
|
||||
Meta['Order'] = int(lss[len('Order: '):])
|
||||
else:
|
||||
if Path.endswith('.md'):
|
||||
if ls.startswith('#'):
|
||||
@ -233,7 +237,7 @@ def OrderPages(Old):
|
||||
New.remove([])
|
||||
return New
|
||||
|
||||
def GetHTMLPagesList(Pages, SiteRoot, Type='Page'):
|
||||
def GetHTMLPagesList(Pages, SiteRoot, Type='Page', Category=None):
|
||||
List = ''
|
||||
ToPop = []
|
||||
LastParent = []
|
||||
@ -251,7 +255,7 @@ def GetHTMLPagesList(Pages, SiteRoot, Type='Page'):
|
||||
if Type == 'Page':
|
||||
IndexPages = OrderPages(IndexPages)
|
||||
for File, Content, Titles, Meta in IndexPages:
|
||||
if Meta['Type'] == Type and Meta['Index'] == 'True' and GetTitle(Meta, Titles, Prefer='HTMLTitle') != 'Untitled':
|
||||
if Meta['Type'] == Type and Meta['Index'] == 'True' and GetTitle(Meta, Titles, Prefer='HTMLTitle') != 'Untitled' and (not Category or Category in Meta['Categories']):
|
||||
n = File.count('/') + 1
|
||||
if n > 1:
|
||||
CurParent = File.split('/')[:-1]
|
||||
@ -292,7 +296,7 @@ def MakeSite(TemplatesText, PartsText, ContextParts, ContextPartsText, SiteRoot)
|
||||
Pages += [[File, Content, Titles, Meta]]
|
||||
PugCompileList(Pages)
|
||||
HTMLPagesList = GetHTMLPagesList(Pages, SiteRoot, 'Page')
|
||||
Macros['BlogPosts'] = GetHTMLPagesList(Pages, SiteRoot, 'Post')
|
||||
Macros['BlogPosts'] = GetHTMLPagesList(Pages, SiteRoot, 'Post', 'Blog')
|
||||
for File, Content, Titles, Meta in Pages:
|
||||
PagePath = 'public/{}.html'.format(StripExt(File))
|
||||
if File.endswith('.md'):
|
||||
|
Loading…
x
Reference in New Issue
Block a user