forked from humiaozuzu/wechat-explorer
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c857006
commit e336282
Showing
5 changed files
with
319 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
import os | ||
import shutil | ||
|
||
from jinja2 import Environment, FileSystemLoader | ||
|
||
from we.wechat import WechatParser | ||
|
||
|
||
class HTMLExporter(object): | ||
|
||
def __init__(self, path, user_id, chatroom_id, start_at, end_at): | ||
self.wechat = WechatParser(path, user_id) | ||
self.records = self.wechat.get_chatroom_records(chatroom_id, start_at, end_at) | ||
self.friends = self.wechat.get_chatroom_friends(chatroom_id) | ||
|
||
def export(self, export_path): | ||
id_nicknames = {friend['id']: friend['nickname'] for friend in self.friends} | ||
for record in self.records: | ||
if not record['user_id']: | ||
continue | ||
|
||
record['nickname'] = id_nicknames.get(record['user_id']) or u'已退群' | ||
|
||
env = Environment(loader=FileSystemLoader('we/contrib/html_exporter_res/')) | ||
template = env.get_template('wechat.html') | ||
output_from_parsed_template = template.render(records=self.records) | ||
|
||
# make dir | ||
export_full_path = os.path.realpath(export_path) + '/records' | ||
os.makedirs(export_full_path) | ||
|
||
# copy res | ||
shutil.copytree('we/contrib/html_exporter_res/css', export_full_path+'/css') | ||
shutil.copytree('we/contrib/html_exporter_res/img', export_full_path+'/img') | ||
|
||
# build records html | ||
with open(export_full_path+"/records.html", "w") as fh: | ||
fh.write(output_from_parsed_template.encode('utf8')) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,241 @@ | ||
html { | ||
-ms-text-size-adjust: 100%; | ||
-webkit-text-size-adjust: 100% | ||
} | ||
|
||
body { | ||
-webkit-font-smoothing: antialiased; | ||
line-height: 1.6 | ||
} | ||
|
||
input,textarea,button,a { | ||
outline: 0 | ||
} | ||
|
||
body,h1,h2,h3,h4,h5,h6,p,ul,ol,dl,dd,fieldset,textarea { | ||
margin: 0 | ||
} | ||
|
||
fieldset,legend,textarea,input { | ||
padding: 0 | ||
} | ||
|
||
ul,ol { | ||
padding-left: 0; | ||
list-style-type: none | ||
} | ||
|
||
a img,fieldset { | ||
border: 0 | ||
} | ||
|
||
article,aside,details,figcaption,figure,footer,header,hgroup,main,nav,section,summary { | ||
display: block | ||
} | ||
|
||
audio,canvas,video { | ||
display: inline-block | ||
} | ||
|
||
|
||
.clearfix:after { | ||
content: " "; | ||
visibility: hidden; | ||
display: block; | ||
height: 0; | ||
clear: both | ||
} | ||
|
||
|
||
body { | ||
font-family: "Helvetica Neue",Helvetica,"Hiragino Sans GB","Microsoft YaHei",Arial,sans-serif; | ||
line-height: 1.6; | ||
} | ||
|
||
pre { | ||
margin: 0; | ||
font-family: inherit; | ||
font-size: inherit; | ||
white-space: pre-wrap; | ||
word-break: initial | ||
} | ||
|
||
.chat_bd { | ||
min-width: 720px; | ||
max-width: 800px; | ||
margin: 0 auto; | ||
position: relative; | ||
background-color: #eee; | ||
height: 100%; | ||
overflow: hidden | ||
} | ||
|
||
.chat_cont { | ||
padding: 0 19px; | ||
overflow-y: auto; | ||
overflow-x: hidden | ||
} | ||
|
||
|
||
.message { | ||
margin-bottom: 16px; | ||
float: left; | ||
width: 100%; | ||
page-break-inside: avoid !important; | ||
} | ||
|
||
.message .avatar { | ||
width: 40px; | ||
height: 40px; | ||
border-radius: 2px; | ||
-moz-border-radius: 2px; | ||
-webkit-border-radius: 2px; | ||
float: left; | ||
cursor: pointer | ||
} | ||
|
||
.message .nickname { | ||
font-weight: 400; | ||
padding-left: 10px; | ||
font-size: 12px; | ||
height: 22px; | ||
line-height: 24px; | ||
color: #4f4f4f; | ||
width: 350px; | ||
overflow: hidden; | ||
text-overflow: ellipsis; | ||
white-space: nowrap; | ||
word-wrap: normal | ||
} | ||
|
||
.message .content { | ||
overflow: hidden | ||
} | ||
|
||
.message_system { | ||
text-align: center; | ||
margin: 10px auto; | ||
max-width: 50% | ||
} | ||
|
||
.message_system .content { | ||
display: inline-block; | ||
background-color: #dcdcdc; | ||
font-size: 12px; | ||
padding: 1px 18px; | ||
color: #fff; | ||
border-radius: 2px; | ||
-moz-border-radius: 2px; | ||
-webkit-border-radius: 2px | ||
} | ||
|
||
.bubble { | ||
max-width: 500px; | ||
min-height: 1em; | ||
display: inline-block; | ||
vertical-align: top; | ||
position: relative; | ||
text-align: left; | ||
font-size: 14px; | ||
border-radius: 3px; | ||
-moz-border-radius: 3px; | ||
-webkit-border-radius: 3px; | ||
margin: 0 10px | ||
} | ||
|
||
.bubble.bubble_default { | ||
background-color: #fff | ||
|
||
} | ||
|
||
.bubble:before,.bubble:after { | ||
position: absolute; | ||
top: 14px; | ||
border: 6px solid transparent; | ||
content: " " | ||
} | ||
|
||
.bubble.left:before,.bubble.left:after { | ||
right: 100% | ||
} | ||
|
||
.bubble.left:after { | ||
border-right-color: #FFF; | ||
border-right-width: 4px | ||
} | ||
|
||
.bubble.right:before,.bubble.right:after { | ||
left: 100% | ||
} | ||
|
||
.bubble.right:after { | ||
border-left-color: #FFF | ||
} | ||
|
||
.bubble.bubble_primary { | ||
background-color: #b2e281 | ||
} | ||
|
||
.bubble.bubble_primary.left:after { | ||
border-right-color: #b2e281; | ||
border-right-width: 4px | ||
} | ||
|
||
.bubble.bubble_primary.right:after { | ||
border-left-color: #b2e281; | ||
border-left-width: 4px | ||
} | ||
|
||
.bubble.bubble_primary.right.arrow_primary:before { | ||
border-left-color: #b2e281; | ||
border-left-width: 4px | ||
} | ||
|
||
.bubble.bubble_primary.right.arrow_primary:after { | ||
border-left-color: #fff; | ||
border-left-width: 4px; | ||
margin-left: -2px | ||
} | ||
|
||
.bubble.no_arrow:before,.bubble.no_arrow:after { | ||
display: none | ||
} | ||
|
||
.bubble.fill { | ||
padding: 0 | ||
} | ||
|
||
.bubble.fill img { | ||
display: block; | ||
cursor: pointer | ||
} | ||
|
||
.bubble_hd { | ||
border-bottom: 1px solid #cfcfcf; | ||
padding-bottom: 7px; | ||
margin-bottom: 5px | ||
} | ||
|
||
.bubble_primary .bubble_hd { | ||
border-bottom: 1px solid #75bf50 | ||
} | ||
|
||
|
||
.bubble_cont { | ||
word-wrap: break-word; | ||
word-break: break-all; | ||
min-height: 25px | ||
} | ||
|
||
.bubble_cont li { | ||
overflow: hidden; | ||
color: #888 | ||
} | ||
|
||
.bubble_cont img { | ||
vertical-align: middle | ||
} | ||
|
||
.bubble_cont .plain { | ||
padding: 9px 13px | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
|
||
<head> | ||
<meta charset="UTF-8"> | ||
<title>Document</title> | ||
<link rel="stylesheet" type="text/css" href="css/style.css"> | ||
</head> | ||
|
||
<body> | ||
<div class="chat_bd"> | ||
<div class="chat_cont"> | ||
{% for record in records %} | ||
<div ng-repeat="message in chatContent" class="ng-scope"> | ||
<div class="clearfix" message-directive=""> | ||
<div ng-switch="" style="overflow: hidden;"> | ||
<div class="message ng-scope you"> | ||
<img class="avatar" src="img/default.jpeg" height="90" width="90" title=""> | ||
<div class="content"> | ||
<h4 class="nickname ng-binding ng-scope">{{ record.nickname }}</h4> | ||
<div class="bubble js_message_bubble ng-scope bubble_default left"> | ||
<div class="bubble_cont ng-scope"> | ||
<div class="plain"> | ||
<pre class="js_message_plain ng-binding" ng-bind-html="message.MMActualContent">{{ record.msg }}</pre> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
{% endfor %} | ||
</div> | ||
</div> | ||
</body> | ||
|
||
</html> |