fix: rm file graph config from user config

Also remove unused helpers for file config keys and file graph code in
mobile.intent.  These removals also result in removing
frontend.common.file.util as it's no longer used
This commit is contained in:
Gabriel Horner
2026-01-08 11:30:37 -05:00
parent 37d9ebda1f
commit 1d15e1f85d
25 changed files with 60 additions and 487 deletions

View File

@@ -1,135 +1,5 @@
{:meta/version 1
;; == FILE GRAPH CONFIG ==
;;
;; Set the preferred format.
;; This is _only_ for file graphs.
;; Available options:
;; - Markdown (default)
;; - Org
;; :preferred-format "Markdown"
;; Set the preferred workflow style.
;; This is _only_ for file graphs.
;; Available options:
;; - :now for NOW/LATER style (default)
;; - :todo for TODO/DOING style
:preferred-workflow :now
;; Exclude directories/files.
;; This is _only_ for file graphs.
;; Example usage:
;; :hidden ["/archived" "/test.md" "../assets/archived"]
:hidden []
;; Define the default journal page template.
;; Enter the template name between the quotes.
;; This is _only_ for file graphs.
:default-templates
{:journals ""}
;; Set a custom date format for the journal page title.
;; This is _only_ for file graphs.
;; Default value: "MMM do, yyyy"
;; e.g., "Jan 19th, 2038"
;; Example usage e.g., "Tue 19th, Jan 2038"
;; :journal/page-title-format "EEE do, MMM yyyy"
;; Specify the journal filename format using a valid date format string.
;; !Warning:
;; This configuration is not retroactive and affects only new journals.
;; To show old journal files in the app, manually rename the files in the
;; journal directory to match the new format.
;; This is _only_ for file graphs.
;; Default value: "yyyy_MM_dd"
;; :journal/file-name-format "yyyy_MM_dd"
;; Set the default location for storing notes.
;; This is _only_ for file graphs.
;; Default value: "pages"
;; :pages-directory "pages"
;; Set the default location for storing journals.
;; This is _only_ for file graphs.
;; Default value: "journals"
;; :journals-directory "journals"
;; Set the default location for storing whiteboards.
;; This is _only_ for file graphs.
;; Default value: "whiteboards"
;; :whiteboards-directory "whiteboards"
;; Enabling this option converts
;; [[Grant Ideas]] to [[file:./grant_ideas.org][Grant Ideas]] for org-mode.
;; For more information, visit https://github.com/logseq/logseq/issues/672
;; This is _only_ for file graphs.
;; :org-mode/insert-file-link? false
;; Favorites to list on the left sidebar
;; This is _only_ for file graphs.
:favorites []
;; Set flashcards interval.
;; This is _only_ for file graphs.
;; Expected value:
;; - Float between 0 and 1
;; higher values result in faster changes to the next review interval.
;; Default value: 0.5
;; :srs/learning-fraction 0.5
;; Set the initial interval after the first successful review of a card.
;; This is _only_ for file graphs.
;; Default value: 4
;; :srs/initial-interval 4
;; Hide specific block properties.
;; This is _only_ for file graphs.
;; Example usage:
;; :block-hidden-properties #{:public :icon}
;; Create a page for all properties.
;; This is _only_ for file graphs.
;; Default value: true
:property-pages/enabled? true
;; Properties to exclude from having property pages
;; This is _only_ for file graphs.
;; Example usage:
;; :property-pages/excludelist #{:duration :author}
;; By default, property value separated by commas will not be treated as
;; page references. You can add properties to enable it.
;; This is _only_ for file graphs.
;; Example usage:
;; :property/separated-by-commas #{:alias :tags}
;; Properties that are ignored when parsing property values for references
;; This is _only_ for file graphs.
;; Example usage:
;; :ignored-page-references-keywords #{:author :website}
;; logbook configuration.
;; This is _only_ for file graphs.
;; :logbook/settings
;; {:with-second-support? false ;limit logbook to minutes, seconds will be eliminated
;; :enabled-in-all-blocks true ;display logbook in all blocks after timetracking
;; :enabled-in-timestamped-blocks false ;don't display logbook at all
;; }
;; Configure the escaping method for special characters in page titles.
;; This is _only_ for file graphs.
;; Warning:
;; This is a dangerous operation. To modify the setting,
;; you'll need to manually rename all affected files and
;; re-index them on all clients after synchronization.
;; Incorrect handling may result in messy page titles.
;; Available options:
;; - :triple-lowbar (default)
;; ;use triple underscore `___` for slash `/` in page title
;; ;use Percent-encoding for other invalid characters
:file/name-format :triple-lowbar
;; == END OF FILE GRAPH CONFIG ==
;; Hide empty block properties
;; This is _only_ for DB graphs.
;; Default value: false

View File

@@ -67,19 +67,11 @@
s))
(defonce default-draw-directory "draws")
;; TODO read configurable value?
(defonce default-whiteboards-directory "whiteboards")
(defn draw?
[path]
(string/starts-with? path default-draw-directory))
(defn whiteboard?
[path]
(and path
(string/includes? path (str default-whiteboards-directory "/"))
(string/ends-with? path ".edn")))
;; TODO: rename
(defonce mldoc-support-formats
#{:org :markdown :md})
@@ -97,21 +89,6 @@
[]
#{:gif :svg :jpeg :ico :png :jpg :bmp :webp})
(defn get-date-formatter
[config]
(or
(:journal/page-title-format config)
;; for compatibility
(:date-formatter config)
"MMM do, yyyy"))
(defn get-preferred-format
[config]
(or
(when-let [fmt (:preferred-format config)]
(keyword (string/lower-case (name fmt))))
:markdown))
(defn get-block-pattern
[format]
(let [format' (keyword format)]
@@ -121,11 +98,6 @@
"-")))
(defn create-config-for-db-graph
"Given a new config.edn file string, creates a config.edn for use with only DB graphs"
[config]
(string/replace config #"(?m)[\s]*;; == FILE GRAPH CONFIG ==(?:.|\n)*?;; == END OF FILE GRAPH CONFIG ==\n?" ""))
(def file-only-config
"File only config keys that are deprecated in DB graphs along with
descriptions for their deprecation."

View File

@@ -5,8 +5,6 @@
[logseq.common.util :as common-util]
[clojure.string :as string]))
(def default-journal-filename-formatter "yyyy_MM_dd")
(defonce built-in-journal-title-formatters
(list
"do MMM yyyy"
@@ -79,12 +77,4 @@
(defn ^:api valid-journal-title-with-slash?
[title]
(some #(valid-journal-title? title %) slash-journal-title-formatters))
(defn ^:api date->file-name
"Date object to filename format"
[date journal-filename-formatter]
(let [formatter (if journal-filename-formatter
(tf/formatter journal-filename-formatter)
(tf/formatter default-journal-filename-formatter))]
(tf/unparse formatter date)))
(some #(valid-journal-title? title %) slash-journal-title-formatters))

View File

@@ -1,9 +1,5 @@
(ns logseq.common.config-test
(:require ["fs" :as fs]
["path" :as node-path]
#?(:org.babashka/nbb [nbb.classpath :as cp])
[cljs.test :refer [deftest is]]
[clojure.string :as string]
(:require [cljs.test :refer [deftest is]]
[logseq.common.config :as common-config]))
(deftest remove-hidden-files
@@ -23,23 +19,4 @@
(map #(str "/" %) files)
{:hidden ["script" "/dev"]}
identity))
"Removes hidden files if they start with '/'")))
(defn find-on-classpath [classpath rel-path]
(some (fn [dir]
(let [f (node-path/join dir rel-path)]
(when (fs/existsSync f) f)))
(string/split classpath #":")))
#?(:org.babashka/nbb
(deftest create-config-for-db-graph
(let [original-config (some-> (find-on-classpath (cp/get-classpath) "templates/config.edn") fs/readFileSync str)
_ (assert original-config "config.edn must not be blank")
migrated-config (common-config/create-config-for-db-graph original-config)
forbidden-kws-regex (re-pattern (str (string/join "|" (keys common-config/file-only-config))))]
;; (println migrated-config)
(is (not (string/includes? migrated-config "== FILE ONLY CONFIG"))
"No longer includes file config header")
(assert (re-find forbidden-kws-regex original-config) "File config keys present in original config")
(is (not (re-find forbidden-kws-regex migrated-config))
"File config keys no longer present in migrated config"))))
"Removes hidden files if they start with '/'")))

View File

@@ -314,11 +314,25 @@
(dissoc :block/priority)))
block))
(defn- get-date-formatter
[config]
(or
(:journal/page-title-format config)
;; for compatibility
(:date-formatter config)
"MMM do, yyyy"))
(defn- config-whiteboard?
[path]
(and path
(string/includes? path (str "whiteboards" "/"))
(string/ends-with? path ".edn")))
(defn- find-or-create-deadline-scheduled-value
"Given a :block/scheduled or :block/deadline value, creates the datetime property value
and any optional journal tx associated with that value"
[date-int page-names-to-uuids user-config]
(let [title (date-time-util/int->journal-title date-int (common-config/get-date-formatter user-config))
(let [title (date-time-util/int->journal-title date-int (get-date-formatter user-config))
existing-journal-page (some->> title
common-util/page-name-sanity-lc
(get @page-names-to-uuids)
@@ -1745,7 +1759,7 @@
(map #(dissoc % :block.temp/original-page-name) pages)))
(update :blocks fix-extracted-block-tags-and-refs))
(common-config/whiteboard? file)
(config-whiteboard? file)
(-> (extract/extract-whiteboard-edn file content extract-options')
(update :pages (fn [pages]
(->> pages
@@ -2102,7 +2116,7 @@
(defn build-doc-options
"Builds options for use with export-doc-files and assets"
[config options]
(-> {:extract-options {:date-formatter (common-config/get-date-formatter config)
(-> {:extract-options {:date-formatter (get-date-formatter config)
;; Remove config keys that break importing
:user-config (dissoc config :property-pages/excludelist :property-pages/enabled?)
:filename-format (or (:file/name-format config) :legacy)

View File

@@ -5,7 +5,6 @@
["path" :as node-path]
[borkdude.rewrite-edn :as rewrite]
[clojure.string :as string]
[logseq.common.config :as common-config]
[logseq.db :as ldb]
[logseq.db.common.sqlite-cli :as sqlite-cli]
[logseq.db.sqlite.build :as sqlite-build]
@@ -43,8 +42,6 @@
(cond-> (or (some-> (find-on-classpath classpath "templates/config.edn") fs/readFileSync str)
(do (println "Setting graph's config to empty since no templates/config.edn was found.")
"{}"))
true
(common-config/create-config-for-db-graph)
additional-config
(pretty-print-merge additional-config))
git-sha (get-git-sha)]