mirror of
https://github.com/CrispyPin/crispypin.cc.git
synced 2025-02-20 19:54:01 +01:00
switch to a more HTML-friendly <include file.html/> style of includes, fix include markers ending in more than 1 character
This commit is contained in:
parent
3f2d1ee37b
commit
0f1a5a2887
4 changed files with 10 additions and 10 deletions
|
@ -5,8 +5,8 @@ PAGE_DIR = "./pages/"
|
|||
TEMPLATE_DIR = "./templates/"
|
||||
TARGET_DIR = "./docs/"
|
||||
|
||||
INCLUDE_MARKER = "&include("
|
||||
INCLUDE_MARKER_END = ")"
|
||||
INCLUDE_MARKER = "<include "
|
||||
INCLUDE_MARKER_END = "/>"
|
||||
|
||||
def process_dir(path: str = "") -> None:
|
||||
items = os.listdir(PAGE_DIR + path)
|
||||
|
@ -45,14 +45,14 @@ def apply_include(contents: str) -> str:
|
|||
|
||||
def insert_contents(contents, new_contents):
|
||||
index_start, index_end = get_marker_indices(contents)
|
||||
return contents[:index_start] + new_contents + contents[index_end+1:]
|
||||
return contents[:index_start] + new_contents + contents[index_end + len(INCLUDE_MARKER_END):]
|
||||
|
||||
|
||||
def get_included_name(contents):
|
||||
marker_start, marker_end = get_marker_indices(contents)
|
||||
name_start = marker_start + len(INCLUDE_MARKER)
|
||||
name_end = marker_end - len(INCLUDE_MARKER_END)
|
||||
return contents[name_start:name_end + 1]
|
||||
name_end = marker_end
|
||||
return contents[name_start:name_end]
|
||||
|
||||
|
||||
def get_marker_indices(contents: str) -> tuple:
|
||||
|
|
|
@ -8,8 +8,8 @@
|
|||
<title>Document</title>
|
||||
</head>
|
||||
<body>
|
||||
&include(header.html)
|
||||
<include header.html/>
|
||||
<p>fractals go here woo</p>
|
||||
&include(footer.html)
|
||||
<include footer.html/>
|
||||
</body>
|
||||
</html>
|
|
@ -8,9 +8,9 @@
|
|||
<title>CrispyPin.cc</title>
|
||||
</head>
|
||||
<body>
|
||||
&include(header.html)
|
||||
<include header.html/>
|
||||
<h1>Homepage</h1>
|
||||
<p>Lorem, ipsum dolor sit amet consectetur adipisicing elit. Earum exercitationem quod laudantium neque. Dolor qui magnam debitis repellendus assumenda tenetur ab aliquam ea sit in harum facere neque ad nemo vel nesciunt distinctio totam, cupiditate, deleniti nam voluptas quia aperiam.</p>
|
||||
&include(footer.html)
|
||||
<include footer.html/>
|
||||
</body>
|
||||
</html>
|
|
@ -1,4 +1,4 @@
|
|||
<header>
|
||||
<a href="/" id="logo"><img src="/logo.png" alt=""></a>
|
||||
</header>
|
||||
&include(navbar.html)
|
||||
<include navbar.html/>
|
Loading…
Add table
Reference in a new issue