-
Notifications
You must be signed in to change notification settings - Fork 72
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
Include YAML frontmatter in the Stork index #398
Conversation
4811585
to
be20c77
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR.
Reading your comments here, I'm convinced that we should disable this feature by default and add an option to index.yaml
for manually enabling it. We can put the option under: https://github.com/EmaApps/emanote/blob/d2a64234fa327b782fcf7e49097226bea90248fe/default/index.yaml#L131-L133
viz:
emanote:
stork:
frontmatter-handling: ignore
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm convinced that we should disable this feature by default and add an option to index.yaml for manually enabling it.
I'll explore that part of the code and see how I do.
be20c77
to
a984a0e
Compare
a984a0e
to
38261b1
Compare
It now reads the config from Tangential, but if I change the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I left some comments indicating the changes the need to be done on top of this PR. I can do them myself, unless you want to give it a go.
Tangential, but if I change the
index.yaml
, the index isn't rebuilt. I have to write a Haskell or Markdown file for it to be rebuilt. Is that a bug?
It normally should, IIUC. What browser you are on?
src/Emanote/Model/Stork/Index.hs
Outdated
newtype StorkInput = StorkInput | ||
{ globalInput :: Input |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe, newtype Config
and configInput
(to keep with the field naming convention).
Firefox. |
Changed |
b952199
to
f5b77b2
Compare
398: Include YAML frontmatter in the Stork index r=srid a=jfpedroza This PR sets the `frontmatter_handling` setting in Stork to `Ignore` so the frontmatter is included in the searchable text. See #397 Co-authored-by: Jhon Pedroza <jhon@pedroza.me> Co-authored-by: Sridhar Ratnakumar <srid@srid.ca>
bors try |
bors r- |
Canceled. |
bors r- |
bors try |
tryAlready running a review |
tryBuild succeeded: |
src/Emanote/Model/Stork/Index.hs
Outdated
instance FromJSON Handling where | ||
parseJSON = genericParseJSON handlingJSONOptions | ||
where | ||
handlingJSONOptions :: Aeson.Options | ||
handlingJSONOptions = | ||
Aeson.defaultOptions | ||
{ Aeson.constructorTagModifier = toString . T.toLower . T.replace "Handling_" "" . toText | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This instance can be simplified using
https://hackage.haskell.org/package/aeson-casing-0.2.0.0/docs/Data-Aeson-Casing.html
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jfpedroza Wanna take a stab at this?
Otherwise, I'll do the rest of the changes (including this one) tomorrow and merge.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I'll give it a try.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The package works on fieldLabelModifier
, not constructorTagModifier
so I can't use the public functions. And even with the internal functions, they don't work on the form Handling_Ignore
, they expect camel case.
The only thing useful is applyFirst
that allows you to do
Aeson.constructorTagModifier = applyFirst toLower . drop 9
It's not worth to add the package for that function. I added it and changed replace
with drop
since it avoids the converting to text and back dance.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right.
I actually should have suggested https://hackage.haskell.org/package/deriving-aeson because that's exactly what we need here.
cf. https://ghc.gitlab.haskell.org/ghc/doc/users_guide/exts/deriving_via.html
bors try |
tryBuild succeeded: |
bors try |
tryBuild succeeded: |
This PR sets the
frontmatter_handling
setting in Stork toIgnore
so the frontmatter is included in the searchable text.See #397