From 320df24922b1fc5257b53aba89404e7dc42322d6 Mon Sep 17 00:00:00 2001 From: octospacc Date: Wed, 13 Apr 2022 12:17:25 +0200 Subject: [PATCH] Add :Closed by default feature, Add autoset main heading --- Source/Data.md | 4 +- Source/Generate.py | 93 +++++++++++++++++++++++++++++----------------- Source/index.html | 77 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 138 insertions(+), 36 deletions(-) mode change 100644 => 100755 Source/Generate.py create mode 100644 Source/index.html diff --git a/Source/Data.md b/Source/Data.md index 457941f..ca1f847 100644 --- a/Source/Data.md +++ b/Source/Data.md @@ -1,4 +1,4 @@ -### Bachecoctt +### Bachecoctt :Closed A collection of some of my saved links and resources, neatly (I hope) categorized for everyone! @@ -14,4 +14,4 @@ uwu links.. ### Finestra test 2 - [Link 1](google.com) -- [Link 2](example.com) \ No newline at end of file +- [Link 2](example.com) diff --git a/Source/Generate.py b/Source/Generate.py old mode 100644 new mode 100755 index c34c2f6..99172cf --- a/Source/Generate.py +++ b/Source/Generate.py @@ -35,40 +35,48 @@ BaseHTML = """
-
- - -
- {INFO} -
-
+{INFO} {BOARDS} """ -BoardHTML = """ -
-
-
- {TITLE} -
-
- -
-
- -
- {CONTENT} -
+InfoHTML = """ +
+ + +
+ <{H}>{TITLE} + {CONTENT}
+
""" -# TODO: Just make it work with any heading by itself.. smh -MainHeading = 'h3' +BoardHTML = """ +
+
+
+ {TITLE} +
+
+ +
+
+ +
+ {CONTENT} +
+
+""" from markdown import Markdown +MainHeading = '' + +def SetMainHeading(Data): + global MainHeading + MainHeading = 'h' + Data.split('')[0] + def SplitPop(String, Key): List = String.split(Key) for i,s in enumerate(List): @@ -87,31 +95,43 @@ def GetDataHTML(): def GetBoards(Data): Boards = SplitPop(Data, '<{}>'.format(MainHeading)) - - for b in range(len(Boards)): - Boards[b] = '<{}>'.format(MainHeading) + Boards[b] - + for i,b in enumerate(Boards): + Boards[i] = '<{}>'.format(MainHeading) + b return Boards -def GenBoard(Data): +def GetBoardParams(Title): + if Title.endswith(':Closed'): + Checkbox = 'checked' + Title = Title[:-len(':Closed')-1] + else: + Checkbox = '' + return (Title, Checkbox) + +def GenBoard(Data, Template): Elements = SplitPop( SplitPop( Data, '<{}>'.format(MainHeading))[0], ''.format(MainHeading)) - Board = BoardHTML.format( - TITLE=Elements[0], + + Title, Checkbox = GetBoardParams(Elements[0]) + + Board = Template.format( + H=MainHeading, + TITLE=Title, + CHECKBOX=Checkbox, CONTENT=Elements[1] ) return Board def WriteHTML(Info, Boards): - Path = 'WebPinBoard.html' + Path = 'index.html' + InfoBoard = GenBoard(Info, InfoHTML) HTMLBoards = '' for b in Boards: - HTMLBoards += GenBoard(b) + HTMLBoards += GenBoard(b, BoardHTML) Title = SplitPop( SplitPop( @@ -119,13 +139,16 @@ def WriteHTML(Info, Boards): '<{}>'.format(MainHeading))[0], ''.format(MainHeading))[0] + Title, Checkbox = GetBoardParams(Title) + try: with open(Path, 'w') as f: f.write( BaseHTML.format( LICENSE=LICENSE, TITLE=Title, - INFO=Info, + CHECKBOX=Checkbox, + INFO=InfoBoard, BOARDS=HTMLBoards)) return True except Exception: @@ -134,7 +157,9 @@ def WriteHTML(Info, Boards): exit(1) def Main(): - Boards = GetBoards(GetDataHTML()) + Data = GetDataHTML() + SetMainHeading(Data) + Boards = GetBoards(Data) Info = Boards[0] Boards.pop(0) WriteHTML(Info, Boards) diff --git a/Source/index.html b/Source/index.html new file mode 100644 index 0000000..c2061ed --- /dev/null +++ b/Source/index.html @@ -0,0 +1,77 @@ + + + + + + + + + + Bachecoctt + + + + +
+ +
+ +
+ + +
+

Bachecoctt

+

A collection of some of my saved links and resources,
neatly (I hope) categorized for everyone!
(and example for my WebPinBoard software)

uwu links..

+
+
+ + +
+
+
+ Finestra test +
+
+ +
+
+ + +
+ +
+
+
+ Finestra test 2 +
+
+ +
+
+ + +
+ + +