At the base of our application is the HTML pages that are visible to our users. These pages are created using Jinja templates. Jinja is a templating language that allows us to create dynamic HTML pages. This means that we can create pages that change based on the data that we pass to them. The overall style is inspired from the Bootstrap Blog Example and heavily modified.
Base template
The base template is the template that all other templates extend. It contains the basic HTML structure of our pages. It also contains the CSS and JavaScript that is used on all pages. To make styling easier we use Bootstrap. Bootstrap is a CSS framework that provides us with a set of CSS classes that we can use to style our pages and is what all the class tags are.
This page contains a few things that are important to note. The first is the {% block title %}{% endblock %}. This is a block that we can use to set the title of the page. We can set the title of the page by adding a block to our template that extends the base template.
The second thing to note is the {% block content %}{% endblock %}. This is a block that we can use to set the content of the page. We can set the content of the page by adding a block to our template that extends the base template.
Bootstrap is added in through a CDN. This means that we don’t have to download the files and add them to our project. We can just add a link to the files that are hosted on a server somewhere else. This is a great way to add libraries to our project without having to download them. It also means that we don’t have to worry about updating the libraries when new versions are released.
The last thing to note is the {{ url_for('static', filename='style.css') }}. This allows us to provide our own CSS files. We can add our own CSS files to the static folder and then link to them in our templates. This allows us to override the Bootstrap styles and add our own styles to our pages.
Navbar
At the top of our site we need a way to navigate between pages. We can do this by adding a navbar to our base template. The navbar will contain links to the home page, the create page and the search page.
As we want this included on every page we can add it to our base template.
Footer
At the bottom of our site we need a way to navigate back to the top of the page. We can do this by adding a footer to our base template. The footer will contain a link to the top of the page and a link to the Tūhura Tech website.
As we want this included on every page we can add it to our base template.
Home page
Our Home page that will first be seen by our users will contain a preview of all of the posts that have been created. We can create a template for this page that extends the base template and use a post template to display each post.
Post Component
As we will want to show the same preview on different pages, eg. the home page and the search page, we can create a component that we can reuse on different pages.
Post page
As our home page only displays a preview of each post we need a way for our users to view the full post. We can do this by creating a post page that will display the full post. We will also include a form that will allow our users to add comments to the post.
Comment Component
As all comments should follow the same structure we can create a component that we can reuse on different pages for displaying comments.
Create Page
To allow our users to create new posts we need to create a page that allows them to do this. This page will mostly be a form that can send data to our server to create a new post.
Search Page
The search page functions as a simple form with a search input. When the user submits the form the page will have all the results loaded beneath the form.