This demo uses a fdb.on/modify metadata trigger to search in ClojureDocs whenever a file changes, and writes the scraped results to another file:
Start by making ~/fdb/user/clojuredocs.txt.
This is where you'll write the query in.
echo "reduce" > ~/fdb/user/clojuredocs.txtThen add metadata with the trigger. This trigger will:
- call https://clojuredocs.org/search with the file contents in the
qparam - scrape the response for
lielements with thearglistclass - write them to
clojuredocs-out.txt
echo '
{:fdb.on/modify
(fn [{:keys [self-path]}]
(-> "https://clojuredocs.org/search"
(fdb.http/add-params {:q (slurp self-path)})
(fdb.http/scrape [:li.arglist])
(->> (mapcat :content)
(clojure.string/join "\n")
(spit (fdb.utils/sibling-path self-path "clojuredocs-out.txt")))))}
' > ~/fdb/user/clojuredocs.txt.meta.ednRead the results
cat ~/fdb/user/clojuredocs-out.txt(reduce f coll)
(reduce f val coll)
(reduced x)
(reduce f init ch)
(reducer coll xf)
(reduce f coll)
(reduce f init coll)
(reduced? x)
(reduce-kv f init coll)
(kv-reduce amap f init)
(coll-reduce coll f)
(coll-reduce coll f val)
(ensure-reduced x)Search for something else.
# search for something else
echo "map" > ~/fdb/user/clojuredocs.txt
cat ~/fdb/user/clojuredocs-out.txt