Skip to content

Commit 50d8fa6

Browse files
committed
支持GITHUB页面
1 parent d53f6f7 commit 50d8fa6

File tree

16 files changed

+191
-113
lines changed

16 files changed

+191
-113
lines changed

script/build_group_index.php

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?php
2+
require dirname(__DIR__).'/server/config.php';
3+
require APPSPATH.'/classes/xunsearch/lib/XS.php';
4+
5+
$wikis = table('wiki_tree')->gets(array('project_id' => 1));
6+
$table = table('wiki_content');
7+
8+
echo "count=".count($wikis)."\n";
9+
10+
$xs = new XS(WEBPATH.'/search.ini');
11+
12+
$index = $xs->index;
13+
$index->beginRebuild();
14+
15+
foreach($wikis as $v)
16+
{
17+
$wiki = $table->get($v['id'])->get();
18+
$data = array(
19+
'pid' => $v['id'],
20+
'subject' => $v['text'],
21+
'message' => $wiki['content'],
22+
'chrono' => time(),
23+
);
24+
25+
$doc = new XSDocument;
26+
$doc->setFields($data);
27+
28+
$ret = $index->add($doc);
29+
echo "index #{$v['id']} ok\n";
30+
}
31+
32+
$index->endRebuild();
33+

server/apps/configs/site.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
22
return array(
33
'static' => 'http://www.swoole.com/static/',
4+
'git_path' => dirname(WEBPATH).'/git',
45
);

server/apps/configs/upload.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
<?php
2-
$upload['base_dir'] = WEBPATH.'/static/uploads/';
2+
$upload['base_dir'] = dirname(WEBPATH).'/web/static/uploads/';
33
$upload['base_url'] = WEBROOT.'/static/uploads/';
44
return $upload;

server/apps/controllers/Person.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -202,21 +202,21 @@ function passwd()
202202

203203
function profile()
204204
{
205-
if($_POST)
205+
if ($_POST)
206206
{
207-
if(empty($_POST['nickname']))
207+
if (empty($_POST['nickname']))
208208
{
209209
return Swoole\JS::js_back('昵称不能为空!');
210210
}
211-
if(!empty($_FILES['avatar']['name']))
211+
if (!empty($_FILES['avatar']['name']))
212212
{
213213
global $php;
214214
$php->upload->thumb_width = 90;
215215
$php->upload->thumb_height = 120;
216216
$php->upload->thumb_qulitity = 90;
217-
$php->upload->base_dir = "/static/uploads/avatar";
217+
$php->upload->sub_dir = "avatar";
218218
$upfile = $php->upload->save('avatar');
219-
if($upfile===false)
219+
if ($upfile === false)
220220
{
221221
return Swoole\JS::js_back('上传失败!');
222222
}

server/apps/controllers/Wiki.php

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,7 @@ private function getPageInfo()
150150
{
151151
$_cont = model('WikiContent');
152152
$_tree = model('WikiTree');
153+
$node = false;
153154

154155
if (!empty($_GET['p']))
155156
{
@@ -165,7 +166,10 @@ private function getPageInfo()
165166
{
166167
$wiki_id = intval($_GET['id']);
167168
}
168-
169+
if (!$node)
170+
{
171+
$node = $_tree->get($wiki_id)->get();
172+
}
169173
$this->pageInfo = $_cont->get($wiki_id)->get();
170174

171175
if (empty($this->pageInfo))
@@ -178,7 +182,14 @@ private function getPageInfo()
178182
$_cont->set($wiki_id, array('read_count' => $this->pageInfo['read_count'] + 1));
179183

180184
$this->nodeInfo = $_tree->get($wiki_id)->get();
181-
$text = $this->pageInfo['content'];
185+
if (!empty($node['markdown_file']))
186+
{
187+
$text = file_get_contents($this->config['site']['git_path'].'/'.$node['markdown_file']);
188+
}
189+
else
190+
{
191+
$text = $this->pageInfo['content'];
192+
}
182193
$this->swoole->tpl->assign("id", $wiki_id);
183194
$this->swoole->tpl->assign("wiki_page", $this->pageInfo);
184195

0 commit comments

Comments
 (0)