Page Menu
Home
Musing Studio
Search
Configure Global Search
Log In
Files
F10494169
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
6 KB
Subscribers
None
View Options
diff --git a/templates/include/post-render.tmpl b/templates/include/post-render.tmpl
index 995d133..6ada0e2 100644
--- a/templates/include/post-render.tmpl
+++ b/templates/include/post-render.tmpl
@@ -1,133 +1,179 @@
<!-- Miscellaneous render related template parts we use multiple times -->
{{define "collection-meta"}}
{{if .Monetization -}}
<meta name="monetization" content="{{.DisplayMonetization}}" />
{{- end}}
+
{{if .Verification -}}
- <meta name="fediverse:creator" content="{{.Verification}}">
<link rel="me" href="{{.Verification}}" />
+
+<script>
+ document.addEventListener('DOMContentLoaded', function () {
+ // Function to convert URL into the desired format
+ function convertUrl(url) {
+ // Remove 'https://' or 'http://' from the beginning of the URL
+ const cleanUrl = url.replace(/^https?:\/\//, "");
+
+ // Split the cleaned URL by "/"
+ const parts = cleanUrl.split("/");
+
+ // Extract the username with @ (last part of the URL)
+ const usernameWithAt = parts[parts.length - 1];
+ const username = usernameWithAt.substring(1); // Remove the "@"
+
+ // Get the base URL without the username part
+ const baseUrl = parts.slice(0, parts.length - 1).join("/");
+
+ // Return the formatted result like "@username@baseurl"
+ const result = `@${username}@${baseUrl}`;
+ return result;
+ }
+
+ // Example URL
+ const url = "{{.Verification}}";
+
+ // Call the function and store the result in a variable
+ const convertedUrl = convertUrl(url);
+
+ // Log the result to confirm the URL is being processed correctly
+ console.log("Converted URL:", convertedUrl);
+
+ // Create a new meta tag
+ const metaTag = document.createElement('meta');
+ metaTag.setAttribute('name', 'fediverse:creator');
+ metaTag.setAttribute('content', convertedUrl);
+
+ // Append the new meta tag to the <head> section
+ document.head.appendChild(metaTag);
+
+ // Log to confirm that the meta tag has been added
+ console.log("Meta tag created and added with content:", metaTag.getAttribute('content'));
+ });
+</script>
+
+
{{- end}}
{{end}}
{{define "highlighting"}}
<script>
// TODO: this feels more like a mutation observer
addEventListener('DOMContentLoaded', function () {
var hlbaseUri = "/js/";
var lb = document.querySelectorAll("code[class^='language-']");
// Custom aliasmap
var aliasmap = {
"elisp" : "lisp",
"emacs-lisp" : "lisp",
"c" : "cpp",
"cc" : "cpp",
"h" : "cpp",
"c++" : "cpp",
"h++" : "cpp",
"hpp" : "cpp",
"hh" : "cpp",
"hxx" : "cpp",
"cxx" : "cpp",
"sh" : "bash",
"js" : "javascript",
"jsx" : "javascript",
"html" : "xml"
};
// Given a set of nodes, run highlighting on them
function highlight(nodes) {
for (i=0; i < nodes.length; i++) {
hljs.highlightBlock(nodes[i]);
}
}
// Given a array of URIs, load them in order
function loadLanguages(uris, callback) {
uris.forEach(function(uri) {
var sc = document.createElement('script');
sc.src = uri;
sc.async = false; // critical?
// Set callback on last script
if (uris.indexOf(uri) == uris.length-1) {
// Set callback regardless
// so we're sure it will run if last element had error
// (we only know after loading, so we've had load time already)
sc.onload = callback; sc.onerror = callback;
}
document.head.appendChild(sc);
});
}
// We don't have to do anything if there are no language blocks
if (lb.length > 0) {
// We have blocks to be highlighted, so we load css
var st = document.createElement('link');
st.rel = "stylesheet";
st.href = "/css/lib/atom-one-light.min.css";
document.head.appendChild(st);
// Construct set of files to load, in order
var jss = [hlbaseUri + "highlight.min.js"];
// Check what we need to load
for (i=0; i < lb.length; i++) {
lang = lb[i].className.replace('language-','').toLowerCase();
// Support the aliases specified above
if (aliasmap[lang]) lang = aliasmap[lang];
lurl = hlbaseUri + "highlightjs/" + lang + ".min.js";
if (!jss.includes(lurl)) {
jss.push(lurl);
}
}
// Load files in order, highlight on last load
loadLanguages(jss, () => {highlight(lb)});
}
});
</script>
{{end}}
<!-- Include mathjax configuration -->
{{define "mathjax"}}
<script>
MathJax = {
tex: {
inlineMath: [
["\\(", "\\)"],
['$', '$'],
],
displayMath: [
['$$', '$$'],
['\\[', '\\]'],
],
},
};
</script>
<script type="text/javascript" id="MathJax-script" src="/js/mathjax/tex-svg-full.js" async>
</script>
{{end}}
{{define "emailsubscribe"}}
{{if .EmailSubsEnabled}}
<div id="emailsub">
{{if .IsSubscriber}}
<p>You're subscribed to email updates. <a href="/api/collections/{{.Alias}}/email/unsubscribe">Unsubscribe</a>.</p>
{{else}}
<form method="post" action="/api/collections/{{.Alias}}/email/subscribe">
<input type="hidden" name="web" value="1" />
<p>Enter your email to subscribe to updates.</p> <div style="position: absolute; left: -5000px;" aria-hidden="true"><input type="email" name="{{.Honeypot}}" tabindex="-1" value="" /><input type="password" name="fake_password" tabindex="-1" placeholder="password" autocomplete="new-password" /></div>
<input type="email" name="email" placeholder="me@example.com" />
<input type="submit" id="subscribe-btn" value="Subscribe" />
</form>
<script type="text/javascript">
var $form = document.getElementById('emailsub').getElementsByTagName('form')[0];
$form.onsubmit = function() {
var $sub = document.getElementById('subscribe-btn');
$sub.disabled = true;
$sub.value = 'Subscribing...';
}
</script>
{{end}}
</div>
{{end}}
{{end}}
\ No newline at end of file
File Metadata
Details
Attached
Mime Type
text/x-diff
Expires
Thu, Mar 6, 8:53 AM (1 d, 12 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3168253
Attached To
rWF WriteFreely
Event Timeline
Log In to Comment