forked from logseq/logseq
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add :hidden config support to graph-parser.cli
Also fix lints and tests from previous commits
- Loading branch information
1 parent
c86fd3c
commit 47508ac
Showing
17 changed files
with
102 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{:paths ["src"] | ||
:api-namespaces [logseq.common.path] | ||
:report {:format :ignore}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
;; API fn | ||
logseq.common.config/remove-hidden-files | ||
;; API fn | ||
logseq.common.graph/get-files |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
(ns logseq.common.config | ||
"This ns provides common fns related to user config" | ||
(:require [clojure.string :as string])) | ||
|
||
(defn- hidden? | ||
[path patterns] | ||
(let [path (if (and (string? path) | ||
(= \/ (first path))) | ||
(subs path 1) | ||
path)] | ||
(some (fn [pattern] | ||
(let [pattern (if (and (string? pattern) | ||
(not= \/ (first pattern))) | ||
(str "/" pattern) | ||
pattern)] | ||
(string/starts-with? (str "/" path) pattern))) patterns))) | ||
|
||
(defn remove-hidden-files | ||
"Removes files that match a pattern specified by :hidden config" | ||
[files config get-path-fn] | ||
(if-let [patterns (seq (:hidden config))] | ||
(remove (fn [file] | ||
(let [path (get-path-fn file)] | ||
(hidden? path patterns))) files) | ||
files)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
(ns logseq.common.config-test | ||
(:require [logseq.common.config :as common-config] | ||
[cljs.test :refer [deftest is]])) | ||
|
||
(deftest remove-hidden-files | ||
(let [files ["pages/foo.md" "pages/bar.md" | ||
"script/README.md" "script/config.edn" | ||
"dev/README.md" "dev/config.edn"]] | ||
(is (= ["pages/foo.md" "pages/bar.md"] | ||
(common-config/remove-hidden-files | ||
files | ||
{:hidden ["script" "/dev"]} | ||
identity)) | ||
"Removes hidden relative files") | ||
|
||
(is (= ["/pages/foo.md" "/pages/bar.md"] | ||
(common-config/remove-hidden-files | ||
(map #(str "/" %) files) | ||
{:hidden ["script" "/dev"]} | ||
identity)) | ||
"Removes hidden files if they start with '/'"))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,9 @@ | ||
(ns frontend.schema.handler.global-config | ||
"Malli schemas for global-config" | ||
(:require [frontend.schema.handler.common-config :as common-config])) | ||
(:require [frontend.schema.handler.common-config :as common-config-schema])) | ||
|
||
;; For now this just references a common schema but repo-config and | ||
;; global-config could diverge | ||
(def Config-edn | ||
"Schema for global config.edn" | ||
common-config/Config-edn) | ||
common-config-schema/Config-edn) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,9 @@ | ||
(ns frontend.schema.handler.repo-config | ||
"Malli schemas for repo-config" | ||
(:require [frontend.schema.handler.common-config :as common-config])) | ||
(:require [frontend.schema.handler.common-config :as common-config-schema])) | ||
|
||
;; For now this just references a common schema but repo-config and | ||
;; global-config could diverge | ||
(def Config-edn | ||
"Schema for repo config.edn" | ||
common-config/Config-edn) | ||
common-config-schema/Config-edn) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters