From fa269cabf1975acf1bbfd9e6a5e602dd0f302131 Mon Sep 17 00:00:00 2001 From: Lizandro Guarnizo <77708265+lizandrogd@users.noreply.github.com> Date: Thu, 25 Jun 2026 11:30:03 -0500 Subject: [PATCH] fix(websms): move code examples to JS to avoid Go template parsing error html/template rejects escaped quotes in attribute values. Code examples are now built in getCodeExample() and rendered via x-text on the
.

Co-Authored-By: Claude Sonnet 4.6 
---
 resources/views/websms_config.html | 119 ++++++++++++++++++++---------
 1 file changed, 81 insertions(+), 38 deletions(-)

diff --git a/resources/views/websms_config.html b/resources/views/websms_config.html
index 6359162..8010716 100644
--- a/resources/views/websms_config.html
+++ b/resources/views/websms_config.html
@@ -201,45 +201,12 @@
         
       
 
-      
-      
+ +
-

+          

         
- -
- - -
-
-

-        
- -
- - -
-
-

-        
- -
- - -
-
-

-        
- @@ -334,7 +301,83 @@ function websmsApp() { }, formatDate(d){ if(!d) return ''; return new Date(d).toLocaleDateString('es-CO',{day:'2-digit',month:'short',year:'numeric',hour:'2-digit',minute:'2-digit'}); }, - copy(text){ navigator.clipboard.writeText(text); this.copied='URL copiada'; setTimeout(()=>this.copied='', 2000); }, + copy(text){ navigator.clipboard.writeText(text); this.copied='Copiado'; setTimeout(()=>this.copied='', 2000); }, + + getCodeExample(tab) { + const key = this.secretKey || '{API_KEY}'; + const url = 'https://admin.u-site.app/api/sms/send'; + if (tab === 'curl') { + return [ + "curl -X POST " + url + " \\", + " -H 'Authorization: Bearer " + key + "' \\", + " -H 'Content-Type: application/json' \\", + " -d '{", + ' "numero": "573001234567",', + ' "mensaje": "Hola, este es tu código: 9821"', + " }'" + ].join('\n'); + } + if (tab === 'js') { + return [ + "const response = await fetch('" + url + "', {", + " method: 'POST',", + " headers: {", + " 'Authorization': 'Bearer " + key + "',", + " 'Content-Type': 'application/json',", + " },", + " body: JSON.stringify({", + " numero: '573001234567',", + " mensaje: 'Hola, este es tu código: 9821',", + " }),", + "});", + "", + "const data = await response.json();", + "console.log(data); // { ok: true, id: '6a3d...' }" + ].join('\n'); + } + if (tab === 'php') { + return [ + " true,", + " CURLOPT_POST => true,", + " CURLOPT_HTTPHEADER => [", + " 'Authorization: Bearer " + key + "',", + " 'Content-Type: application/json',", + " ],", + ' CURLOPT_POSTFIELDS => json_encode([', + " 'numero' => '573001234567',", + " 'mensaje' => 'Hola, este es tu código: 9821',", + " ]),", + "]);", + "$response = json_decode(curl_exec($ch), true);", + "curl_close($ch);", + "// $response['ok'] === true" + ].join('\n'); + } + if (tab === 'python') { + return [ + "import requests", + "", + "response = requests.post(", + " '" + url + "',", + " headers={", + " 'Authorization': 'Bearer " + key + "',", + " 'Content-Type': 'application/json',", + " },", + " json={", + " 'numero': '573001234567',", + " 'mensaje': 'Hola, este es tu código: 9821',", + " },", + ")", + "", + "data = response.json()", + "print(data) # {'ok': True, 'id': '6a3d...'}" + ].join('\n'); + } + return ''; + }, } }