Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Full-text-search via Stork #327

Merged
merged 57 commits into from
Aug 21, 2022
Merged
Show file tree
Hide file tree
Changes from 11 commits
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
b030b50
Added stork search
applejag Jul 28, 2022
116265a
Added search tmp docs
applejag Jul 28, 2022
46a5c0e
Fixed rg cmd
applejag Jul 28, 2022
6a29a32
Extracted to hooks
applejag Jul 30, 2022
22965ee
Removed search.md
applejag Jul 30, 2022
a5a67a2
Style so search results overlap notes
applejag Jul 30, 2022
b49c00b
Removed duplicate stylings
applejag Jul 30, 2022
809d5dd
Cleaned up JS a little
applejag Jul 30, 2022
79f23c4
Added shift 1px so borders align
applejag Jul 30, 2022
1a1c9e8
Get baseUrl from Emanote instead of <base>
applejag Jul 30, 2022
b470373
Moved JS & CSS to default/index.yaml
applejag Jul 31, 2022
69a2605
Add search snippets to docs
applejag Jul 31, 2022
a6c915d
Update default/templates/layouts/note.tpl
applejag Jul 31, 2022
b3489ff
Moved from hook to component, and enable via snippet
applejag Jul 31, 2022
64cc2f1
Fixed borders
applejag Jul 31, 2022
ba3363f
Add stork to nix shell
srid Aug 1, 2022
12cf3a1
Build stork.st index in Haskell
srid Aug 1, 2022
b216807
Fix autoformat
srid Aug 1, 2022
79f04dd
Fix hlint warning
srid Aug 1, 2022
62ff42e
Up ver
srid Aug 1, 2022
5dc1c38
nix: add stork as runtime dependency
srid Aug 1, 2022
dc82292
Added missing stork-search from headHtml
applejag Aug 2, 2022
47a7928
Merge branch 'feature/stork-search' of github.com:jilleJr/emanote int…
applejag Aug 2, 2022
b82c6ff
Advance ema
srid Aug 3, 2022
bcd9ee7
Revert "Added missing stork-search from headHtml"
applejag Aug 13, 2022
0b52f4a
Merge remote-tracking branch 'origin/master' into feature/stork-search
applejag Aug 13, 2022
d7d7cb5
Moved back to be in templates instead of snippet
applejag Aug 13, 2022
ace87ec
Merge branch 'feature/stork-search' of github.com:jilleJr/emanote int…
applejag Aug 13, 2022
460a1f2
Fix compilation
srid Aug 13, 2022
4957829
Fixed template
applejag Aug 13, 2022
d957084
lint fix
applejag Aug 13, 2022
a305339
nix: Use master branch of ema
srid Aug 13, 2022
f93922e
Added missing styling
applejag Aug 13, 2022
9f47d00
Changed to modal
applejag Aug 13, 2022
a5fe67b
Added listener for Ctrl+K
applejag Aug 13, 2022
2c2be46
Update nix inputs to use Stock 1.5.0
srid Aug 14, 2022
b308b8d
Use /dev/stdout instead of --output=-
applejag Aug 14, 2022
2b8ff25
nix: Unmark stork as broken (on intel mac only)
srid Aug 14, 2022
0d96667
Added hotkeys Cmd+K and Esc
applejag Aug 14, 2022
6c5c604
refactor: rename module
srid Aug 14, 2022
2f603bb
Cache stork index for reuse (when notes haven't been changed)
srid Aug 14, 2022
e683c78
Refactor: re-organize around, do newtype wrappers
srid Aug 14, 2022
084b873
Log the time it took for stork to run (1 second here)
srid Aug 14, 2022
dbdef65
remove debug
srid Aug 14, 2022
415c4af
Exclude tvar modification from the measure
srid Aug 14, 2022
b26171d
Group stork templates under components/stork
srid Aug 16, 2022
029609d
design: use icon to initiate search in all 3 places (note, book, brea…
srid Aug 17, 2022
92bacc8
Update ema
srid Aug 19, 2022
2de10a8
Inc major ver
srid Aug 19, 2022
1374943
Format!
srid Aug 19, 2022
a383d1c
Workaround the unicode issue with tomland
srid Aug 19, 2022
5959f67
docs: add full-text search
srid Aug 19, 2022
ebaa0b6
refactor: merge stork js/css into a single file, and include that in …
srid Aug 21, 2022
1bde671
add right padding to search icon in mobile view of note layout
srid Aug 21, 2022
f83d1ca
remove close button
srid Aug 21, 2022
c564971
Namespace the stork JS functions
srid Aug 21, 2022
b97f690
remove redundant
srid Aug 21, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
102 changes: 102 additions & 0 deletions default/index.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,108 @@ js:
</script>
<script async="" id="MathJax-script" src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js"></script>

stork-search-base: |
<link rel="stylesheet" href="https://files.stork-search.net/releases/v1.5.0/basic.css" />
<!-- Stork-search styling base stylings -->
<style>
.stork-wrapper .stork-output {
margin-top: 0;
border-radius: 0;
position: sticky;
border-color: rgba(99,102,241,var(--tw-border-opacity));
--tw-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1),0 4px 6px -2px rgba(0, 0, 0, 0.05);
box-shadow: var(--tw-ring-offset-shadow,0 0 #0000),var(--tw-ring-shadow,0 0 #0000),var(--tw-shadow);
}

.stork-wrapper .stork-message {
padding: 0.5rem 1rem;
border-radius: 0;
border-color: rgba(99,102,241,var(--tw-border-opacity));
}

.stork-wrapper .stork-close-button {
top: 0;
margin: 0.8em 0.6em;
}

.stork-wrapper .stork-close-button svg {
top: unset;
margin-left: auto;
margin-right: auto;
}
</style>
<!-- Stork search scripts, styling added in more-head.tpl -->
<script src="https://files.stork-search.net/releases/v1.5.0/stork.js"></script>
<ema:metadata>
<with var="template">
<script data-emanote-base-url="${value:baseUrl}">
(function() {
const indexName = 'emanote-search'; // used to match input[data-stork] attribute value
const baseUrl = document.currentScript.getAttribute('data-emanote-base-url') || '/';
const indexUrl = baseUrl + 'stork.st';
if (document.readyState !== 'complete') {
window.addEventListener('load', function() {
stork.register(indexName, indexUrl);
});
} else {
stork.register(indexName, indexUrl, {forceOverwrite: true});
}
})();
</script>
</with>
</ema:metadata>
stork-search-book: |
<snippet var="js.stork-search-base"/>
<!-- Stork-search styling, specific to Emanote's book layout -->
<style>
@media (min-width: 768px) {
.stork-wrapper .stork-output {
top: 0;
left: calc(100% - 1px);
position: absolute;
width: calc(768px - 12rem);
}

.stork-wrapper {
margin-right: -1px;
}
}

@media (min-width: 1024px) {
.stork-wrapper .stork-output {
width: calc(1024px - 12rem);
}
}

@media (min-width: 1280px) {
.stork-wrapper .stork-output {
width: calc(1280px - 16rem);
}
}

@media (min-width: 1536px) {
.stork-wrapper .stork-output {
width: calc(1536px - 16rem);
}
}

nav#sidebar {
z-index: 100;
}
</style>
stork-search-note: |
<snippet var="js.stork-search-base"/>
<!-- Stork-search styling, specific to Emanote's Neuron-like layout -->
<style>
.stork-wrapper .stork-output {
position: absolute;
}
</style>
# This adds styling for the "default layout", and should
# be used if you rely on Emanote's default layout.
stork-search: |
<snippet var="js.stork-search-book"/>

emanote:
# Whether to automatically treat folder notes as a folgezettel parent of its contents
folder-folgezettel: true
Expand Down
2 changes: 1 addition & 1 deletion default/templates/base.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,4 @@
<body-main />
</body>

</html>
</html>
3 changes: 2 additions & 1 deletion default/templates/layouts/book.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
<!-- Sidebar column -->
<nav id="sidebar"
class="flex-shrink hidden leading-relaxed md:block md:sticky md:top-0 md:h-full md:w-48 xl:w-64">
<apply template="hooks/search-box" />
<div class="px-2 py-2 text-gray-800">

<div id="indexing-links" class="flex flex-row float-right p-2 space-x-2 text-gray-500">
Expand Down Expand Up @@ -76,4 +77,4 @@
<apply template="components/footer" />
</div>
</bind>
</apply>
</apply>
5 changes: 3 additions & 2 deletions default/templates/layouts/note.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,13 @@

<apply template="base">
<bind tag="head-main">
<link rel="stylesheet" href="${ema:emanoteStaticLayerUrl}/inverted-tree.css" />
<link rel="stylesheet" href="/${ema:emanoteStaticLayerUrl}/inverted-tree.css" />
applejag marked this conversation as resolved.
Show resolved Hide resolved
</bind>
<bind tag="body-main">
<div class="${containerClass}">
<div class="mt-2 md:mt-4">
<apply template="components/note-uptree" />
<apply template="hooks/search-box" />
<div class="md:shadow-2xl md:mb-8">
<div class="flex-1 w-full overflow-x-auto bg-white">
<main class="px-4 py-4">
Expand All @@ -30,4 +31,4 @@
</div>
</div>
</bind>
</apply>
</apply>
4 changes: 4 additions & 0 deletions docs/templates/hooks/search-box.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<div class="stork-wrapper">
<input data-stork="emanote-search" class="px-4 py-2 block w-full rounded-none border border-gray-300 focus:ring-indigo-500 focus:border-indigo-500 focus:outline-none" placeholder="Search..." />
<div data-stork="emanote-search-output" class="stork-output"></div>
</div>