mirror of
https://gitlab.com/octtspacc/staticoso
synced 2025-03-13 01:30:10 +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)
|
- [pug-cli >= 1.0.0-alpha6](https://npmjs.com/package/pug-cli)
|
||||||
|
|
||||||
## Features roadmap
|
## Features roadmap
|
||||||
- [-] Open Graph support
|
- [ ] Open Graph support
|
||||||
- [ ] Custom categories for blog posts
|
- [ ] Custom categories for blog posts
|
||||||
- [x] Custom static page parts programmable by context
|
- [x] Custom static page parts programmable by context
|
||||||
- [x] Handle showing creation and modified date for posts
|
- [x] Handle showing creation and modified date for posts
|
||||||
|
@ -120,6 +120,7 @@ def PreProcessor(Path, SiteRoot):
|
|||||||
'HTMLTitle': '',
|
'HTMLTitle': '',
|
||||||
'Description': '',
|
'Description': '',
|
||||||
'Image': '',
|
'Image': '',
|
||||||
|
'Categories': [],
|
||||||
'CreatedOn': '',
|
'CreatedOn': '',
|
||||||
'EditedOn': '',
|
'EditedOn': '',
|
||||||
'Order': None}
|
'Order': None}
|
||||||
@ -131,12 +132,15 @@ def PreProcessor(Path, SiteRoot):
|
|||||||
ItemText = '{}: '.format(Item)
|
ItemText = '{}: '.format(Item)
|
||||||
if lss.startswith(ItemText):
|
if lss.startswith(ItemText):
|
||||||
Meta[Item] = lss[len(ItemText):]
|
Meta[Item] = lss[len(ItemText):]
|
||||||
if lss.startswith('Background: '):
|
if lss.startswith('Categories: '):
|
||||||
Meta['Style'] += "#MainBox{Background:" + ls[len('// Background: '):] + ";} "
|
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: '):
|
elif lss.startswith('Style: '):
|
||||||
Meta['Style'] += ls[len('// Style: '):] + ' '
|
Meta['Style'] += lss[len('Style: '):] + ' '
|
||||||
elif lss.startswith('Order: '):
|
elif lss.startswith('Order: '):
|
||||||
Meta['Order'] = int(ls[len('// Order: '):])
|
Meta['Order'] = int(lss[len('Order: '):])
|
||||||
else:
|
else:
|
||||||
if Path.endswith('.md'):
|
if Path.endswith('.md'):
|
||||||
if ls.startswith('#'):
|
if ls.startswith('#'):
|
||||||
@ -233,7 +237,7 @@ def OrderPages(Old):
|
|||||||
New.remove([])
|
New.remove([])
|
||||||
return New
|
return New
|
||||||
|
|
||||||
def GetHTMLPagesList(Pages, SiteRoot, Type='Page'):
|
def GetHTMLPagesList(Pages, SiteRoot, Type='Page', Category=None):
|
||||||
List = ''
|
List = ''
|
||||||
ToPop = []
|
ToPop = []
|
||||||
LastParent = []
|
LastParent = []
|
||||||
@ -251,7 +255,7 @@ def GetHTMLPagesList(Pages, SiteRoot, Type='Page'):
|
|||||||
if Type == 'Page':
|
if Type == 'Page':
|
||||||
IndexPages = OrderPages(IndexPages)
|
IndexPages = OrderPages(IndexPages)
|
||||||
for File, Content, Titles, Meta in 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
|
n = File.count('/') + 1
|
||||||
if n > 1:
|
if n > 1:
|
||||||
CurParent = File.split('/')[:-1]
|
CurParent = File.split('/')[:-1]
|
||||||
@ -292,7 +296,7 @@ def MakeSite(TemplatesText, PartsText, ContextParts, ContextPartsText, SiteRoot)
|
|||||||
Pages += [[File, Content, Titles, Meta]]
|
Pages += [[File, Content, Titles, Meta]]
|
||||||
PugCompileList(Pages)
|
PugCompileList(Pages)
|
||||||
HTMLPagesList = GetHTMLPagesList(Pages, SiteRoot, 'Page')
|
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:
|
for File, Content, Titles, Meta in Pages:
|
||||||
PagePath = 'public/{}.html'.format(StripExt(File))
|
PagePath = 'public/{}.html'.format(StripExt(File))
|
||||||
if File.endswith('.md'):
|
if File.endswith('.md'):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user