Przeglądaj źródła

【格式化】

PJ-568 2 lat temu
rodzic
commit
24f57d3d98
4 zmienionych plików z 114 dodań i 114 usunięć
  1. 10 10
      client.sh
  2. 51 51
      html-chat.css
  3. 27 27
      index.html
  4. 26 26
      server.py

+ 10 - 10
client.sh

@@ -6,13 +6,13 @@ source config.ini
 # 主页界面
 show_home_page() {
     dialog --title "聊天室" \
-           --form "请选择操作:" 0 0 \
-           0 "昵称:" 1 1 "$NICKNAME" 1 15 20 \
-           1 "房间号:" 2 1 "$ROOM_ID" 2 15 20 \
-           2 "" 3 1 "" 3 1 "" \
-           3 "进入房间" 4 1 "" 4 1 "" \
-           4 "设置" 5 1 "" 5 1 "" \
-           5 "退出" 6 1 "" 6 1 ""
+        --form "请选择操作:" 0 0 \
+        0 "昵称:" 1 1 "$NICKNAME" 1 15 20 \
+        1 "房间号:" 2 1 "$ROOM_ID" 2 15 20 \
+        2 "" 3 1 "" 3 1 "" \
+        3 "进入房间" 4 1 "" 4 1 "" \
+        4 "设置" 5 1 "" 5 1 "" \
+        5 "退出" 6 1 "" 6 1 ""
     case $? in
         3) show_settings ;;
         4) enter_room ;;
@@ -43,7 +43,7 @@ show_settings() {
     local server_address=$(dialog --stdout --inputbox "设置服务器地址和端口:" 10 60 $SERVER_ADDRESS)
     local use_dialog=$(dialog --stdout --radiolist "是否使用 dialog:" 10 60 4 "yes" "是" on "no" "否" off)
     local reset_default=$(dialog --stdout --checklist "还原默认设置:" 10 60 1 "reset" "是" off)
-
+    
     if [[ $server_address ]]; then
         SERVER_ADDRESS=$server_address
     fi
@@ -56,7 +56,7 @@ show_settings() {
         # Reset to default settings
         source defaults.ini
     fi
-
+    
     echo "Settings updated."
 }
 
@@ -68,7 +68,7 @@ enter_room() {
             curl -X POST -d "nickname=$NICKNAME&roomid=$ROOM_ID&messageInput=$message" http://$SERVER_ADDRESS/send_message
             sleep 1
         fi
-
+        
         local log=$(curl -s "http://$SERVER_ADDRESS/log?id=$ROOM_ID")
         dialog --msgbox "$log" 0 0
     done

+ 51 - 51
html-chat.css

@@ -1,87 +1,87 @@
 body {
-    font-family: Arial, sans-serif;
-    background-color: #f4f4f4;
-    margin: 0;
-    padding-top: 20px;
-    color: #333;
+	font-family: Arial, sans-serif;
+	background-color: #f4f4f4;
+	margin: 0;
+	padding-top: 20px;
+	color: #333;
 }
 
 .container {
-    box-sizing: border-box;
-    overflow: hidden;
-    width: 100%;
-    max-width: 600px;
-    margin: 0 auto;
-    padding: 20px;
-    background-color: #fff;
-    border: 1px solid #ccc;
-    box-shadow: 2px 2px 5px rgba(0, 0, 0, 0.1);
-    border-radius: 5px;
+	box-sizing: border-box;
+	overflow: hidden;
+	width: 100%;
+	max-width: 600px;
+	margin: 0 auto;
+	padding: 20px;
+	background-color: #fff;
+	border: 1px solid #ccc;
+	box-shadow: 2px 2px 5px rgba(0, 0, 0, 0.1);
+	border-radius: 5px;
 }
 
 fieldset {
-    border: 1px solid #ddd;
-    padding: 10px;
-    margin-bottom: 5px;
+	border: 1px solid #ddd;
+	padding: 10px;
+	margin-bottom: 5px;
 }
 
 legend {
-    font-weight: bold;
-    padding: 0 10px;
+	font-weight: bold;
+	padding: 0 10px;
 }
 
 label {
-    display: block;
-    margin-bottom: 5px;
+	display: block;
+	margin-bottom: 5px;
 }
 
 input[type="text"],
 iframe {
-    box-sizing: border-box;
-    max-width: 100%;
-    width: 100%;
-    padding: 8px;
-    margin-bottom: 10px;
-    border: 1px solid #ddd;
-    border-radius: 3px;
+	box-sizing: border-box;
+	max-width: 100%;
+	width: 100%;
+	padding: 8px;
+	margin-bottom: 10px;
+	border: 1px solid #ddd;
+	border-radius: 3px;
 }
 
 a,
 a:visited,
 button {
-    align-items: center;
-    vertical-align:middle;
-    font-size: medium;
-    text-decoration: none;
-    max-height: 33px;
-    padding: 8px 15px;
-    background-color: #007BFF;
-    color: #fff;
-    border: none;
-    border-radius: 3px;
-    cursor: pointer;
+	align-items: center;
+	vertical-align: middle;
+	font-size: medium;
+	text-decoration: none;
+	max-height: 33px;
+	padding: 8px 15px;
+	background-color: #007BFF;
+	color: #fff;
+	border: none;
+	border-radius: 3px;
+	cursor: pointer;
 }
 
 a,
 a:visited:hover,
 button:hover {
-    background-color: #0056b3;
+	background-color: #0056b3;
 }
 
 button:active {
-    background-color: #0067b8;
+	background-color: #0067b8;
 }
 
 button:focus {
-    outline: 2px solid #007BFF;
+	outline: 2px solid #007BFF;
 }
 
 @media (max-width: 600px) {
-    .container {
-        width: 100%;
-        height: 100%;
-        border: none;
-        border-radius: 0;
-        box-shadow: none;
-    }
-}
+	.container {
+		width: 100%;
+		height: 100%;
+		border: none;
+		border-radius: 0;
+		box-shadow: none;
+	}
+}

+ 27 - 27
index.html

@@ -1,28 +1,28 @@
-<!DOCTYPE html>
-<html lang="zh-Hans">
-
-<head>
-    <meta charset="UTF-8">
-    <title>聊天室</title>
-    <link type="text/css" rel="stylesheet" href="html-chat.css">
-    <meta name="viewport" content="width=192, initial-scale=1.0">
-</head>
-
-<body>
-    <div class="container">
-        <form action="./chat" method="get">
-            <fieldset>
-                <legend>主页</legend>
-                <label for="nickname">昵称</label>
-                <input type="text" id="nickname" name="nickname" placeholder="匿名">
-                <br>
-                <label for="roomid">房间号:</label>
-                <input type="text" id="roomid" name="roomid" placeholder="默认">
-                <br>
-                <button type="submit">进入聊天室</button>
-            </fieldset>
-        </form>
-    </div>
-</body>
-
+<!DOCTYPE html>
+<html lang="zh-Hans">
+
+<head>
+	<meta charset="UTF-8">
+	<title>聊天室</title>
+	<link type="text/css" rel="stylesheet" href="html-chat.css">
+	<meta name="viewport" content="width=192, initial-scale=1.0">
+</head>
+
+<body>
+	<div class="container">
+		<form action="./chat" method="get">
+			<fieldset>
+				<legend>主页</legend>
+				<label for="nickname">昵称</label>
+				<input type="text" id="nickname" name="nickname" placeholder="匿名">
+				<br>
+				<label for="roomid">房间号:</label>
+				<input type="text" id="roomid" name="roomid" placeholder="默认">
+				<br>
+				<button type="submit">进入聊天室</button>
+			</fieldset>
+		</form>
+	</div>
+</body>
+
 </html>

+ 26 - 26
server.py

@@ -153,27 +153,27 @@ class ChatServer(http.server.BaseHTTPRequestHandler):
 <!DOCTYPE html>
 <html lang="zh-Hans">
 <head>
-    <meta charset="UTF-8">
-    <title>聊天室 - {roomid}</title>
-    <link type="text/css" rel="stylesheet" href="html-chat.css">
-    <meta name="viewport" content="width=192, initial-scale=1.0">
+	<meta charset="UTF-8">
+	<title>聊天室 - {roomid}</title>
+	<link type="text/css" rel="stylesheet" href="html-chat.css">
+	<meta name="viewport" content="width=192, initial-scale=1.0">
 </head>
 <body>
-    <div class="container">
-        <form action="./send_message" method="post">
-            <fieldset>
-                <legend>聊天室 - {roomid}</legend>
-                <iframe src="./log?id={roomid}" frameborder="0">加载中……</iframe>
-                <br>
-                <label for="messageInput">{nickname}说:</label>
-                <input type="text" id="messageInput" name="messageInput">
-                <button type="submit">发送</button>
-                <a href=".">退出</a>
-            </fieldset>
-            <input type="text" id="nickname" name="nickname" value="{nickname}" style="display: none;">
-            <input type="text" id="roomid" name="roomid" value="{roomid}" style="display: none;">
-        </form>
-    </div>
+	<div class="container">
+		<form action="./send_message" method="post">
+			<fieldset>
+				<legend>聊天室 - {roomid}</legend>
+				<iframe src="./log?id={roomid}" frameborder="0">加载中……</iframe>
+				<br>
+				<label for="messageInput">{nickname}说:</label>
+				<input type="text" id="messageInput" name="messageInput">
+				<button type="submit">发送</button>
+				<a href=".">退出</a>
+			</fieldset>
+			<input type="text" id="nickname" name="nickname" value="{nickname}" style="display: none;">
+			<input type="text" id="roomid" name="roomid" value="{roomid}" style="display: none;">
+		</form>
+	</div>
 </body>
 </html>
 '''.encode('utf-8')
@@ -185,15 +185,15 @@ class ChatServer(http.server.BaseHTTPRequestHandler):
 <!DOCTYPE html>
 <html lang="zh-Hans">
 <head>
-    <meta charset="UTF-8">
-    <title>聊天记录 - {roomid}</title>
-    <meta name="viewport" content="width=device-width, initial-scale=1.0">
-    <meta http-equiv="refresh" content="60">
+	<meta charset="UTF-8">
+	<title>聊天记录 - {roomid}</title>
+	<meta name="viewport" content="width=device-width, initial-scale=1.0">
+	<meta http-equiv="refresh" content="60">
 </head>
 <body style="font-family: Arial, sans-serif;">
-    <span>
-        {chat_log}
-    </span>
+	<span>
+		{chat_log}
+	</span>
 </body>
 </html>
 '''.encode('utf-8')