mirror of
https://gitlab.com/octtspacc/staticoso
synced 2025-03-13 01:30:10 +01:00
Add page ordering support, detach MD support
This commit is contained in:
parent
bccbe2ec64
commit
3fff1e9442
@ -15,6 +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
|
||||||
|
- [ ] Custom page ordering
|
||||||
- [ ] SCSS compilation support for CSS templates
|
- [ ] SCSS compilation support for CSS templates
|
||||||
- [ ] Pug support for base templates and page side parts
|
- [ ] Pug support for base templates and page side parts
|
||||||
- [ ] Differential recompile (to optimize resource waste on non-ephemeral servers)
|
- [ ] Differential recompile (to optimize resource waste on non-ephemeral servers)
|
||||||
|
@ -75,54 +75,36 @@ def PreProcessor(p):
|
|||||||
'Template': 'Standard.html',
|
'Template': 'Standard.html',
|
||||||
'Style': '',
|
'Style': '',
|
||||||
'Index': 'True',
|
'Index': 'True',
|
||||||
'Title': ''}
|
'Title': '',
|
||||||
|
'Order': None}
|
||||||
for l in File.splitlines():
|
for l in File.splitlines():
|
||||||
ls = l.lstrip()
|
ls = l.lstrip()
|
||||||
if p.endswith('.pug'):
|
if ls.startswith('//'):
|
||||||
if ls.startswith('//'):
|
if ls.startswith('// Template: '):
|
||||||
if ls.startswith('// Template: '):
|
Meta['Template'] = ls[len('// Template: '):]
|
||||||
Meta['Template'] = ls[len('// Template: '):]
|
elif ls.startswith('// Background: '):
|
||||||
elif ls.startswith('// Background: '):
|
Meta['Style'] += "#MainBox{Background:" + ls[len('// Background: '):] + ";} "
|
||||||
Meta['Style'] += "#MainBox{Background:" + ls[len('// Background: '):] + ";} "
|
elif ls.startswith('// Style: '):
|
||||||
elif ls.startswith('// Style: '):
|
Meta['Style'] += ls[len('// Style: '):] + ' '
|
||||||
Meta['Style'] += ls[len('// Style: '):] + ' '
|
elif ls.startswith('// Index: '):
|
||||||
elif ls.startswith('// Index: '):
|
Meta['Index'] = ls[len('// Index: '):]
|
||||||
Meta['Index'] += ls[len('// Index: '):] + ' '
|
elif ls.startswith('// Title: '):
|
||||||
elif ls.startswith('// Title: '):
|
Meta['Title'] = ls[len('// Title: '):]
|
||||||
Meta['Title'] += ls[len('// Title: '):] + ' '
|
elif ls.startswith('// Order: '):
|
||||||
elif ls.startswith(('h1', 'h2', 'h3', 'h4', 'h5', 'h6')):
|
Meta['Order'] = int(ls[len('// Order: '):])
|
||||||
if ls[2:].startswith(("(class='NoTitle", '(class="NoTitle')):
|
elif ls.startswith(('h1', 'h2', 'h3', 'h4', 'h5', 'h6')):
|
||||||
|
if ls[2:].startswith(("(class='NoTitle", '(class="NoTitle')):
|
||||||
|
Content += l + '\n'
|
||||||
|
else:
|
||||||
|
Title = '#'*int(ls[1]) + str(ls[3:])
|
||||||
|
Titles += [Title]
|
||||||
|
# We should handle headers that for any reason already have parenthesis
|
||||||
|
if ls[2:] == '(':
|
||||||
Content += l + '\n'
|
Content += l + '\n'
|
||||||
else:
|
else:
|
||||||
Title = '#'*int(ls[1]) + str(ls[3:])
|
Content += GetTitleIdLine(l, Title) + '\n'
|
||||||
Titles += [Title]
|
else:
|
||||||
# We should handle headers that for any reason already have parenthesis
|
Content += l + '\n'
|
||||||
if ls[2:] == '(':
|
|
||||||
Content += l + '\n'
|
|
||||||
else:
|
|
||||||
Content += GetTitleIdLine(l, Title) + '\n'
|
|
||||||
else:
|
|
||||||
Content += l + '\n'
|
|
||||||
elif p.endswith('.md'):
|
|
||||||
if ls.startswith('\%'):
|
|
||||||
Content += ls[1:] + '\n'
|
|
||||||
elif ls.startswith('% - '):
|
|
||||||
Content += '<!-- {} -->'.format(ls[4:]) + '\n'
|
|
||||||
elif ls.startswith('% Template: '):
|
|
||||||
Meta['Template'] = ls[len('% Template: '):]
|
|
||||||
elif ls.startswith('% Background: '):
|
|
||||||
Meta['Style'] += "#MainBox{Background:" + ls[len('% Background: '):] + ";} "
|
|
||||||
elif ls.startswith('% Style: '):
|
|
||||||
Meta['Style'] += ls[len('% Style: '):] + ' '
|
|
||||||
elif ls.startswith('% Index: '):
|
|
||||||
Meta['Index'] += ls[len('% Index: '):] + ' '
|
|
||||||
elif ls.startswith('% Title: '):
|
|
||||||
Meta['Title'] += ls[len('% Title: '):] + ' '
|
|
||||||
else:
|
|
||||||
Content += l + '\n'
|
|
||||||
Heading = ls.split(' ')[0].count('#')
|
|
||||||
if Heading > 0:
|
|
||||||
Titles += [ls]
|
|
||||||
return Content, Titles, Meta
|
return Content, Titles, Meta
|
||||||
|
|
||||||
def PugCompileList(Pages):
|
def PugCompileList(Pages):
|
||||||
@ -150,9 +132,25 @@ def PatchHTML(Template, Parts, HTMLPagesList, Content, Titles, Meta):
|
|||||||
def FileToStr(File, Truncate=''):
|
def FileToStr(File, Truncate=''):
|
||||||
return str(File)[len(Truncate):]
|
return str(File)[len(Truncate):]
|
||||||
|
|
||||||
|
def OrderPages(Old):
|
||||||
|
New = []
|
||||||
|
Max = 0
|
||||||
|
for i,e in enumerate(Old):
|
||||||
|
Curr = e[3]['Order']
|
||||||
|
if Curr > Max:
|
||||||
|
Max = Curr
|
||||||
|
for i in range(Max+1):
|
||||||
|
New += [[]]
|
||||||
|
for i,e in enumerate(Old):
|
||||||
|
New[e[3]['Order']] = e
|
||||||
|
while [] in New:
|
||||||
|
New.remove([])
|
||||||
|
return New
|
||||||
|
|
||||||
def GetHTMLPagesList(Pages, Root):
|
def GetHTMLPagesList(Pages, Root):
|
||||||
List = ''
|
List = ''
|
||||||
LastParent = []
|
LastParent = []
|
||||||
|
Pages = OrderPages(Pages)
|
||||||
for File, Content, Titles, Meta in Pages:
|
for File, Content, Titles, Meta in Pages:
|
||||||
if Meta['Index'] == 'True' and Titles:
|
if Meta['Index'] == 'True' and Titles:
|
||||||
n = File.count('/') + 1
|
n = File.count('/') + 1
|
||||||
@ -218,7 +216,6 @@ def Main(Args):
|
|||||||
|
|
||||||
Templates = LoadFromDir('Templates')
|
Templates = LoadFromDir('Templates')
|
||||||
Parts = LoadFromDir('Parts')
|
Parts = LoadFromDir('Parts')
|
||||||
#HTMLPages = SearchIndexedPages()
|
|
||||||
shutil.copytree('Pages', 'public')
|
shutil.copytree('Pages', 'public')
|
||||||
MakeSite(Templates, Parts, Root)
|
MakeSite(Templates, Parts, Root)
|
||||||
os.system("cp -R Assets/* public/")
|
os.system("cp -R Assets/* public/")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user