Skip to content

Commit df32a9b

Browse files
committed
评论
1 parent 84b36bc commit df32a9b

File tree

7 files changed

+2682
-37
lines changed

7 files changed

+2682
-37
lines changed

script/import_comment.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@
66
$table3 = table('wiki_comment');
77

88
$i = 0;
9-
$json = json_decode(file_get_contents('./export.json'), true);
10-
$threads = array();
119

1210
foreach($json['threads'] as $li)
1311
{
@@ -55,5 +53,6 @@
5553
foreach($json['posts'] as $li)
5654
{
5755
if (!isset($threads[$li['thread_id']])) continue;
56+
$record ['wiki_id'] = $threads[$li['thread_id']];
5857
debug($li, $threads[$li['thread_id']]);
5958
}

script/update.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ function getNews()
1111
'Referer' => 'https://www.oschina.net/p/swoole-server',
1212
));
1313
$html = $curl->get('https://www.oschina.net/search?scope=news&q=swoole&sort_by_time=1');
14+
15+
1416
$dom = new Swoole\DOM\Tree($html);
1517
$list = $dom->find('ul#results > h3 > a');
1618

server/apps/configs/session.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<?php
2+
$session_config = array(
3+
'use_php_session' => false,
4+
'cookie_domain' => 'swoole.com',
5+
'cookie_lifetime' => 86400000,
6+
);
7+
return $session_config;

server/apps/controllers/Wiki.php

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ function index()
3737
$this->getTreeData();
3838
$_GET['id'] = $this->project['home_id'];
3939
$this->getPageInfo();
40+
$this->getComments();
4041
$this->swoole->tpl->display("wiki/noframe/index.html");
4142
}
4243

@@ -109,6 +110,19 @@ function main()
109110
$this->page();
110111
}
111112

113+
protected function getComments()
114+
{
115+
$thread_key = 'wiki-'.$this->tpl->_tpl_vars['id'];
116+
$t = table('duoshuo_posts');
117+
$list = $t->gets(array('thread_key' => $thread_key, 'order' => 'id asc'));
118+
$this->tpl->assign('comments', $list);
119+
120+
$t2 = table('duoshuo_thread');
121+
$list2 = $t2->gets(array('thread_key' => $thread_key, 'limit' => 1, 'order' => ''));
122+
$this->tpl->assign('thread', $list2[0]);
123+
}
124+
125+
112126
function page()
113127
{
114128
$this->getPageInfo();
@@ -123,6 +137,7 @@ function page()
123137
$this->getProjectInfo();
124138
$this->getTreeData();
125139
$this->getProjectLinks();
140+
$this->getComments();
126141
$this->swoole->tpl->display("wiki/noframe/index.html");
127142
}
128143

@@ -279,7 +294,6 @@ function edit()
279294
//更新节点
280295
$node->update_uid = $uid;
281296
$node->text = $cont->title;
282-
$node->link = trim($_POST['link']);
283297

284298
//更新缓存
285299
App\Content::clearCache($node->id);

server/apps/templates/wiki/noframe/index.html

Lines changed: 107 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -93,39 +93,116 @@ <h1 id="h_title">{{$wiki_page.title}}
9393
</article>
9494
<hr />
9595
<!-- Duoshuo Comment BEGIN -->
96-
<div class="ds-thread" data-thread-key="wiki-{{$wiki_page.id}}" data-title="{{$wiki_page.title}}"
97-
data-url="http://wiki.swoole.com/wiki/page/{{$wiki_page.id}}.html"></div>
96+
{{if $wiki_page.close_comment == 0}}
97+
<div class="ds-thread" data-thread-key="wiki-106" data-title="Swoole扩展"
98+
data-url="http://wiki.swoole.com/wiki/page/106.html" id="ds-thread">
99+
<div id="ds-reset">
100+
<div class="ds-meta"><a href="javascript:void(0)"
101+
class="ds-like-thread-button ds-rounded ds-thread-liked"><span
102+
class="ds-icon ds-icon-heart"></span> <span class="ds-thread-like-text">已喜欢</span><span
103+
class="ds-thread-cancel-like">取消喜欢</span></a><span class="ds-like-panel"><span
104+
class="ds-highlight">{{$thread.likes}}</span> 人喜欢</span></div>
105+
<div class="ds-comments-info">
106+
<div class="ds-sort"><a class="ds-order-desc">最新</a><a class="ds-order-asc ds-current">最早</a><a
107+
class="ds-order-hot">最热</a></div>
108+
<ul class="ds-comments-tabs">
109+
<li class="ds-tab"><a class="ds-comments-tab-duoshuo ds-current"
110+
href="javascript:void(0);"><span class="ds-highlight">{{$comments|@count}}</span>条评论</a>
111+
</li>
112+
</ul>
113+
</div>
114+
115+
<ul class="ds-comments">
116+
{{foreach item=v from=$comments}}
117+
<li class="ds-post" >
118+
<div class="ds-post-self">
119+
<div class="ds-avatar" data-user-id="8435783"><a rel="nofollow author" target="_blank"
120+
href="{{$v.author_url}}"
121+
title="{{$v.author_name}}"><img
122+
src="https://wiki.swoole.com/static/images/default.png"
123+
alt="{{$v.author_name}}"></a></div>
124+
<div class="ds-comment-body">
125+
<div class="ds-comment-header"><a class="ds-user-name ds-highlight" data-qqt-account=""
126+
href="{{$v.author_url}}"
127+
rel="nofollow" target="_blank" data-user-id="8435783">{{$v.author_name}}</a>
128+
</div>
129+
<p>{{$v.message}}</p>
130+
131+
<div class="ds-comment-footer ds-comment-actions"><span class="ds-time">{{$v.created_at|substr:0:10}}</span><a
132+
class="ds-post-reply" href="javascript:void(0);"><span
133+
class="ds-icon ds-icon-reply"></span>回复</a><a class="ds-post-likes"
134+
href="javascript:void(0);"><span
135+
class="ds-icon ds-icon-like"></span></a><a class="ds-post-repost"
136+
href="javascript:void(0);">
137+
</div>
138+
</div>
139+
</li>
140+
{{/foreach}}
141+
</ul>
142+
<div class="ds-paginator" style="display: none;">
143+
<div class="ds-border"></div>
144+
<a data-page="1" href="javascript:void(0);" class="ds-current">1</a></div>
145+
<div class="ds-toolbar">
146+
<div class="ds-account-control"><span class="ds-icon ds-icon-settings"></span> <span>帐号管理</span>
147+
<ul>
148+
<li><a class="ds-bind-more" href="javascript:void(0);" style="border-top: none">绑定更多</a>
149+
</li>
150+
<li><a target="_blank" href="http://duoshuo.com/settings/">设置</a></li>
151+
<li><a rel="nofollow" href="http://www4swoole.duoshuo.com/logout/"
152+
style="border-bottom: none">登出</a></li>
153+
</ul>
154+
</div>
155+
<div class="ds-visitor"><a class="ds-visitor-name" href="http://weibo.com/hantianfeng"
156+
target="_blank">Rango-韩天峰</a><a class="ds-unread-comments-count"
157+
href="javascript:void(0);" title="你没有新回复"
158+
style="display: none;">0</a></div>
159+
</div>
160+
<div class="ds-replybox"><a class="ds-avatar" href="http://duoshuo.com/settings/avatar/" target="_blank"
161+
title="设置头像"><img
162+
src="http://tva4.sinaimg.cn/crop.1.1.561.561.50/3fecf63djw8f7t533npdhj20g00i5dgz.jpg"
163+
alt="Rango-韩天峰"></a>
164+
165+
<form method="post"><input type="hidden" name="thread_id" value="1163167853466092117">
166+
<input type="hidden" name="parent_id" value="">
167+
<input type="hidden" name="nonce" value="573edf51578e7">
168+
169+
<div class="ds-textarea-wrapper ds-rounded-top"><textarea name="message" title="Ctrl+Enter快捷提交"
170+
placeholder="说点什么吧…"></textarea>
171+
<pre class="ds-hidden-text"></pre>
172+
</div>
173+
<div class="ds-post-toolbar">
174+
<div class="ds-post-options ds-gradient-bg"><span class="ds-sync"><input
175+
id="ds-sync-checkbox" type="checkbox" name="repost" checked="checked" value="weibo"> <label
176+
for="ds-sync-checkbox">分享到:</label><a href="javascript:void(0)"
177+
class="ds-service-icon ds-weibo"
178+
data-service="weibo" title="新浪微博"></a></span>
179+
</div>
180+
<button class="ds-post-button" type="submit">发布</button>
181+
<div class="ds-toolbar-buttons"><a class="ds-toolbar-button ds-add-emote" title="插入表情"></a>
182+
</div>
183+
</div>
184+
</form>
185+
</div>
186+
</div>
187+
</div>
188+
<link href="/static/css/duoshuo.css" rel="stylesheet">
189+
{{/if}}
98190
<script type="text/javascript">
99191
var _bdhmProtocol = (("https:" == document.location.protocol) ? "https://" : "http://");
100-
// {{if $wiki_page.close_comment=='0' and $project.close_comment=='0'}}
101192

102-
var duoshuoQuery = {short_name:"www4swoole"};
103-
(function() {
104-
var ds = document.createElement('script');
105-
ds.type = 'text/javascript';
106-
ds.async = true;
107-
ds.src = _bdhmProtocol + 'static.duoshuo.com/embed.js';
108-
ds.charset = 'UTF-8';
109-
(document.getElementsByTagName('head')[0]
110-
|| document.getElementsByTagName('body')[0]).appendChild(ds);
111-
$(ds).ready(function() {
112-
var resize_count = 0;
113-
var timer = setInterval(function() {
114-
if ($('div#ds-thread')[0].clientHeight < 100) {
115-
return;
116-
}
117-
var a = $("#sidebar")[0];
118-
var b = $("div.wiki_content")[0];
119-
if (a.clientHeight < b.clientHeight) {
120-
a.style.height = (b.clientHeight + 2) + "px";
121-
} else {
122-
b.style.height = (a.clientHeight + 2) + "px";
123-
}
124-
window.clearInterval(timer);
125-
}, 300);
126-
});
127-
})();
128-
// {{/if}}
193+
$(document).ready(function () {
194+
var resize_count = 0;
195+
var timer = setInterval(function () {
196+
var a = $("#sidebar")[0];
197+
var b = $("div.wiki_content")[0];
198+
if (a.clientHeight < b.clientHeight) {
199+
a.style.height = (b.clientHeight + 2) + "px";
200+
} else {
201+
b.style.height = (a.clientHeight + 2) + "px";
202+
}
203+
window.clearInterval(timer);
204+
}, 300);
205+
});
129206

130207
$(document).ready(function() {
131208
$('a').each(function(e){

web/index.en.html

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,11 +80,11 @@ <h2 style="margin-bottom: 25px;">Swoole:Redefined PHP Program Language</h2>
8080
<p style="margin-top: 25px;">
8181
<iframe src="http://ghbtns.com/github-btn.html?user=swoole&repo=swoole-src&type=star&count=true&size=large" frameborder="0" scrolling="0" width="160px" height="30px"></iframe>
8282
<iframe src="http://ghbtns.com/github-btn.html?user=swoole&repo=swoole-src&type=fork&count=true&size=large" frameborder="0" scrolling="0" width="158px" height="30px"></iframe>
83-
<a class="btn btn-sm btn-success" href="https://github.com/swoole/swoole-src/releases/tag/v1.9.4" style="margin-top: -20px; height: 20px;">
84-
<i class="glyphicon glyphicon-download"></i> &nbsp; Download <span style="font-size: 60%;">(1.9.4)</span> &nbsp; &nbsp;
83+
<a class="btn btn-sm btn-success" href="https://github.com/swoole/swoole-src/releases/tag/v1.9.8" style="margin-top: -20px; height: 20px;">
84+
<i class="glyphicon glyphicon-download"></i> &nbsp; Download <span style="font-size: 60%;">(1.9.8)</span> &nbsp; &nbsp;
8585

86-
<a class="btn btn-sm btn-success" href="https://github.com/swoole/swoole-src/releases/tag/v2.0.5" style="margin-top: -20px; margin-left: 20px; height: 20px;">
87-
<i class="glyphicon glyphicon-download"></i> &nbsp; Download <span style="font-size: 60%;">(2.0.5)</span> &nbsp;
86+
<a class="btn btn-sm btn-success" href="https://github.com/swoole/swoole-src/releases/tag/v2.0.7" style="margin-top: -20px; margin-left: 20px; height: 20px;">
87+
<i class="glyphicon glyphicon-download"></i> &nbsp; Download <span style="font-size: 60%;">(2.0.7)</span> &nbsp;
8888
</a>
8989
</p>
9090
</div>

0 commit comments

Comments
 (0)