Some fix for syndication and webmentions
This commit is contained in:
@@ -9,7 +9,7 @@ import hashlib
|
||||
http_domain = "https://fundor333.com"
|
||||
domain = "fundor333.com"
|
||||
token = os.getenv("WEBMENTIONS_TOKEN")
|
||||
since_days = 31
|
||||
since_days = 360 * 20 # 31
|
||||
|
||||
|
||||
class WebmentionFinder:
|
||||
@@ -71,10 +71,43 @@ class WebmentionFinder:
|
||||
|
||||
files = os.listdir(path_f)
|
||||
|
||||
out_dict = []
|
||||
out_dict = {
|
||||
"source": [],
|
||||
"stats": {
|
||||
"like-of": 0,
|
||||
"bookmark-of": 0,
|
||||
"mention-of": 0,
|
||||
"repost-of": 0,
|
||||
"in-reply-to": 0,
|
||||
"comments": [],
|
||||
},
|
||||
}
|
||||
source = []
|
||||
for e in files:
|
||||
with open(os.path.join(path_f, e)) as file:
|
||||
out_dict.append(json.load(file))
|
||||
for element in json.load(file):
|
||||
source.append(element)
|
||||
|
||||
out_dict["source"] += source
|
||||
comments = []
|
||||
links = []
|
||||
|
||||
for e in source:
|
||||
wm_property = e["wm-property"]
|
||||
out_dict["stats"][wm_property] += 1
|
||||
link = e["wm-source"]
|
||||
if e.get("content", False):
|
||||
if not (link in links):
|
||||
single_data = {
|
||||
"content": e["content"]["text"],
|
||||
"link": e["wm-source"],
|
||||
"author_name": e["author"]["name"],
|
||||
"author_photo": e["author"]["photo"],
|
||||
"author_url": e["author"]["url"],
|
||||
}
|
||||
comments.append(single_data)
|
||||
links.append(link)
|
||||
out_dict["stats"]["comments"] = comments
|
||||
|
||||
with open(os.path.join("data", "webmentions", folder + ".json"), "w") as fp:
|
||||
json.dump(out_dict, fp)
|
||||
|
||||
@@ -1,19 +1,13 @@
|
||||
|
||||
|
||||
|
||||
{{if in site.Params.commentSections .Type}}
|
||||
|
||||
<hr>
|
||||
<script src="/js/webmention.min.js"
|
||||
data-wordcount='50'
|
||||
data-page-url='{{replace (absURL .RelPermalink) "localhost:1313" "fundor333.com"}}'
|
||||
data-alternative-url='{{ range .Aliases }}{{ (absURL .) }}{{ end }}' async>
|
||||
</script>
|
||||
<div id="webmentions"></div>
|
||||
{{ partial "webmention" . }}
|
||||
|
||||
<p>To reply to this post, you can send a <a href="https://indieweb.org/Webmention" target="_blank">Webmention</a> or you can toot me at <a href="https://mastodon.social/@fundor333">fundor333@mastodon.social</a> <br>
|
||||
|
||||
You mentioned this post on your site? Send a <a href="https://indieweb.org/Webmention" target="_blank">Webmention</a></p>
|
||||
|
||||
{{end}}
|
||||
|
||||
{{if in site.Params.suggestionSections .Type}}
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
|
||||
{{ $urlized := (replace (absURL .RelPermalink) "http://localhost:1313" "https://fundor333.com") | md5 }}
|
||||
{{ $urlized := .Page.Permalink | md5 }}
|
||||
{{ if index .Site.Data.syndication $urlized }}
|
||||
|
||||
|
||||
7
layouts/partials/webmention.html
Normal file
7
layouts/partials/webmention.html
Normal file
@@ -0,0 +1,7 @@
|
||||
<script src="/js/webmention.min.js"
|
||||
data-wordcount='50'
|
||||
data-page-url='{{replace (absURL .RelPermalink) "localhost:1313" "fundor333.com"}}'
|
||||
data-alternative-url='{{ range .Aliases }}{{ (absURL .) }}{{ end }}' async>
|
||||
</script>
|
||||
<div id="webmentions"></div>
|
||||
|
||||
@@ -1,17 +1,15 @@
|
||||
<h1> ----- </h1>
|
||||
{{ $urlized := .Page.Permalink | md5 }}
|
||||
{{ $urlized := (replace (absURL .RelPermalink) "http://localhost:1313" "https://fundor333.com") | md5 }}
|
||||
|
||||
|
||||
|
||||
{{index .Site.Data.webmentions $urlized }}
|
||||
|
||||
{{ if index .Site.Data.webmentions $urlized }}
|
||||
|
||||
{{ $data:= index .Site.Data.webmentions $urlized }}
|
||||
{{ $data:= index (index .Site.Data.webmentions $urlized ) "stats" }}
|
||||
|
||||
|
||||
{{ range (index .Site.Data.webmentions $urlized )}}
|
||||
{{ . }}
|
||||
{{ end }}
|
||||
<h1>---</h1>
|
||||
|
||||
{{ $likes := index (index .Site.Data $urlized) "like-of" }}
|
||||
{{ $replys := index (index .Site.Data $urlized) "in-reply-to" }}
|
||||
|
||||
Reference in New Issue
Block a user