diff --git a/README.md b/README.md index 6b00865..fb05398 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,25 @@ # ordinary 第二届华清大学特普通奖学金集体创作系统 + +## Run in Develop Mode + +```bash +export FLASK_APP=app.py +export FLASK_ENV=development +flask run +python3 init_data.py # in an another terminal +``` + +Open http://127.0.0.1:5000/ordinary in a browser. + +## To-Do + +测试: +- [ ] 电脑端 + - [ ] 常规创作 + - [ ] 树形创作 +- [ ] 手机端 + - [ ] 常规创作 + - [ ] 树形创作 +- [ ] 微信浏览器 diff --git a/app.py b/app.py index af31c5d..51fb489 100644 --- a/app.py +++ b/app.py @@ -46,7 +46,7 @@ class Story(db.Model): title = db.Column(db.String(30)) avatar = db.Column(db.String(128)) text = db.Column(db.Text) - tail = db.Column(db.Integer) # 最后一个Paragraph的id + tail = db.Column(db.Integer) # 最后一个 Paragraph 的 id total_like_num = db.Column(db.Integer, default=0) is_tree = db.Column(db.Boolean, default=False) diff --git a/init_data.py b/init_data.py index 8ed8a07..2921355 100644 --- a/init_data.py +++ b/init_data.py @@ -4,12 +4,63 @@ from datetime import datetime db.drop_all() db.create_all() -BEGIN_WORDS = [("候选%d的标题" % (i + 1), "第%d个故事的示例开头" % (i + 1)) for i in range(10)] +BEGIN_WORDS = [ + ( + "候选" + "甲", + "男生。某传统工科。他从未想过自己会来华清,可机缘巧合之下还是来到了这里,身处数百人的庞大书院。他之前曾对园子里的生活有过很多美好的畅想,可如今却也都一一破灭了。大一上的微积分,到最后几节课他已经完全听不懂了,也不敢问同学。直到期末考试前一天晚上,他艰难地试图啃着天书般的教材,刷着课程群里他完全无法理解的讨论。第二天的考试,他没有去参加,而根据华清大学的规定,不参加期末考试便以挂科处理。", + "boy.png" + ), + ( + "候选" + "乙", + "女生。商科和管理学科。明年就要离开华清了,却似乎从未融入过园子里的生活。", + "girl.png" + ), + ( + "候选" + "丙", + "男生。艺术。追过三个女孩子,全都无功而返。在家人和朋友前毅然做出的“我要学艺术”的选择,在经过了几年的学习之后,却似乎已然记不得如此选择的理由了。“我真的喜欢学艺术嘛?”他的心头似乎总是为一层迷雾所笼罩。", + "boy.png" + ), + ( + "候选" + "丁", + "女生。某热门工科。高考失利,拼了一口气学了四年,才终于来到了华清。选择现在的专业最大的原因,就是招生办跟她讲“女孩子一般可能不太能学好这个”,她偏不同意,她想证明女生也是可以学好这个专业的。", + "boy.png" + ), + ( + "候选" + "戊", + "男生。理科。大概率要延毕了。毕业,曾以为是唾手可得的,却成了最渴望却也最遥远的梦想。曾经有一个想当理论科学家的远大志向,可是看着自己困顿的生活和迷茫的未来,却不知道该如何是好……", + "girl.png" + ), + ( + "候选" + "己", + "女生。不喜欢打扮。那年她收到了华清大学的录取通知书……", + "girl.png" + ), + ( + "候选" + "庚", + "男生。喜欢穿风衣。那年他收到了华清大学的录取通知书……", + "boy.png" + ), + ( + "候选" + "辛", + "女生。出门一般都戴帽子。那年他收到了华清大学的录取通知书……", + "girl.png" + ), + ( + "候选" + "壬", + "猫猫。那年它不小心从西门溜进了华清大学……", + "cat.jpg" + ), + ( + "候选" + "癸", + "留学生。那年华清大学的录取通知书漂洋过海寄到了家里……", + "v.jpg" + ), +] -for idx, (t, w) in zip(range(10), BEGIN_WORDS): - s = Story(id=idx, title=t, text=w, tail=idx, - avatar="https://bbs.pku.edu.cn/v2/images/user/portrait-anony.png") - p = Paragraph(id=idx, text=w, story_id=idx, is_chosen=True, +for idx, (title, text, avatar) in zip(range(10), BEGIN_WORDS): + s = Story(id=idx, title=title, text=text, tail=idx, + avatar="/ordinary/static/img/" + avatar) + p = Paragraph(id=idx, text=text, story_id=idx, is_chosen=True, author="初始设定", time=datetime.now()) db.session.add(s) db.session.add(p) diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..b0a714a --- /dev/null +++ b/requirements.txt @@ -0,0 +1,5 @@ +Flask~=2.0.2 +Flask_Limiter~=1.4 +Flask_SQLAlchemy~=2.5.1 +mastodon~=0.0.1 +Mastodon.py~=1.5.1 diff --git a/static/img/boy.png b/static/img/boy.png new file mode 100644 index 0000000..e9ee551 Binary files /dev/null and b/static/img/boy.png differ diff --git a/static/img/cat.jpg b/static/img/cat.jpg new file mode 100644 index 0000000..6fdf42c Binary files /dev/null and b/static/img/cat.jpg differ diff --git a/static/img/girl.png b/static/img/girl.png new file mode 100644 index 0000000..5b34d87 Binary files /dev/null and b/static/img/girl.png differ diff --git a/static/img/v.jpg b/static/img/v.jpg new file mode 100644 index 0000000..6450367 Binary files /dev/null and b/static/img/v.jpg differ diff --git a/templates/story.html b/templates/story.html index 14e74eb..19a889b 100644 --- a/templates/story.html +++ b/templates/story.html @@ -22,7 +22,7 @@
- +