diff --git a/src/main/frontend/components/search.cljs b/src/main/frontend/components/search.cljs index 3d3204da1..e7efdbdfc 100644 --- a/src/main/frontend/components/search.cljs +++ b/src/main/frontend/components/search.cljs @@ -5,7 +5,6 @@ [frontend.components.svg :as svg] [frontend.handler.route :as route] [frontend.handler.page :as page-handler] - [frontend.handler.file :as file-handler] [frontend.db :as db] [frontend.handler.search :as search-handler] [frontend.ui :as ui] @@ -141,10 +140,7 @@ (rum/defc search-auto-complete [{:keys [pages files blocks has-more?] :as result} search-q all?] (rum/with-context [[t] i18n/*tongue-context*] - (let [new-file (when-let [ext (util/get-file-ext search-q)] - (when (contains? config/mldoc-support-formats (keyword (string/lower-case ext))) - [{:type :new-file}])) - pages (when-not all? (map (fn [page] {:type :page :data page}) pages)) + (let [pages (when-not all? (map (fn [page] {:type :page :data page}) pages)) files (when-not all? (map (fn [file] {:type :file :data file}) files)) blocks (map (fn [block] {:type :block :data block}) blocks) search-mode (state/get-search-mode) @@ -159,7 +155,7 @@ [{:type :new-page}]) result (if config/publishing? (concat pages files blocks) - (concat new-page pages new-file files blocks))] + (concat new-page pages files blocks))] [:div.rounded-md.shadow-lg {:style (merge {:top 48 @@ -180,9 +176,6 @@ (route/redirect! {:to :page :path-params {:name data}}) - :new-file - (file-handler/create! search-q) - :file (route/redirect! {:to :file :path-params {:path data}}) @@ -221,10 +214,6 @@ [:div.text.font-bold (str (t :new-page) ": ") [:span.ml-1 (str "\"" search-q "\"")]] - :new-file - [:div.text.font-bold (str (t :new-file) ": ") - [:span.ml-1 (str "\"" search-q "\"")]] - :page (search-result-item "Page" (highlight-exact-query data search-q)) diff --git a/src/main/frontend/extensions/code.cljs b/src/main/frontend/extensions/code.cljs index 6260c2df5..ad1ea7c56 100644 --- a/src/main/frontend/extensions/code.cljs +++ b/src/main/frontend/extensions/code.cljs @@ -3,7 +3,6 @@ [frontend.util :as util] [goog.dom :as gdom] [goog.object :as gobj] - [medley.core :as medley] [frontend.db :as db] [frontend.state :as state] [frontend.handler.editor :as editor-handler] diff --git a/src/main/frontend/handler/config.cljs b/src/main/frontend/handler/config.cljs index b7cdfcaa9..885744ce1 100644 --- a/src/main/frontend/handler/config.cljs +++ b/src/main/frontend/handler/config.cljs @@ -2,7 +2,6 @@ (:require [frontend.state :as state] [frontend.handler.file :as file-handler] [frontend.config :as config] - [frontend.db :as db] [clojure.string :as string])) (defn set-config! @@ -18,7 +17,3 @@ [project] (when-not (string/blank? project) (set-config! [:project :name] project))) - -(defn set-preferred-workflow! - [workflow] - (set-config! :preferred-workflow (name workflow))) diff --git a/src/main/frontend/handler/draw.cljs b/src/main/frontend/handler/draw.cljs index 4a404d937..54239af80 100644 --- a/src/main/frontend/handler/draw.cljs +++ b/src/main/frontend/handler/draw.cljs @@ -7,11 +7,7 @@ [frontend.db :as db] [frontend.handler.file :as file-handler] [frontend.date :as date] - [frontend.config :as config] - [frontend.storage :as storage] - [clojure.string :as string] - [cljs-time.core :as t] - [cljs-time.coerce :as tc])) + [frontend.config :as config])) (defn create-draws-directory! [repo] diff --git a/src/main/frontend/handler/editor/lifecycle.cljs b/src/main/frontend/handler/editor/lifecycle.cljs index 8ade99695..947478186 100644 --- a/src/main/frontend/handler/editor/lifecycle.cljs +++ b/src/main/frontend/handler/editor/lifecycle.cljs @@ -58,31 +58,9 @@ input :upload-images)))) (editor-handler/clear-when-saved!) - (if file? - (let [path (:file-path config) - content (db/get-file-no-sub path) - value (some-> (gdom/getElement path) - (gobj/get "value"))] - (when (and - (not (string/blank? value)) - (not= (string/trim value) (string/trim content))) - (let [old-page-name (db/get-file-page path false)] - (p/let [[journal? new-name] (page-handler/rename-when-alter-title-property! old-page-name path format content value)] - (if (and journal? new-name (not= old-page-name (string/lower-case new-name))) - (notification/show! "Journal title can't be changed." :warning) - (let [new-name (if journal? (date/journal-title->default new-name) new-name) - new-path (if new-name - (if (and - new-name old-page-name - (= (string/lower-case new-name) (string/lower-case old-page-name))) - path - (page-handler/compute-new-file-path path new-name)) - path)] - (file/alter-file (state/get-current-repo) new-path (string/trim value) - {:re-render-root? true}))))))) - ;; TODO: ugly - (when-not (contains? #{:insert :indent :outdent :auto-save :undo :redo} (state/get-editor-op)) - (editor-handler/save-block! (get-state) value)))) + ;; TODO: ugly + (when-not (contains? #{:insert :indent :outdent :auto-save :undo :redo} (state/get-editor-op)) + (editor-handler/save-block! (get-state) value))) state) (def lifecycle diff --git a/src/main/frontend/handler/external.cljs b/src/main/frontend/handler/external.cljs index 3e0667504..1c2062e21 100644 --- a/src/main/frontend/handler/external.cljs +++ b/src/main/frontend/handler/external.cljs @@ -7,7 +7,6 @@ [frontend.date :as date] [frontend.config :as config] [clojure.string :as string] - [promesa.core :as p] [frontend.db :as db])) (defonce debug-files (atom nil)) diff --git a/src/main/frontend/handler/file.cljs b/src/main/frontend/handler/file.cljs index e0cf93548..0532e93f4 100644 --- a/src/main/frontend/handler/file.cljs +++ b/src/main/frontend/handler/file.cljs @@ -276,7 +276,7 @@ (when-not (string/blank? file) (-> (p/let [_ (or (config/local-db? repo) (git/remove-file repo file)) - result (fs/unlink! (config/get-repo-path repo file) nil)] + _ (fs/unlink! (config/get-repo-path repo file) nil)] (when-let [file (db/entity repo [:file/path file])] (common-handler/check-changed-files-status) (let [file-id (:db/id file) diff --git a/src/main/frontend/handler/metadata.cljs b/src/main/frontend/handler/metadata.cljs index 0fcd60f27..ee3e41a1c 100644 --- a/src/main/frontend/handler/metadata.cljs +++ b/src/main/frontend/handler/metadata.cljs @@ -6,8 +6,7 @@ [frontend.db :as db] [datascript.db :as ddb] [clojure.string :as string] - [promesa.core :as p] - [medley.core :as medley])) + [promesa.core :as p])) (def default-metadata-str "{}") diff --git a/src/main/frontend/handler/page.cljs b/src/main/frontend/handler/page.cljs index 13b4934bd..272b19980 100644 --- a/src/main/frontend/handler/page.cljs +++ b/src/main/frontend/handler/page.cljs @@ -22,10 +22,7 @@ [frontend.fs :as fs] [promesa.core :as p] [lambdaisland.glogi :as log] - [frontend.format.mldoc :as mldoc] [frontend.format.block :as block] - [cljs-time.core :as t] - [cljs-time.coerce :as tc] [cljs.reader :as reader] [goog.object :as gobj])) @@ -304,11 +301,7 @@ (let [new-name (string/trim new-name)] (when-not (string/blank? new-name) (when (and old-name new-name) - (let [case-changed? (and (= (string/lower-case old-name) - (string/lower-case new-name)) - (not= (string/trim old-name) - (string/trim new-name))) - name-changed? (not= (string/lower-case (string/trim old-name)) + (let [name-changed? (not= (string/lower-case (string/trim old-name)) (string/lower-case (string/trim new-name)))] (when-let [repo (state/get-current-repo)] (when-let [page (db/entity [:block/name (string/lower-case old-name)])] @@ -317,13 +310,12 @@ journal? (:block/journal? page)] (d/transact! (db/get-conn repo false) [{:db/id (:db/id page) + :block/uuid (:block/uuid page) :block/name (string/lower-case new-name) :block/original-name new-name}]) (when (and file (not journal?) name-changed?) - (rename-file! file new-name - (fn [] - (page-add-properties! (string/lower-case new-name) {:title new-name})))) + (rename-file! file new-name (fn [] nil))) ;; update all files which have references to this page (let [files (db/get-files-that-referenced-page (:db/id page))] @@ -351,21 +343,6 @@ (ui-handler/re-render-root!)))))))) -(defn rename-when-alter-title-property! - [page path format original-content content] - (when (and page (contains? config/mldoc-support-formats format)) - (let [old-name page - new-name (let [ast (mldoc/->edn content (mldoc/default-config format))] - (db/get-page-name path ast)) - journal? (date/valid-journal-title? old-name)] - (if (not= old-name new-name) - (if journal? - [true old-name] - (do - (rename! old-name new-name) - [false new-name])) - [journal? old-name])))) - (defn handle-add-page-to-contents! [page-name] (let [last-block (last (db/get-page-blocks (state/get-current-repo) "contents"))