summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Makefile5
-rw-r--r--assets/css/_utils.scss4
-rw-r--r--assets/css/components/_page-header.scss12
-rw-r--r--assets/css/components/_page.scss80
-rw-r--r--assets/css/scopes/_page.scss107
-rw-r--r--assets/css/scopes/_refs.scss9
-rw-r--r--assets/css/style.scss2
-rw-r--r--content/index.md2
-rw-r--r--filters/element_classes.lua15
-rw-r--r--filters/links_to_refs.lua3
-rw-r--r--filters/macros.lua23
-rwxr-xr-xscripts/build_content.sh32
-rwxr-xr-x[-rw-r--r--]scripts/metadata_tpl.json0
-rwxr-xr-xscripts/watch_filters.sh7
-rw-r--r--templates/base.html4
-rw-r--r--templates/pageHeader.html2
-rw-r--r--templates/pageHeaderSm.html2
-rw-r--r--templates/pagelistByYear.html4
18 files changed, 178 insertions, 135 deletions
diff --git a/Makefile b/Makefile
index b8ebbbe..861b8b6 100644
--- a/Makefile
+++ b/Makefile
@@ -37,7 +37,10 @@ watch_templates: build_only
37watch_metadata: build_only 37watch_metadata: build_only
38 @scripts/watch_metadata.sh 38 @scripts/watch_metadata.sh
39 39
40watch: watch_sass watch_content watch_templates watch_metadata 40watch_filters: build_only
41 @scripts/watch_filters.sh
42
43watch: watch_sass watch_content watch_templates watch_metadata watch_filters
41 44
42serve_only: build_only 45serve_only: build_only
43 @python -m http.server --bind 127.0.0.1 --directory output 46 @python -m http.server --bind 127.0.0.1 --directory output
diff --git a/assets/css/_utils.scss b/assets/css/_utils.scss
index e241d84..519a3a7 100644
--- a/assets/css/_utils.scss
+++ b/assets/css/_utils.scss
@@ -15,3 +15,7 @@
15 } 15 }
16 } 16 }
17} 17}
18
19.u-mt0 {
20 margin-top: 0;
21}
diff --git a/assets/css/components/_page-header.scss b/assets/css/components/_page-header.scss
index ee86daf..7cf2aa1 100644
--- a/assets/css/components/_page-header.scss
+++ b/assets/css/components/_page-header.scss
@@ -1,5 +1,7 @@
1.c-page-header { 1.c-page-header {
2 margin-bottom: $line-height * 2em; 2 margin-bottom: $line-height * 2em;
3 margin-left: -1 * $page--item-prefix--width;
4 padding-left: $page--item-prefix--width;
3 overflow: hidden; 5 overflow: hidden;
4 6
5 &::after { 7 &::after {
@@ -9,13 +11,19 @@
9 z-index: -10; 11 z-index: -10;
10 height: $line-height; 12 height: $line-height;
11 margin-top: px-to-em(2px); 13 margin-top: px-to-em(2px);
14 margin-left: -1 * $page--item-prefix--width;
12 padding-top: px-to-em(2px); 15 padding-top: px-to-em(2px);
13 border-top: 1px solid var(--fg-hi); 16 border-top: 1px solid var(--fg-hi);
14 color: var(--fg-hi); 17 color: var(--fg-hi);
15 line-height: $code-block--line-height; 18 line-height: $code-block--line-height;
16 } 19 }
17 20
18 > :first-child { 21 @media (max-width: map-get($breakpoints, 'sm')) {
19 margin-top: 0; 22 margin-left: 0;
23 padding-left: 0;
24
25 &::after {
26 margin-left: 0;
27 }
20 } 28 }
21} 29}
diff --git a/assets/css/components/_page.scss b/assets/css/components/_page.scss
new file mode 100644
index 0000000..21969d7
--- /dev/null
+++ b/assets/css/components/_page.scss
@@ -0,0 +1,80 @@
1.c-page {
2 &__content {
3 padding-left: $page--item-prefix--width;
4
5 > :first-child {
6 margin-top: 0;
7 }
8 }
9
10 &__prefixed {
11 position: relative;
12 margin-left: -1 * $page--item-prefix--width;
13 padding-left: $page--item-prefix--width;
14
15 &::before {
16 display: inline-block;
17 position: absolute;
18 box-sizing: border-box;
19 width: $page--item-prefix--width;
20 margin-left: -1 * $page--item-prefix--width;
21 padding-right: $page--item-prefix--pad;
22 color: var(--page--item-prefix--fg);
23 font-weight: normal;
24 text-align: right;
25 }
26
27 &--h1 {
28 font-size: px-to-em($content--h1--font-size);
29
30 &::before {
31 content: '#';
32 font-size: px-to-em($font-size, $content--h1--font-size);
33 }
34 }
35
36 &--h2::before {
37 content: '##';
38 }
39
40 &--h3::before {
41 content: '###';
42 }
43
44 &--pre {
45 $scale-factor: $font-size / $code-block--font-size;
46
47 margin-top: $line-height * 1em;
48 // margin-left: calc(#{-1 * $page--item-prefix--width} * #{$scale-factor});
49 // padding-left: calc(#{$page--item-prefix--width} * #{$scale-factor});
50
51 &::before {
52 content: str-repeat('``\A', 40);
53 height: 100%;
54 overflow: hidden;
55 color: var(--page--item-prefix--fg);
56 // font-size: px-to-em($font-size, $code-block--font-size);
57 // line-height: $code-block--line-height / $scale-factor;
58 }
59 }
60
61 &--ref::before {
62 content: '->';
63 }
64 }
65
66 @media (max-width: map-get($breakpoints, 'sm')) {
67 &__content {
68 padding-left: 0;
69 }
70
71 &__prefixed {
72 margin-left: 0;
73 padding-left: 0;
74
75 &::before {
76 display: none;
77 }
78 }
79 }
80}
diff --git a/assets/css/scopes/_page.scss b/assets/css/scopes/_page.scss
index 6448d08..bf3df8d 100644
--- a/assets/css/scopes/_page.scss
+++ b/assets/css/scopes/_page.scss
@@ -1,70 +1,4 @@
1.s-page { 1.s-page {
2 &__content {
3 padding-left: $page--item-prefix--width;
4
5 > :first-child {
6 margin-top: 0;
7 }
8 }
9
10 h1,
11 h2,
12 h3,
13 .s-refs li,
14 pre {
15 position: relative;
16 margin-left: -1 * $page--item-prefix--width;
17 padding-left: $page--item-prefix--width;
18
19 &::before {
20 display: inline-block;
21 position: absolute;
22 box-sizing: border-box;
23 width: $page--item-prefix--width;
24 margin-left: -1 * $page--item-prefix--width;
25 padding-right: $page--item-prefix--pad;
26 color: var(--page--item-prefix--fg);
27 font-weight: normal;
28 text-align: right;
29 }
30 }
31
32 h1 {
33 font-size: px-to-em($content--h1--font-size);
34
35 &::before {
36 content: '#';
37 font-size: px-to-em($font-size, $content--h1--font-size);
38 }
39 }
40
41 h2::before {
42 content: '##';
43 }
44
45 h3::before {
46 content: '###';
47 }
48
49 .s-refs li::before {
50 content: '->';
51 }
52
53 pre {
54 margin-top: $line-height * 1em;
55
56 &::before {
57 content: str-repeat('``\A', 40);
58 height: 100%;
59 overflow: hidden;
60 color: var(--page--item-prefix--fg);
61 }
62 }
63
64 hr {
65 margin-left: -1 * $page--item-prefix--width;
66 }
67
68 :link { 2 :link {
69 color: var(--page--link--idle--fg); 3 color: var(--page--link--idle--fg);
70 } 4 }
@@ -80,45 +14,4 @@
80 color: var(--page--link--hover--fg); 14 color: var(--page--link--hover--fg);
81 } 15 }
82 } 16 }
83
84 .c-page-header {
85 margin-left: -1 * $page--item-prefix--width;
86 padding-left: $page--item-prefix--width;
87
88 &::after {
89 margin-left: -1 * $page--item-prefix--width;
90 }
91 }
92
93 @media (max-width: map-get($breakpoints, 'sm')) {
94 &__content {
95 padding-left: 0;
96 }
97
98 h1,
99 h2,
100 h3,
101 .s-refs li,
102 pre {
103 margin-left: 0;
104 padding-left: 0;
105
106 &::before {
107 display: none;
108 }
109 }
110
111 hr {
112 margin-left: 0;
113 }
114
115 .c-page-header {
116 margin-left: 0;
117 padding-left: 0;
118
119 &::after {
120 margin-left: 0;
121 }
122 }
123 }
124} 17}
diff --git a/assets/css/scopes/_refs.scss b/assets/css/scopes/_refs.scss
deleted file mode 100644
index 79434ff..0000000
--- a/assets/css/scopes/_refs.scss
+++ /dev/null
@@ -1,9 +0,0 @@
1.s-refs {
2 li {
3 padding-left: 0;
4
5 &::before {
6 display: none;
7 }
8 }
9}
diff --git a/assets/css/style.scss b/assets/css/style.scss
index 90c1bfc..7986bd9 100644
--- a/assets/css/style.scss
+++ b/assets/css/style.scss
@@ -5,11 +5,11 @@
5@import 'components/spacer'; 5@import 'components/spacer';
6@import 'components/hlist'; 6@import 'components/hlist';
7@import 'components/nav'; 7@import 'components/nav';
8@import 'components/page';
8@import 'components/page-header'; 9@import 'components/page-header';
9 10
10@import 'layouts/container'; 11@import 'layouts/container';
11 12
12@import 'scopes/refs';
13@import 'scopes/page'; 13@import 'scopes/page';
14 14
15@import 'utils'; 15@import 'utils';
diff --git a/content/index.md b/content/index.md
index f9111ef..8c49e44 100644
--- a/content/index.md
+++ b/content/index.md
@@ -22,7 +22,7 @@ Welcome to my website! I'm Volpeon and here's an [inline link](#d).
221. Lorem ipsum dolor sit amet 221. Lorem ipsum dolor sit amet
232. Another item 232. Another item
24 24
25::: { .s-refs } 25::: { macro=refs }
26- [Lorem ipsum dolor sit amet](#a) 26- [Lorem ipsum dolor sit amet](#a)
27- [Another item](#b) 27- [Another item](#b)
28::: 28:::
diff --git a/filters/element_classes.lua b/filters/element_classes.lua
new file mode 100644
index 0000000..643ff75
--- /dev/null
+++ b/filters/element_classes.lua
@@ -0,0 +1,15 @@
1function CodeBlock(el)
2 el.attributes.class = 'c-page__prefixed c-page__prefixed--pre'
3 return el
4end
5
6function Header(el)
7 if el.level == 1 then
8 el.attributes.class = 'c-page__prefixed c-page__prefixed--h1'
9 elseif el.level == 2 then
10 el.attributes.class = 'c-page__prefixed c-page__prefixed--h2'
11 elseif el.level == 3 then
12 el.attributes.class = 'c-page__prefixed c-page__prefixed--h3'
13 end
14 return el
15end
diff --git a/filters/links_to_refs.lua b/filters/links_to_refs.lua
deleted file mode 100644
index f19a0f9..0000000
--- a/filters/links_to_refs.lua
+++ /dev/null
@@ -1,3 +0,0 @@
1function Link (el)
2 return { pandoc.Span(el.content), pandoc.Note { pandoc.Plain(pandoc.Link(el.content, el.target, el.title)) } }
3end
diff --git a/filters/macros.lua b/filters/macros.lua
new file mode 100644
index 0000000..86e94ba
--- /dev/null
+++ b/filters/macros.lua
@@ -0,0 +1,23 @@
1function Div(el)
2 if el.attributes.macro == nil then
3 return el
4 end
5
6 if el.attributes.macro == 'refs' and el.content[1].tag == 'BulletList' then
7 local newchildren = pandoc.List()
8
9 newchildren:insert(pandoc.RawBlock('html', '<ul>'))
10
11 for k, children in ipairs(el.content[1].content) do
12 newchildren:insert(pandoc.RawBlock('html', '<li class="c-page__prefixed c-page__prefixed--ref">'))
13 newchildren:extend(children)
14 newchildren:insert(pandoc.RawBlock('html', '</li>'))
15 end
16
17 newchildren:insert(pandoc.RawBlock('html', '</ul>'))
18
19 el.content = newchildren
20 end
21
22 return el.content
23end
diff --git a/scripts/build_content.sh b/scripts/build_content.sh
index 719b7c9..b258449 100755
--- a/scripts/build_content.sh
+++ b/scripts/build_content.sh
@@ -1,14 +1,31 @@
1#!/bin/bash 1#!/bin/bash
2 2
3CONTENT_DIR="content/" 3CONTENT_DIR="content/"
4FILTERS_DIR="filters/"
4METADATA_DIR="metadata/" 5METADATA_DIR="metadata/"
5TEMPLATES_DIR="templates/" 6TEMPLATES_DIR="templates/"
6OUTPUT_DIR="output/" 7OUTPUT_DIR="output/"
7 8
8CATEGORY_SHORT_LEN=3
9CATEGORY_MAP=$(cat "$METADATA_DIR/categories.json") 9CATEGORY_MAP=$(cat "$METADATA_DIR/categories.json")
10 10
11target_filename () { 11get_filters() {
12 filters_args=""
13
14 mapfile -d $'\0' filters < <(find $FILTERS_DIR \
15 -type f \
16 -name "*.lua" ! -name ".*" \
17 -print0)
18
19 for file in "${filters[@]}"; do
20 filters_args="$filters_args --lua-filter $file"
21 done
22
23 echo $filters_args
24}
25
26FILTERS=$(get_filters)
27
28target_filename() {
12 filename=$1 29 filename=$1
13 filename=${filename#"$CONTENT_DIR"} 30 filename=${filename#"$CONTENT_DIR"}
14 if [ "${filename##*.}" = "md" ]; then 31 if [ "${filename##*.}" = "md" ]; then
@@ -17,7 +34,7 @@ target_filename () {
17 echo "$OUTPUT_DIR$filename" 34 echo "$OUTPUT_DIR$filename"
18} 35}
19 36
20target_url_rel () { 37target_url_rel() {
21 basedir=$1 38 basedir=$1
22 filename=$2 39 filename=$2
23 filename=$(realpath --relative-to="$basedir" "$filename") 40 filename=$(realpath --relative-to="$basedir" "$filename")
@@ -28,7 +45,7 @@ target_url_rel () {
28 echo "$filename" 45 echo "$filename"
29} 46}
30 47
31target_url_abs () { 48target_url_abs() {
32 echo "/$(target_url_rel "$CONTENT_DIR" "$1")" 49 echo "/$(target_url_rel "$CONTENT_DIR" "$1")"
33} 50}
34 51
@@ -148,6 +165,10 @@ handle () {
148 # echo "$(get_metadata "$1")" 165 # echo "$(get_metadata "$1")"
149 echo "$(get_metadata "$1")" > "$subpages_meta_file" 166 echo "$(get_metadata "$1")" > "$subpages_meta_file"
150 167
168 # echo $(pandoc "$1" \
169 # -f markdown \
170 # -t json)
171
151 pandoc "$1" \ 172 pandoc "$1" \
152 -f markdown \ 173 -f markdown \
153 -t html5 \ 174 -t html5 \
@@ -157,7 +178,8 @@ handle () {
157 --metadata section=$section \ 178 --metadata section=$section \
158 --metadata "is$section" \ 179 --metadata "is$section" \
159 --metadata-file metadata/metadata.yaml \ 180 --metadata-file metadata/metadata.yaml \
160 --metadata-file "$subpages_meta_file" 181 --metadata-file "$subpages_meta_file" \
182 $FILTERS
161 # --lua-filter "filters/add_refs.lua" 183 # --lua-filter "filters/add_refs.lua"
162 184
163 rm "$subpages_meta_file" 185 rm "$subpages_meta_file"
diff --git a/scripts/metadata_tpl.json b/scripts/metadata_tpl.json
index 76e4439..76e4439 100644..100755
--- a/scripts/metadata_tpl.json
+++ b/scripts/metadata_tpl.json
diff --git a/scripts/watch_filters.sh b/scripts/watch_filters.sh
new file mode 100755
index 0000000..9bb3b44
--- /dev/null
+++ b/scripts/watch_filters.sh
@@ -0,0 +1,7 @@
1#!/bin/bash
2
3inotifywait -qrme close_write,delete,move --format "%w%f" filters \
4 | while read file
5 do
6 scripts/build_content.sh "all_md"
7 done
diff --git a/templates/base.html b/templates/base.html
index 330e759..3fca9f1 100644
--- a/templates/base.html
+++ b/templates/base.html
@@ -38,8 +38,8 @@
38 </div> 38 </div>
39 </nav> 39 </nav>
40 40
41 <main class="s-page l-container l-container--content l-container--pad-v"> 41 <main class="c-page s-page l-container l-container--content l-container--pad-v">
42 <div class="s-page__content"> 42 <div class="c-page__content">
43 $if(ishome)$ 43 $if(ishome)$
44 <header class="c-page-header u-hidden@sm-down" role="presentation"> 44 <header class="c-page-header u-hidden@sm-down" role="presentation">
45${pageHeader()} 45${pageHeader()}
diff --git a/templates/pageHeader.html b/templates/pageHeader.html
index 40ee251..b44f394 100644
--- a/templates/pageHeader.html
+++ b/templates/pageHeader.html
@@ -7,7 +7,7 @@ $-- '| \__,~"´ /:) / |:\ \ ,~( ) . | | ) `, '
7$-- ___\___.___:____(:/\_-,______\:.\_-,____.__\_.\______.__:___\__.___)_.___,/_____ 7$-- ___\___.___:____(:/\_-,______\:.\_-,____.__\_.\______.__:___\__.___)_.___,/_____
8$-- ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ 8$-- ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
9 9
10<pre class="u-hidden@sm-down"> 10<pre class="c-page__prefixed c-page__prefixed--pre u-mt0 u-hidden@sm-down">
11' | ' ' ' ' ' | | | ' ' 11' | ' ' ' ' ' | | | ' '
12 | ' ' ' <strong>//\_</strong> ' | ' . | ' ' 12 | ' ' ' <strong>//\_</strong> ' | ' . | ' '
13 .| ' <strong>____,...,______..,_~`` -`..,</strong> ' | ' | ' ' 13 .| ' <strong>____,...,______..,_~`` -`..,</strong> ' | ' | ' '
diff --git a/templates/pageHeaderSm.html b/templates/pageHeaderSm.html
index c480773..232b5b2 100644
--- a/templates/pageHeaderSm.html
+++ b/templates/pageHeaderSm.html
@@ -3,7 +3,7 @@ $-- | _.~-"""-----~`` ,-´ ' ' |' | ' '
3$-- '| .´ ,~'\ ).,__,)/,," ' . ' | | | ' .' 3$-- '| .´ ,~'\ ).,__,)/,," ' . ' | | | ' .'
4$-- |_ `~´ (/\\, (/\\, _' '_ _| ' |_ _' '_ 4$-- |_ `~´ (/\\, (/\\, _' '_ _| ' |_ _' '_
5 5
6<pre class="$if(ishome)$u-hidden@sm-up$endif$"> 6<pre class="c-page__prefixed c-page__prefixed--pre u-mt0 $if(ishome)$u-hidden@sm-up$endif$">
7.| <strong> //\__</strong> ' .' | . | ' . ' 7.| <strong> //\__</strong> ' .' | . | ' . '
8 | <strong> _.~-"""-----~`` ,-´</strong> ' ' |' | ' ' 8 | <strong> _.~-"""-----~`` ,-´</strong> ' ' |' | ' '
9'| <strong>.´ ,~'\ ).,__,)/,," </strong> ' . ' | | | ' .' 9'| <strong>.´ ,~'\ ).,__,)/,," </strong> ' . ' | | | ' .'
diff --git a/templates/pagelistByYear.html b/templates/pagelistByYear.html
index 20ce6c4..b884d89 100644
--- a/templates/pagelistByYear.html
+++ b/templates/pagelistByYear.html
@@ -2,9 +2,9 @@ $for(pages)$
2$for(it.by_year)$ 2$for(it.by_year)$
3$-- <hr class="c-spacer" /> 3$-- <hr class="c-spacer" />
4$-- <h2>$it.key$</h2> 4$-- <h2>$it.key$</h2>
5<ul class="s-refs"> 5<ul>
6 $for(it.value)$ 6 $for(it.value)$
7 <li> 7 <li class="c-page__prefixed c-page__prefixed--ref">
8 <a href="$it.url_rel$">$it.category/uppercase$ $it.date$ - $it.title$</a> 8 <a href="$it.url_rel$">$it.category/uppercase$ $it.date$ - $it.title$</a>
9 </li> 9 </li>
10 $endfor$ 10 $endfor$