summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ircbot/urltitle.py10
-rw-r--r--irclog/view/index.html14
-rw-r--r--irclog/view/view9.js (renamed from irclog/view/view8.js)10
3 files changed, 21 insertions, 13 deletions
diff --git a/ircbot/urltitle.py b/ircbot/urltitle.py
index 2d06fdc..d367d17 100644
--- a/ircbot/urltitle.py
+++ b/ircbot/urltitle.py
@@ -13,13 +13,9 @@ title_regex = re.compile(
)
headers = {
- "User-Agent": "spider/2.1",
- "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7",
- "Accept-Encoding": "gzip, deflate, br",
- "Accept-Language": "zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6",
- "Connection": "keep-alive",
- "DNT": "1",
- "Upgrade-Insecure-Requests": "1",
+ "User-Agent": "Mozilla/5.0 (compatible; The Lounge IRC Client; +https://github.com/thelounge/thelounge)" +
+ " facebookexternalhit/1.1 Twitterbot/1.0",
+ "X-Purpose": "preview",
}
def url_titles(text):
diff --git a/irclog/view/index.html b/irclog/view/index.html
index ceee973..55232b2 100644
--- a/irclog/view/index.html
+++ b/irclog/view/index.html
@@ -56,6 +56,18 @@
color: black;
text-decoration: none;
}
+ .logimg {
+ vertical-align: top;
+ display: inline-block;
+ max-width: 300px;
+ max-height: 300px
+ }
+ .logvid {
+ vertical-align: top;
+ display: inline-block;
+ max-width: 300px;
+ max-height: 300px
+ }
</style>
</head>
<body>
@@ -73,6 +85,6 @@
<div id="log-container"></div>
<button onclick="setPreviousDay()">上一天</button>
<button onclick="setNextDay()">下一天</button>
- <script src="./view8.js"></script>
+ <script src="./view9.js"></script>
</body>
</html>
diff --git a/irclog/view/view8.js b/irclog/view/view9.js
index c8cdad0..bc2c158 100644
--- a/irclog/view/view8.js
+++ b/irclog/view/view9.js
@@ -86,7 +86,7 @@ function isPic(url) {
'.gif'
];
for (let s of pics) {
- if (url.endsWith(s)) {
+ if (url.toLowerCase().endsWith(s)) {
return true;
}
}
@@ -97,10 +97,10 @@ function isVideo(url) {
const vids = [
'.webm',
'.ogv',
- 'mp4'
+ '.mp4'
];
for (let s of vids) {
- if (url.endsWith(s)) {
+ if (url.toLowerCase().endsWith(s)) {
return true;
}
}
@@ -111,10 +111,10 @@ function linkify(text) {
const urlRegex = /(\b(https?):\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])/ig;
return text.replace(urlRegex, function(url) {
if (isPic(url)) {
- return `<a href="${url}" target="_blank"><img style="vertical-align:top;display:inline-block;max-width:300px;max-height:300px" src="${url}"></a>`;
+ return `<a href="${url}" target="_blank"><img class="logimg" src="${url}"></a>`;
}
if (isVideo(url)) {
- return `<video style="vertical-align:top;display:inline-block;max-width:300px;max-height:300px" src="${url}" controls></video>`
+ return `<video class="logvid" src="${url}" controls></video>`
}
return `<a href="${url}" target="_blank">${url}</a>`;
});