Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP - Basic webmention support #39

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions config.toml.example
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,13 @@ theme = "indigo"
MicroBlogUser = "MicroBlogUserName"
Country = "CountryName"
City = "CityName"
[params.endpoints]
Auth = "https://indieauth.com/auth"
# To get webmention support, just register at webmention.io and paste the link for endpoint here.
#Webmention = "https://webmention.io/<yourusername>/webmention"
# To get micropub support, you'll need to install a Micropub endpoint at your site and put its link there.
# To get an endpoint with Hugo support, use nanopub: https://github.com/dg01d/nanopub
# It will probably require some PHP hackery though, as it's fairly basic.
#Micropub = ""
# To get microsub support, you can use Aperture from p3k. Either go to https://aperture.p3k.io or self-host it (it's open source!)
#Microsub = ""
22 changes: 22 additions & 0 deletions layouts/_default/single.html
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,28 @@ <h1 class="post-title p-name">{{ .Title }}</h1>
<section class="content e-content">
{{ .Content }}
</section>
<script>
function injectcomments(data) {
var i;
for (i = 0; i < data.links.length; i++) {
var date = new Date(data.links[i].data.published);
document.getElementById('comments').innerHTML += `<div class="comment"><span class="comment-author"><img src="${data.links[i].data.author.photo}" class="comment-author-avatar"></img><a class="comment-author-name" href="${data.links[i].data.author.url}">${data.links[i].data.author.name}</a><p class="comment-time"><a href="${data.links[i].data.url}">replied</a> at ${date.toLocaleString("en-US")}:</p><div class="comment-content">${data.links[i].data.content}</div></div>`;
}
}
$(function(){
$.getJSON("https://webmention.io/api/mentions?jsonp=?", {
target: '{{ .Permalink }}',
"wm-property": "in-reply-to"
}, injectcomments);
});
</script>
<form method="post" action="https://webmention.io/fireburn.ru/webmention">
<p>Have you published a response to this? <label for="webmention-source">Let me know the <abbr title="Uniform Resource Locator">URL</abbr></label>:</p>
<input type="url" name="source" id="webmention-source">
<input type="hidden" name="target" value="{{ .Permalink }}">
<button type="submit">Ping!</button>
</form>
<div id="comments"> </div>
<footer>
<a class="permalink u-url" href="{{ .Permalink }}">{{ .Site.Params.PermalinkText }}</a>
{{ if .Params.tags }}
Expand Down
12 changes: 10 additions & 2 deletions layouts/partials/head.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,17 @@
{{ with .Site.Params.IndieWeb.TwitterUser }}<link rel="me" href="https://twitter.com/{{ . }}">{{ end }}
{{ with .Site.Params.IndieWeb.MicroBlogUser }}<link rel="me" href="https://micro.blog/{{ . }}">{{ end }}
<!-- IndieAuth endpoint -->
<link rel="authorization_endpoint" href="https://indieauth.com/auth">
{{ with .Site.Params.Endpoints.Auth }}<link rel="authorization_endpoint" href="{{ . }}">{{ end }}
{{ with .Site.Params.Endpoints.Webmention }}<link rel="webmention" href="{{ . }}">{{ end }}
{{ with .Site.Params.Endpoints.Microsub }}<link rel="microsub" href="{{ . }}">{{ end }}
{{ with .Site.Params.Endpoints.Micropub }}<link rel="micropub" href="{{ . }}">{{ end }}
<!-- Other stuff to make the site work -->
<script
src="https://code.jquery.com/jquery-3.3.1.min.js"
integrity="sha384-tsQFqpEReu7ZLhBV2VZlAu7zcOV+rXbYlF2cqB8txI/8aZajjp4Bqd+V6D5IgvKT"
crossorigin="anonymous"
/>
<style type="text/css">{{ partial "fonts.css" . | safeCSS }}</style>
<link rel="stylesheet" href="{{ .Site.BaseURL }}css/style.css" />
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>
</head>