git.s-ol.nu hw/hw.s-ol.nu / 8de4a8d
update iconlinks s-ol 27 days ago
3 changed file(s) with 5 addition(s) and 195 deletion(s). Raw diff Collapse all Expand all
8282 }),
8383 div({
8484 class = 'icons',
85 iconlink('https://github.com/s-ol', 'https://cdn.jsdelivr.net/npm/simple-icons@latest/icons/github.svg', 'github'),
8685 iconlink('https://merveilles.town/@s_ol', 'https://cdn.jsdelivr.net/npm/simple-icons@latest/icons/mastodon.svg', 'mastodon'),
87 iconlink('https://twitter.com/S0lll0s', 'https://cdn.jsdelivr.net/npm/simple-icons@latest/icons/twitter.svg', 'twitter')
86 iconlink('https://twitter.com/S0lll0s', 'https://cdn.jsdelivr.net/npm/simple-icons@latest/icons/twitter.svg', 'twitter'),
87 iconlink('https://www.youtube.com/channel/UCWBiBzZvRzf0hzHbsJnwqsA', 'https://cdn.jsdelivr.net/npm/simple-icons@latest/icons/youtube.svg', 'youtube'),
88 iconlink('https://instagram.com/s_ol.pics', 'https://cdn.jsdelivr.net/npm/simple-icons@latest/icons/instagram.svg', 'instagram')
8889 })
8990 })
9091 local get_header_tags
+0
-192
$mmm/plugins/layout/converts: text$moonscript -> table.lua less more
0 local header, aside, footer, nav, div, svg, script, g, path, ul, li, h1, span, b, a, img
1 do
2 local _obj_0 = require('mmm.dom')
3 header, aside, footer, nav, div, svg, script, g, path, ul, li, h1, span, b, a, img = _obj_0.header, _obj_0.aside, _obj_0.footer, _obj_0.nav, _obj_0.div, _obj_0.svg, _obj_0.script, _obj_0.g, _obj_0.path, _obj_0.ul, _obj_0.li, _obj_0.h1, _obj_0.span, _obj_0.b, _obj_0.a, _obj_0.img
4 end
5 local navigate_to
6 navigate_to = (require('mmm.mmmfs.util'))(require('mmm.dom')).navigate_to
7 local get_plugins
8 get_plugins = require('mmm.mmmfs.meta').get_plugins
9 local unpack = unpack or table.unpack
10 local pick
11 pick = function(...)
12 local num = select('#', ...)
13 local i = math.ceil(math.random() * num)
14 return (select(i, ...))
15 end
16 local iconlink
17 iconlink = function(href, src, alt, style)
18 return a({
19 class = 'iconlink',
20 target = '_blank',
21 rel = 'me',
22 href = href,
23 img({
24 src = src,
25 alt = alt,
26 style = style
27 })
28 })
29 end
30 local logo = svg({
31 class = 'sun',
32 viewBox = '0 0 1 1',
33 xmlns = 'http://www.w3.org/2000/svg',
34 baseProfile = 'full',
35 version = '1.1',
36 g({
37 transform = 'translate(0.5, 0.52)',
38 g({
39 class = 'circle out',
40 path({
41 fill = 'none',
42 ['stroke-width'] = 0.053,
43 d = 'M 0.5 0.15625 C 0.44839986 0.15625 0.22697194 0.28343797 0.20117188 0.328125 C 0.17537181 0.37281203 0.1753718 0.62718797 0.20117188 0.671875 C 0.22697195 0.71656203 0.44839986 0.84375 0.5 0.84375 C 0.55160014 0.84375 0.77302806 0.71656203 0.79882812 0.671875 C 0.82462819 0.62718797 0.8246282 0.37281203 0.79882812 0.328125 C 0.77302805 0.28343797 0.55160014 0.15625 0.5 0.15625 z',
44 transform = 'translate(-0.5, -0.5)'
45 })
46 }),
47 g({
48 class = 'circle in',
49 path({
50 stroke = 'none',
51 d = 'M 0.50195312 0.38476562 C 0.4851293 0.38476563 0.41466191 0.42683639 0.40625 0.44140625 C 0.39783809 0.45597611 0.39783809 0.53816452 0.40625 0.55273438 C 0.41466191 0.56730423 0.4851293 0.609375 0.50195312 0.609375 C 0.51877695 0.609375 0.59119746 0.56730423 0.59960938 0.55273438 C 0.60802129 0.53816452 0.60802129 0.45597611 0.59960938 0.44140625 C 0.59119746 0.42683639 0.51877695 0.38476562 0.50195312 0.38476562 z',
52 transform = 'translate(-0.5, -0.5)'
53 })
54 })
55 })
56 })
57 local gen_header
58 gen_header = function(self)
59 return header({
60 div({
61 h1({
62 navigate_to('', logo),
63 span({
64 span('kb', {
65 class = 'bold'
66 }),
67 '​',
68 '.s‑ol.nu'
69 })
70 }),
71 "low-profile hexagon keyboards."
72 })
73 })
74 end
75 footer = footer({
76 span({
77 'made with \xe2\x98\xbd by ',
78 a('s-ol', {
79 href = 'https://s-ol.nu'
80 }),
81 ", " .. tostring(os.date('%Y'))
82 }),
83 div({
84 class = 'icons',
85 iconlink('https://github.com/s-ol', 'https://cdn.jsdelivr.net/npm/simple-icons@latest/icons/github.svg', 'github'),
86 iconlink('https://merveilles.town/@s_ol', 'https://cdn.jsdelivr.net/npm/simple-icons@latest/icons/mastodon.svg', 'mastodon'),
87 iconlink('https://twitter.com/S0lll0s', 'https://cdn.jsdelivr.net/npm/simple-icons@latest/icons/twitter.svg', 'twitter')
88 })
89 })
90 local get_header_tags
91 get_header_tags = function(self)
92 local title = (self:get('title: text/plain')) or self:gett('name: alpha')
93 local l
94 l = function(str)
95 str = str:gsub('[%s\n]+$', '')
96 return str:gsub('\n', ' ')
97 end
98 local e
99 e = function(str)
100 return string.format('%q', l(str))
101 end
102 local meta = "\n <meta charset=\"UTF-8\">\n <title>" .. tostring(l(title)) .. "</title>\n "
103 do
104 local page_meta = self:get('_meta: mmm/dom')
105 if page_meta then
106 meta = meta .. page_meta
107 else
108 meta = meta .. "\n <meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">\n\n <meta property=\"og:title\" content=" .. tostring(e(title)) .. " />\n <meta property=\"og:type\" content=\"website\" />\n <meta property=\"og:url\" content=\"https://kb.s-ol.nu" .. tostring(self.path) .. "/\" />\n <meta property=\"og:site_name\" content=\"mmm\" />"
109 do
110 local desc = self:get('description: text/plain')
111 if desc then
112 meta = meta .. "\n <meta property=\"og:description\" content=" .. tostring(e(desc)) .. " />"
113 end
114 end
115 end
116 end
117 return meta
118 end
119 local get_scripts
120 get_scripts = function(self)
121 local scripts = ''
122 for plugin in get_plugins(self) do
123 do
124 local snippet = plugin:get('scripts: text/html+frag')
125 if snippet then
126 scripts = scripts .. snippet
127 end
128 end
129 end
130 return scripts
131 end
132 local render
133 render = function(content, fileder, opts)
134 if opts == nil then
135 opts = { }
136 end
137 opts.meta = opts.meta or get_header_tags(fileder)
138 opts.scripts = opts.scripts or ''
139 if not (opts.noview) then
140 content = [[ <div class="view main">
141 <div class="content">
142 ]] .. content .. [[ </div>
143 </div>
144 ]]
145 end
146 local buf = [[<!DOCTYPE html>
147 <html>
148 <head>]]
149 buf = buf .. (function()
150 if STATIC then
151 return STATIC.style
152 else
153 return "<link rel=\"stylesheet\" type=\"text/css\" href=\"/static/style/:text/css\" />"
154 end
155 end)()
156 buf = buf .. "\n " .. tostring(opts.meta) .. "\n " .. tostring(get_scripts(fileder)) .. "\n </head>\n <body>\n " .. tostring(gen_header(fileder)) .. "\n\n " .. tostring(content) .. "\n\n " .. tostring(footer)
157 buf = buf .. (function()
158 if STATIC then
159 return ''
160 else
161 return [[ <script type="text/javascript" src="/static/highlight-pack/:text/javascript"></script>
162 <script type="text/javascript">hljs.initHighlighting()</script>]]
163 end
164 end)()
165 buf = buf .. opts.scripts
166 if STATIC then
167 buf = buf .. STATIC.scripts
168 end
169 buf = buf .. "\n </body>\n</html>"
170 return buf
171 end
172 return {
173 {
174 inp = 'mmm/dom',
175 out = 'text/html',
176 cost = 3,
177 transform = function(self, html, fileder)
178 return render(html, fileder)
179 end
180 },
181 {
182 inp = 'mmm/dom%+noview',
183 out = 'text/html',
184 cost = 3,
185 transform = function(self, html, fileder)
186 return render(html, fileder, {
187 noview = true
188 })
189 end
190 }
191 }
6060 }
6161 div {
6262 class: 'icons',
63 iconlink 'https://github.com/s-ol', 'https://cdn.jsdelivr.net/npm/simple-icons@latest/icons/github.svg', 'github'
6463 iconlink 'https://merveilles.town/@s_ol', 'https://cdn.jsdelivr.net/npm/simple-icons@latest/icons/mastodon.svg', 'mastodon'
6564 iconlink 'https://twitter.com/S0lll0s', 'https://cdn.jsdelivr.net/npm/simple-icons@latest/icons/twitter.svg', 'twitter'
65 iconlink 'https://www.youtube.com/channel/UCWBiBzZvRzf0hzHbsJnwqsA', 'https://cdn.jsdelivr.net/npm/simple-icons@latest/icons/youtube.svg', 'youtube'
66 iconlink 'https://instagram.com/s_ol.pics', 'https://cdn.jsdelivr.net/npm/simple-icons@latest/icons/instagram.svg', 'instagram'
6667 }
6768 }
6869