aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorredmatrix <redmatrix@redmatrix.me>2015-07-05 19:52:41 -0700
committerredmatrix <redmatrix@redmatrix.me>2015-07-05 19:52:41 -0700
commitf20933e1e0f955d49fff3780c367ea2edf581728 (patch)
treed384d386afc276e666c853051256bbe912412261
parentdf8f6e45e244be95dd8ddc51e1f0b1245eaebc6e (diff)
downloadvolse-hubzilla-f20933e1e0f955d49fff3780c367ea2edf581728.tar.gz
volse-hubzilla-f20933e1e0f955d49fff3780c367ea2edf581728.tar.bz2
volse-hubzilla-f20933e1e0f955d49fff3780c367ea2edf581728.zip
more work on db storage of doco
-rw-r--r--doc/main.bb1
-rwxr-xr-xinclude/items.php2
-rw-r--r--include/nav.php4
-rw-r--r--mod/help.php59
-rwxr-xr-xutil/importdoc33
5 files changed, 92 insertions, 7 deletions
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/mod/help.php b/mod/help.php
index ff51799d9..7d024a725 100644
--- a/mod/help.php
+++ b/mod/help.php
@@ -33,13 +33,14 @@ 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 * from item left join item_id on item.id = item.iid where service = 'docfile' and
- sid = '%s' limit 1",
- dbesc($s)
+ $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')))
+ if(file_exists($s) && (filemtime($s) > datetime_convert('UTC','UTC',$r[0]['edited'],'U')))
return file_get_contents($s);
return($r[0]['body']);
}
@@ -49,6 +50,56 @@ function find_doc_file($s) {
}
+
+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['channel_id'],$x['item_id'],ITEM_TYPE_DOC,$s,'docfile',0,$item['mid']);
+ }
+
+
+}
+
+
function help_content(&$a) {
nav_set_selected('help');
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/*');
+
+
+