Comments (2)
Antora definitely looks like a project that would make sense for a Stork integration.
Being realistic - project-specific integrations take time, and I'll likely invest the next few chunks of time improving Stork itself, rather than building external integrations. If there are specific pain points you have integrating with Antora that I can address in the meantime, I can evaluate them separately, but unless this Github issue takes off, I likely won't get to this feature for a long time.
Thanks for the feature suggestion, though! I'm excited that you're liking Stork and am happy to help you keep working with it however I can.
James
from stork.
Hi!
I want to share my workaround for self-hosted Stork for Antora.
After Antora static HTML generation we could parse sitemap.xml
, extract all .html
files and document titles and generate .toml
configuration for stork.
Here is my sample Python script:
#!/usr/bin/env python3
import re
from string import Template
toml = Template("""
[input]
base_directory = "."
url_prefix = "$prefix"
html_selector = "main.article"
stemming="English"
files = $files
[output]
displayed_results_count=10
excerpt_buffer=8
#exclude_html_selector="code"
excerpts_per_result=5
debug = false
""")
PREFIX = "<static env of dynamic from CI>"
ptn = re.compile("^\\s*<meta property=\"og:title\".*?content=\"(.*)\">$", re.UNICODE)
def build_node(s: str) -> dict:
tail = s\
.rstrip()\
.removeprefix("<loc>" + PREFIX_BROKEN)\
.removesuffix("</loc>")
full = "_public/<YOUR_PROJECT>/1.0"+tail
return {"path": full, "url": tail, "title": extract_title(full), "filetype": "HTML"}
def compile_toml() -> str:
with open('_public/sitemap.xml') as sitemap_file:
files = [
build_node(line)
for line in sitemap_file if line.startswith("<loc>")
]
return toml.substitute(files=str(files).replace("': '", "' = '"), prefix=PREFIX)
def extract_title(filepath: str) -> str:
with open(filepath) as html_file:
for line in html_file:
matches = re.search(ptn, line)
if matches:
return matches.group(1)
return ""
if __name__ == "__main__":
arg = compile_toml()
with open("docs.toml", "w") as f:
f.write(arg)
Next, run stork build --input docs.toml --output ./supplemental_ui/search_index.st
.
Add stork to partials:
supplemental_ui/partials/footer-content.hbs
<script src="{{{uiRootPath}}}/js/stork.js"></script>
<script>
stork.initialize("{{{uiRootPath}}}/stork.wasm")
stork.register(
"docs",
"{{{uiRootPath}}}/search_index.st"
);
</script>
Also I've made some patches to an Antora Default UI bundle:
Add stork.js
to js/vendor/
folder:
src/partials/footer-scripts.hbs
<script src="{{{uiRootPath}}}/js/vendor/stork.js"></script>
Add search input:
src/partials/header-content.hbs
<div class="stork-wrapper-flat">
<input data-stork="docs" class="stork-input" />
<div data-stork="docs-output" class="stork-output"></div>
</div>
Add stork CSS:
@import url("stork-flat.css");
from stork.
Related Issues (20)
- Search required 3 chars to return results, but appear to load with 1 and 2 HOT 4
- Question: Exclude HTML tags of CSS selectors from being added to the search index HOT 6
- Build & publish Mac ARM binary upon new release HOT 1
- Working with Subtitles | timestamp_format "MinutesAndSeconds" HOT 2
- Allow user to configure result messages HOT 1
- Test failure in pretty_print_search_results
- indexation is pretty slow HOT 1
- Ruby text isn't handled properly
- How to enable search with filename HOT 2
- Enable exact searching for phrases by using quotes
- Publish Stork indexer library to NPM
- Expose URLs for each excerpt in a result
- Filter results by metadata when searching
- how to use Stork to handle a list of 200-500 documents? (lunrjs style) HOT 1
- Main thread panic in stork search "not a char boundary" HOT 3
- Panic when importing indices built with excerpts_per_result == 0
- onResultSelected should stop changing location if the returned promise is rejected
- Stork freezes the page on iOS when search index is >20MB HOT 1
- Stork was not compiled with test server support
- Ubuntu error HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from stork.