summaryrefslogtreecommitdiff
path: root/irclog
diff options
context:
space:
mode:
authorMistivia <i@mistivia.com>2025-11-02 15:30:55 +0800
committerMistivia <i@mistivia.com>2025-11-02 15:30:55 +0800
commit67135da61e10d806e6ecbba050f75d16233dabe1 (patch)
tree7e6afeae1a238bd0e3e59fd8723d71530f5ab9b7 /irclog
parent9f42c2d5f911cb4e215d7873221e642ce7df4d61 (diff)
delete lecagy irc log viewer
Diffstat (limited to 'irclog')
-rw-r--r--irclog/index.html0
-rw-r--r--irclog/linksub.js130
-rw-r--r--irclog/nginx.config9
-rw-r--r--irclog/view.html243
4 files changed, 0 insertions, 382 deletions
diff --git a/irclog/index.html b/irclog/index.html
deleted file mode 100644
index e69de29..0000000
--- a/irclog/index.html
+++ /dev/null
diff --git a/irclog/linksub.js b/irclog/linksub.js
deleted file mode 100644
index f855435..0000000
--- a/irclog/linksub.js
+++ /dev/null
@@ -1,130 +0,0 @@
-(function() {
- 'use strict';
-
- const targetUrlPattern = /https:\/\/raye\.mistivia\.com\/irclog\/([^/]+)\/(\d+)\/$/;
-
- const currentUrl = window.location.href;
-
- const match = currentUrl.match(targetUrlPattern);
-
- if (match) {
- let channel = match[1];
- let year = match[2];
-
- channel = channel.replace(/%23/g, '#');
- year = year.replace(/%23/g, '#');
-
- const links = document.querySelectorAll('a');
-
- links.forEach(link => {
- const originalHref = link.getAttribute('href');
-
- if (originalHref && originalHref.match(/^(\d{2}-\d{2}|\d{4}-\d{2}-\d{2}|[a-zA-Z0-9_-]+)\.txt$/)) {
-
- let datePart = originalHref.replace(/\.txt$/, '');
-
- datePart = datePart.replace(/%23/g, '#');
- const newHref = `https://raye.mistivia.com/irclog/view.html#${channel}/${year}/${datePart}`;
-
- link.setAttribute('href', newHref);
- }
- });
- }
-})();
-
-(function() {
- // Check if the title starts with "Index of"
- if (document.title.startsWith("Index of")) {
- // --- Mobile-Friendly Styles (CSS equivalent) ---
- var style = document.createElement('style');
- style.textContent = `
- body {
- font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
- margin: 0;
- padding: 15px;
- background-color: #ffffff;
- color: #333;
- max-width: 900px;
- }
- h1 {
- font-size: 1.8em; /* 标题稍大 */
- margin-bottom: 15px;
- color: #2c3e50;
- }
- hr {
- border: 0;
- border-top: 1px solid #ddd;
- margin: 10px 0 15px 0;
- }
- pre {
- white-space: pre-wrap;
- word-wrap: break-word;
- padding: 0;
- margin: 0;
- }
-
- /* 列表项链接样式 */
- a {
- display: block;
- padding: 12px 10px; /* 增加点击区域和间距 */
- font-size: 1.2em; /* 字体大一点 */
- text-decoration: none;
- color: #007aff;
- border-bottom: 1px solid #eee;
- transition: background-color 0.2s ease; /* 添加过渡效果 */
- }
-
- /* 鼠标悬停变色 (桌面端) */
- a:hover {
- background-color: #f0f8ff; /* 浅蓝色背景 */
- color: #005bb5; /* 链接颜色略深 */
- }
-
- /* 最后一个元素不显示底部分割线 */
- pre a:last-child {
- border-bottom: none;
- }
-
- /* 确保只显示文件名 */
- .filename-only {
- display: block !important;
- white-space: nowrap;
- overflow: hidden;
- text-overflow: ellipsis;
- width: 100%;
- }
- `;
- document.head.appendChild(style);
- const standardContent = 'width=device-width, initial-scale=1.0, viewport-fit=cover';
- const newViewport = document.createElement('meta');
- newViewport.setAttribute('name', 'viewport');
- newViewport.setAttribute('content', standardContent);
- document.head.appendChild(newViewport);
-
-
- // --- Clean up the Listing (JavaScript DOM Manipulation) ---
- var pre = document.querySelector('pre');
- if (pre) {
-
- var links = pre.querySelectorAll('a');
-
- // 2. Clear the original <pre> content
- pre.textContent = '';
-
- links.forEach(function(link) {
- // Get the href and the filename text
- var filename = link.textContent.trim(); // Trim whitespace
- var href = link.getAttribute('href');
-
- // Create a new, clean anchor element
- var newLink = document.createElement('a');
- newLink.setAttribute('href', href);
- newLink.classList.add('filename-only');
- newLink.textContent = filename; // Only the filename
-
- // Append the clean link to the <pre> block
- pre.appendChild(newLink);
- });
- }
- }
-})();
diff --git a/irclog/nginx.config b/irclog/nginx.config
deleted file mode 100644
index d00dae1..0000000
--- a/irclog/nginx.config
+++ /dev/null
@@ -1,9 +0,0 @@
-server {
- # ...
- location /irclog/ {
- charset UTF-8;
- autoindex on;
- sub_filter_types text/html;
- sub_filter '</body>' '<script src="/irclog/linksub.js"></script></body>';
- }
-}
diff --git a/irclog/view.html b/irclog/view.html
deleted file mode 100644
index 34b5154..0000000
--- a/irclog/view.html
+++ /dev/null
@@ -1,243 +0,0 @@
-<!DOCTYPE html>
-<html lang="en">
-<head>
- <meta charset="UTF-8">
- <meta name="viewport" content="width=device-width, initial-scale=1.0, viewport-fit=cover">
- <title>IRC Log Viewer</title>
- <style>
- body {
- font-family: Arial, sans-serif;
- max-width: 1000px;
- margin: 20px;
- background-color: #f4f4f4;
- }
- #log-container {
- border: 1px solid #ccc;
- padding: 15px;
- background-color: #fff;
- white-space: pre-wrap; /* 允许文本在新行换行 */
- }
- pre {
- /* 确保 pre 标签内的内容保持预格式化文本的特点 */
- font-family: Consolas, monospace;
- margin: 0;
- padding: 0;
- overflow-wrap: anywhere;
- white-space: pre-wrap; /* 允许文本在新行换行 */
- }
- .error {
- color: red;
- font-weight: bold;
- }
- .loading {
- color: blue;
- }
-@media (max-width: 600px) {
- pre {
- font-size: 0.7em;
- }
-}
- </style>
-</head>
-<body>
-
- <h1>IRC Log Viewer</h1>
- <!-- 新增日期选择界面 -->
- <div id="controls">
- <label for="log-date">选择日期:</label>
- <input type="date" id="log-date" value="">
- <br>
- <br>
- </div>
- <div id="status"></div>
- <button onclick="setPreviousDay()">上一天</button>
- <button onclick="setNextDay()">下一天</button>
- <div id="log-container">
- </div>
- <button onclick="setPreviousDay()">上一天</button>
- <button onclick="setNextDay()">下一天</button>
-
- <script>
- document.addEventListener('DOMContentLoaded', () => {
- const statusDiv = document.getElementById('status');
- const logContainer = document.getElementById('log-container');
-
- // 1. 读取URL的哈希值 (去掉开头的 #)
- let urlHash = window.location.hash.substring(1);
-
- if (!urlHash) {
- statusDiv.className = 'error';
- statusDiv.textContent = 'Error: No hash fragment found in the URL. Please append a hash (e.g., #2023-01-01) to the URL.';
- return;
- }
-var dateRegex = /(\d{4})\/(\d{2})-(\d{2})/;
-
-var match = urlHash.match(dateRegex);
-var formattedDate = null;
-
-if (match) {
- formattedDate = match[1] + '-' + match[2] + '-' + match[3];
- document.getElementById("log-date").value = formattedDate;
-}
-
- urlHash = urlHash.replace(/#/g, '%23');
-var parts = urlHash.split('/');
-
- var chan = "";
-if (parts.length >= 1) {
- chan= parts[0];
- }
- // 2. 构造TXT文件的URL
- const logBaseUrl = 'https://raye.mistivia.com/irclog/';
- let targetUrl = `${logBaseUrl}${urlHash}.txt`; // 假设日志文件是 .txt 格式
-
- statusDiv.className = 'loading';
- statusDiv.textContent = `Loading log for: ${urlHash} from ${targetUrl} ...`;
- logContainer.innerHTML = '';
-
- // --- 新增: HTML特殊字符转义函数 ---
- function escapeHtml(unsafe) {
- if (!unsafe) return '';
- // 替换 <, >, &, "
- return unsafe
- .replace(/&/g, "&amp;")
- .replace(/</g, "&lt;")
- .replace(/>/g, "&gt;")
- .replace(/"/g, "&quot;")
- .replace(/'/g, "&#039;");
- }
-
- function ircAction(text) {
- const regex =
- /^(\[[^\]]+\])(\s*<)([^>]+)(>:\s*)(\u0001ACTION\s+)([^\u0001]+)(\u0001)(.*)$/gm;
- const replacement = '$1 * $3 $6$8';
- return text.replace(regex, replacement);
- }
-
- function linkify(text) {
- const urlRegex = /(\b(https?):\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])/ig;
- return text.replace(urlRegex, function(url) {
- return `<a href="${url}" target="_blank">${url}</a>`;
- });
- }
-
- function loadLog(targetUrl) {
- fetch(targetUrl)
- .then(response => {
- if (!response.ok) {
- throw new Error(`HTTP Error: ${response.status} ${response.statusText} for hash: ${urlHash}`);
- }
- return response.text();
- })
- .then(text => {
- statusDiv.textContent = ''
- statusDiv.className = '';
- text = ircAction(text);
- let safeText = escapeHtml(text);
-
- const finalHtml = linkify(safeText);
- logContainer.innerHTML = `<pre>${finalHtml}</pre>`;
- })
- .catch(error => {
- console.error('Fetch error:', error);
- statusDiv.className = 'error';
- logContainer.innerHTML = '';
- });
- }
- loadLog(targetUrl);
-function ondatechange() {
- var dateInput = this;
- var dateValue = dateInput.value; // 获取当前选择的日期,格式为 yyyy-mm-dd
-
- if (dateValue && chan) {
-
- var dateParts = dateValue.split('-'); // 结果如: ["2025", "10", "21"]
-
- var year = dateParts[0];
- var month = dateParts[1];
- var day = dateParts[2];
-
- var finalPath = "https://raye.mistivia.com/irclog/" + chan + "/" + year + "/" + month + '-' + day + '.txt';
- loadLog(finalPath);
-const currentUrl = window.location.href;
-const datePattern = /(\/)\d{4}(\/)\d{2}-\d{2}$/;
-const newDateReplacement = `$1${year}$2${month + '-' + day}`;
-const newUrl = currentUrl.replace(datePattern, newDateReplacement);
-window.history.pushState(null, '', newUrl);
- }
-}
-
-
-document.getElementById("log-date").addEventListener('change', ondatechange, false);
-
- });
-
- const dateInput = document.getElementById('log-date');
-
- /**
- * 格式化 Date 对象为 YYYY-MM-DD 字符串
- * @param {Date} date - 要格式化的 Date 对象
- * @returns {string} 格式化后的日期字符串 (YYYY-MM-DD)
- */
- function formatDate(date) {
- const year = date.getFullYear();
- // getMonth() 返回 0-11,所以需要 +1
- const month = String(date.getMonth() + 1).padStart(2, '0');
- const day = String(date.getDate()).padStart(2, '0');
- return `${year}-${month}-${day}`;
- }
-
- /**
- * 设置日期输入框的值
- * @param {number} days - 要调整的天数 (例如: -1 为前一天, 1 为后一天)
- */
- function changeDate(days) {
- let currentDate;
-
- // 1. 获取当前值,如果为空,则使用当前日期
- const value = dateInput.value;
- if (value) {
- // 如果有值,从 ISO 格式 (YYYY-MM-DD) 创建 Date 对象
- // 使用 new Date(string) 可能会有时区问题,但对于 YYYY-MM-DD 格式,它通常会解析为 UTC 午夜,
- // 然后转换为本地时间。为了避免这个问题,可以手动解析或使用 new Date(year, monthIndex, day)。
- // 另一种更简单的办法是创建一个新的 Date 对象,然后使用 setDate()
- currentDate = new Date(value);
- } else {
- // 如果没有值,使用今天的日期
- currentDate = new Date();
- }
-
- // 2. 调整日期
- // new Date() 可能会包含时间部分,我们只需要日期。
- // 确保使用正确的方法来处理月份和年份的正确跨越。
- // setDate() 方法可以自动处理月份和年份的进位或退位。
- // 获取当前日期的“日”数
- const currentDay = currentDate.getDate();
- // 设置新的“日”数 (例如: 当前日 - 1 或 当前日 + 1)
- currentDate.setDate(currentDay + days);
-
- // 3. 格式化并设置回输入框
- dateInput.value = formatDate(currentDate);
- dateInput.dispatchEvent(new Event('change'));
- }
-
- /**
- * 设置日期为前一天
- */
- function setPreviousDay() {
- changeDate(-1);
- window.scrollTo(0, 0);
- }
-
- /**
- * 设置日期为后一天
- */
- function setNextDay() {
- changeDate(1);
- window.scrollTo(0, 0);
- }
-
- </script>
-
-</body>
-</html>