Skip to content

Commit

Permalink
v3.5.9 site-level search namespaces option
Browse files Browse the repository at this point in the history
  • Loading branch information
tosher committed Jan 26, 2020
1 parent 8f776bb commit 802fb1d
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 5 deletions.
3 changes: 3 additions & 0 deletions Changelog.mediawiki
Original file line number Diff line number Diff line change
Expand Up @@ -607,3 +607,6 @@ Support folding/unfolding for:
== Mediawikier 3.5.8 ==
* Fixed command {{Command|Open page in browser}} for child hosts (parent wiki settings ignoring).
== Mediawikier 3.5.9 ==
* Site-level option {{Property|search_namespaces}}, it overrides the global value.
2 changes: 1 addition & 1 deletion messages.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"install": "messages/install.txt",
"3.5.8": "messages/latest_version.txt"
"3.5.9": "messages/latest_version.txt"
}
2 changes: 1 addition & 1 deletion messages/latest_version.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
## Mediawiker 3.5.8
## Mediawiker 3.5.9

Please, check the release-notes in `Preferences / Package Settings / Mediawiker / Changelog`.
2 changes: 1 addition & 1 deletion mwcommands/mw_events.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ def on_query_completions(self, view, prefix, locations):
ns_text, internal_link = internal_link.split(utils.api.NAMESPACE_SPLITTER)

if len(internal_link) >= word_cursor_min_len:
namespaces_search = [ns.strip() for ns in utils.props.get_setting('search_namespaces').split(',')]
namespaces_search = utils.get_search_ns()
if ns_text:
ns_text_number = utils.api.call('get_namespace_number', name=ns_text)

Expand Down
3 changes: 2 additions & 1 deletion mwcommands/mw_properties.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,8 @@ class MediawikerProperties(object):
'preview_custom_head': {'text': 'Custom html head tags for preview', 'type': list, 'default': []},
'preview_sandbox': {'text': 'Special rewritable page for preview', 'type': str, 'default': ''},
'show_red_links': {'text': 'Mark red links in page text', 'type': bool, 'default': False},
'parent': {'text': 'Parent site name', 'type': str, 'default': ''}
'parent': {'text': 'Parent site name', 'type': str, 'default': ''},
'search_namespaces': {'text': 'Site level option: namespaces to search ', 'type': str, 'default': ''}
}

def __init__(self):
Expand Down
2 changes: 1 addition & 1 deletion mwcommands/mw_search_string.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def run(self, edit):
sublime.active_window().show_input_panel('Wiki search:', search_pre, self.show_results, None, None)

def do_search(self, string_value):
namespace = utils.props.get_setting('search_namespaces')
namespace = '|'.join(utils.get_search_ns())
search_limit = utils.props.get_setting('search_results_count', 20)
return utils.api.call('get_search_result', search=string_value, limit=search_limit, namespace=namespace)

Expand Down
13 changes: 13 additions & 0 deletions mwcommands/mw_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,19 @@ def get_page_url(page_name=None):
return ''


def get_search_ns():
'''
Returns 'search_namespaces':
* if defined on site level, then site-level-namespaces
* else global option
'''

nses = props.get_site_setting(get_view_site(), 'search_namespaces')
if not nses:
nses = props.get_setting('search_namespaces')
return [ns.strip() for ns in nses.split(',')]


def status_message(message, replace_patterns=None, is_panel=None, new_line=True, panel_name=None, syntax=None, new=False):

def status_message_sublime(message, replace_patterns=None):
Expand Down

0 comments on commit 802fb1d

Please sign in to comment.