Skip to content

Commit 3fef613

Browse files
authored
Merge pull request #386 from knatten/less-x
Less x
2 parents de492ad + 040e685 commit 3fef613

File tree

4 files changed

+59
-6
lines changed

4 files changed

+59
-6
lines changed

quiz/static/quiz.css

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,3 +202,31 @@ h4.quiz_mode
202202
#cppinsights-ce {
203203
font-style:italic;
204204
}
205+
.copy-box {
206+
border: 1px solid #ccc;
207+
padding: 5px;
208+
background: #f9f9f9;
209+
font-family: Arial, sans-serif;
210+
}
211+
212+
.copy-text {
213+
flex-grow: 1;
214+
margin-right: 10px;
215+
font-size: 14px;
216+
word-break: break-word;
217+
}
218+
219+
.copy-button {
220+
padding: 5px 10px;
221+
border: none;
222+
background-color: #ccf;
223+
}
224+
225+
.copy-button:hover {
226+
background-color: #aaf;
227+
}
228+
229+
.copy-button:disabled {
230+
background-color: #ccc;
231+
cursor: default;
232+
}

templates/base.html

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,6 @@ <h1><a href="/">C++ Quiz</a></h1>
107107
<a href="https://github.com/knatten/cppquiz/blob/master/CODE_OF_CONDUCT.md">CoC</a> |
108108
<a href="https://mastodon.online/@cppquiz"><img src="{{STATIC_URL}}/mastodon.png" height="15" alt="Mastodon"> Mastodon</a> |
109109
<a href="https://bsky.app/profile/cppquiz.bsky.social"><img src="{{STATIC_URL}}/bluesky.png" height="15" alt="Bluesky"> Bluesky</a> |
110-
<a href="https://x.com/intent/follow?screen_name=CppQuiz" class="x-follow"><img src="{{STATIC_URL}}/x.png" height="9" alt="X"> X</a> |
111110
<a href="https://github.com/knatten/cppquiz"> GitHub</a> |
112111
© <a href="http://knatten.org">Anders Schau Knatten</a> {% now "Y"%}.
113112
</p>

templates/quiz/finished.html

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,37 @@ <h3>All right!</h3>
2020
<p>You finished with {{quiz_in_progress.score|floatformat:2}} out of {{quiz_in_progress.get_total_nof_questions|floatformat:1}} <abbr title="1 point per correct question, but -0.5 points if you used a hint, and /2 for each wrong attempt.".>possible</abbr> points.</p>
2121

2222
<p>
23-
Now <a href="https://x.com/intent/tweet?hashtags=cpp,cplusplus&text=I got {{quiz_in_progress.score|floatformat:2}} of {{quiz_in_progress.get_total_nof_questions}} points on this @CppQuiz https://{{request.get_host}}{{request.get_full_path}} ! Can you match that?">boast about it on X</a>!
24-
<br>
25-
(This link takes you to x.com, we would never post on your behalf).
23+
Now boast about it on social media! Here's a suggestion, and feel free to tag us as
24+
<a href="https://bsky.app/profile/cppquiz.bsky.social">@cppquiz.bsky.social</a> or
25+
<a href="https://mastodon.online/@cppquiz">@cppquiz@mastodon.online</a>:
2626
</p>
2727

28+
<div class="copy-box">
29+
<span class="copy-text" id="quizMessage">
30+
I got {{quiz_in_progress.score|floatformat:2}} of {{quiz_in_progress.get_total_nof_questions}} points on this C++ Quiz https://{{request.get_host}}{{request.get_full_path}}! Can you match that?
31+
</span>
32+
<button class="copy-button" id="copyButton" onclick="copyToClipboard()">Copy</button>
33+
</div>
34+
35+
<script>
36+
function copyToClipboard() {
37+
const text = document.getElementById("quizMessage").innerText;
38+
const button = document.getElementById("copyButton");
39+
40+
navigator.clipboard.writeText(text).then(() => {
41+
button.innerText = "Copied!";
42+
button.disabled = true;
43+
44+
setTimeout(() => {
45+
button.innerText = "Copy";
46+
button.disabled = false;
47+
}, 1000);
48+
}).catch(err => {
49+
console.error("Could not copy text: ", err);
50+
});
51+
}
52+
</script>
53+
2854
<p>
2955
Why not <a href="/quiz/start">Start a new quiz</a>, <a href="/">go back to training mode</a>, or <a href="https://pragprog.com/titles/akbrain/c-brain-teasers/">get the official book</a>?
3056
</p>

templates/quiz/help.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<a href="/">Continue quiz</a>
55
<h2>About</h2>
66
<p>
7-
C++ Quiz is written by <a href="http://knatten.org">Anders Schau Knatten</a> with valuable input from <a href="http://www.pvv.org/~oma/cv.html">Olve Maudal</a>, <a href="http://fcacciola.50webs.com/">Fernando Cacciola</a>, other members of the <a href="http://accu.org/">ACCU</a>, and several other contributors. If you discover any errors, or would like to contribute, please contact me at anders AT knatten.org, on <a href="https://x.com/CppQuiz">X</a>, or on <a href="https://github.com/knatten/cppquiz/issues">GitHub</a>.
7+
C++ Quiz is written by <a href="http://knatten.org">Anders Schau Knatten</a> with valuable input from <a href="http://www.pvv.org/~oma/cv.html">Olve Maudal</a>, <a href="http://fcacciola.50webs.com/">Fernando Cacciola</a>, other members of the <a href="http://accu.org/">ACCU</a>, and several other contributors. If you discover any errors, or would like to contribute, please contact me at anders AT knatten.org or on <a href="https://github.com/knatten/cppquiz/issues">GitHub</a>.
88
</p>
99
<h2>Help/FAQ</h2>
1010
<h3>What is this?</h3>
@@ -21,7 +21,7 @@ <h3>What features are planned?</h3>
2121
<p>See <a href="https://github.com/knatten/cppquiz/issues?state=open">open issues on GitHub</a>.</p>
2222
</ol>
2323
<h3>How can I help?</h3>
24-
<p>If you know C++, by adding more questions, or joining our mailing-list <a href="mailto:cppquiz-discuss@cppquiz.org">cppquiz-discuss@cppquiz.org</a>. If you know Python/Django/JavaScript, by extending functionality. If you know web-design, by improving the design. Please contact me at anders AT knatten.org or <a href="https://x.com/knatten">X</a>.</p>
24+
<p>If you know C++, by adding more questions, or joining our mailing-list <a href="mailto:cppquiz-discuss@cppquiz.org">cppquiz-discuss@cppquiz.org</a>. If you know Python/Django/JavaScript, by extending functionality. If you know web-design, by improving the design. Please contact me at anders AT knatten.org or have a look at our <a href="https://github.com/knatten/cppquiz/issues">open GitHub issues</a>.
2525

2626
<h3 id="cookies">Cookies</h3>
2727
<p>

0 commit comments

Comments
 (0)