Skip to content

Commit 1331b80

Browse files
committed
Don't encourage people to post on X
Suggest other sites like Bluesky and Mastodon instead.
1 parent de492ad commit 1331b80

File tree

2 files changed

+57
-3
lines changed

2 files changed

+57
-3
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/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>

0 commit comments

Comments
 (0)