Add notice macro

This commit is contained in:
rubenwardy 2018-07-20 19:50:19 +01:00
parent d7b7c053de
commit 5614c15b06
No known key found for this signature in database
GPG Key ID: A1E29D52FF81513C
6 changed files with 70 additions and 13 deletions

View File

@ -44,6 +44,12 @@ title: Chapter Name
layout: default layout: default
root: .. root: ..
idx: 4.5 idx: 4.5
long_notice:
level: tip
title: This is a long tip!
message: This is a very long tip, so it would be unreadable if
placed in the main body of the chapter. Therefore,
it is a good idea to put it in the frontmatter instead.
--- ---
## Chapter Name ## Chapter Name
@ -57,6 +63,8 @@ Explain why/how these concepts are useful in modding
## List the ## List the
{% include notice.html notice=page.long_notice %}
Paragraphs Paragraphs
{% highlight lua %} {% highlight lua %}

View File

@ -71,9 +71,7 @@ One such IDE is Eclipse with the Koneki Lua plugin:
## Coding in Lua ## Coding in Lua
<div class="notice"> {% include notice.html level="warning" message="This section is a Work in Progress. May be unclear." %}
This section is a Work in Progress. May be unclear.
</div>
Programs are a series of commands that run one after another. Programs are a series of commands that run one after another.
We call these commands "statements." We call these commands "statements."

View File

@ -116,8 +116,8 @@ minetest.register_craftitem("mymod:mudpie", {
description = "Alien Mud Pie", description = "Alien Mud Pie",
inventory_image = "myfood_mudpie.png", inventory_image = "myfood_mudpie.png",
on_use = function(itemstack, user, pointed_thing) on_use = function(itemstack, user, pointed_thing)
hp_change = 20 local hp_change = 20
replace_with_item = nil local replace_with_item = nil
minetest.chat_send_player(user:get_player_name(), "You ate an alien mud pie!") minetest.chat_send_player(user:get_player_name(), "You ate an alien mud pie!")

View File

@ -233,9 +233,4 @@ end,
## Adding to an existing page ## Adding to an existing page
<div class="notice"> {% include notice.html level="warning" title="To Do" message="This section will be added soon&trade;. This placeholder is just to let you know that it is possible!" %}
<h2>To Do</h2>
This section will be added soon&trade;.
This placeholder is just to let you know that it is possible!
</div>

21
_includes/notice.html Normal file
View File

@ -0,0 +1,21 @@
{% if include.notice %}
{% assign notice=include.notice %}
{% else %}
{% assign notice=include %}
{% endif %}
<div class="notice notice-{{ notice.level }}">
{% if notice.level == "warning" %}
<span></span>
{% else if notice.level == "tip" %}
<span>i</span>
{% else %}
<span>?</span>
{% endif %}
<div>
{% if notice.title %}
<h2>{{ notice.title }}</h2>
{% endif %}
{{ notice.message }}
</div>
</div>

View File

@ -27,19 +27,54 @@ figure {
padding: 0 0 0 6px; padding: 0 0 0 6px;
} }
.notice-danger {
background: #933 !important;
border: 1px solid #c44 !important;
}
.notice-warning {
background: #FED;
border: 1px solid #fc9;
}
.notice-tip {
background: #ccf;
border: 1px solid #66a;
}
.notice-green {
background: #161;
border: 1px solid #393;
}
.notice { .notice {
margin: 10px; margin: 10px;
display: block; display: block;
padding: 5px; padding: 5px;
border: 1px solid orange;
border-radius: 5px; border-radius: 5px;
background: #FFEEDD; position: relative;
}
.notice > span {
position: absolute;
top: 0;
left: 0;
bottom: 0;
width: 40px;
font-size: 24px;
text-align: center;
display: block;
}
.notice > div {
margin-left: 35px;
} }
.notice h2 { .notice h2 {
margin: 0 0 5px 0; margin: 0 0 5px 0;
padding: 0 0 2px 0; padding: 0 0 2px 0;
font-size: 110%;
} }
.header-link, .anchor { .header-link, .anchor {