add Render

This commit is contained in:
ppwwyyxx
2014-11-22 22:30:10 +08:00
parent d3c20d3490
commit 9a509ab2d8
5 changed files with 5855 additions and 10 deletions
+1 -5
View File
@@ -1,7 +1,7 @@
#!/usr/bin/env python2
# -*- coding: UTF-8 -*-
# File: Msg.py
# Date: Sat Nov 22 20:58:01 2014 +0800
# Date: Sat Nov 22 22:28:15 2014 +0800
# Author: Yuxin Wu <[email protected]>
from datetime import datetime
@@ -38,10 +38,6 @@ class WeChatMsg(object):
if self.content:
self.content = ensure_unicode(self.content)
def msg_html(self, res):
# TODO
assert res is not None
def msg_str(self):
# TODO: fix more types
if self.type == TYPE_LOCATION:
+2 -5
View File
@@ -1,7 +1,7 @@
#!/usr/bin/env python2
# -*- coding: UTF-8 -*-
# File: Parser.py
# Date: Sat Nov 22 20:48:04 2014 +0800
# Date: Sat Nov 22 22:17:27 2014 +0800
# Author: Yuxin Wu <[email protected]>
import sqlite3
@@ -9,7 +9,6 @@ from collections import defaultdict
import itertools
from .Msg import WeChatMsg
from .Res import Resource
from .utils import ensure_unicode
""" tables in concern:
@@ -23,7 +22,7 @@ rcontact
"""
class WeChatDBParser(object):
def __init__(self, db_fname, res_dir=None):
def __init__(self, db_fname):
""" db_fname: EnMicroMsg.db"""
self.db_fname = db_fname
self.db_conn = sqlite3.connect(self.db_fname)
@@ -31,8 +30,6 @@ class WeChatDBParser(object):
self.contacts = {}
self.msgs_by_talker = defaultdict(list)
self.res = Resource(res_dir) if res_dir else None
def _parse_contact(self):
contacts = self.cc.execute(
"""
Executable
+27
View File
@@ -0,0 +1,27 @@
#!/usr/bin/env python2
# -*- coding: UTF-8 -*-
# File: Render.py
# Date: Sat Nov 22 22:29:56 2014 +0800
# Author: Yuxin Wu <[email protected]>
import os
LIB_PATH = os.path.dirname(os.path.abspath(__file__))
CSS_FILE = os.path.join(LIB_PATH, 'static/wx.css')
HTML_FILE = os.path.join(LIB_PATH, 'static/template.html')
class HTMLRender(object):
def __init__(self, res=None):
self.css = open(CSS_FILE).read().replace('\n', '')
self.html = open(HTML_FILE).read()
self.res = res
def render_msg(self, msg):
""" render a message"""
# TODO
pass
if __name__ == '__main__':
r = HTMLRender()
with open('/tmp/a.html', 'w') as f:
print >> f, r.html.format(style=r.css, talker='talker',
messages='haha')
+30
View File
@@ -0,0 +1,30 @@
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>WeChat</title>
<link rel="stylesheet" type="text/css" href="http://localhost:8000/wx.css">
<style type="text/css">{style}</style>
</head>
<body ctrl="1">
<div id="container">
<div id="chat" class="chatPanel normalPanel" ctrl="1">
<div class="chatContainer" style="height: 800px;">
<div class="chatMainPanel" id="chatMainPanel">
<div class="chatTitle">
<div class="chatNameWrap">
<p class="chatName" id="messagePanelTitle">{talker}</p>
</div>
</div>
<div class="chatScorll" style="height: 770px; overflow-y: scroll; position: relative;">
<div id="chat_chatmsglist" class="chatContent" ctrl="1" style="position: absolute;">
{messages}
</div>
</div>
</div>
</div>
</div>
</div>
</body>
</html>
+5795
View File
File diff suppressed because it is too large Load Diff