mirror of
https://github.com/thangisme/notes.git
synced 2025-01-05 00:26:27 -05:00
Add the rake tasks for search init
This commit is contained in:
parent
16ec5c0257
commit
b06e4198df
27
bin/just-the-docs
Normal file
27
bin/just-the-docs
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
#!/usr/bin/env ruby
|
||||||
|
|
||||||
|
# Run rake tasks
|
||||||
|
# from my_gem once it's installed.
|
||||||
|
#
|
||||||
|
# Example:
|
||||||
|
#
|
||||||
|
# my_gem rake some-task
|
||||||
|
# my_gem rake some-task[args]
|
||||||
|
#
|
||||||
|
# Note: cucumber features have '.feature' appended automatically,
|
||||||
|
# no need for you to do it ;)
|
||||||
|
#
|
||||||
|
# Author:: N David Brown
|
||||||
|
gem_dir = File.expand_path("..",File.dirname(__FILE__))
|
||||||
|
$LOAD_PATH.unshift gem_dir# Look in gem directory for resources first.
|
||||||
|
exec_type = ARGV[0]
|
||||||
|
if exec_type == 'rake' then
|
||||||
|
require 'rake'
|
||||||
|
require 'pp'
|
||||||
|
pwd=Dir.pwd
|
||||||
|
Dir.chdir(gem_dir) # We'll load rakefile from the gem's dir.
|
||||||
|
Rake.application.init
|
||||||
|
Rake.application.load_rakefile
|
||||||
|
Dir.chdir(pwd) # Revert to original pwd for any path args passed to task.
|
||||||
|
Rake.application.invoke_task(ARGV[1])
|
||||||
|
end
|
21
lib/tasks/search.rake
Normal file
21
lib/tasks/search.rake
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
,nit do
|
||||||
|
touch search-data.json
|
||||||
|
|
||||||
|
File.open('search-data.json', 'w') do |f|
|
||||||
|
f.puts '
|
||||||
|
---
|
||||||
|
---
|
||||||
|
{
|
||||||
|
{% for page in site.html_pages %}"{{ forloop.index0 }}": {
|
||||||
|
"id": "{{ forloop.index0 }}",
|
||||||
|
"title": "{{ page.title | xml_escape }}",
|
||||||
|
"content": "{{ page.content | markdownify | strip_html | xml_escape | remove: 'Table of contents' | remove: page.title | strip_newlines | replace: '\', ' '}}",
|
||||||
|
"url": "{{ page.url | xml_escape }}"
|
||||||
|
}{% if forloop.last %}{% else %},
|
||||||
|
{% endif %}{% endfor %}
|
||||||
|
}
|
||||||
|
|
||||||
|
end
|
||||||
|
end'
|
||||||
|
|
||||||
|
end
|
Loading…
Reference in New Issue
Block a user