diff --git a/deployer/src/config_creator.py b/deployer/src/config_creator.py index 02862b76..73d7e496 100644 --- a/deployer/src/config_creator.py +++ b/deployer/src/config_creator.py @@ -210,6 +210,51 @@ def to_larecipe_config(config, urls=None): return config +def to_publii_config(config, urls=None): + if urls: + config["sitemap_urls"] = [ + extract_root_from_input(urls[0]) + "sitemap.xml"] + + config["selectors"]["lvl0"] = OrderedDict(( + ("selector", ".active-parent > span"), + ("global", True), + ("default_value", "Documentation") + )) + + config["selectors"]["lvl1"] = ".content h1" + config["selectors"]["lvl2"] = ".content h2" + config["selectors"]["lvl3"] = ".content h3" + config["selectors"]["lvl4"] = ".content h4" + config["selectors"]["lvl5"] = ".content h5" + config["selectors"]["text"] = ".content p, .content li" + config["only_content_level"] = True + + return config + + +def to_jsdoc_config(config, urls=None): + config["stop_urls"] = ["\\.js\\.html", + "/index\\.html$"] + + config["selectors"]["lvl0"] = OrderedDict(( + ("selector", "#main .page-title"), + ("global", True), + ("default_value", "Documentation") + )) + + config["selectors"]["lvl1"] = "#main h3" + config["selectors"]["lvl2"] = "#main h4" + config["selectors"]["lvl3"] = "#main h5" + config["selectors"]["lvl4"] = "#main h6, #main td.name" + del config["selectors"]["lvl5"] + config["selectors"]["text"] = "#main p, #main li" + config["selectors_exclude"] = [".signature", + ".type-signature", + ".details"] + + return config + + def create_config(u=None): config = OrderedDict(( ("index_name", ""), @@ -250,6 +295,10 @@ def create_config(u=None): config = to_vuepress_config(config) elif helpdesk_helper.is_larecipe_conversation(conversation): config = to_larecipe_config(config, urls) + elif helpdesk_helper.is_publii_conversation(conversation): + config = to_publii_config(config, urls) + elif helpdesk_helper.is_jsdoc_conversation(conversation): + config = to_jsdoc_config(config, urls) config["conversation_id"] = [cuid] diff --git a/deployer/src/helpdesk_helper.py b/deployer/src/helpdesk_helper.py index 2ccdb21e..847412c9 100644 --- a/deployer/src/helpdesk_helper.py +++ b/deployer/src/helpdesk_helper.py @@ -103,7 +103,7 @@ def get_emails_from_conversation(conversation): if len(emails) > 1: print( "Conversation sent by \033[1;33m" + customers_mail + "\033[0m" + ( - " with " + " ".join(emails[1:]))) + " with " + " ".join(emails[1:]))) return emails @@ -138,7 +138,9 @@ def get_conversation_url_from_cuid(cuid): def is_docusaurus_conversation(conversation): - return "docusaurus" in conversation.get("tags") + return "docusaurus" in conversation.get( + "tags") or "ds_docusaurus" in conversation.get( + "tags") or "gen-docusaurus" in conversation.get("tags") def is_gitbook_conversation(conversation): @@ -146,17 +148,33 @@ def is_gitbook_conversation(conversation): def is_pkgdown_conversation(conversation): - return "pkgdown" in conversation.get("tags") + return "pkgdown" in conversation.get( + "tags") or "ds_pkgdown" in conversation.get( + "tags") or "gen-pkgdown" in conversation.get("tags") def is_vuepress_conversation(conversation): - return "vuepress" in conversation.get("tags") + return "vuepress" in conversation.get( + "tags") or "ds_vuepress" in conversation.get( + "tags") or "gen-vuepress" in conversation.get("tags") def is_larecipe_conversation(conversation): return "larecipe" in conversation.get("tags") +def is_publii_conversation(conversation): + return "publii" in conversation.get( + "tags") or "ds_publii" in conversation.get( + "tags") or "gen-publii" in conversation.get("tags") + + +def is_jsdoc_conversation(conversation): + return "jsdoc" in conversation.get( + "tags") or "ds_jsdoc" in conversation.get( + "tags") or "gen-jsdoc" in conversation.get("tags") + + @rate_limited(200, 60) def search(query, page=1, pageSize=50, sortField="modifiedAt", sortOrder="asc"): diff --git a/deployer/src/snippeter.py b/deployer/src/snippeter.py index 9f2815f9..0aeb37fd 100644 --- a/deployer/src/snippeter.py +++ b/deployer/src/snippeter.py @@ -40,7 +40,7 @@ def get_email_for_config(config, analytics_statuses=None): - Add a search input in your page if you don't have any yet. Then update the inputSelector value in JS snippet to a CSS selector that targets your search input field.{{FACETS}} - Optionally customize the look and feel by following the DocSearch documentation (https://community.algolia.com/docsearch/styling.html) -- You can also check your configuration in our github repo (https://github.com/algolia/docsearch-configs/blob/master/configs/{{INDEX_NAME}}.json). +- You can also check your configuration in our GitHub repo (https://github.com/algolia/docsearch-configs/blob/master/configs/{{INDEX_NAME}}.json). {{ANALYTICS}} Please open a pull request if want to leverage your configuration! @@ -100,11 +100,14 @@ def get_email_for_config(config, analytics_statuses=None): if len(example_options) > 0: algolia_options += ",\n algoliaOptions: { 'facetFilters': [" + ( - ', '.join(example_options)) + "] }" + ', '.join(example_options)) + "] }" facet_template += base_example_template.replace( '{{EXAMPLE_PHRASE}}', ' and '.join(example_phrase)) \ .replace('{{EXAMPLE_CODE}}', ', '.join(example_code)) + if facet_template == "\n": + facet_template = "" + api_key = algolia_helper.get_docsearch_key(config) api_key = "### REPLACE ME ####" if api_key == 'Not found' else api_key