aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHaakon Meland Eriksen <haakon.eriksen@far.no>2015-07-07 19:24:36 +0200
committerHaakon Meland Eriksen <haakon.eriksen@far.no>2015-07-07 19:24:36 +0200
commit3f9e39a9e3d72681056475fe60b193ef78caf536 (patch)
tree0fe9c6bcbcc48ccbcceb0a31a95c10fae7207f28
parentb51bcba26398a90f9d29d7ced2615a88040a6aac (diff)
parent862bfbdd2bc60b201918d02351f2591ccf5aea04 (diff)
downloadvolse-hubzilla-3f9e39a9e3d72681056475fe60b193ef78caf536.tar.gz
volse-hubzilla-3f9e39a9e3d72681056475fe60b193ef78caf536.tar.bz2
volse-hubzilla-3f9e39a9e3d72681056475fe60b193ef78caf536.zip
Merge remote-tracking branch 'upstream/master'
-rw-r--r--doc/Primary-Directory.md (renamed from doc/Primary-Directory)0
-rw-r--r--doc/main.bb1
-rwxr-xr-xinclude/items.php2
-rw-r--r--include/nav.php4
-rw-r--r--install/INSTALL.txt8
-rw-r--r--mod/help.php155
-rw-r--r--mod/search.php4
-rwxr-xr-xutil/importdoc33
-rw-r--r--version.inc2
-rw-r--r--view/css/widgets.css4
-rw-r--r--view/theme/redbasic/schema/focus.php2
11 files changed, 206 insertions, 9 deletions
diff --git a/doc/Primary-Directory b/doc/Primary-Directory.md
index 37b0c0431..37b0c0431 100644
--- a/doc/Primary-Directory
+++ b/doc/Primary-Directory.md
diff --git a/doc/main.bb b/doc/main.bb
index d71f819b2..4428b152b 100644
--- a/doc/main.bb
+++ b/doc/main.bb
@@ -1,4 +1,3 @@
-[img][baseurl]/assets/hashlogo.png[/img]
[zrl=[baseurl]/help/about][b]What is the $Projectname?[/b][/zrl]
$Projectname is a decentralized communication and publishing platform that enables you to keep in control of your communication needs by automatic encryption and finely grained access control. It's you, and only you who decides who is allowed to see your stuff.
diff --git a/include/items.php b/include/items.php
index 5e584b09c..c067d3c1e 100755
--- a/include/items.php
+++ b/include/items.php
@@ -4911,6 +4911,8 @@ function update_remote_id($channel,$post_id,$webpage,$pagetitle,$namespace,$remo
$page_type = 'BUILDBLOCK';
elseif($webpage == ITEM_TYPE_PDL)
$page_type = 'PDL';
+ elseif($webpage == ITEM_TYPE_DOC)
+ $page_type = 'docfile';
elseif($namespace && $remote_id) {
$page_type = $namespace;
$pagetitle = $remote_id;
diff --git a/include/nav.php b/include/nav.php
index 0ca554897..898805bba 100644
--- a/include/nav.php
+++ b/include/nav.php
@@ -157,7 +157,7 @@ EOT;
$nav['apps'] = array('apps', t('Apps'), "", t('Applications, utilities, links, games'),'apps_nav_btn');
- $nav['search'] = array('search', t('Search'), "", t('Search site content'));
+ $nav['search'] = array('search', t('Search'), "", t('Search site @name, #tag, ?docs, content'));
$nav['directory'] = array('directory', t('Directory'), "", t('Channel Directory'),'directory_nav_btn');
@@ -244,7 +244,7 @@ $powered_by = '';
'$localuser' => local_channel(),
'$sel' => $a->nav_sel,
'$powered_by' => $powered_by,
- '$help' => t('@name, #tag, content'),
+ '$help' => t('@name, #tag, ?doc, content'),
'$pleasewait' => t('Please wait...')
));
diff --git a/install/INSTALL.txt b/install/INSTALL.txt
index 003defeed..65df17fdd 100644
--- a/install/INSTALL.txt
+++ b/install/INSTALL.txt
@@ -137,6 +137,14 @@ use SSL, your webserver must not listen on port 443 at all.
cd mywebsite
util/update_addon_repo matrix
+ - Create searchable represenations of the online documentation. You may do this any time
+ that the documentation is updated.
+
+ cd mywebsite
+ util/importdoc
+
+
+
3. Create an empty database and note the access details (hostname, username,
password, database name).
diff --git a/mod/help.php b/mod/help.php
index 694b356aa..809313a3e 100644
--- a/mod/help.php
+++ b/mod/help.php
@@ -11,25 +11,172 @@
*/
-if(! function_exists('load_doc_file')) {
+
+
+
+
function load_doc_file($s) {
$lang = get_app()->language;
if(! isset($lang))
$lang = 'en';
$b = basename($s);
$d = dirname($s);
- if(file_exists("$d/$lang/$b"))
- return file_get_contents("$d/$lang/$b");
+
+ $c = find_doc_file("$d/$lang/$b");
+ if($c)
+ return $c;
+ $c = find_doc_file($s);
+ if($c)
+ return $c;
+ return '';
+}
+
+function find_doc_file($s) {
+
+ // If the file was edited more recently than we've stored a copy in the database, use the file.
+ // The stored database item will be searchable, the file won't be.
+
+ $r = q("select item.* from item left join item_id on item.id = item_id.iid where service = 'docfile' and
+ sid = '%s' and item_type = %d limit 1",
+ dbesc($s),
+ intval(ITEM_TYPE_DOC)
+ );
+
+ if($r) {
+ if(file_exists($s) && (filemtime($s) > datetime_convert('UTC','UTC',$r[0]['edited'],'U')))
+ return file_get_contents($s);
+ return($r[0]['body']);
+ }
if(file_exists($s))
return file_get_contents($s);
return '';
-}}
+}
+
+function search_doc_files($s) {
+
+ $a = get_app();
+
+ $itemspage = get_pconfig(local_channel(),'system','itemspage');
+ $a->set_pager_itemspage(((intval($itemspage)) ? $itemspage : 20));
+ $pager_sql = sprintf(" LIMIT %d OFFSET %d ", intval($a->pager['itemspage']), intval($a->pager['start']));
+
+ // If the file was edited more recently than we've stored a copy in the database, use the file.
+ // The stored database item will be searchable, the file won't be.
+
+ $regexop = db_getfunc('REGEXP');
+
+ $r = q("select item_id.sid, item.* from item left join item_id on item.id = item_id.iid where service = 'docfile' and
+ body $regexop '%s' and item_type = %d $pager_sql",
+ dbesc($s),
+ intval(ITEM_TYPE_DOC)
+ );
+
+ $r = fetch_post_tags($r,true);
+ require_once('include/html2plain.php');
+
+ for($x = 0; $x < count($r); $x ++) {
+
+ $r[$x]['text'] = html2plain(prepare_text($r[$x]['body'],$r[$x]['mimetype'], true));
+
+ $r[$x]['rank'] = 0;
+ if($r[$x]['term']) {
+ foreach($r[$x]['term'] as $t) {
+ if(stristr($t['term'],$s)) {
+ $r[$x]['rank'] ++;
+ }
+ }
+ }
+ if(stristr($r[$x]['sid'],$s))
+ $r[$x]['rank'] ++;
+ $r[$x]['rank'] += substr_count(strtolower($r[$x]['text']),strtolower($s));
+ }
+ usort($r,'doc_rank_sort');
+ return $r;
+}
+
+
+function doc_rank_sort($a,$b) {
+ if($a['rank'] == $b['rank'])
+ return 0;
+ return (($a['rank'] < $b['rank']) ? 1 : (-1));
+}
+
+
+
+
+
+function store_doc_file($s) {
+
+ if(is_dir($s))
+ return;
+ $item = array();
+ $sys = get_sys_channel();
+
+ $item['aid'] = 0;
+ $item['uid'] = $sys['channel_id'];
+
+
+ if(strpos($s,'.md'))
+ $item['mimetype'] = 'text/markdown';
+ elseif(strpos($s,'.html'))
+ $item['mimetype'] = 'text/html';
+ else
+ $item['mimetype'] = 'text/bbcode';
+
+
+ $item['body'] = file_get_contents($s);
+ $item['plink'] = z_root() . '/' . str_replace('doc','help',$s);
+ $item['owner_xchan'] = $item['author_xchan'] = $sys['channel_hash'];
+ $item['item_type'] = ITEM_TYPE_DOC;
+
+ $r = q("select item.* from item left join item_id on item.id = item_id.iid where service = 'docfile' and
+ sid = '%s' and item_type = %d limit 1",
+ dbesc($s),
+ intval(ITEM_TYPE_DOC)
+ );
+
+ if($r) {
+ $item['id'] = $r[0]['id'];
+ $item['mid'] = $item['parent_mid'] = $r[0]['mid'];
+ $x = item_store_update($item);
+ }
+ else {
+ $item['mid'] = $item['parent_mid'] = item_message_id();
+ $x = item_store($item);
+ }
+
+ if($x['success']) {
+ update_remote_id($sys,$x['item_id'],ITEM_TYPE_DOC,$s,'docfile',0,$item['mid']);
+ }
+
+
+}
function help_content(&$a) {
nav_set_selected('help');
+ if($_REQUEST['search']) {
+ $r = search_doc_files($_REQUEST['search']);
+ if($r) {
+ $o .= '<ul>';
+ foreach($r as $rr) {
+ $dirname = dirname($rr['sid']);
+ $fname = basename($rr['sid']);
+ $fname = substr($fname,0,strrpos($fname,'.'));
+ $path = trim(substr($dirname,4),'/');
+
+ $o .= '<li><a href="help/' . (($path) ? $path . '/' : '') . $fname . '" >' . ucwords(str_replace('_',' ',notags($fname))) . '</a><br />' .
+ str_replace('$Projectname',PLATFORM_NAME,substr($rr['text'],0,200)) . '...<br /><br /></li>';
+
+ }
+ $o .= '</ul>';
+ }
+ return $o;
+ }
+
+
global $lang;
$doctype = 'markdown';
diff --git a/mod/search.php b/mod/search.php
index dceb7d72a..ce8357fb9 100644
--- a/mod/search.php
+++ b/mod/search.php
@@ -59,6 +59,10 @@ function search_content(&$a,$update = 0, $load = false) {
$search = substr($search,1);
goaway(z_root() . '/directory' . '?f=1&navsearch=1&search=' . $search);
}
+ if(strpos($search,'?') === 0) {
+ $search = substr($search,1);
+ goaway(z_root() . '/help' . '?f=1&navsearch=1&search=' . $search);
+ }
// look for a naked webbie
if(strpos($search,'@') !== false) {
diff --git a/util/importdoc b/util/importdoc
new file mode 100755
index 000000000..b89e12e97
--- /dev/null
+++ b/util/importdoc
@@ -0,0 +1,33 @@
+#!/usr/bin/env php
+<?php
+
+require_once('include/cli_startup.php');
+
+cli_startup();
+
+require_once('mod/help.php');
+
+function update_docs_dir($s) {
+ $f = basename($s);
+ $d = dirname($s);
+ if($s === 'doc/html')
+ return;
+
+ $files = glob("$d/$f");
+ if($files) {
+ foreach($files as $fi) {
+ if($fi === 'doc/html')
+ continue;
+ echo $fi . "\n";
+ if(is_dir($fi))
+ update_docs_dir("$fi/*");
+ else
+ store_doc_file($fi);
+ }
+ }
+}
+
+update_docs_dir('doc/*');
+
+
+
diff --git a/version.inc b/version.inc
index 39bb632b7..fe5a631ad 100644
--- a/version.inc
+++ b/version.inc
@@ -1 +1 @@
-2015-07-03.1082
+2015-07-06.1085
diff --git a/view/css/widgets.css b/view/css/widgets.css
index 0a901b1f9..63c380c75 100644
--- a/view/css/widgets.css
+++ b/view/css/widgets.css
@@ -13,6 +13,10 @@
border-bottom-right-radius: 0px;
}
+.tags {
+ word-wrap: break-word;
+}
+
/* suggest */
.suggest-widget-more {
diff --git a/view/theme/redbasic/schema/focus.php b/view/theme/redbasic/schema/focus.php
index 2a6900271..d93ee003e 100644
--- a/view/theme/redbasic/schema/focus.php
+++ b/view/theme/redbasic/schema/focus.php
@@ -46,7 +46,7 @@ if (! $radius)
if (! $shadow)
$shadow = "0";
if (! $converse_width)
- $converse_width = "640";
+ $converse_width = "676";
if(! $top_photo)
$top_photo = '48px';
if(! $comment_indent)