Skip to content

Commit

Permalink
Merge pull request #437 from algolia/bootstrap_update_tags
Browse files Browse the repository at this point in the history
[bootstrap] Update tags from helpscout
  • Loading branch information
Sylvain Pace authored Mar 22, 2019
2 parents 8f9cc52 + 8d6e22c commit ca08e70
Show file tree
Hide file tree
Showing 3 changed files with 76 additions and 6 deletions.
49 changes: 49 additions & 0 deletions deployer/src/config_creator.py
Original file line number Diff line number Diff line change
Expand Up @@ -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", ""),
Expand Down Expand Up @@ -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]

Expand Down
26 changes: 22 additions & 4 deletions deployer/src/helpdesk_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -138,25 +138,43 @@ 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):
return "gitbook" in conversation.get("tags")


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"):
Expand Down
7 changes: 5 additions & 2 deletions deployer/src/snippeter.py
Original file line number Diff line number Diff line change
Expand Up @@ -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!
Expand Down Expand Up @@ -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

Expand Down

0 comments on commit ca08e70

Please sign in to comment.