diff --git a/frappe/__init__.py b/frappe/__init__.py
index d049ddbe7f..c01c040299 100644
--- a/frappe/__init__.py
+++ b/frappe/__init__.py
@@ -14,6 +14,7 @@ from .exceptions import *
from .utils.jinja import get_jenv, get_template, render_template
__version__ = "7.0.27"
+__title__ = "Frappe Framework"
local = Local()
diff --git a/frappe/public/js/frappe/ui/toolbar/navbar.html b/frappe/public/js/frappe/ui/toolbar/navbar.html
index 13ee00028f..7aa60f5a26 100644
--- a/frappe/public/js/frappe/ui/toolbar/navbar.html
+++ b/frappe/public/js/frappe/ui/toolbar/navbar.html
@@ -52,7 +52,7 @@
Documentation
+ data-path="/documentation/index" target="_blank">Documentation
diff --git a/frappe/public/js/frappe/ui/toolbar/toolbar.js b/frappe/public/js/frappe/ui/toolbar/toolbar.js
index 0e1119a3ae..9e3a32f388 100644
--- a/frappe/public/js/frappe/ui/toolbar/toolbar.js
+++ b/frappe/public/js/frappe/ui/toolbar/toolbar.js
@@ -85,7 +85,7 @@ frappe.ui.toolbar.Toolbar = Class.extend({
});
$("#input-help + span").on("click", function () {
- var keywords = $(this).val();
+ var keywords = $("#input-help").val();
show_help_results(keywords);
$(this).val("");
});
@@ -115,10 +115,13 @@ frappe.ui.toolbar.Toolbar = Class.extend({
for (var i = 0; i < links.length; i++) {
var link = links[i];
var url = link.url;
+ var app_name = url.split('//', 2)[1].split('/', 2)[1];
+ console.log(app_name)
var data_path = url.slice(url.indexOf('/user'));
if(data_path.lastIndexOf('.')){
data_path = data_path.slice(0, data_path.lastIndexOf('.'));
}
+ data_path = data_path.replace('user', app_name);
$("", {
href: link.url,
diff --git a/frappe/utils/help.py b/frappe/utils/help.py
index b329b433db..c0d9595380 100644
--- a/frappe/utils/help.py
+++ b/frappe/utils/help.py
@@ -54,13 +54,14 @@ class HelpDatabase(object):
def make_table(self):
if not 'help' in self.db.get_tables():
self.db.sql('''create table help(
- path text,
+ path varchar(255),
content text,
title text,
intro text,
full_path text,
fulltext(title),
- fulltext(content))
+ fulltext(content),
+ fulltext(path))
COLLATE=utf8mb4_unicode_ci
ENGINE=MyISAM
CHARACTER SET=utf8mb4''')
@@ -75,9 +76,6 @@ class HelpDatabase(object):
where path like "{path}%" order by path desc limit 1'''
result = None
- if not path.startswith('/user'):
- path = '%' + path
-
if not path.endswith('index'):
result = self.db.sql(query.format(path=os.path.join(path, 'index')))
@@ -88,10 +86,17 @@ class HelpDatabase(object):
def sync_pages(self):
self.db.sql('truncate help')
+ doc_contents = ''
for app in os.listdir('../apps'):
docs_folder = '../apps/{app}/{app}/docs/user'.format(app=app)
self.out_base_path = '../apps/{app}/{app}/docs'.format(app=app)
if os.path.exists(docs_folder):
+ try:
+ app_name = frappe.get_attr('{app}.__title__'.format(app=app)) or app
+ doc_contents += '- {app_name}
'.format(
+ app=app, app_name=app_name)
+ except Exception, e:
+ pass
for basepath, folders, files in os.walk(docs_folder):
files = self.reorder_files(files)
for fname in files:
@@ -102,11 +107,16 @@ class HelpDatabase(object):
{'docs_base_url': '/assets/{app}_docs'.format(app=app)})
relpath = self.get_out_path(fpath)
- content = self.make_content(content, fpath)
+ relpath = relpath.replace("user", app)
+ content = markdown(content)
title = self.make_title(basepath, fname, content)
intro = self.make_intro(content)
+ content = self.make_content(content, fpath, relpath)
self.db.sql('''insert into help(path, content, title, intro, full_path)
values (%s, %s, %s, %s, %s)''', (relpath, content, title, intro, fpath))
+ doc_contents += "
"
+ self.db.sql('''insert into help(path, content, title, intro, full_path) values (%s, %s, %s, %s, %s)''',
+ ('/documentation/index', doc_contents, 'Documentation', '', ''))
def make_title(self, basepath, filename, html):
@@ -126,8 +136,10 @@ class HelpDatabase(object):
intro = "Help Video: " + intro
return intro
- def make_content(self, content, path):
- html = markdown(content)
+ def make_content(self, html, path, relpath):
+
+ if '' in html:
+ html = html.split('
', 1)[1]
if '{next}' in html:
html = html.replace('{next}', '')
@@ -156,9 +168,9 @@ class HelpDatabase(object):
if '.' in data_path:
data_path = data_path[: data_path.rindex('.')]
if data_path:
- link['data-path'] = data_path
+ link['data-path'] = data_path.replace("user", app_name)
- parent = self.get_parent(path)
+ parent = self.get_parent(relpath)
if parent:
parent_tag = soup.new_tag('a')
parent_tag.string = parent['title']
@@ -223,10 +235,17 @@ class HelpDatabase(object):
child_path = child_path[: child_path.rindex('index')]
if child_path[-1] == '/':
child_path = child_path[:-1]
+ child_path = child_path[: child_path.rindex('/')]
- parent_path = self.get_out_path(child_path[: child_path.rindex('/')] + "/index")
-
- out = self.get_content(parent_path)
+ out = None
+ if child_path:
+ parent_path = child_path + "/index"
+ out = self.get_content(parent_path)
+ #if parent is documentation root
+ else:
+ parent_path = "/documentation/index"
+ out = {}
+ out['title'] = "Documentation"
if not out:
return None