Skip to content

Commit 33b7d25

Browse files
committed
Update index.html
1 parent fe71a5b commit 33b7d25

File tree

1 file changed

+65
-13
lines changed

1 file changed

+65
-13
lines changed

index.html

Lines changed: 65 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
<meta charset="UTF-8">
55
<meta name="viewport" content="width=device-width, initial-scale=1.0">
66
<title>tinystruct Framework</title>
7+
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/prism/1.29.0/themes/prism.min.css" integrity="sha512-tN7Ec6zAFaVSG3TpNAKtk4DOHNpSwKHxxrsiw4GHKESGPs5njn/0sMCUMl2svV4wo4BK/rCP7juYz+zx+l6oeQ==" crossorigin="anonymous" referrerpolicy="no-referrer" />
78
<style>
89
/* General Styles */
910
body {
@@ -78,14 +79,6 @@
7879
border-radius: 5px;
7980
}
8081

81-
pre {
82-
background: #ececec;
83-
padding: 1rem;
84-
border: 1px solid #ddd;
85-
border-radius: 5px;
86-
overflow-x: auto;
87-
}
88-
8982
a {
9083
color: #4b3c6e;
9184
text-decoration: none;
@@ -129,6 +122,36 @@
129122
border-radius: 5px;
130123
cursor: pointer;
131124
}
125+
126+
pre {
127+
position: relative;
128+
background: #ececec;
129+
padding: 1rem;
130+
border: 1px solid #ddd;
131+
border-radius: 5px;
132+
overflow-x: auto;
133+
margin-bottom: 1rem;
134+
}
135+
136+
pre code {
137+
display: block;
138+
}
139+
140+
.copy-btn {
141+
position: absolute;
142+
top: 10px;
143+
right: 10px;
144+
background: #4b3c6e;
145+
color: #fff;
146+
border: none;
147+
border-radius: 5px;
148+
padding: 0.5rem 1rem;
149+
cursor: pointer;
150+
}
151+
152+
.copy-btn:hover {
153+
background: #3a2d58;
154+
}
132155
</style>
133156
</head>
134157
<body>
@@ -175,21 +198,23 @@ <h2 id="use-cases" class="lang" data-en="Best Use Cases and Their Benefits" data
175198

176199
<h2 id="installation" class="lang" data-en="Installation and Getting Started" data-fr="Installation et démarrage" data-de="Installation und Einstieg" data-zh="安装和入门">Installation and Getting Started</h2>
177200
<p class="lang" data-en="Add the dependency into your pom.xml." data-fr="Ajoutez la dépendance dans votre fichier pom.xml." data-de="Fügen Sie die Abhängigkeit in Ihre pom.xml ein." data-zh="将以下 Maven 依赖项添加到您的项目中:">Add the dependency into your pom.xml.</p>
178-
<pre><code>&lt;dependency&gt;
201+
<pre class="language-xml"><code>&lt;dependency&gt;
179202
&lt;groupId&gt;org.tinystruct&lt;/groupId&gt;
180203
&lt;artifactId&gt;tinystruct&lt;/artifactId&gt;
181204
&lt;version&gt;1.4.4&lt;/version&gt;
182205
&lt;classifier&gt;jar-with-dependencies&lt;/classifier&gt;
183-
&lt;/dependency&gt;</code></pre>
206+
&lt;/dependency&gt;</code><button class="copy-btn" onclick="copyCode(this)">Copy</button>
207+
</pre>
184208

185209
<p class="lang" data-en="Extend the AbstractApplication in Java" data-fr="Étendez la classe AbstractApplication en Java" data-de="Erweitern Sie die AbstractApplication in Java" data-zh="在 Java 中扩展 AbstractApplication 类">Extend the AbstractApplication in Java</p>
186-
<pre><code>package tinystruct.examples;
210+
<pre class="language-java"><code>package tinystruct.examples;
211+
187212

188213
import org.tinystruct.AbstractApplication;
189214
import org.tinystruct.ApplicationException;
190215
import org.tinystruct.system.annotation.Action;
191216

192-
public class Example extends AbstractApplication {
217+
public class example extends AbstractApplication {
193218

194219
@Override
195220
public void init() {
@@ -206,26 +231,53 @@ <h2 id="installation" class="lang" data-en="Installation and Getting Started" da
206231
return "Praise to the Lord!";
207232
}
208233

234+
@Action("say")
235+
public String say() throws ApplicationException {
236+
if (null != this.context.getAttribute("--words"))
237+
return this.context.getAttribute("--words").toString();
238+
239+
throw new ApplicationException("Could not find the parameter <i>words</i>.");
240+
}
241+
209242
@Action("say")
210243
public String say(String words) {
211244
return words;
212245
}
246+
213247
}
214-
</code></pre>
248+
</code><button class="copy-btn" onclick="copyCode(this)">Copy</button>
249+
</pre>
215250
</div>
216251

217252
<!-- Footer -->
218253
<footer>
219254
<p class="lang" data-en="Created with ❤️ by James ZHOU" data-fr="Créé avec ❤️ par James ZHOU" data-de="Erstellt mit ❤️ von James ZHOU" data-zh="❤️ 创建者: James ZHOU">Created with ❤️ by James ZHOU</p>
220255
</footer>
221256

257+
<script src="https://cdnjs.cloudflare.com/ajax/libs/prism/1.29.0/prism.min.js" integrity="sha512-7Z9J3l1+EYfeaPKcGXu3MS/7T+w19WtKQY/n+xzmw4hZhJ9tyYmcUS+4QqAlzhicE5LAfMQSF3iFTK9bQdTxXg==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
258+
<script src="https://cdnjs.cloudflare.com/ajax/libs/prism/1.29.0/components/prism-java.min.js"></script>
222259
<script>
223260
// Language Change Function
224261
function changeLanguage(lang) {
225262
document.querySelectorAll('.lang').forEach(element => {
226263
element.innerText = element.getAttribute('data-' + lang);
227264
});
228265
}
266+
267+
// Copy Code Function
268+
function copyCode(button) {
269+
const codeBlock = button.previousElementSibling;
270+
navigator.clipboard.writeText(codeBlock.innerText)
271+
.then(() => {
272+
button.innerText = 'Copied!';
273+
setTimeout(() => {
274+
button.innerText = 'Copy';
275+
}, 2000);
276+
})
277+
.catch(err => {
278+
console.error('Failed to copy code:', err);
279+
});
280+
}
229281
</script>
230282
</body>
231283
</html>

0 commit comments

Comments
 (0)