Improve JS and portability

This commit is contained in:
2019-10-16 20:03:39 +02:00
parent 4dda1e0a9c
commit e49778e0ed
2 changed files with 11 additions and 5 deletions

View File

@@ -34,8 +34,12 @@ extensions = [ "hardLineBreak" ]
Diaspora = "diasp.eu/u/mxmehl" Diaspora = "diasp.eu/u/mxmehl"
[params.mastodoncomments] [params.mastodoncomments]
# Link to your Mastodon profile. Please use the format https://<instanceURL>/users/<youruser>
user = "https://mastodon.social/users/mxmehl" user = "https://mastodon.social/users/mxmehl"
regex = '/\/?blog\/\d\d\d\d\/.+$/' # A regex which defines the relative path for URLs which you want to grep comments for.
# Character classes like \d (digits) have to be escaped, so \\d
regex = '/blog/\\d\\d\\d\\d/.+$'
# Contact address or URL. Can be a relative or absolute URL, or also a mailto:// address
contact = "/contact/" contact = "/contact/"
## Main Menu ## Main Menu

View File

@@ -1,7 +1,9 @@
$(document).ready(function() { $(document).ready(function() {
// check if we show a blog post or not. You might have to adapt this // check if we show a blog post or not. Regex is defined in site-wide config
var isArticle = /\/?blog\/\d\d\d\d\/.+$/.test(RelPermalink); var patt = new RegExp(BlogRegex);
console.log(patt);
var isArticle = patt.test(RelPermalink);
if (isArticle === false) { if (isArticle === false) {
console.log("Not a blog post, no need to search for comments"); console.log("Not a blog post, no need to search for comments");
return; return;
@@ -38,11 +40,11 @@ $(document).ready(function() {
} }
}); });
if (parseInt(root) > 0) { if (parseInt(root) > 0) {
$("#reference").append("<a href='https://mastodon.social/users/mxmehl/statuses/" + root + "'>Join the discussion on Mastodon!</a>"); $("#reference").append("<a href='" + MastodonUser + "/statuses/" + root + "'>Join the discussion on Mastodon!</a>");
} else { } else {
$("#comments").empty(); $("#comments").empty();
$("#statistics").empty(); $("#statistics").empty();
$("#reference").append("Comments are handled by my <a href='https://mastodon.social/@mxmehl'>Mastodon account</a>. Sadly this article wasn't published at Mastodon. Feel free to <a href='https://mehl.mx/contact/'>send me a mail</a> if you want to share your thoughts regarding this topic."); $("#reference").append("Comments are handled by my <a href='" + MastodonUser + "'>Mastodon account</a>. Sadly this article wasn't published at Mastodon. Feel free to <a href='" + CommentsContact + "/'>send me a mail</a> if you want to share your thoughts regarding this topic.");
} }
} }