Skip to content

Commit 3115f40

Browse files
built on Sun Apr 13 20:37:36 UTC 2025
0 parents  commit 3115f40

12 files changed

+1070
-0
lines changed

Diff for: .github/workflows/update.yaml

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: Build Release
2+
3+
on:
4+
workflow_dispatch:
5+
push:
6+
branches: [ main ]
7+
schedule:
8+
- cron: '28 * * * *'
9+
10+
jobs:
11+
build:
12+
name: Update
13+
runs-on: ubuntu-latest
14+
steps:
15+
16+
- name: Checkout
17+
uses: actions/checkout@v3
18+
19+
- name: Fetch data
20+
run: |
21+
. update.sh
22+
23+
- name: Push to release
24+
run: |
25+
git branch -D release || true
26+
git checkout --orphan release
27+
echo library.jlulug.org > CNAME
28+
git add data.json CNAME
29+
git config --local user.name "github-actions[bot]"
30+
git config --local user.email "github-actions[bot]@users.noreply.github.com"
31+
git commit -m "built on $(date)"
32+
git push -f -u origin release

Diff for: CNAME

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
library.jlulug.org

Diff for: LICENSE

+661
Large diffs are not rendered by default.

Diff for: README.md

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# LUG @ JLU 互助书柜
2+
3+
吉林大学 Linux 用户协会互助书柜的前端页面。
4+
5+
- `index.html` 前端渲染的独立页面
6+
- `style.css` 手搓的简易样式表
7+
- `vue.global.prod.js` Vue.js 3
8+
- `script.js` Vue 渲染逻辑
9+
- `paul-*.jpg` 背景图片
10+
11+
- `csv2json.py` 将 Google 表格提供的 CSV 转换成 JSON
12+
- `update.sh` 用于获取表格信息的脚本
13+
14+
15+
## 版权协议
16+
17+
本作品在 [GNU Affero 通用公共许可证第三版 (AGPLv3)](./LICENSE) 条件下开源。
18+
19+
部分文件来自外部,适用不同的版权协议:
20+
21+
- `vue.global.prod.js` 版权所有 2013 尤雨溪 (Evan You)
22+
-[MIT 许可证](https://opensource.org/licenses/MIT) 授权
23+
- `paul-melki-bByhWydZLW0-unsplash.jpg` 版权所有 2020 Paul Melki
24+
-[Unsplash 许可证](https://unsplash.com/license) 授权

Diff for: csv2json.py

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import csv
2+
import json
3+
import sys
4+
5+
COLNAME_MAP = {
6+
"ISBN": ("isbn", str),
7+
"豆瓣ID": (b'', lambda _: _),
8+
"豆瓣*": ("url", str),
9+
"书名": ("name", str),
10+
"作者": ("author", str),
11+
"分类": ("tags", str),
12+
"可用数*": ("avail", int),
13+
"馆藏数*": ("total", int),
14+
"来源*": ("source", str),
15+
}
16+
17+
18+
def main() -> list:
19+
header, *body = list(csv.reader(sys.stdin))
20+
json.dump([
21+
{
22+
col[0]: col[1](line[i])
23+
for i, k in enumerate(header)
24+
if (col := COLNAME_MAP.get(k, (k, lambda x: x)))
25+
}
26+
for line in body
27+
], sys.stdout, ensure_ascii=False, skipkeys=True)
28+
29+
30+
if __name__ == "__main__":
31+
main()

Diff for: data.json

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
[{"isbn": "9787302564607", "url": "https://book.douban.com/subject/35252459", "name": "CUDA 编程:基础与实践", "author": "樊哲勇", "tags": "CUDA;异构计算;C++;多线程;GPU", "avail": 1, "total": 1, "source": "史皓航捐赠"}, {"isbn": "9787111719489", "url": "https://book.douban.com/subject/36243215", "name": "现代 CPU 性能分析与优化", "author": "Denis Bakhvalov", "tags": "体系结构;并行效率;性能分析;流水线", "avail": 1, "total": 1, "source": "史皓航捐赠"}, {"isbn": "9787111416296", "url": "https://book.douban.com/subject/22181973", "name": "大规模并行处理器程序设计(英文版•第2版)", "author": "David B. Kirk / Wen-mei W. Hwu", "tags": "GPU;CUDA;OpenCL;OpenACC", "avail": 1, "total": 1, "source": "史皓航捐赠"}, {"isbn": "9787111582564", "url": "https://book.douban.com/subject/27201349", "name": "系统编程:分布式应用的设计与开发", "author": "Richard John Anthony", "tags": "分布式;套接字;体系结构;云;集群", "avail": 1, "total": 1, "source": "史皓航捐赠"}, {"isbn": "9787111681816", "url": "https://book.douban.com/subject/35501216", "name": "数据库系统概念(原书第7版)", "author": "Abraham Silberschatz / Henry F. Korth / S. Sudarshan", "tags": "数据库;关系模型;SQL;大数据;物理存储;事务;分布式", "avail": 1, "total": 1, "source": "史皓航捐赠"}, {"isbn": "9787111581659", "url": "https://book.douban.com/subject/30124664", "name": "现代操作系统(英文版)(第4版)", "author": "Andrew S.Tanenbaum / Herbert Bos", "tags": "操作系统;系统调用;进程;线程;内存管理;文件系统;死锁;虚拟化;云", "avail": 1, "total": 1, "source": "史皓航捐赠"}, {"isbn": "9787111392842", "url": "https://book.douban.com/subject/20374756", "name": "并行程序设计导论", "author": "Peter Pacheco", "tags": "MPI;OpenMP;Pthreads;多线程", "avail": 1, "total": 1, "source": "史皓航捐赠"}, {"isbn": "9787115328670", "url": "https://book.douban.com/subject/25809330", "name": "Linux/UNIX 系统编程手册(上、下册)", "author": "Michael Kerrisk / 孙剑", "tags": "系统编程;IO;进程;文件系统;信号;线程同步", "avail": 2, "total": 2, "source": "史皓航捐赠"}, {"isbn": "9787111338291", "url": "https://book.douban.com/subject/6097773", "name": "Linux 内核设计与实现(原书第3版)", "author": "Robert Love", "tags": "linux内核;进程管理;系统调用;中断处理;内核同步;内存管理;虚拟文件系统", "avail": 1, "total": 1, "source": "史皓航捐赠"}, {"isbn": "9787111641247", "url": "https://book.douban.com/subject/34907497", "name": "深入理解 Java 虚拟机:JVM 高级特性与最佳实践(第3版)", "author": "周志明", "tags": "java;JVM;垃圾回收;字节码;代码优化;多线程", "avail": 1, "total": 1, "source": "史皓航捐赠"}, {"isbn": "9787115576613", "url": "https://book.douban.com/subject/35635836", "name": "Go 语言设计与实现", "author": "左书祺", "tags": "go;并发编程;元编程", "avail": 0, "total": 1, "source": "史皓航捐赠"}, {"isbn": "9787512422407", "url": "https://book.douban.com/subject/33434575", "name": "C++ 进阶心法", "author": "吕吕 / 王琥", "tags": "C++;内存管理;多态;泛型编程;异常处理", "avail": 1, "total": 1, "source": "史皓航捐赠"}, {"isbn": "9787115508652", "url": "https://book.douban.com/subject/33400354", "name": "重构:改善既有代码的设计(第2版)", "author": "Martin Fowler", "tags": "重构;代码的坏味道;封装", "avail": 0, "total": 1, "source": "史皓航捐赠"}, {"isbn": "9787121412639", "url": "https://book.douban.com/subject/35491437", "name": "C++ 服务器开发精髓", "author": "张远龙", "tags": "后端开发;gdb;多线程;TCP;通信协议;redis", "avail": 1, "total": 1, "source": "史皓航捐赠"}, {"isbn": "9787111453833", "url": "https://book.douban.com/subject/26825411", "name": "TCP/IP 详解 卷1:协议(原书第2版)", "author": "Kevin R. Fall W. Richard Stevens", "tags": "计算机网络;TCP;IPv4;IPv6;NAT;UDP;DNS;ICMP", "avail": 1, "total": 1, "source": "史皓航捐赠"}, {"isbn": "9787121192821", "url": "https://book.douban.com/subject/20471211", "name": "Linux 多线程服务端编程:使用 muduo C++ 网络库", "author": "陈硕", "tags": "线程安全;线程同步;多线程;muduo;分布式", "avail": 1, "total": 1, "source": "史皓航捐赠"}, {"isbn": "9787115358851", "url": "https://book.douban.com/subject/25911735", "name": "TCP/IP 网络编程", "author": "尹圣雨", "tags": "TCP;UDP;网络编程;多进程;异步IO", "avail": 1, "total": 1, "source": "史皓航捐赠"}, {"isbn": "9787115367204", "url": "https://book.douban.com/subject/26434599", "name": "UNIX 网络编程 卷2:进程间通信(第2版)", "author": "W. Richard Stevens", "tags": "UNIX;管道;消息队列;信号量;共享内存", "avail": 1, "total": 1, "source": "史皓航捐赠"}, {"isbn": "9787115516756", "url": "https://book.douban.com/subject/34854427", "name": "UNIX 环境高级编程 第3版", "author": "W. Richard Stevens / Stephen A. Rago", "tags": "UNIX;进程;线程;进程间通信;套接字", "avail": 1, "total": 1, "source": "史皓航捐赠"}, {"isbn": "9787111464747", "url": "https://book.douban.com/subject/25900156", "name": "Redis 设计与实现", "author": "黄健宏", "tags": "redis;跳跃表;压缩列表;事件;sentinel;集群;lua", "avail": 1, "total": 1, "source": "史皓航捐赠"}, {"isbn": "9787302517276", "url": "https://book.douban.com/subject/33437381", "name": "统计学习方法(第2版)", "author": "李航", "tags": "统计学习;有监督学习;无监督学习;PageRank", "avail": 1, "total": 1, "source": "史皓航捐赠"}, {"isbn": "9787115414342", "url": "https://book.douban.com/subject/26745156", "name": "操作系统真象还原", "author": "郑钢", "tags": "操作系统;实模式;保护模式;中断;线程;内存管理;进程;文件系统", "avail": 1, "total": 1, "source": "史皓航捐赠"}, {"isbn": "9787121415616", "url": "https://book.douban.com/subject/35543446", "name": "PostgreSQL 技术内幕:事务处理深度探索", "author": "张树杰", "tags": "事务;锁;MVCC;故障恢复;SSI", "avail": 1, "total": 1, "source": "史皓航捐赠"}, {"isbn": "9787830093136", "url": "https://book.douban.com/subject/36115220", "name": "算法竞赛进阶指南", "author": "李煜东", "tags": "算法;数据结构;搜索;动态规划;图论;数学", "avail": 1, "total": 1, "source": "史皓航捐赠"}, {"isbn": "9787111605485", "url": "https://book.douban.com/subject/30932110", "name": "计算机体系结构基础(第二版)", "author": "胡伟武", "tags": "体系结构;组成原理;并行;性能分析", "avail": 1, "total": 1, "source": "史皓航捐赠"}, {"isbn": "9787111610410", "url": "https://book.douban.com/subject/30481523", "name": "并行多核体系结构基础", "author": "汤孟岩(Yan Solihin)", "tags": "并行;缓存;同步;SIMT", "avail": 1, "total": 1, "source": "史皓航捐赠"}, {"isbn": "9787121085116", "url": "https://book.douban.com/subject/3652388", "name": "程序员的自我修养:链接、装载与库", "author": "俞甲子 / 石凡 / 潘爱民", "tags": "静态链接;动态链接;ELF;延迟绑定", "avail": 1, "total": 1, "source": "史皓航捐赠"}, {"isbn": "9787111724605", "url": "https://book.douban.com/subject/36371037", "name": "高性能超标量 CPU:微架构剖析与设计", "author": "李东声", "tags": "指令集架构;缓存;分支预测;指令重排序;高性能计算", "avail": 1, "total": 1, "source": "史皓航捐赠"}, {"isbn": "9787115514080", "url": "https://book.douban.com/subject/34453160", "name": "信息检索导论(修订版)", "author": "Prabhakar Raghavan / Hinrich Schütze / Christopher Manning", "tags": "检索;索引;贝叶斯方法;SVD;聚类;PageRank", "avail": 1, "total": 1, "source": "史皓航捐赠"}, {"isbn": "9787111600640", "url": "https://book.douban.com/subject/30250702", "name": "结构化并行程序设计:高效计算模式", "author": "Michael McCool / Arch D. Robison / James Reinders", "tags": "并行模式;map-reduce;fork-join;流水线", "avail": 1, "total": 1, "source": "史皓航捐赠"}, {"isbn": "9787115517791", "url": "https://book.douban.com/subject/34844693", "name": "UNIX 网络编程 卷1 套接字联网 API 第3版", "author": "W. Richard Stevens / Bill Fenner / Andrew M.Rudoff", "tags": "TCP;UDP;SCTP;多播;IPv4;IPv6", "avail": 1, "total": 1, "source": "史皓航捐赠"}, {"isbn": "9787111655169", "url": "https://book.douban.com/subject/35078474", "name": "数据库系统内幕", "author": "Alex Petrov", "tags": "数据库;存储引擎;B 树;事务;分布式;", "avail": 1, "total": 1, "source": "史皓航捐赠"}, {"isbn": "9787121181184", "url": "https://book.douban.com/subject/20260928", "name": "编码:隐匿在计算机软硬件背后的语言", "author": "Charles Petzold", "tags": "编码;逻辑门;微处理器;操作系统", "avail": 1, "total": 1, "source": "史皓航捐赠"}, {"isbn": "9787115549990", "url": "https://book.douban.com/subject/35283154", "name": "奔跑吧 Linux 内核(第2版)卷1:基础架构", "author": "笨叔", "tags": "A64指令集;体系结构;虚拟内存;进程调度;负载均衡", "avail": 1, "total": 1, "source": "史皓航捐赠"}, {"isbn": "9787302522560", "url": "https://book.douban.com/subject/30499851", "name": "C# 高级编程:C# 7 & .NET Core 2.0 (第11版)", "author": "Christian Nagel", "tags": "C#;.NET;继承;泛型;委托;LINQ;反射;多线程;网络编程", "avail": 1, "total": 1, "source": "史皓航捐赠"}, {"isbn": "9787115487377", "url": "https://book.douban.com/subject/30311070", "name": "自制编程语言 基于C语言", "author": "郑钢", "tags": "词法分析;语法分析;语义分析;虚拟机;垃圾回收", "avail": 1, "total": 1, "source": "史皓航捐赠"}, {"isbn": "9787508338637", "url": "https://book.douban.com/subject/1723151", "name": "Linux 设备驱动程序", "author": "科波特", "tags": "设备驱动;内存管理;块设备;字符设备", "avail": 1, "total": 1, "source": "史皓航捐赠"}, {"isbn": "9787302179399", "url": "https://book.douban.com/subject/3155710", "name": "算法概论", "author": "Sanjoy Dasgupta / Christos Papadimitriou / Umesh Vazirani", "tags": "数论;分治;图论;贪心;最短路;动态规划;线性规划;NP完全性;量子算法", "avail": 1, "total": 1, "source": "史皓航捐赠"}, {"isbn": "9787115366610", "url": "https://book.douban.com/subject/26268767", "name": "Wireshark 网络分析就这么简单", "author": "林沛满", "tags": "wireshark;TCP;网络抓包;NFS协议解析;FTP;HTTP;kerberos", "avail": 1, "total": 1, "source": "史皓航捐赠"}, {"isbn": "9787302539414", "url": "https://book.douban.com/subject/35038473", "name": "汇编语言(第4版)", "author": "王爽", "tags": "汇编语言;8086;BIOS;中断", "avail": 1, "total": 1, "source": "史皓航捐赠"}, {"isbn": "9787111666073", "url": "https://book.douban.com/subject/35208251", "name": "现代操作系统:原理与实现", "author": "陈海波 / 夏虞斌", "tags": "操作系统;内存管理;进程管理;进程互斥;文件系统;虚拟化", "avail": 1, "total": 1, "source": "史皓航捐赠"}, {"isbn": "9787111453161", "url": "https://book.douban.com/subject/25813550", "name": "计算机组成与设计:硬件/软件接口(MIPS版)(英文版·第5版·亚洲版)", "author": "David A. Patterson / John L. Hennessy", "tags": "缓存;高性能计算;片上网络;GPU;RISC", "avail": 1, "total": 1, "source": "史皓航捐赠"}, {"isbn": "9787111376613", "url": "https://book.douban.com/subject/10549733", "name": "JavaScript 权威指南(第6版)", "author": "David Flanagan", "tags": "javascript;编程语言;jQuery;HTML5", "avail": 1, "total": 1, "source": "史皓航捐赠"}, {"isbn": "9787121261930", "url": "https://book.douban.com/subject/26744177", "name": "操作系统设计与实现", "author": "Andrew S. Tanenbaum(美)", "tags": "操作系统;MINIX;存储管理;文件系统", "avail": 1, "total": 1, "source": "童亦洲捐赠"}, {"isbn": "9787040471700", "url": "https://book.douban.com/subject/27021033", "name": "Python 语言程序设计基础(第 2 版)", "author": "嵩天 / 礼欣 / 黄天羽", "tags": "python", "avail": 1, "total": 1, "source": "许惠东捐赠"}, {"isbn": "9787121302954", "url": "https://book.douban.com/subject/26960678", "name": "计算机网络(第 7 版)", "author": "谢希仁", "tags": "计算机网络;TCP;IPv4;IPv6;NAT;UDP;DNS;ICMP", "avail": 1, "total": 1, "source": "许惠东捐赠"}, {"isbn": "9787302233602", "url": "https://book.douban.com/subject/5339673", "name": "嵌入式系统原理及应用教程", "author": "孟祥莲", "tags": "ARM;微处理器;嵌入式系统", "avail": 1, "total": 1, "source": "许惠东捐赠"}, {"isbn": "9787121357978", "url": "https://book.douban.com/subject/34860338", "name": "Python 编程入门指南(上、下册)", "author": "明日科技", "tags": "python", "avail": 1, "total": 1, "source": "许惠东捐赠"}, {"isbn": "9787517059875", "url": "https://book.douban.com/subject/30764030", "name": "中文版 MATLAB 2018 从入门到精通", "author": "天工在线", "tags": "matlab;向量;绘图;矩阵分析", "avail": 1, "total": 1, "source": "许惠东捐赠"}]

Diff for: index.html

+59
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
<!DOCTYPE html>
2+
<html lang="zh">
3+
<head>
4+
<meta charset="utf-8">
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
6+
<title>LUG@JLU 互助书柜</title>
7+
<link rel="stylesheet" href="./style.css">
8+
</head>
9+
<body>
10+
<header>
11+
<h1>LUG @ JLU <br>互助书柜</h1>
12+
<p>
13+
<button onclick="window.open('https://jlulug.org/library/', '_blank')">借阅须知</button>
14+
</p>
15+
</header>
16+
17+
<main><div>
18+
<div v-if="!books.length" id="loading"></div>
19+
<table v-else v-cloak>
20+
<thead>
21+
<tr>
22+
<th>书名</th>
23+
<th>作者</th>
24+
<th>ISBN</th>
25+
<th>状态</th>
26+
<th>来源</th>
27+
<th>分类</th>
28+
</tr>
29+
</thead>
30+
<tbody>
31+
<tr v-for="book in books">
32+
<td><a :href="book.url">{{ book.name }}</a></td>
33+
<td>{{ book.author }}</td>
34+
<td>{{ book.isbn }}</td>
35+
<td v-if="book.avail">
36+
<mark class="available">可用 <span v-if="book.avail > 1">{{ book.avail }} 本</mark>
37+
</td>
38+
<td v-else>
39+
<mark class="unavailable">已借出</mark>
40+
</td>
41+
<td>{{ book.source }}</td>
42+
<td><div>
43+
<mark v-for="tag in book_tags(book.tags)" :style="{ backgroundColor: tag[1] }">
44+
{{ tag[0] }}
45+
</mark>
46+
</div></td>
47+
</tr>
48+
</tbody>
49+
</table>
50+
<footer>
51+
<p>本页面由<a href="https://jlulug.org" target="_blank">吉林大学 Linux 用户协会</a>维护,保留一切权利。</p>
52+
<p>吉林大学 Linux 用户协会是由 GNU/Linux 用户与爱好者自愿结成的注册社团,旨在联络沟通同道中人,推广 GNU/Linux 的使用,宣传自由软件的价值,培养开放社区氛围。</p>
53+
</footer>
54+
</div></main>
55+
56+
<script src="./vue.global.prod.js"></script>
57+
<script src="./script.js"></script>
58+
</body>
59+
</html>

Diff for: paul-melki-bByhWydZLW0-unsplash.jpg

51.3 KB
Loading

Diff for: script.js

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
const hash = s => Math.abs(s.split('').reduce((a,b) => (((a << 5) - a) + b.charCodeAt(0))|0, 0))
2+
const colors = ['#DB2828','#F2711C','#FBBD08','#B5CC18','#21BA45','#00B5AD','#2185D0',
3+
'#6435C9','#A333C8','#E03997','#A5673F','#767676','#1B1C1D']
4+
5+
const app = Vue.createApp({
6+
data() {
7+
return {
8+
books_raw: [],
9+
}
10+
},
11+
computed: {
12+
books() {
13+
// filter out books with no stock (historical)
14+
// sort available books before lent out books
15+
return [...this.books_raw].filter(x => x.total > 0).sort((a,b) => (!!b.avail)-(!!a.avail))
16+
},
17+
},
18+
methods: {
19+
book_tags(tag_str) {
20+
return tag_str.split(';') // split tag string by ;
21+
.map(x=>x.trim()) // remove whitespaces
22+
.filter(x=>x) // remove empty item (consecutive ;;)
23+
.map(x=>[x, colors[hash(x) % colors.length]]) // choose color by string hash
24+
},
25+
},
26+
async mounted() {
27+
this.books_raw = await (await fetch('./data.json')).json()
28+
},
29+
})
30+
31+
app.mount('main')

0 commit comments

Comments
 (0)