html.sh - randomcrap - random crap programs of varying quality
(HTM) git clone git://git.codemadness.org/randomcrap
(DIR) Log
(DIR) Files
(DIR) Refs
(DIR) README
(DIR) LICENSE
---
html.sh (1899B)
---
1 #!/bin/sh
2
3 cat <<!
4 <style type="text/css">
5 div.p {
6 margin: 0 auto;
7 border: 2px solid #aaa;
8 box-shadow: #777 0px 10px 10px;
9 margin-bottom: 10px;
10 width: 975px;
11 padding: 5px;
12 }
13 h1, h2 {
14 text-align: center;
15 }
16 .puzzles {
17 columns: 2;
18 }
19 .puzzle {
20 text-align: center;
21 font-weight: bold;
22 padding-bottom: 15px;
23 }
24 .diagram {
25 width: 480px;
26 height: 515px;
27 }
28 .label {
29 height: 50px;
30 }
31 img {
32 width: 480px;
33 height: 480px;
34 border: 1px solid #aaa;
35 }
36 </style>
37 <div id="#main">
38 <h1>The Woodpecker Method</h1>
39 !
40
41 LC_ALL=C awk '
42 BEGIN {
43 easy=1;
44 }
45 /easy/ {
46 pageoffset = 31;
47 if (section != "easy")
48 page = 0;
49 section = "easy";
50 }
51 /intermediate/ {
52 pageoffset = 69;
53 if (section != "intermediate")
54 page = 0;
55 section = "intermediate";
56 }
57 /hard/ {
58 pageoffset = 197;
59 if (section != "hard")
60 page = 0;
61 section = "hard";
62 }
63 /^FILE:/ {
64 totalpage++;
65 page++; # page per section.
66 # DEBUG
67 # if (p != 6) {
68 # print "ERROR";
69 # }
70 p=0;
71 if (i) {
72 print "</div>";
73 print "</div>";
74 }
75 i=1;
76
77 print "<div class=\"p\">";
78 print "<h2>Page " (page + pageoffset) " (" section ")</h2>";
79 print "<div class=\"puzzles\">";
80 next;
81 }
82 length($0) {
83 number++;
84 fen = $0;
85 name = $0;
86
87 gsub("/", "_", name);
88 gsub(" ", "_", name);
89
90 getline label <"labels.txt";
91
92 p++;
93 print "<div class=\"puzzle\">";
94 print "<div class=\"label\">" number ". " label "</div>";
95
96 linkfen = fen;
97 gsub(" ", "_", linkfen);
98
99 # link = "https://lichess.org/editor/" linkfen "?color=white";
100 # link = "https://codemadness.org/onlyfens?fen=" fen;
101 # link = "https://lichess.org/analysis/" linkfen "?color=white";
102 link = "https://lichess.org/analysis/" linkfen;
103
104 print "<div class=\"diagram\">";
105 print "<a href=\"" link "\">";
106 print "<img src=\"svg/" name ".svg\" loading=\"lazy\" width=\"480\" height=\"480\" />";
107 print "</a>";
108 print "</div>";
109
110 print "</div>";
111 }
112 END {
113 if (i) {
114 print "</div>";
115 print "</div>";
116 }
117 }
118 '
119
120 cat <<!
121 </div>
122 !