mirror of
https://gitlab.com/octospacc/WebPinBoard
synced 2025-04-24 07:37:25 +02:00
Add :Closed by default feature, Add autoset main heading
This commit is contained in:
parent
38e94da543
commit
320df24922
@ -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)
|
||||
- [Link 2](example.com)
|
||||
|
93
Source/Generate.py
Normal file → Executable file
93
Source/Generate.py
Normal file → Executable file
@ -35,40 +35,48 @@ BaseHTML = """
|
||||
<div id="Background"> <!-- https://pixelfed.uno/i/web/post/419157143827461664 (CC BY-SA 4.0) -->
|
||||
<img src="https://i.imgur.com/GwCgSFC.png"> <!-- https://i.imgur.com/5bdkMlg.gif -->
|
||||
</div>
|
||||
<div class="InfoWindow">
|
||||
<label for="{TITLE}-Toggle"><p>Info Open/Close</p></label>
|
||||
<input type="checkbox" id="{TITLE}-Toggle">
|
||||
<div class="InfoWindowBody">
|
||||
{INFO}
|
||||
</div>
|
||||
</div>
|
||||
{INFO}
|
||||
{BOARDS}
|
||||
</body>
|
||||
</html>
|
||||
"""
|
||||
|
||||
BoardHTML = """
|
||||
<div class="window">
|
||||
<div class="title-bar">
|
||||
<div class="title-bar-text">
|
||||
{TITLE}
|
||||
</div>
|
||||
<div class="title-bar-controls">
|
||||
<label for="{TITLE}-Toggle"><pre></pre></label>
|
||||
</div>
|
||||
</div>
|
||||
<input type="checkbox" id="{TITLE}-Toggle">
|
||||
<div class="window-body">
|
||||
{CONTENT}
|
||||
</div>
|
||||
InfoHTML = """
|
||||
<div class="InfoWindow">
|
||||
<label for="{TITLE}-Toggle"><p>Info Open/Close</p></label>
|
||||
<input type="checkbox" id="{TITLE}-Toggle" {CHECKBOX}>
|
||||
<div class="InfoWindowBody">
|
||||
<{H}>{TITLE}</{H}>
|
||||
{CONTENT}
|
||||
</div>
|
||||
</div>
|
||||
"""
|
||||
|
||||
# TODO: Just make it work with any heading by itself.. smh
|
||||
MainHeading = 'h3'
|
||||
BoardHTML = """
|
||||
<div class="window">
|
||||
<div class="title-bar">
|
||||
<div class="title-bar-text">
|
||||
{TITLE}
|
||||
</div>
|
||||
<div class="title-bar-controls">
|
||||
<label for="{TITLE}-Toggle"><pre></pre></label>
|
||||
</div>
|
||||
</div>
|
||||
<input type="checkbox" id="{TITLE}-Toggle" {CHECKBOX}>
|
||||
<div class="window-body">
|
||||
{CONTENT}
|
||||
</div>
|
||||
</div>
|
||||
"""
|
||||
|
||||
from markdown import Markdown
|
||||
|
||||
MainHeading = ''
|
||||
|
||||
def SetMainHeading(Data):
|
||||
global MainHeading
|
||||
MainHeading = 'h' + Data.split('<h')[1].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)
|
||||
|
77
Source/index.html
Normal file
77
Source/index.html
Normal file
@ -0,0 +1,77 @@
|
||||
|
||||
<!DOCTYPE html>
|
||||
|
||||
<!--
|
||||
WebPinBoard
|
||||
Copyright (C) 2022, OctoSpacc
|
||||
https://gitlab.com/octospacc
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
-->
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Bachecoctt</title>
|
||||
<link rel="stylesheet" href="https://unpkg.com/98.css"> <!-- Credits: https://github.com/jdan/98.css -->
|
||||
<link rel="stylesheet" href="Style.css">
|
||||
</head>
|
||||
<body>
|
||||
<div id="Background"> <!-- https://pixelfed.uno/i/web/post/419157143827461664 (CC BY-SA 4.0) -->
|
||||
<img src="https://i.imgur.com/GwCgSFC.png"> <!-- https://i.imgur.com/5bdkMlg.gif -->
|
||||
</div>
|
||||
|
||||
<div class="InfoWindow">
|
||||
<label for="Bachecoctt-Toggle"><p>Info Open/Close</p></label>
|
||||
<input type="checkbox" id="Bachecoctt-Toggle" checked>
|
||||
<div class="InfoWindowBody">
|
||||
<h3>Bachecoctt</h3>
|
||||
<p>A collection of some of my saved links and resources,<br />neatly (I hope) categorized for everyone!<br />(and example for my <a href="https://gitlab.com/octospacc/WebPinBoard">WebPinBoard</a> software)</p><ul><li>Data.md file License: <a href="https://creativecommons.org/licenses/by-sa/4.0/">CC BY-SA 4.0</a></li></ul><p>uwu links..</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="window">
|
||||
<div class="title-bar">
|
||||
<div class="title-bar-text">
|
||||
Finestra test
|
||||
</div>
|
||||
<div class="title-bar-controls">
|
||||
<label for="Finestra test-Toggle"><pre></pre></label>
|
||||
</div>
|
||||
</div>
|
||||
<input type="checkbox" id="Finestra test-Toggle" >
|
||||
<div class="window-body">
|
||||
<ul><li><a href="example.com">Link 1</a></li><li><a href="example.com">Link 2</a></li></ul>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="window">
|
||||
<div class="title-bar">
|
||||
<div class="title-bar-text">
|
||||
Finestra test 2
|
||||
</div>
|
||||
<div class="title-bar-controls">
|
||||
<label for="Finestra test 2-Toggle"><pre></pre></label>
|
||||
</div>
|
||||
</div>
|
||||
<input type="checkbox" id="Finestra test 2-Toggle" >
|
||||
<div class="window-body">
|
||||
<ul><li><a href="google.com">Link 1</a></li><li><a href="example.com">Link 2</a></li></ul>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</body>
|
||||
</html>
|
Loading…
x
Reference in New Issue
Block a user