summaryrefslogtreecommitdiff
path: root/internal/generator/theme_matrix.go
blob: d964a1170eff525b46aa40f0ae41b4621cd0b366 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
package generator

// matrixTemplate is a hacker-style theme inspired by The Matrix — black
// background, bright matrix-green (#00ff41) text, monospace throughout,
// no decorations beyond a faint scanline overlay.
// WebGL scene: digital rain particle columns that simulate the iconic falling
// green characters, with vertex-colour fading from bright head to dark tail.
const matrixTemplate = `<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>snonux.foo // MATRIX</title>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/three.js/r134/three.min.js"></script>
    <style>
        :root { --g:#00ff41; --g2:#008f11; --g3:#003b00; --bg:#000; }
        * { margin:0; padding:0; box-sizing:border-box; }
        body { font-family:'Courier New',Courier,monospace; background:var(--bg); color:var(--g);
               overflow:hidden; height:100vh; }
        /* scanline overlay sits above WebGL */
        body::before { content:''; position:fixed; inset:0; z-index:999; pointer-events:none;
            background:repeating-linear-gradient(0deg,transparent,transparent 3px,
                rgba(0,0,0,0.08) 3px,rgba(0,0,0,0.08) 4px); }
        @keyframes blink { 0%,100%{opacity:1} 50%{opacity:0} }
        /* WebGL background canvas */
        #three-canvas { position:fixed; top:0; left:0; width:100%; height:100%; z-index:1; }
        .overlay { position:relative; z-index:10; height:100vh; display:flex; flex-direction:column; }
        header { padding:12px 24px; background:#000; border-bottom:1px solid var(--g2);
                 display:flex; align-items:center; justify-content:space-between; }
        .logo { display:flex; align-items:center; gap:14px; }
        .logo-mark { font-size:1.8rem; color:var(--g); text-shadow:0 0 18px var(--g); letter-spacing:3px; }
        /* blinking cursor after logo mark */
        .logo-mark::after { content:'_'; animation:blink 1.2s step-start infinite; }
        .logo-title h1 { font-size:1.2rem; color:var(--g); text-shadow:0 0 10px var(--g);
                         letter-spacing:4px; font-weight:normal; }
        .logo-title .subtitle { font-size:0.72rem; color:var(--g2); margin-top:2px; letter-spacing:1px; }
        .logo-title .subtitle a { color:var(--g); text-decoration:none; }
        .logo-title .subtitle a:hover { text-shadow:0 0 6px var(--g); }
        .transmit-btn { border:1px solid var(--g2); color:var(--g); padding:8px 18px;
                        text-decoration:none; font-size:0.82rem; letter-spacing:2px;
                        transition:all 0.1s; }
        .transmit-btn:hover { background:var(--g); color:var(--bg); }
        a.header-feed-link { color:var(--g2); }
        a.header-feed-link:hover { color:var(--g); text-shadow:0 0 8px var(--g); }
        .nav-hints { background:#000; border-bottom:1px solid var(--g3); color:var(--g2);
                     padding:4px 24px; display:flex; gap:18px; font-size:0.68rem; flex-wrap:wrap; }
        .nav-hints kbd { background:transparent; border:1px solid var(--g3); color:var(--g);
                         padding:0 5px; font-size:0.68rem; margin:0 2px; }
        .content { flex:1; overflow-y:auto; padding:14px 24px;
                   scrollbar-width:thin; scrollbar-color:var(--g2) var(--bg); }
        .page-nav { display:flex; justify-content:center; margin:12px 0; }
        .page-nav a { border:1px solid var(--g2); color:var(--g); padding:7px 20px;
                      text-decoration:none; font-size:0.82rem; letter-spacing:2px; }
        .page-nav a:hover { background:var(--g); color:var(--bg); }
        .post { background:#000; border:1px solid var(--g3); padding:16px 18px;
                margin-bottom:10px; cursor:pointer; transition:border-color 0.15s; }
        .post:hover { border-color:var(--g2); box-shadow:0 0 8px rgba(0,255,65,0.2); }
        .post-active { border-color:var(--g) !important; background:rgba(0,255,65,0.03) !important;
                       box-shadow:0 0 14px rgba(0,255,65,0.3),inset 3px 0 0 var(--g) !important; }
        .post-header { display:flex; justify-content:space-between; margin-bottom:10px; font-size:0.85rem; }
        .post-time { color:var(--g2); font-size:0.78rem; }
        .post-text { line-height:1.6; font-size:0.88rem; }
        .post-text a { color:var(--g); text-decoration:underline; }
        .post-image { max-width:100%; margin-top:10px; border:1px solid var(--g3); }
        .post-audio { width:100%; margin-top:10px; }
        .post-modal { display:none; position:fixed; inset:0; z-index:100;
                      background:rgba(0,0,0,0.98); overflow-y:auto; padding:40px 20px; }
        .post-modal.active { display:block; }
        .modal-inner { max-width:740px; margin:0 auto; background:#000;
                       border:1px solid var(--g); padding:36px;
                       box-shadow:0 0 40px rgba(0,255,65,0.25); }
        .modal-close { float:right; background:none; border:none; color:var(--g2);
                       font-family:monospace; font-size:0.9rem; cursor:pointer; letter-spacing:2px; }
        @media(max-width:640px) { .nav-hints{display:none;} header{padding:10px 16px;} .content{padding:10px 16px;} }
        .splash-overlay.splash-matrix { background: #000; font-family:'Courier New',monospace; }
        .splash-matrix .splash-rain {
            position:absolute; inset:0; overflow:hidden; pointer-events:none; opacity:0.35; z-index:1;
            font-size:11px; line-height:14px; color:var(--g2); text-align:left; padding:8px;
            white-space:pre; animation: splashMatrixScroll 16s linear infinite;
        }
        @keyframes splashMatrixScroll { to { transform: translateY(-24px); } }
        .splash-matrix .splash-title {
            position:relative; z-index:1; font-size:clamp(1.1rem,3.5vw,1.5rem); color:var(--g);
            text-shadow:0 0 20px var(--g); letter-spacing:0.35em;
            animation: splashMatrixGlow 1.8s ease-in-out infinite alternate;
        }
        @keyframes splashMatrixGlow { from { opacity:0.85; } to { opacity:1; text-shadow:0 0 28px var(--g); } }
        .splash-matrix .splash-tag { position:relative; z-index:1; color:rgba(0,255,65,0.88); }
        .splash-matrix .splash-hint { position:relative; z-index:1; color:rgba(0,255,65,0.82); }
    </style>
</head>
<body>
    {{template "splashGate"}}
    <div id="splash-overlay" class="splash-overlay splash-matrix" tabindex="-1" aria-label="Open microblog">
        <canvas class="splash-gl-canvas" id="splash-gl-canvas" aria-hidden="true"></canvas>
        <div class="splash-rain" aria-hidden="true">01001110 01000101 01001111
10101010 11001100 00110011
01110011 01101110 01101111
11001010 10100101 01011010</div>
        <div class="splash-inner">
            <div class="splash-title">SNONUX.FOO</div>
            <div class="splash-tag">Follow the signal</div>
            <div class="splash-hint">wake up — click or enter</div>
        </div>
    </div>
    <script>
    (function(){
        if(document.documentElement.classList.contains('sno-splash-skip'))return;
        var cv=document.getElementById('splash-gl-canvas');
        if(!cv||typeof THREE==='undefined')return;
        var raf,ren,sc,ca,pts,pos,t0=performance.now(),N=28,i,arr;
        function cleanup(){window.removeEventListener('resize',sz);if(raf)cancelAnimationFrame(raf);raf=null;if(ren)ren.dispose();ren=null;window._snonuxSplashWebGLCleanup=null;}
        window._snonuxSplashWebGLCleanup=cleanup;
        function sz(){var w=cv.clientWidth||2,h=cv.clientHeight||2;if(ren)ren.setSize(w,h,false);if(ca){ca.aspect=w/h;ca.updateProjectionMatrix();}}
        ren=new THREE.WebGLRenderer({canvas:cv,antialias:true,alpha:true});ren.setClearColor(0,0);ren.setPixelRatio(Math.min(window.devicePixelRatio||1,2));
        sc=new THREE.Scene();ca=new THREE.PerspectiveCamera(55,1,0.1,80);ca.position.set(0,0.5,10);
        arr=new Float32Array(N*3*20);for(i=0;i<arr.length;i+=3){arr[i]=(Math.random()-0.5)*16;arr[i+1]=Math.random()*22;arr[i+2]=(Math.random()-0.5)*8;}
        var geo=new THREE.BufferGeometry();geo.setAttribute('position',new THREE.BufferAttribute(arr,3));
        pts=new THREE.Points(geo,new THREE.PointsMaterial({color:0x00ff41,size:0.14,transparent:true,opacity:0.85,blending:THREE.AdditiveBlending,depthWrite:false,sizeAttenuation:true}));
        sc.add(pts);pos=geo.attributes.position;sz();window.addEventListener('resize',sz);
        function loop(now){raf=requestAnimationFrame(loop);var t=(now-t0)*0.001,j,p;
            for(j=0;j<pos.count;j++){p=j*3;pos.array[p+1]-=0.045+Math.sin(t+j*0.1)*0.012;if(pos.array[p+1]<-2)pos.array[p+1]=20;}
            pos.needsUpdate=true;pts.rotation.y=t*0.15;ren.render(sc,ca);}
        raf=requestAnimationFrame(loop);
    })();
    </script>
    <canvas id="three-canvas"></canvas>
    <div class="overlay">
        <header>
            <div class="logo">
                <span class="logo-mark">SN</span>
                <div class="logo-title">
                    <h1>SNONUX.FOO</h1>
                    <p class="subtitle">MICROBLOG / <a href="https://foo.zone">FOO.ZONE</a> IS THE REAL BLOG</p>
                    <p class="logo-host">Site served by a Raspberry Pi 3</p>
                </div>
            </div>
            <div class="nav">
                <a href="atom.xml" class="header-feed-link" rel="alternate" title="Atom feed" type="application/atom+xml">atom.xml</a>
                <a href="https://foo.zone/about" class="transmit-btn">TRANSMIT</a>
            </div>
        </header>
        {{template "navhints" .}}
        <div class="content" id="post-content">
            {{range $i, $post := .Posts}}
            <div class="post" data-index="{{$i}}" onclick="selectPost({{$i}})">
                <div class="post-header">
                    <div><strong>@snonux</strong></div>
                    <div class="post-time">{{$post.FormattedTime}}</div>
                </div>
                <div class="post-text">{{$post.ContentHTML}}</div>
            </div>
            {{end}}
            {{if or .PrevPage .NextPage}}
            <div class="page-nav page-nav-dual">
                {{if .PrevPage}}<a href="{{.PrevPage}}">&lt;-- NEWER</a>{{end}}
                {{if .NextPage}}<a href="{{.NextPage}}">OLDER --&gt;</a>{{end}}
            </div>
            {{end}}
        </div>
    </div>
    {{template "navmodal" .}}
    <script>
    // Matrix WebGL scene: 80 columns of falling particles with per-vertex colour.
    // Each column has a "head" that falls at a random speed; particles near the head
    // are bright green and fade to near-black further behind, simulating digital rain.
    (function() {
        var NUM_COLS   = 80;   // number of rain columns
        var COL_LEN    = 25;   // particles per column
        var SPACING    = 2.2;  // vertical gap between particles in a column
        var Y_TOP      = 30;   // world-space top of the rain field
        var Y_BOTTOM   = -30;  // world-space bottom

        var scene, camera, renderer;
        var points;
        var posArr, colArr;
        // Per-column state: x position, head y, and fall speed
        var colX = [], headY = [], speed = [];

        function initThree() {
            scene = new THREE.Scene();
            scene.background = new THREE.Color(0x000000);

            camera = new THREE.PerspectiveCamera(60, window.innerWidth / window.innerHeight, 0.1, 200);
            camera.position.set(0, 0, 50);

            renderer = new THREE.WebGLRenderer({ canvas: document.getElementById('three-canvas'), antialias: false });
            renderer.setSize(window.innerWidth, window.innerHeight);
            renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));

            var totalPts = NUM_COLS * COL_LEN;
            posArr = new Float32Array(totalPts * 3);
            colArr = new Float32Array(totalPts * 3);

            // Spread columns across x: -50..50; initialise heads at random y positions
            for (var c = 0; c < NUM_COLS; c++) {
                colX[c]  = -50 + (c / (NUM_COLS - 1)) * 100;
                headY[c] = Y_TOP - Math.random() * (Y_TOP - Y_BOTTOM);
                speed[c] = 0.08 + Math.random() * 0.07; // 0.08–0.15 units per frame
            }

            var geo = new THREE.BufferGeometry();
            geo.setAttribute('position', new THREE.BufferAttribute(posArr, 3));
            geo.setAttribute('color',    new THREE.BufferAttribute(colArr, 3));

            var mat = new THREE.PointsMaterial({ size: 0.35, vertexColors: true });
            points = new THREE.Points(geo, mat);
            scene.add(points);

            window.addEventListener('resize', onResize);
            animate();
        }

        function onResize() {
            camera.aspect = window.innerWidth / window.innerHeight;
            camera.updateProjectionMatrix();
            renderer.setSize(window.innerWidth, window.innerHeight);
        }

        function animate() {
            requestAnimationFrame(animate);

            for (var c = 0; c < NUM_COLS; c++) {
                // Advance the head downward each frame
                headY[c] -= speed[c];
                // When the head exits the bottom, reset to a random point above the top
                if (headY[c] < Y_BOTTOM - COL_LEN * SPACING) {
                    headY[c] = Y_TOP + Math.random() * 20;
                }

                var base = c * COL_LEN;
                for (var p = 0; p < COL_LEN; p++) {
                    var i = base + p;
                    var y = headY[c] + p * SPACING; // particles trail upward from head
                    posArr[i * 3]     = colX[c];
                    posArr[i * 3 + 1] = y;
                    posArr[i * 3 + 2] = 0;

                    // Brightness falls off with distance behind the head:
                    // p=0 is the head (bright), p=COL_LEN-1 is the tail (dim)
                    var bright = Math.max(0, 1 - p / (COL_LEN * 0.7));
                    // Head particle: #00ff41, tail: #003b00
                    colArr[i * 3]     = 0;
                    colArr[i * 3 + 1] = bright * (p === 0 ? 1.0 : 0.88);
                    colArr[i * 3 + 2] = bright * (p === 0 ? 0.255 : 0.04);
                }
            }

            points.geometry.attributes.position.needsUpdate = true;
            points.geometry.attributes.color.needsUpdate    = true;
            renderer.render(scene, camera);
        }

        initThree();
    })();
    </script>
    {{template "navscript" .}}
</body>
</html>`