Skip to content
Browse files

better INSTALL in README.md

  • Loading branch information...
1 parent 6f93100 commit b06ddfa00774fbdfb1de9cad28ce8518197a48c1 @LTaoist LTaoist committed Oct 11, 2012
View
71 README.md
@@ -6,23 +6,12 @@ argon是全新的[argo](http://bbs.sysu.edu.cn)实现。使用python实现。
* database: sql表,数据库层
* model: 数据表达层,提供Board, User等模型及其相关操作,封装底层数据库操作
* web: argo 的web端逻辑, 使用tornado
- * lib: 公用函数库
* test: 各类测试工具
* telnet: argo 的telnet端逻辑. base on [chaofeng](https://github.com/LTaoist/chaofeng)
+ * tools: 配套工具
我们不喜欢重造轮子,如果你有好的建议,务必告诉我们!
-一些我们的讨论可以在[这里](http://bbs.sysu.edu.cn/bbstcon?board=Programming&file=M.1338262485.A)找到。
-
-Todo
-----
-
- * telnet完善
- * web的原型
- * frgg搜索
- * 更多人的参与
- * ...
-
About Argo
----------
@@ -62,8 +51,6 @@ Dependencies
其中jinja2目前被telnet端使用,可能会被web端使用。
-web端准备使用tornado 。
-
Install
-------
@@ -78,54 +65,32 @@ git clone https://github.com/argolab/argon.git
测试一下需要的依赖是否被满足:
```bash
-python -c 'import MySQLdb,eventlet,jinja2,redis,bcrypt,yaml'
+python -c 'import jinja2,MySQLdb,redis,eventlet,bcrypt,chaofeng,tornado,yaml'
```
-应该没有任何异常输出
+如果不使用telnet,chaofeng,eventlet和jinja2可以省去
-### 安装数据库Mysql和Redis
+应该没有任何异常输出,继续下一步。
-```bash
-sudo pacman -S mysql redis
-```
+### 安装数据库Mysql和Redis
目前很多一部分代码都在硬编码。配置还没有整合到一起。而数据库的
-封装层在model文件夹,他的配置文件在 argon/argo_config.py
-
-```python
-
-class ConfigDB:
- '''
- Database config
- '''
- host = "localhost"
- port= 3306
- user= "bbs"
- passwd= "forargo"
- dbname = "argo"
-
-class ConfigCache:
- '''
- Cache config
- '''
- host = "localhost"
- port = 6379
+封装层在model文件夹,他的配置文件在 argon/argo_config.py。
-```
+新建一个用户名为`bbs`,密码为`forargo`,并授权给`argo`数据库。
-### 初始化数据库
+redis使用默认的6379端口。
-首选需要根据上面ConfigDB的配置创建数据库和用户,然后使用我们目前提供的一个简单的python脚本创建数据库表:
+初始化mysql和redis :
```bash
-./admin.sh
->>> init_database()
+./tools/init_database.sh
+```
另外,需要初始化权限设置
```bash
-./admin.sh
->>> mrg.userperm.init_system()
+./tools/init_redis.sh
```
如果数据库正常启动,配置无错误,telnet即可启动了:
@@ -145,13 +110,23 @@ $ telnet localhost 5000
版块等等,也没有讨论区分区。
```bash
+cd ../ ## 回到 argon/
./admin.sh
-mrg.team.joint_team('你注册的帐号', 'SYS_SUPER')
+>>> mrg.team.joint_team('你注册的帐号', 'SYS_SUPER')
```
这将会将你注册的帐号设置为超级帐号,然后登录(可能需要登出再登入)。
即可简单管理入口。
+### 测试web
+
+```bash
+cd web
+python server.py
+```
+
+使用8080端口。
+
### 补充
如果存在一些旧的数据和旧的设置,可能会导致出现问题(SQL和redis设置
View
8 argo_conf.py
@@ -8,20 +8,20 @@
import os
BASE_DIR = os.path.dirname(os.path.abspath(__file__))
-DATA_DIR = os.path.join(BASE_DIR, 'database/')
+SQL_DIR = os.path.join(BASE_DIR, 'database/')
#######################
# Database Configure ##
#######################
-SQL_TPL_DIR = BASE_DIR
-
DB_HOST = 'localhost'
DB_PORT = 3306
DB_USER = 'bbs'
DB_PASSWD = 'forargo'
DB_NAME = 'argo'
-BASE_TABLE = [ 'attachead','boardhead','sectionhead','user','userattr']
+BASE_TABLE = [ 'attachead','boardhead','sectionhead','user','userattr',
+ 'annhead', 'filehead_junk', 'undenylist', 'denylist',
+ 'mailhead', 'filehead']
###################
# Redis Configure #
View
BIN argon_preojct.jpg
Deleted file not rendered
View
1 database/argo_attachead.sql
@@ -1,3 +1,4 @@
+-- THIS TABLE IS FROM FUTURE AND NOT USED YET
DROP TABLE IF EXISTS `argo_attachead`;
CREATE TABLE IF NOT EXISTS `argo_attachead` (
`aid` int(11) unsigned NOT NULL auto_increment,
View
28 database/template/argo_annhead.sql
@@ -1,28 +0,0 @@
-/*
- pid : Parent annhead id
- editor: The bm who edited this ann
- flag:
- 'r'->regular file(post)
- 'd'->dir
- 'l'->link
- Find all of the children:
- select id from argo_annhead_xxx where pid = id
-*/
-DROP TABLE IF EXISTS `argo_annhead_${boardname}`;
-CREATE TABLE IF NOT EXISTS `argo_annhead_${boardname}` (
- `id` int(11) unsigned NOT NULL auto_increment default 0,
- `pid` int(11) unsigned NOT NULL default 0,
- `rank` int(11) unsigned NOT NULL,
- `title` varchar(60),
-
- `owner` varchar(14),
- `editor` varchar(14),
-
- `flag` varchar(2),
- `mtime` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
-
- `tags` varchar(64),
- `content` text,
-
- PRIMARY KEY (`id`)
-) ENGINE=InnoDB DEFAULT CHARSET=UTF8;
View
31 database/template/argo_filehead.sql
@@ -1,31 +0,0 @@
-DROP TABLE IF EXISTS `argo_filehead_${boardname}`;
-CREATE TABLE IF NOT EXISTS `argo_filehead_${boardname}` (
- `pid` int(11) unsigned NOT NULL auto_increment,
- `bid` int(11) unsigned NOT NULL,
- `owner` varchar(14),
- `realowner` varchar(14),
- `title` varchar(60),
- `flag` int(11) unsigned default 0,
- `tid` int(11) unsigned default 0,
- `replyid` int(11) unsigned default 0,
- `posttime` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
- `attachidx` varchar(20),
-
- `fromaddr` varchar(64),
- `fromhost` varchar(64) NOT NULL default "Yat-sen Channel",
-
- `content` text,
- `quote` text,
- `signature` text,
-
- `agree` int(11) unsigned NOT NULL default 0,
- `disagree` int(11) unsigned NOT NULL default 0,
- `credit` int(11) NOT NULL default 0,
-
- `originalfilename` varchar(32), /* M.123456789.A */
- `replyable` boolean NOT NULL,
-
- `look_reply` boolean NOT NULL default false,
-
- PRIMARY KEY (`pid`)
-) ENGINE=InnoDB DEFAULT CHARSET=UTF8;
View
31 database/template/argo_filehead_junk.sql
@@ -1,31 +0,0 @@
-DROP TABLE IF EXISTS `argo_filehead_${boardname}_junk`;
-CREATE TABLE IF NOT EXISTS `argo_filehead_${boardname}_junk` (
- `jid` int(11) unsigned NOT NULL auto_increment,
-
- `pid` int(11) unsigned NOT NULL,
- `bid` int(11) unsigned NOT NULL,
- `owner` varchar(14),
- `realowner` varchar(14),
- `title` varchar(60),
- `flag` int(11) unsigned default 0,
- `tid` int(11) unsigned default 0,
- `replyid` int(11) unsigned default 0,
- `posttime` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
- `attachidx` varchar(20),
-
- `fromaddr` varchar(64),
- `fromhost` varchar(64) NOT NULL default "Yat-sen Channel",
-
- `content` text,
- `quote` text,
- `signature` text,
-
- `agree` int(11) unsigned NOT NULL default 0,
- `disagree` int(11) unsigned NOT NULL default 0,
- `credit` int(11) NOT NULL default 0,
-
- `originalfilename` varchar(32), /* M.123456789.A */
- `replyable` boolean NOT NULL,
-
- PRIMARY KEY (`jid`)
-) ENGINE=InnoDB DEFAULT CHARSET=UTF8;
View
26 database/template/argo_mailhead.sql
@@ -1,26 +0,0 @@
-/*
- tableid = uid / 100
-*/
-DROP TABLE IF EXISTS `argo_mailhead_${tableid}`;
-CREATE TABLE IF NOT EXISTS `argo_mailhead_${tableid}` (
- `mid` int(11) unsigned NOT NULL auto_increment,
- `fromuserid` varchar(16) NOT NULL,
- `touserid` varchar(16) NOT NULL,
- `attachidx` varchar(128),
-
- `tid` int(11) unsigned ,
- `replyid` int(11) unsigned NOT NULL default 0,
- `title` varchar(60),
-
- `sendtime` timestamp NOT NULL default CURRENT_TIMESTAMP ,
- `fromaddr` varchar(64),
-
- `readmark` int(11) unsigned NOT NULL default 0,
- `flag` int(11) unsigned NOT NULL default 0,
- `content` text,
- `quote` text,
- `signature` text,
-
- PRIMARY KEY (`mid`)
-) ENGINE=MyISAM DEFAULT CHARSET=UTF8;
-
View
50 doc/status.md
@@ -1,50 +0,0 @@
-IDLE: ""
-NEW: "新站友注册"
-LOGIN: "进入本站"
-DIGESTRACE: "浏览精华区"
-MMENU: "主选单"
-ADMIN: "管理者选单"
-SELECT: "选择讨论区"
-READBRD: "一览众山小"
-READNEW: "看看新文章"
-READING: "品味文章"
-POSTING: "文豪挥笔"
-// MAIL: "处理信笺"
-SMAIL: "寄语信鸽"
-RMAIL: "阅览信笺"
-TMENU: "聊天选单"
-LUSERS: "东张西望:)"
-FRIEND: "寻找好友"
-MONITOR: "探视民情"
-QUERY: "查询网友"
-TALK: "聊天"
-PAGE: "呼叫"
-CHAT1: "国际会议厅"
-CHAT2: "咖啡红茶馆"
-CHAT3: "Chat3"
-CHAT4: "Chat4"
-LAUSERS: "探视网友"
-XMENU: "系统资讯"
-VOTING: "投票中..."
-EDITUFILE: "编辑个人档"
-EDITSFILE: "编修系统档"
-ZAP: "订阅讨论区"
-SYSINFO: "检查系统"
-DICT: "翻查字典"
-LOCKSCREEN: "屏幕锁定"
-NOTEPAD: "留言板"
-GMENU: "工具箱"
-MSG: "送讯息"
-USERDEF: "自订参数"
-EDIT: "修改文章"
-OFFLINE: "自杀中.."
-EDITANN: "编修精华"
-LOOKMSGS: "察看讯息"
-WFRIEND: "寻人名册"
-WNOTEPAD: "欲走还留"
-BBSNET: "BBSNET"
-WINMINE: "键盘扫雷"
-FIVE: "决战五子棋"
-// WORKER: "推箱子"
-PAGE_FIVE: "邀请下棋"
-default: "扑朔迷离"
View
15 doc/str.md
@@ -0,0 +1,15 @@
+目录结构
+========
+
+database 数据库设计
+model 抽象数据接口
+telnet telnet的实现
+web web的实现
+test 测试样例
+tools 配套工具
+doc 文档
+
+argo_conf.py 公用配置段
+admin.sh 管理工具
+
+
View
2 install.sh
@@ -0,0 +1,2 @@
+echo 'Check for dependencies...'
+python -c 'import jinja2,MySQLdb,redis,eventlet,bcrypt,chaofeng,tornado,yaml'
View
6 model/__init__.py
@@ -1,14 +1,14 @@
-#import config
import status
+import argo_conf
from error import *
def init_database():
- for table_name in config.BASE_TABLE :
+ for table_name in argo_conf.BASE_TABLE :
init_table(table_name)
def init_table(table_name):
from globaldb import global_conn as db
- with open(config.SQL_TPL_DIR+'argo_'+table_name+'.sql') as f:
+ with open(argo_conf.SQL_DIR+'argo_'+table_name+'.sql') as f:
sql = f.read()
print sql
try:
View
4 model/globaldb.py
@@ -278,7 +278,7 @@ def _finish_conn(self, conn):
OperationalError = MySQLdb.OperationalError
def connect_db():
- from config import DB_HOST, DB_PORT, DB_USER, DB_PASSWD, DB_NAME
+ from argo_conf import DB_HOST, DB_PORT, DB_USER, DB_PASSWD, DB_NAME
try:
from config import USE_EVENTLET_DB_POOL
except ImportError:
@@ -297,7 +297,7 @@ def connect_db():
database=DB_NAME)
def connect_ch():
- from config import REDIS_HOST, REDIS_PORT
+ from argo_conf import REDIS_HOST, REDIS_PORT
return redis.Redis(host=REDIS_HOST, port=REDIS_PORT)
global_conn = connect_db()
View
2 telnet/menu.yaml
@@ -13,7 +13,7 @@ sysinfo :
- ['', (A)bout 查看系统属性, [help, {pagename: about }], a, [13,25]]
- ['', (T)est 测试键盘按键, test_keyboard, t]
- ['$AUTHED_USER', (B)ugReport 错误报告, post_bug, b]
- - ['', (P)layFilm 电影放映室, movie, p]
+ ## - ['', (P)layFilm 电影放映室, movie, p]
- ['', (E)xit 回到主选单, main, e]
mail:
View
2 tools/init_database.sh
@@ -0,0 +1,2 @@
+cd database
+cat argo_attachead.sql argo_boardhead.sql argo_sectionhead.sql argo_user.sql argo_userattr.sql argo_annhead.sql argo_filehead_junk.sql argo_undenylist.sql argo_denylist.sql argo_mailhead.sql argo_filehead.sql | mysql argo -u bbs -p
View
1 tools/init_redis.sh
@@ -0,0 +1 @@
+python -c 'from model import manager ; manager.userperm.init_system()'
View
4 web/board.py
@@ -14,8 +14,8 @@ def get(self, boardname, rank=None):
posts = manager.post.get_posts(board['bid'], rank, 30)
elif self.get_current_user() :
userid = self.get_current_user()
- lastread = manager.readmark.get_first_read(userid, boardname)
- lastread = manager.post.prev_three_post(board.bid, lastread)
+ lastread = manager.readmark.get_first_read(userid, boardname) or 0
+ lastread = manager.post.prev_three_post(board.bid, lastread) or 0
posts = manager.post.get_posts_after_pid(
board.bid, lastread, 30)
rank = manager.post.get_rank_num(board.bid, lastread)
View
8 web/post.py
@@ -1,3 +1,6 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+
import tornado.web
from lib import BaseHandler, manager, fun_gen_quote
@@ -36,7 +39,10 @@ def get(self, replyid):
if not self.get_current_user():
raise tornado.web.HTTPError(404)
default = fun_gen_quote(self.get_current_user(), post.content)
- self.srender("replypost.html", post=post, default=default)
+ title = post.title if post.title.startswith('Re:') \
+ else 'Re: %s' % post.title
+ self.srender("replypost.html", post=post, title=title,
+ default=default)
def post(self, replyid):
userid = self.get_current_user()
View
1 web/static/css/argo.css
@@ -248,6 +248,7 @@ div.center{
.post-content{
padding:2em;
min-height:81px;
+ font-family:monospace;
}
.time{
View
BIN web/static/images/avatar/LTaoist
Binary file not shown.
View
BIN web/static/images/avatar/admin
Binary file not shown.
View
BIN web/static/images/avatar/ltaoist
Binary file not shown.
View
BIN web/static/images/avatar/test
Binary file not shown.
View
2 web/template/newpost.html
@@ -2,7 +2,7 @@
{% block main %}
<div>
- {% module Editor('发表文章') %}
+ {% module Editor(header='发表文章') %}
</div>
{% end %}
View
2 web/template/post.html
@@ -15,7 +15,7 @@
</div>
</div>
<div class="post-content">
- {% raw post.content.replace("\n", "<br/>\n") %}
+ {% raw escape(post.content).replace("\n", "<br/>\n") %}
</div>
<div class="post-sign">
{{ post.signature }}
View
2 web/template/replypost.html
@@ -2,7 +2,7 @@
{% block main %}
<div>
- {% module Editor(title='回复文章', default=default) %}
+ {% module Editor(header='回复文章', title=title, default=default) %}
</div>
{% end %}
View
4 web/template/ui/editor.html
@@ -1,9 +1,9 @@
<form method="post" class="form-horizontal">
- <legend>{{ title }}</legend>
+ <legend>{{ header }}</legend>
<div class="control-group">
<label class="control-label" for="inputTitle">标题</label>
<div class="controls">
- <input name="title" type="text" id="inputTitle" class="span5"/>
+ <input name="title" type="text" id="inputTitle" value="{{ title }}" class="span5"/>
</div>
</div>
<div class="control-group">
View
23 web/template/ui/postnav.html
@@ -1,18 +1,27 @@
<div class="post-nav">
+ {% if prevpid %}
+ <a href="/post/{{ prevpid }}">上一篇</a>
+ {% else %}
+ 前面没有了
+ {% end %}
+ {% if nextpid %}
+ <a href="/post/{{ nextpid }}">下一篇</a>
+ {% else %}
+ 后面没有了
+ {% end %}
+ |
{% if (pid==firstpid) and (pid==lastpid) %}
<span>这是唯一一篇</span>
{% else %}
- {% if pid==firstpid %}
- <span>前面没有文章了</span>
+ {% if pid == firstpid %}
+ <span>这是主题第一贴</span>
{% else %}
- <a href="/post/{{ firstpid }}">第一篇</a>
- <a href="/post/{{ prevpid }}">上一篇</a>
+ <a href="/post/{{ firstpid }}">主题第一贴</a>
{% end %}
{% if pid==lastpid %}
- <span>后面没有文章了</span>
+ <span>这是主题最新贴</span>
{% else %}
- <a href="/post/{{ nextpid }}">下一篇</a>
- <a href="/post/{{ lastpid }}">最后一篇</a>
+ <a href="/post/{{ lastpid }}">主题最新贴</a>
{% end %}
{% end %}
</div>
View
7 web/uimodules.py
@@ -56,8 +56,9 @@ def render(self, firstpid, prevpid, nextpid, lastpid, pid):
return self.render_string('ui/postnav.html', firstpid=firstpid,
prevpid=prevpid, nextpid=nextpid,
lastpid=lastpid, pid=pid)
+
class Editor(tornado.web.UIModule):
- def render(self, title='发表文章', default=''):
- return self.render_string('ui/editor.html', title=title,
- default=default)
+ def render(self, header='发表文章', title='', default=''):
+ return self.render_string('ui/editor.html', header=header,
+ title=title, default=default)

0 comments on commit b06ddfa

Please sign in to comment.
Something went wrong with that request. Please try again.