Skip to content

Commit

Permalink
Add some global substitutions. Adjust styles
Browse files Browse the repository at this point in the history
- Add the substitution for nav center
- Add the substitution for after-post (usually comment section)
- Block images are not indented
- Add margin to some blog elements
  • Loading branch information
MetroWind committed Oct 1, 2024
1 parent d3c0295 commit 9dd13cd
Show file tree
Hide file tree
Showing 8 changed files with 84 additions and 7 deletions.
2 changes: 2 additions & 0 deletions src/app.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1067,6 +1067,8 @@ nlohmann::json App::baseTemplateData(const httplib::Request& req) const
}
data["stylesheets"] = theme_manager.stylesheets(theme);
data["current_theme"] = theme;
data["nav_center"] = config.substitutions.nav_center;
data["after_post"] = config.substitutions.after_post;
return data;
}

Expand Down
14 changes: 14 additions & 0 deletions src/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,5 +98,19 @@ E<Configuration> Configuration::fromYaml(const std::filesystem::path& path)
{
tree["default-theme"] >> config.default_theme;
}
if(tree["substitutions"].has_key())
{
if(tree["substitutions"]["nav-center"].has_key())
{
tree["substitutions"]["nav-center"] >>
config.substitutions.nav_center;
}
if(tree["substitutions"]["after-post"].has_key())
{
tree["substitutions"]["after-post"] >>
config.substitutions.after_post;
}
}

return E<Configuration>{std::in_place, std::move(config)};
}
7 changes: 7 additions & 0 deletions src/config.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@

#include "error.hpp"

struct Substitutions
{
std::string nav_center;
std::string after_post;
};

struct Configuration
{
using StringMap = std::unordered_map<std::string, std::string>;
Expand All @@ -23,6 +29,7 @@ struct Configuration
std::vector<std::string> languages;
std::string blog_title;
std::string default_theme;
Substitutions substitutions;

StringMap vars;
StringMap custom_vars;
Expand Down
6 changes: 6 additions & 0 deletions templates/footer.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<footer>
<a href="{{ url_for("feed") }}">Feed</a>
<span>
Powered by <a href="https://github.com/MetroWind/planck-blog">Planck Blog</a>
</span>
</footer>
2 changes: 1 addition & 1 deletion templates/nav.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
{% endif %}
</span>

<span id="NavCenter"></span>
<span id="NavCenter">{{ nav_center }}</span>

<span id="NavRight"><label for="SelectTheme">Theme</label>
<select name="theme" id="SelectTheme">
Expand Down
5 changes: 5 additions & 0 deletions templates/post.html
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,12 @@ <h1>{{ post.title }}</h1>
</div>
<div id="PostBody">{{ post.content }}</div>
</article>
<hr/>
<div id="AfterPost">
{{ after_post }}
</div>
</main>
{% include "footer.html" %}
</div>
</body>
</html>
19 changes: 19 additions & 0 deletions themes/generic/1-styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@ body
line-height: 1.5;
}

pre
{
line-height: 1.3;
}

h1, h2, h3, h4, h5, h6
{
margin: 1.5em 0;
Expand Down Expand Up @@ -66,6 +71,20 @@ code, pre
display: none;
}

nav
{
display: flex;
justify-content: space-between;
align-items: center;
}

footer
{
display: flex;
justify-content: center;
gap: 4em;
}

#Post img
{
max-width: 100%;
Expand Down
36 changes: 30 additions & 6 deletions themes/planck/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ body
font-size: 19px;
}

nav
nav, footer
{
background-color: var(--color-alt-bg);
font-size: 80%;
Expand All @@ -34,6 +34,16 @@ code, pre
font-size: 95%;
}

pre, ul, ol
{
margin: 0.8em 0;
}

nav ul
{
margin: 0;
}

p
{
margin: unset;
Expand Down Expand Up @@ -65,11 +75,20 @@ p:first-of-type, pre p, h2 + p, h3 + p, h4 + p, h5 + p, h6 + p
text-indent: unset;
}

nav
.imageblock, #Post > #PostBody p:has(> img:only-child)
{
text-align: center;
text-indent: 0px;
margin-top: 0.7em;
margin-bottom: 0.7em;
}

hr
{
display: flex;
justify-content: space-between;
align-items: center;
width: 64px;
height: 4px;
background-color: var(--color-alt-bg);
border: none;
}

#Menu
Expand Down Expand Up @@ -157,7 +176,12 @@ h1.PostTitle > a

#PostBody
{
margin: 1em 0 4em 0;
margin: 1em 0 3em 0;
}

#AfterPost
{
margin: 3em 0;
}

#FormPost
Expand Down

0 comments on commit 9dd13cd

Please sign in to comment.