Add OpenGraph data
authorLanius Trolling <lanius@laniustrolling.dev>
Wed, 2 Aug 2023 16:27:22 +0000 (12:27 -0400)
committerLanius Trolling <lanius@laniustrolling.dev>
Wed, 2 Aug 2023 16:27:22 +0000 (12:27 -0400)
graphics/icon.svg [deleted file]
src/main/kotlin/info/mechyrdia/lore/parser_tags.kt
src/main/kotlin/info/mechyrdia/lore/parser_toc.kt
src/main/kotlin/info/mechyrdia/lore/view_og.kt [new file with mode: 0644]
src/main/kotlin/info/mechyrdia/lore/view_tpl.kt
src/main/kotlin/info/mechyrdia/lore/views_lore.kt
src/main/resources/static/images/icon.png

diff --git a/graphics/icon.svg b/graphics/icon.svg
deleted file mode 100644 (file)
index a2889bf..0000000
+++ /dev/null
@@ -1,60 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<svg
-   version="1.1"
-   viewBox="0 -24 128 128"
-   height="256px"
-   width="256px"
-   id="svg191"
-   sodipodi:docname="icon.svg"
-   inkscape:export-filename="icon.png"
-   inkscape:export-xdpi="192"
-   inkscape:export-ydpi="192"
-   inkscape:version="1.2 (dc2aedaf03, 2022-05-15)"
-   xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
-   xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
-   xmlns="http://www.w3.org/2000/svg"
-   xmlns:svg="http://www.w3.org/2000/svg">
-  <sodipodi:namedview
-     id="namedview193"
-     pagecolor="#ffffff"
-     bordercolor="#000000"
-     borderopacity="0.25"
-     inkscape:showpageshadow="2"
-     inkscape:pageopacity="0.0"
-     inkscape:pagecheckerboard="0"
-     inkscape:deskcolor="#d1d1d1"
-     showgrid="false"
-     inkscape:zoom="5.1484375"
-     inkscape:cx="118.48255"
-     inkscape:cy="128"
-     inkscape:window-width="2560"
-     inkscape:window-height="1529"
-     inkscape:window-x="-8"
-     inkscape:window-y="-8"
-     inkscape:window-maximized="1"
-     inkscape:current-layer="svg191" />
-  <defs
-     id="defs187">
-    <linearGradient
-       id="linearGradient1830"
-       x1="64"
-       y1="16"
-       x2="64"
-       y2="96"
-       gradientUnits="userSpaceOnUse">
-      <stop
-         style="stop-color:#ec6;stop-opacity:1;"
-         offset="0"
-         id="stop182" />
-      <stop
-         style="stop-color:#a82;stop-opacity:1;"
-         offset="1"
-         id="stop184" />
-    </linearGradient>
-  </defs>
-  <path
-     d="m 61.16257,93.263012 c -3.44507,-3.930396 -3.52089,-4.721141 -1.03012,-10.743918 0.33698,-0.814847 -0.2512,-0.522102 -2.0086,0.999736 -1.46772,1.270948 -3.32126,2.282339 -4.52745,2.470407 -3.70647,0.577895 -4.88897,1.522419 -4.88897,3.904963 0,1.172539 -0.15243,2.131687 -0.33876,2.131497 -0.95899,-10e-4 -2.22321,-2.351522 -2.22321,-4.13342 0,-2.61498 1.40189,-3.895764 5.88111,-5.373183 2.68797,-0.886587 3.79105,-1.603638 4.7841,-3.109906 2.13383,-3.236559 1.65195,-3.699409 -1.85349,-1.780197 -3.58024,1.960136 -6.47342,2.197781 -9.89417,0.812712 -1.82807,-0.740201 -2.48994,-0.777661 -3.56982,-0.201824 -2.67527,1.426477 -2.89576,3.509479 -0.63288,5.979081 1.10308,1.203848 1.25303,1.573983 0.52276,1.290423 -0.56321,-0.218848 -1.12457,-0.397668 -1.24748,-0.397668 -0.59291,0 -1.9607,-3.603152 -1.9607,-5.165088 0,-2.88879 2.53204,-4.048241 8.84651,-4.05088 7.20065,-0.0021 10.12228,-1.607271 12.03292,-6.607148 1.15288,-3.016934 0.93563,-4.275939 -0.81068,-4.698115 -2.37136,-0.573261 -2.98896,-1.314436 -2.98896,-3.587072 0,-2.041511 0.014,-2.053993 0.88627,-0.793677 1.17579,1.698745 2.85212,1.621264 4.02226,-0.185926 1.20148,-1.855613 0.45666,-4.799559 -1.95269,-7.718093 l -1.63691,-1.982853 -2.0394,2.063806 c -1.12166,1.135047 -2.59628,3.168409 -3.27693,4.518546 -0.93876,1.862116 -1.36132,2.259889 -1.75015,1.647481 -0.40207,-0.633205 -0.93799,-0.310288 -2.48509,1.497239 -2.78986,3.259513 -2.6276,3.743399 1.25839,3.752744 4.27516,0.0112 5.83559,0.469438 5.83559,1.717158 0,0.558007 0.3843,1.337277 0.854,1.731767 0.88033,0.739354 1.11302,2.679469 0.51157,4.265543 -0.2886,0.761111 -0.50639,0.700606 -1.38623,-0.38497 -0.90978,-1.122573 -1.19778,-1.192977 -2.24271,-0.548283 -1.55406,0.95879 -2.38299,0.407014 -1.95867,-1.303787 0.36005,-1.45177 -0.97514,-2.609136 -2.99943,-2.599972 -1.54747,0.007 -10.82875,7.185267 -11.29666,8.736941 -0.58944,1.954606 -1.95799,3.328664 -2.93679,2.94856 -0.50138,-0.194655 -1.4406,0.311226 -2.28142,1.228868 -0.78608,0.857871 -1.53258,1.455172 -1.65888,1.327379 -0.12629,-0.127913 0.24806,-1.758824 0.83193,-3.624483 0.85718,-2.738917 1.43321,-3.598672 2.99156,-4.465035 2.07743,-1.154992 6.33191,-5.063098 5.9417,-5.457987 -0.13049,-0.132169 -1.52077,0.19107 -3.08942,0.718479 -1.96373,0.660038 -2.7584,1.205752 -2.55129,1.751929 0.4023,1.060891 -3.92453,2.28628 -5.34895,1.514844 -1.10459,-0.598239 -3.96056,-0.232556 -4.4506,0.569836 -0.49709,0.813944 -1.95063,0.584147 -1.95063,-0.308363 0,-0.448666 1.12468,-2.037834 2.49929,-3.531543 2.23398,-2.427439 2.70238,-2.683985 4.41228,-2.416574 2.05275,0.321055 7.89091,-0.62617 7.89091,-1.280273 0,-0.217273 -1.9317,-0.819481 -4.29269,-1.337956 -3.33459,-0.732276 -4.60873,-0.796947 -5.70872,-0.289813 -1.06551,0.4913 -1.58128,0.485657 -2.08375,-0.02282 -0.96559,-0.977131 -2.03422,-0.836191 -3.91042,0.515759 -1.65061,1.189399 -1.65353,1.189441 -1.65353,0.02667 0,-0.640528 0.66403,-1.630408 1.47561,-2.199706 0.81161,-0.56934 1.89333,-1.488838 2.40384,-2.043393 1.23764,-1.34432 3.03575,-1.272887 4.87833,0.193759 1.48668,1.183435 8.3452,2.769222 12.15664,2.810797 1.57227,0.01792 2.21384,-0.459335 4.38145,-3.254144 2.41915,-3.119112 2.85152,-4.65712 1.12021,-3.984803 -1.29794,0.504027 -0.90611,-0.55263 0.48458,-1.306748 1.47899,-0.802008 5.24715,-6.036064 4.52171,-6.280765 -0.2672,-0.09028 -2.51475,0.859712 -4.99457,2.110758 -4.95357,2.499081 -10.91265,4.274615 -13.25347,3.949031 l -1.50314,-0.208992 1.42332,-0.629307 c 1.99178,-0.880609 4.28533,-3.512167 5.35563,-6.144838 1.18722,-2.920242 1.16905,-2.972592 -0.61998,-1.786356 -6.84193,4.536628 -14.27771,6.36951 -19.68048,4.851131 -2.0212,-0.568045 -2.95733,-1.689681 -1.42332,-1.705425 2.40798,-0.02443 14.08342,-7.956754 14.08872,-9.571593 0.001,-0.440483 -1.8715,-0.641026 -5.83348,-0.62456 -6.24995,0.02576 -9.12739,-0.764604 -11.70584,-3.21588 l -1.33117,-1.265529 4.76155,-0.638562 c 3.8182,-0.512062 5.3473,-1.026372 7.71809,-2.59589 1.6261,-1.076524 2.96115,-2.151753 2.96678,-2.389432 0.006,-0.237645 -1.05609,-0.432104 -2.35937,-0.432104 -3.5714,0 -8.2245,-1.713174 -10.87429,-4.003704 l -2.36658,-2.045682 4.82309,-0.295231 c 3.81729,-0.233654 5.20753,-0.572232 6.66658,-1.623598 2.28813,-1.648752 2.31311,-2.163102 0.12657,-2.605637 C 18.45509,15.70041 13.80384,13.069595 11.70742,10.721358 10.55937,9.435373 9.7549903,8.2466929 9.9199103,8.079789 10.08486,7.9129111 11.03968,8.064109 12.04178,8.4191057 c 2.04105,0.720027 8.49021,0.880367 8.47269,0.2105584 -0.006,-0.237641 -1.3099,-1.2098458 -2.89709,-2.1604569 C 14.41267,4.5497583 10.31885,0.40452243 8.91519,-2.3423006 L 8,-4.1332652 l 2.41992,1.1115795 c 1.33097,0.6113854 3.66825,1.1172878 5.19395,1.1242308 2.40194,0.011201 2.67895,-0.1030328 2.06527,-0.8515572 -0.38982,-0.4753047 -1.01141,-0.8641931 -1.38135,-0.8641931 -1.58347,0 -8.49251,-9.7886698 -7.5688,-10.7234418 0.16338,-0.165312 1.54469,0.339246 3.06962,1.121187 1.52493,0.782004 3.66403,1.512405 4.75357,1.623127 l 1.98094,0.201374 -0.19612,-2.242533 -0.19613,-2.242531 1.82073,2.098479 c 1.0014,1.154206 2.06475,2.098501 2.36301,2.098501 1.1542,0 7.45966,3.5106162 8.52604,4.7469426 1.88232,2.1823198 2.74927,4.7275647 2.38469,7.00107804 C 32.98,1.6612805 33.15914,2.4667854 33.97065,3.374791 c 0.75689,0.8469684 1.06081,2.0229016 1.03188,3.9924889 -0.0372,2.5292761 0.10837,2.8545231 1.54677,3.4574631 2.19991,0.922142 2.93426,1.982269 3.3018,4.766611 0.3093,2.343154 0.36159,2.392948 2.33218,2.22094 1.3915,-0.121402 2.4934,0.204286 3.55791,1.051567 1.40492,1.118321 1.6221,1.146613 2.44089,0.318057 0.4943,-0.500235 1.43299,-1.198848 2.08595,-1.552476 l 1.18721,-0.642991 -1.16498,-0.937621 c -1.43195,-1.152526 -2.28241,-2.783291 -2.44193,-4.682498 -0.24096,-2.8686583 -0.0505,-3.0304082 1.75672,-1.491552 0.96342,0.820357 2.0065,1.491552 2.31797,1.491552 1.33787,0 2.19296,-1.775984 2.19296,-4.5546391 0,-2.4553102 -0.21859,-3.0534797 -1.40271,-3.8386228 C 51.45069,2.1359156 51.13831,2.1299347 49.5865,2.9134811 47.95236,3.7384508 47.8919,3.7281689 48.42725,2.7161376 49.63987,0.4232512 48.63435,0.39991019 45.39399,2.6457986 42.30031,4.7899947 40.93653,5.1871007 39.09703,4.4793716 36.89592,3.6324962 36.12776,1.5668791 37.24072,-0.51242526 l 0.88852,-1.65999714 0.0228,1.56412574 c 0.0442,3.03085606 3.20034,3.43764196 8.09696,1.0435701 1.31316,-0.64204874 2.97995,-1.16735365 3.70396,-1.16735365 1.94708,0 1.60852,-0.93087649 -1.04636,-2.87705679 -3.10004,-2.2725013 -5.81874,-2.3539951 -6.93001,-0.2078704 l -0.78921,1.5243003 -1.22161,-1.2362354 c -2.6687,-2.7005907 -0.67211,-7.8017455 3.23305,-8.2602055 0.98194,-0.115129 1.58837,-0.582377 1.72658,-1.329934 0.46638,-2.522218 2.3289,-2.592978 8.05191,-0.305781 4.94835,1.977565 6.54967,2.138215 7.35565,0.737854 0.51692,-0.898104 0.58219,-0.865043 0.59761,0.302471 0.014,1.004662 -0.3862,1.392381 -1.71084,1.660467 -1.64698,0.333336 -1.68295,0.400355 -0.76575,1.4259608 1.094,1.2233335 3.07513,1.4098119 4.08801,0.3847874 0.53137,-0.5377126 0.6832,-0.4141979 0.6832,0.5558787 0,0.6859781 -0.49744,1.5166375 -1.10544,1.8458945 -1.08469,0.5874633 -1.08094,0.6548414 0.20026,3.5926511 1.30948,3.00260876 2.61315,4.2497286 2.61315,2.49981737 0,-0.51434915 0.53123,-1.98894327 1.18053,-3.27685467 l 1.18052,-2.3417175 -1.21027,-0.8578087 c -1.72529,-1.2229051 -1.15122,-2.1081556 1.39589,-2.1525288 2.53466,-0.044116 3.30962,-1.1675782 1.17875,-1.7088072 -0.99522,-0.252762 -1.44809,-0.759137 -1.44809,-1.619184 0,-1.216364 0.0224,-1.220397 0.80047,-0.143807 0.89277,1.235519 1.67356,1.096771 8.67286,-1.541433 2.93155,-1.104969 3.73514,-1.20698 4.9816,-0.632217 0.88858,0.409691 1.48621,1.153552 1.48621,1.849835 0,0.798292 0.37534,1.164644 1.19314,1.164644 4.33816,0 6.72995,5.9270655 3.42096,8.4774641 -1.29398,0.9973151 -1.50089,0.9268233 -2.26564,-0.7717029 -0.60008,-1.3327789 -0.92153,-1.4729113 -2.70629,-1.1798103 -2.04788,0.3362937 -5.90475,2.8665744 -5.90475,3.8737686 0,0.30076499 0.44834,0.54804098 0.99632,0.54949707 0.54797,0.00168 2.53349,0.64348382 4.41227,1.42667739 1.87878,0.78317024 3.9527,1.43012914 4.6087,1.43763304 1.42894,0.01792 3.06319,-1.6635814 3.1133,-3.2004025 0.0297,-0.9093727 0.13511,-0.8560824 0.59088,0.29854994 C 91.91041,2.5257401 89.45629,5.481889 86.10797,4.6563363 85.26481,4.448466 83.50401,3.5398534 82.19506,2.6371797 78.89332,0.36026349 77.43978,0.47544074 79.55974,2.8459461 80.49286,3.88936 80.47096,3.8952729 78.8481,3.0388066 76.67706,1.893139 76.12995,1.9210487 74.95272,3.2375162 74.23407,4.0410941 74.02428,5.1210205 74.15283,7.3551305 74.3774,11.25831 75.44394,12.075886 77.95274,10.268139 l 1.78294,-1.284774 v 2.145373 c 0,1.400719 -0.49403,2.800786 -1.42332,4.033727 -1.59758,2.119601 -1.72179,2.541393 -0.74835,2.541393 0.37123,0 1.24938,0.546089 1.95146,1.213543 l 1.27648,1.213521 1.32218,-1.261749 c 1.02982,-0.982774 1.79423,-1.199518 3.45714,-0.98031 2.03391,0.268149 2.13499,0.203615 2.13499,-1.36499 0,-2.613318 1.19383,-4.586426 3.49335,-5.773584 1.97947,-1.0219063 2.10749,-1.2422565 1.80776,-3.1113571 -0.21663,-1.351237 -0.0202,-2.4814048 0.6041,-3.4427948 0.58731,-0.9070416 0.92671,-2.6566166 0.92671,-4.7770241 0,-4.6466351 1.97188,-7.0221103 8.25662,-9.946499 2.68383,-1.248824 5.1762,-2.856383 5.9154,-3.815328 L 109.9876,-16 l -0.36739,1.717654 c -0.20206,0.944742 -0.41164,1.981774 -0.46579,2.304536 -0.18145,1.081721 3.84403,0.269718 7.14083,-1.440409 l 3.25394,-1.687889 -0.58495,1.569547 c -1.17875,3.162636 -4.83475,8.176768 -6.90103,9.4646542 -1.1674,0.7276435 -2.12948,1.5174453 -2.1379,1.7550873 -0.0309,0.872749 4.8975,0.3730266 7.32837,-0.7430529 1.37743,-0.6323994 2.60435,-1.0487028 2.72651,-0.9250985 0.33684,0.3408833 -3.71063,5.6255851 -5.7289,7.4801468 -0.97862,0.8992247 -3.05927,2.4514573 -4.62364,3.4493337 -2.2025,1.4049934 -2.59838,1.8623127 -1.75441,2.0268206 1.55398,0.3028232 7.81742,-0.2311711 9.06853,-0.7731833 1.00099,-0.4336406 1.00869,-0.3681664 0.15367,1.3049796 -1.52466,2.9836385 -6.23354,5.9151265 -10.93528,6.8077435 -2.52829,0.479985 -2.26595,1.338357 0.90992,2.977365 1.94159,1.001998 3.478,1.29629 6.76764,1.29629 h 4.25585 l -1.59677,1.686607 c -2.17318,2.295417 -6.44374,4.050776 -10.87341,4.469355 -2.02621,0.191301 -3.68401,0.515135 -3.68401,0.719248 0,0.204063 1.40761,1.234377 3.12807,2.28955 2.44771,1.501228 4.20226,2.062546 8.06718,2.580832 l 4.93915,0.66237 -1.83047,1.558688 c -2.57195,2.190024 -5.75364,2.948714 -12.16895,2.901712 -3.05299,-0.02261 -5.55094,0.156355 -5.55094,0.397024 0,1.621063 7.95895,7.343039 12.52474,9.004514 1.56589,0.569831 2.84708,1.213314 2.84708,1.429971 0,0.590601 -4.74384,1.682981 -7.30872,1.682981 -3.23811,0 -8.99073,-1.948081 -12.61771,-4.272914 -2.92161,-1.872708 -3.14374,-1.929762 -3.31733,-0.851922 -0.28832,1.790418 4.2394,7.362219 6.02163,7.410192 0.39142,0.0112 0.71164,0.311836 0.71164,0.669518 0,1.722267 -10.27469,-1.237891 -16.36812,-4.715603 -1.68779,-0.963312 -2.98894,-1.41396 -2.98894,-1.035214 0,0.908318 2.649,4.514333 4.48545,6.10586 1.20205,1.041738 1.2986,1.293979 0.49615,1.296289 -0.54797,0.0014 -0.99633,0.283337 -0.99633,0.6261 0,0.608586 3.70842,5.555427 4.83928,6.455392 1.39184,1.107614 12.21032,-0.809491 14.45227,-2.561041 1.62741,-1.271417 2.78916,-1.342837 4.00308,-0.246059 5.06973,4.580345 6.18236,6.427256 2.57423,4.272962 -1.78297,-1.064567 -2.20019,-1.117806 -3.4511,-0.440321 -1.13903,0.616873 -1.64744,0.628725 -2.54826,0.05936 -0.91063,-0.575508 -1.936022,-0.520338 -5.3735,0.288937 -2.33645,0.550096 -4.24812,1.185178 -4.24812,1.411286 0,0.676147 5.26257,1.566032 7.3216,1.238053 1.71251,-0.272766 2.17489,-0.02016 4.4123,2.411065 2.59503,2.819806 3.33285,4.813321 1.50296,4.060814 -2.63055,-1.081768 -4.34387,-1.365399 -5.25772,-0.870466 -1.38402,0.749546 -4.94021,-0.341315 -5.26974,-1.616477 -0.26097,-1.009949 -4.77012,-2.823056 -5.41013,-2.175401 -0.43363,0.438818 4.89141,5.524898 5.78445,5.524898 1.42646,0 2.54422,2.067748 4.04881,7.489753 0.385378,1.388786 0.330138,1.373302 -1.54321,-0.432097 -1.06859,-1.029859 -2.50226,-1.872455 -3.18593,-1.872455 -0.85191,0 -1.35571,-0.454317 -1.60113,-1.443909 -0.4101,-1.653411 -4.97834,-6.009141 -8.25967,-7.875393 -1.22163,-0.694811 -2.22113,-1.474816 -2.22113,-1.733336 0,-0.25852 -0.7289,-0.47004 -1.61974,-0.47004 -1.59409,0 -3.8464,1.766175 -3.15045,2.470471 0.19593,0.198015 0.19347,0.789785 -0.006,1.314435 -0.28582,0.753753 -0.5319,0.811018 -1.17259,0.27294 -0.89681,-0.753179 -3.16096,0.09319 -3.16096,1.181651 0,1.149188 -1.00696,-0.05979 -1.28772,-1.546143 -0.38027,-2.01304 1.28799,-5.856909 2.71104,-6.246534 0.62626,-0.171581 2.73988,-0.315301 4.69694,-0.319641 1.95706,-0.0042 3.5583,-0.224624 3.5583,-0.489444 0,-0.264862 -0.93176,-1.69183 -2.07057,-3.171014 -1.79603,-2.332896 -2.15879,-2.567384 -2.73594,-1.768596 -0.57178,0.791276 -0.80973,0.596887 -1.69146,-1.381814 -0.56434,-1.266468 -2.02574,-3.29047 -3.24754,-4.497805 -2.20191,-2.175806 -2.23101,-2.185165 -3.30593,-1.064475 -1.48927,1.552884 -3.45884,5.26595 -3.45884,6.521021 0,1.302478 2.30587,3.53972 3.64829,3.53972 0.5571,0 1.14617,-0.515604 1.30902,-1.145807 0.38198,-1.478085 1.30528,-0.910487 1.30528,0.802442 0,1.569048 -1.40277,2.927453 -3.55828,3.445677 -1.74644,0.419915 -1.96374,1.678682 -0.81068,4.69605 1.93246,5.057021 4.08626,6.222277 12.22296,6.613063 6.28322,0.301776 6.55317,0.368728 7.90718,1.961655 1.03476,1.217374 1.30968,2.042889 1.0499,3.152511 -0.42909,1.832637 -2.07419,4.214076 -3.16537,4.582132 -0.44157,0.148956 -0.10571,-0.567548 0.7463,-1.592234 1.72169,-2.070597 1.81823,-2.493887 0.9452,-4.144638 -0.9686,-1.83146 -3.01869,-2.317454 -5.71501,-1.35475 -3.56171,1.271648 -6.11547,1.032575 -9.57336,-0.896199 -1.69536,-0.945644 -3.18738,-1.613187 -3.3156,-1.48344 -0.45242,0.45783 1.55458,3.712835 2.99746,4.861401 0.80379,0.639814 2.26268,1.341379 3.24199,1.559065 4.92281,1.094151 7.01366,4.031441 5.36307,7.53415 -1.08008,2.292015 -2.03315,2.568051 -1.63762,0.474254 0.37439,-1.981887 -1.77201,-4.291543 -3.98817,-4.291543 -2.05897,0 -3.62032,-0.799235 -5.9836,-3.062849 -1.60491,-1.537246 -1.84762,-1.623576 -1.83012,-0.651029 0.0112,0.616691 0.3863,1.769395 0.83381,2.561574 1.55522,2.753113 1.08347,4.772215 -1.86551,7.984379 -1.49572,1.629209 -2.84075,2.935803 -2.98897,2.903573 -0.14821,-0.0323 -1.32578,-1.263714 -2.61682,-2.736625 z"
-     fill="url(#linearGradient1830)"
-     style="fill-opacity:1;stroke:#fd7;stroke-width:4;stroke-linecap:round;stroke-linejoin:round;stroke-opacity:1;paint-order:markers stroke fill"
-     id="path189" />
-</svg>
index 4b61fb6228936e01e3f7fb9e8af74c671d33b38a..87039f1898656e0f1154331f374331d212dba0b8 100644 (file)
@@ -141,6 +141,17 @@ enum class TextParserFormattingTag(val type: TextParserTagType<Unit>) {
                )
        ),
        
+       // Metadata
+       DESC(
+               TextParserTagType.Direct(
+                       { _, _ -> "" },
+                       { "" },
+               )
+       ),
+       THUMB(
+               TextParserTagType.Indirect { _, _, _ -> "" }
+       ),
+       
        // Resource showing
        IMAGE(
                TextParserTagType.Indirect { tagParam, content, _ ->
@@ -379,3 +390,6 @@ val INSIDE_TAG_TEXT = Regex("\\[.*?]")
 
 fun headerContentToLabel(content: String) = TextParserState.uncensorText(content.replace(INSIDE_TAG_TEXT, ""))
 fun headerContentToAnchor(content: String) = headerContentToLabel(content).replace(NON_ANCHOR_CHAR, "-")
+
+fun imagePathToOpenGraphValue(path: String) = "https://mechyrdia.info/assets/images/${sanitizeLink(path)}"
+fun descriptionContentToPlainText(content: String) = TextParserState.uncensorText(content.replace(INSIDE_TAG_TEXT, ""))
index c1e837c02d9e11af048e8ff001166702b8e9a453..89180657be11c95d92ae4984c6b82816e54ea191 100644 (file)
@@ -5,7 +5,7 @@ class TableOfContentsBuilder {
        private val levels = mutableListOf<Int>()
        private val links = mutableListOf<NavLink>()
        
-       fun add(text: String, level: Int, toAnchor: String) {
+       fun addHeader(text: String, level: Int, toAnchor: String) {
                if (level == 0) {
                        if (title == null)
                                title = text
@@ -25,8 +25,28 @@ class TableOfContentsBuilder {
                links.plusAssign(NavLink("#$toAnchor", "$number. $text", aClasses = "left"))
        }
        
+       private var description: String? = null
+       private var image: String? = null
+       
+       fun addDescription(plainText: String) {
+               description = description.orEmpty() + plainText
+       }
+       
+       fun addImage(path: String, overWrite: Boolean = false) {
+               if (overWrite || image == null)
+                       image = path
+       }
+       
        fun toPageTitle() = title ?: MISSING_TITLE
        
+       fun toOpenGraph() = title?.let { title ->
+               description?.let { desc ->
+                       image?.let { image ->
+                               OpenGraphData(title, desc, image)
+                       }
+               }
+       }
+       
        fun toNavBar(): List<NavItem> = listOf(NavLink("#page-top", title ?: MISSING_TITLE, aClasses = "left")) + links.toList()
        
        companion object {
@@ -37,39 +57,57 @@ class TableOfContentsBuilder {
 enum class TextParserToCBuilderTag(val type: TextParserTagType<TableOfContentsBuilder>) {
        H1(
                TextParserTagType.Indirect { _, content, builder ->
-                       builder.add(headerContentToLabel(content), 0, headerContentToAnchor(content))
+                       builder.addHeader(headerContentToLabel(content), 0, headerContentToAnchor(content))
                        "[h1]$content[/h1]"
                }
        ),
        H2(
                TextParserTagType.Indirect { _, content, builder ->
-                       builder.add(headerContentToLabel(content), 1, headerContentToAnchor(content))
+                       builder.addHeader(headerContentToLabel(content), 1, headerContentToAnchor(content))
                        "[h2]$content[/h2]"
                }
        ),
        H3(
                TextParserTagType.Indirect { _, content, builder ->
-                       builder.add(headerContentToLabel(content), 2, headerContentToAnchor(content))
+                       builder.addHeader(headerContentToLabel(content), 2, headerContentToAnchor(content))
                        "[h3]$content[/h3]"
                }
        ),
        H4(
                TextParserTagType.Indirect { _, content, builder ->
-                       builder.add(headerContentToLabel(content), 3, headerContentToAnchor(content))
+                       builder.addHeader(headerContentToLabel(content), 3, headerContentToAnchor(content))
                        "[h4]$content[/h4]"
                }
        ),
        H5(
                TextParserTagType.Indirect { _, content, builder ->
-                       builder.add(headerContentToLabel(content), 4, headerContentToAnchor(content))
+                       builder.addHeader(headerContentToLabel(content), 4, headerContentToAnchor(content))
                        "[h5]$content[/h5]"
                }
        ),
        H6(
                TextParserTagType.Indirect { _, content, builder ->
-                       builder.add(headerContentToLabel(content), 5, headerContentToAnchor(content))
+                       builder.addHeader(headerContentToLabel(content), 5, headerContentToAnchor(content))
                        "[h6]$content[/h6]"
                }
+       ),
+       DESC(
+               TextParserTagType.Indirect { _, content, builder ->
+                       builder.addDescription(descriptionContentToPlainText(content))
+                       content
+               }
+       ),
+       IMAGE(
+               TextParserTagType.Indirect { param, content, builder ->
+                       builder.addImage(imagePathToOpenGraphValue(content))
+                       "[image=$param]$content[/image]"
+               }
+       ),
+       THUMB(
+               TextParserTagType.Indirect { _, content, builder ->
+                       builder.addImage(imagePathToOpenGraphValue(content), true)
+                       ""
+               }
        );
        
        companion object {
diff --git a/src/main/kotlin/info/mechyrdia/lore/view_og.kt b/src/main/kotlin/info/mechyrdia/lore/view_og.kt
new file mode 100644 (file)
index 0000000..e6c745c
--- /dev/null
@@ -0,0 +1,30 @@
+package info.mechyrdia.lore
+
+import io.ktor.server.application.*
+import io.ktor.server.request.*
+import kotlinx.html.HEAD
+import kotlinx.html.meta
+import kotlinx.serialization.Serializable
+
+@Serializable
+data class OpenGraphData(
+       val title: String,
+       val desc: String,
+       val image: String
+)
+
+fun HEAD.ogProperty(property: String, content: String) {
+       meta {
+               attributes["property"] = "og:$property"
+               attributes["content"] = content
+       }
+}
+
+context(ApplicationCall)
+fun HEAD.renderOgData(data: OpenGraphData) {
+       ogProperty("title", data.title)
+       ogProperty("type", "website")
+       ogProperty("description", data.desc)
+       ogProperty("image", data.image)
+       ogProperty("url", "https://mechyrdia.info/${request.path().removePrefix("/")}")
+}
index c1e58095aedeb62eab642fbb15f4f2ebe2b0008a..d42afc898265e9aaac9c97366f5dbb53eeeca2da 100644 (file)
@@ -36,7 +36,7 @@ private val images = listOf(
        "panel.png",
 )
 
-fun ApplicationCall.page(pageTitle: String, navBar: List<NavItem>? = null, sidebar: Sidebar? = null, content: SECTIONS.() -> Unit): HTML.() -> Unit {
+fun ApplicationCall.page(pageTitle: String, navBar: List<NavItem>? = null, sidebar: Sidebar? = null, ogData: OpenGraphData? = null, content: SECTIONS.() -> Unit): HTML.() -> Unit {
        val theme = request.cookies["FACTBOOK_THEME"]
        
        return {
@@ -50,6 +50,10 @@ fun ApplicationCall.page(pageTitle: String, navBar: List<NavItem>? = null, sideb
                        meta(charset = "utf-8")
                        meta(name = "viewport", content = "width=device-width, initial-scale=1.0")
                        
+                       ogData?.let { data ->
+                               renderOgData(data)
+                       }
+                       
                        script(src = "/static/obj-viewer/three.js") {}
                        script(src = "/static/obj-viewer/three-examples.js") {}
                        script(src = "/static/obj-viewer/OrbitControls.js") {}
index 5458a426461422cfe8152f658d3286acf41edfcd..f92dcf743a4cb281b9406f05a841773c6b9d6a23 100644 (file)
@@ -1,6 +1,7 @@
 package info.mechyrdia.lore
 
 import info.mechyrdia.Configuration
+import info.mechyrdia.JsonFileCodec
 import info.mechyrdia.data.*
 import io.ktor.server.application.*
 import io.ktor.util.*
@@ -11,10 +12,13 @@ import kotlinx.html.*
 import java.io.File
 
 suspend fun ApplicationCall.loreIntroPage(): HTML.() -> Unit {
+       val metaJsonFile = File(Configuration.CurrentConfiguration.articleDir).parentFile.combineSafe("introMeta.json")
+       val metaData = JsonFileCodec.decodeFromString(OpenGraphData.serializer(), metaJsonFile.readText())
+       
        val htmlFile = File(Configuration.CurrentConfiguration.articleDir).parentFile.combineSafe("intro.html")
        val fileHtml = htmlFile.readText()
        
-       return page("Welcome to Mechyrdia", standardNavBar(), null) {
+       return page(metaData.title, standardNavBar(), null, metaData) {
                section {
                        a { id = "page-top" }
                        unsafe { raw(fileHtml) }
@@ -75,7 +79,7 @@ suspend fun ApplicationCall.loreArticlePage(): HTML.() -> Unit {
                val navbar = standardNavBar(pagePathParts)
                val sidebar = PageNavSidebar(pageNav)
                
-               return page(pageToC.toPageTitle(), navbar, sidebar) {
+               return page(pageToC.toPageTitle(), navbar, sidebar, pageToC.toOpenGraph()) {
                        section {
                                a { id = "page-top" }
                                unsafe { raw(pageHtml) }
index a51c89ea71c51a864e43dc531ab5be6d8d684788..6e083e74663c4bbf23d9c08168a3b524b99997d4 100644 (file)
Binary files a/src/main/resources/static/images/icon.png and b/src/main/resources/static/images/icon.png differ