A mirror of my website's source code.

By using this site, you agree to have cookies stored on your device, strictly for functional purposes, such as storing your session and preferences.

Dismiss

Create list index

steve0greatness,
created on Saturday, 20 January 2024, 06:32:59 (1705732379), received on Monday, 6 May 2024, 02:55:35 (1714964135)
Author identity: Steve0Greatness <75220768+Steve0Greatness@users.noreply.github.com>

50d3cc52a5c80b072e77a165c763e2a6b393fe71

build.py

@@ -185,11 +185,18 @@ def CreateJSONFeed():

                                
                                
                                
                            
                                
                                    
                                        
                                            
                                            def RenderLists():
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                Lists = GetLists()
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                CreateDirectory(BUILD_DIRECTORY + "/list/")
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            ListIndex = "<ul>"
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                for List in Lists:
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                FileLocation = BUILD_DIRECTORY + "/list/" + List["filename"].replace(".yml", ".html")
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                print("%s -> %s" % ("lists/" + List["filename"], FileLocation))
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                with open(FileLocation, "w") as file:
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                    file.write(RenderTemplate("list.html", Content=List["content"], Title=List["title"]))
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                FileLocation = "/list/" + List["filename"].replace(".yml", ".html")
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                Title = List["title"]
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                print("%s -> %s" % ("lists/" + List["filename"], BUILD_DIRECTORY + FileLocation))
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                with open(BUILD_DIRECTORY + FileLocation, "w") as file:
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                    file.write(RenderTemplate("list.html", Content=List["content"], Title=Title))
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                ListIndex += "<li><a href=\"%s\">%s</a></li>" % (FileLocation, Title)
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            ListIndex += "</ul>"
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            print("Building list index")
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            with open(BUILD_DIRECTORY + "/list/index.html", "w") as file:
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                file.write(RenderTemplate("list-index.html", Content=ListIndex))
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                            
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                            if __name__ == "__main__":
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                print("Wiping directory")
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                            
                                

views/list-index.html

@@ -0,0 +1,11 @@

                                
                                
                                
                            
                                
                                    
                                        
                                        {% extends "_layout.html" %}
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                        {% block Head %}
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                        {{super()}}
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                        {% endblock %}
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                        {% block title %}List Index{% endblock %}
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                        {% from "_macros.html" import GenerateBreadcrumbs %}
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                        {% block breadcrumbs %}{{ GenerateBreadcrumbs([{ "href": "/list", "title": "List Index" }]) }}{% endblock %}
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                        {% block content %}
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                        <h1>List Index</h1>
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                        {{ Content }}
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                        {% endblock %}