-
Notifications
You must be signed in to change notification settings - Fork 0
/
blog.html
executable file
·166 lines (140 loc) · 6.33 KB
/
blog.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
<?php $this->yellow->layout("header") ?>
<div class="content">
<div class="h-entry main" role="main">
<?php $this->yellow->page->set("entryClass", "entry") ?>
<?php if ($this->yellow->page->isExisting("tag")): ?>
<?php foreach (preg_split("/\s*,\s*/", $this->yellow->page->get("tag")) as $tag) { $this->yellow->page->set("entryClass", $this->yellow->page->get("entryClass")." tag-".$this->yellow->lookup->normaliseArguments($tag, false)); } ?>
<?php endif ?>
<div class="<?php echo $this->yellow->page->getHtml("entryClass") ?>">
<div class="entry-title p-name"><h1><?php echo $this->yellow->page->getHtml("titleContent") ?></h1></div>
<div class="entry-meta"><span class="dt-published"><?php echo $this->yellow->page->getDateHtml("published") ?></span> <?php echo $this->yellow->language->getTextHtml("blogBy") ?> <span class="p-author h-card"><?php $authorCounter = 0; foreach (preg_split("/\s*,\s*/", $this->yellow->page->get("author")) as $author) { if (++$authorCounter>1) echo ", "; echo "<a href=\"".$this->yellow->page->getPage("blogStart")->getLocation(true).$this->yellow->lookup->normaliseArguments("author:$author")."\">".htmlspecialchars($author)."</a>"; } ?></span></div>
<div class="entry-content e-content"><?php echo $this->yellow->page->getContent() ?></div>
<?php echo $this->yellow->page->getExtra("profiles") ?>
<?php echo $this->yellow->page->getExtra("links") ?>
<?php if ($this->yellow->page->isExisting("tag")): ?>
<div class="entry-tags">
<p><?php echo $this->yellow->language->getTextHtml("blogTag") ?> <span class="p-category"><?php $tagCounter = 0; foreach (preg_split("/\s*,\s*/", $this->yellow->page->get("tag")) as $tag) { if (++$tagCounter>1) echo ", "; echo "<a href=\"".$this->yellow->page->getPage("blogStart")->getLocation(true).$this->yellow->lookup->normaliseArguments("tag:$tag")."\">".htmlspecialchars($tag)."</a>"; } ?></span></p>
</div>
<div class="permalink">Permalink:
<a class="u-url" href="<?php
// Program to display current page URL.
$link = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS']
=== 'on' ? "https" : "http") .
"://" . $_SERVER['HTTP_HOST'] .
$_SERVER['REQUEST_URI'];
echo $link;
?>"><?php echo $link ?></a>
</div>
<script>
var target_url = "<?php echo $link ?>";
var target_url1 = "https://www.disquisitioner.com/posts/post-darkmode/";
// jsonp=f option to disable json return
var count_url = "https://webmention.io/api/count.json?target=";
var mention_url = "https://webmention.io/api/mentions.jf2?target=";
var mfilter = "&wm-property=in-reply-to";
var defaultphoto = "https://aaronparecki.com/assets/images/no-profile-photo.png"
fetch(count_url+target_url)
.then(response => {return(response.text());})
.then(myJson => {showCounts(1,JSON.parse(myJson));});
fetch(mention_url+target_url)
.then(response => {return(response.text());})
.then(myJson => {showMentions(JSON.parse(myJson));});
function showCounts(index, data) {
// Add code to hide mention panel if data.count = 0
if(data.type.like) { document.getElementById("wm_like"+index).innerHTML = data.type.like; }
if(data.type.mention) { document.getElementById("wm_ment"+index).innerHTML = data.type.mention; }
if(data.type.reply) {
document.getElementById("wm_reply"+index).innerHTML =
pluralize(data.type.reply,"reply","replies");
}
if(data.type.repost) {
document.getElementById("wm_repost"+index).innerHTML =
pluralize(data.type.repost,"repost","reposts");
}
if(data.type.bookmark) { document.getElementById("wm_bkmk"+index).innerHTML = data.type.bookmark; }
}
function pluralize(num,singular,plural) {
if(num == 1) return num + " " + singular;
return num + " " + plural;
}
function showMentions(mentions) {
var panel = document.getElementById("mentionpanel");
for(i=0;i<mentions.children.length;i++) {
var m = mentions.children[i];
var m_div = document.createElement("DIV");
m_div.className = "webmention";
panel.appendChild(m_div);
var m_img = document.createElement("IMG");
if(m.author.photo) {
m_img.setAttribute("src",m.author.photo);
}
else {
m_img.setAttribute("src",defaultphoto);
}
m_img.setAttribute("width","64");
m_div.appendChild(m_img);
var m_info = document.createElement("DIV");
m_info.className = "wm_info";
m_div.appendChild(m_info);
// First line is author's name, liked to author's web site if present
if(m.author.url) {
var m_auth = document.createElement("A");
m_auth.href = m.author.url;
if(m.author.name) {
m_auth.innerHTML = m.author.name;
}
m_auth.className = "m_author";
m_info.appendChild(m_auth);
}
else {
if(m.author.name) {
var m_auth = document.createElement("SPAN");
m_auth.innerHTML = m.author.name;
m_auth.className = "m_author";
m_info.appendChild(m_auth);
}
}
// Second line = name of post linked to post URL, though
// if no name then is just URL
var m_art = document.createElement("A");
m_art.href = m.url;
if(m.name) {
m_art.innerHTML = m.name;
}
else {
m_art.innerHTML = m.url;
}
m_info.appendChild(m_art);
if(m.published) {
var d = new Date(m.published);
var m_pub = document.createElement("TIME");
m_pub.datetime = m.published;
m_pub.innerHTML = "Published: " + d.toString();
m_pub.className = "m_published";
m_info.appendChild(m_pub);
}
}
}
</script>
<div class="wm_box">
<div class="wm_summary">
<h3>Webmentions</h3>
<ul class="menicons">
<li class="micon"><i class="fa-regular fa-star"></i><span id="wm_like1"> </span> likes</li>
<li class="micon"><i class="fa-regular fa-file"></i><span id="wm_ment1"> </span> mentions</li>
<li class="micon"><i class="fa-regular fa-comment"></i><span id="wm_reply1"> </span></li>
<li class="micon"><i class="fa-solid fa-repeat"></i><span id="wm_repost1"> </span></li>
<li class="micon"><i class="fa-regular fa-bookmark"></i><span id="wm_bkmk1"> </span> bookmarks</li>
</div>
<hr>
<div id="mentionpanel"></div>
</div>
<?php echo $this->yellow->page->getExtra("previousnext") ?>
<?php endif ?>
<?php echo $this->yellow->page->getExtra("comments") ?>
<?php echo $this->yellow->page->getExtra("webmention") ?>
</div>
</div>
<div class="line-2"></div>
</div>
<?php $this->yellow->layout("footer") ?>