Skip to content

Commit

Permalink
add doc search
Browse files Browse the repository at this point in the history
  • Loading branch information
cldougl committed Sep 15, 2017
1 parent bc7b225 commit d32351a
Show file tree
Hide file tree
Showing 8 changed files with 80 additions and 120 deletions.
24 changes: 24 additions & 0 deletions _config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,27 @@ kramdown:
markdown: redcarpet
redcarpet:
extensions: ["tables", "fenced_code_blocks"]

# ---
# Algolia Search
# ---
algolia:
application_id: '7EK9KHJW8M'
index_name: 'dev_schema'
read_only_api_key: '4dae07ded6a721de73bde7356eec9280'
excluded_files:
- '*.Rmd'
- '_posts/dashboards'
- '_posts/ggplot2'
- '_posts/ipython-notebooks'
- '_posts/julia'
- '_posts/matlab'
- '_posts/matplotlib'
- '_posts/misc'
- '_posts/nodejs'
- '_posts/numpy'
- '_posts/pandas'
- '_posts/plotly_js'
- '_posts/r'
- '_posts/scala'
- '_posts/scikit'
2 changes: 1 addition & 1 deletion _config_dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ plotlyjs_download_url: https://cdn.plot.ly/plotly-latest.min.js
# Excludes
# ---
# all of the posts: ['*.Rmd','_posts/2015-09-09-matlab-reference.html','_posts/2015-09-06-r-reference.html','_posts/2015-09-06-python-reference.html','_posts/2015-08-19-plotly_js-reference.html','_posts/2015-04-05-ggplot2-index.html','_posts/2015-04-05-julia-index.html','_posts/2015-04-05-matlab-index.html','_posts/2015-04-05-matplotlib-index.html','_posts/2015-04-05-node_js-index.html','_posts/2015-04-05-plotly_js-index.html','_posts/2015-04-05-plotlyjs-function-reference.md','_posts/2015-04-05-python-index.html','_posts/2015-05-25-ipython-notebooks_gallery.html','_posts/2015-05-25-ipython-notebooks_index.html','_posts/2015-07-13-eula_index.html','_posts/2015-07-19-pandas.html','_posts/2015-07-26-index.html','_posts/2015-07-30-r-index.Rmd','_posts/2015-07-30-r-index.md','_posts/2015-08-20-research-box-index.html','_posts/ggplot2','_posts/julia','_posts/matlab','_posts/matplotlib','_posts/nodejs','_posts/pandas','_posts/plotly_js','_posts/python','_posts/r','_posts/tutorials','_posts/user_guide_matlab','_posts/user_guide_python']
exclude: ['*.Rmd','_posts/dashboards','_posts/ggplot2','_posts/julia','_posts/matplotlib','_posts/misc','_posts/nodejs','_posts/numpy','_posts/pandas','_posts/scala','_posts/scikit','_posts/tutorials','_posts/user_guide_matlab','_posts/user_guide_python']
exclude: ['*.Rmd','_posts/javascript','_posts/r','_posts/matlab','_posts/dashboards','_posts/ggplot2','_posts/julia','_posts/matplotlib','_posts/misc','_posts/nodejs','_posts/numpy','_posts/pandas','_posts/scala','_posts/scikit','_posts/tutorials','_posts/user_guide_matlab','_posts/user_guide_python']
#exclude: [_posts/temp, '*.Rmd']

# ---
Expand Down
26 changes: 26 additions & 0 deletions _includes/_new/_page-components/_footer-main.html
Original file line number Diff line number Diff line change
Expand Up @@ -176,3 +176,29 @@ <h6 class="--footer-heading">Connect</h6>&#x9;&#x9;&#x9;
});

</script>

<script>
window.ALGOLIA_CONFIG = {
'applicationId': '{{ site.algolia.application_id }}',
'indexName': '{{ site.algolia.index_name }}',
'apiKey': '{{ site.algolia.read_only_api_key }}',
'baseurl': '{{ site.baseurl }}'
}
</script>
<script id="algolia__template" type="text/template">
{% raw %}
<div class="algolia__result">
<a class="algolia__result-link" href="{{ full_url }}">{{{ _highlightResult.name.value }}}</a>
<div class="algolia__result-text">{{{ _highlightResult.description.value }}}</div>
</div>
{% endraw %}
</script>
<script id="algolia__template--no-results" type="text/template">
No results found.
</script>
<script src="//cdn.jsdelivr.net/jquery/2.1.4/jquery.min.js"></script>
<script src="//cdn.jsdelivr.net/algoliasearch/3.6.0/algoliasearch.min.js"></script>
<script src="//cdn.jsdelivr.net/algoliasearch.helper/2.1.0/algoliasearch.helper.min.js"></script>
<script src="//cdn.jsdelivr.net/hogan.js/3.0.2/hogan.min.js"></script>
<script src="//cdn.jsdelivr.net/momentjs/2.10.3/moment.min.js"></script>
<script src="{{ site.baseurl }}/public/js/algolia.js"></script>
14 changes: 14 additions & 0 deletions _includes/side-bar.html
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,20 @@

<aside class="--sidebar-container">
<div class="--sidebar-fixed reference" data-spy="affix" data-offset-top="435" data-offset-bottom="610" id="where">
<!-- {% if page.language == "python" %}
<header class="--sidebar-header">Search</header>
<input type="text" class="algolia__input js-algolia__input" autocomplete="off" name="query" placeholder="Search Plotly's Python Docs" />
<nav class="--sidebar-body watch" id="search">
{% endif %} -->
{% assign pages_list = site.pages %}
{% for node in pages_list %}
{% if node.title != null %}
{% if node.layout == "user-guide" %}
<a class="sidebar-nav-item{% if page.url == node.url %} active{% endif %}" href="{{ site.baseurl }}{{ node.url }}">{{ node.title }}</a>
{% endif %}
{% endif %}
{% endfor %}
</nav>
<header class="--sidebar-header">Quick Start</header>
<nav class="--sidebar-body watch" id="where">
<ul class="--sidebar-list">
Expand Down
3 changes: 1 addition & 2 deletions _layouts/default.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,11 @@
{% include side-bar.html %}
<section class="--page-body --tutorial-index">
<div class="content container">
<div class="algolia__initial-content js-algolia__initial-content">{{ content }}</div>

<div class="algolia__search-content js-algolia__search-content">
<h1 class="page-title">Search</h1>
<div class="posts algolia__results"></div>
</div>
<div class="algolia__initial-content js-algolia__initial-content">{{ content }}</div>
</div>

</section>
Expand Down
10 changes: 10 additions & 0 deletions _posts/python/2015-04-05-python-index.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,16 @@ <h1>Plotly Python Library</h1>
</div>
</header>

<div class="content container">
<div class="--section-header">Search</div>
<input type="text" class="algolia__input js-algolia__input" autocomplete="off" name="query" placeholder="Search Plotly's Python Docs" />
<nav class="--sidebar-body watch" id="search">

<div class="algolia__search-content js-algolia__search-content">
<div class="posts algolia__results"></div>
</div>
</div>

{% assign languagelistimg = site.posts | where:"page_type":"example_index" | where:"language","python" | where:"has_thumbnail",true % | sort: "order" %}
{% assign languagelist = site.posts | where:"page_type":"example_index" | where:"language","python" %}
{% include documentation_eg.html %}
112 changes: 0 additions & 112 deletions all_static/javascripts/algolia.js

This file was deleted.

9 changes: 4 additions & 5 deletions public/js/algolia.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,12 @@ $(function(config) {
$searchContentResults.html(content);
}

// return url from search item
function renderResults(data) {
return $.map(data.hits, function(hit) {
if (hit.posted_at) {
hit.posted_at_readable = moment.unix(hit.posted_at).fromNow();
}
hit.css_selector = encodeURI(hit.css_selector);
hit.full_url = config.baseurl + hit.url;
hit.full_url = "../" + hit.permalink;



return templateResult.render(hit);
}).join('');
Expand Down

0 comments on commit d32351a

Please sign in to comment.