pull/645/head
Tienson Qin 2020-09-29 12:49:29 +08:00
parent e099500f55
commit b452b87b9e
24 changed files with 62 additions and 32 deletions

View File

@ -1,7 +1,6 @@
(ns frontend.components.commit
(:require [rum.core :as rum]
[frontend.util :as util :refer-macros [profile]]
[frontend.handler :as handler]
[frontend.handler.git :as git-handler]
[frontend.handler.repo :as repo-handler]
[frontend.state :as state]

View File

@ -3,7 +3,6 @@
[frontend.db :as db]
[frontend.format :as format]
[frontend.format.protocol :as protocol]
[frontend.handler :as handler]
[frontend.handler.editor :as editor-handler]
[frontend.handler.export :as export-handler]
[frontend.handler.image :as image-handler]

View File

@ -2,7 +2,6 @@
(:require [rum.core :as rum]
[frontend.util :as util]
[frontend.config :as config]
[frontend.handler :as handler]
[frontend.handler.git :as git-handler]
[frontend.handler.file :as file]
[frontend.handler.notification :as notification]

View File

@ -11,7 +11,6 @@
[dommy.core :as d]
[clojure.string :as string]
[frontend.date :as date]
[frontend.handler :as handler]
[frontend.handler.notification :as notification]
[frontend.handler.draw :as draw :refer
[*files

View File

@ -2,7 +2,6 @@
(:require [rum.core :as rum]
[frontend.components.svg :as svg]
[frontend.config :as config]
[frontend.handler :as handler]
[frontend.handler.editor :as editor-handler :refer [get-state]]
[frontend.handler.image :as image-handler]
[frontend.util :as util :refer-macros [profile]]

View File

@ -1,7 +1,6 @@
(ns frontend.components.file
(:require [rum.core :as rum]
[frontend.util :as util]
[frontend.handler :as handler]
[frontend.handler.project :as project]
[frontend.handler.ui :as ui-handler]
[frontend.handler.image :as image-handler]

View File

@ -17,7 +17,6 @@
[frontend.components.block :as block-comp]
[frontend.ui :as ui]
[frontend.components.widgets :as widgets]
[frontend.handler :as handler]
[frontend.handler.ui :as ui-handler]
[frontend.handler.image :as image-handler]
[frontend.handler.editor :as editor-handler]

View File

@ -2,9 +2,9 @@
(:require [rum.core :as rum]
[frontend.util :as util :refer-macros [profile]]
[frontend.date :as date]
[frontend.handler :as handler]
[frontend.handler.notification :as notification]
[frontend.handler.repo :as repo-handler]
[frontend.handler.page :as page-handler]
[frontend.handler.editor :as editor]
[frontend.handler.ui :as ui-handler]
[frontend.db :as db]
@ -106,7 +106,7 @@
[:div.journal.content {:key journal-name}
(journal-cp [journal-name format])])
{:on-load (fn []
(handler/load-more-journals!))})])
(page-handler/load-more-journals!))})])
(rum/defc all-journals < rum/reactive
[]

View File

@ -2,7 +2,6 @@
(:require [rum.core :as rum]
[medley.core :as medley]
[frontend.util :as util :refer-macros [profile]]
[frontend.handler :as handler]
[frontend.handler.file :as file]
[frontend.handler.page :as page-handler]
[frontend.handler.ui :as ui-handler]

View File

@ -1,7 +1,6 @@
(ns frontend.components.project
(:require [rum.core :as rum]
[frontend.util :as util :refer-macros [profile]]
[frontend.handler :as handler]
[frontend.handler.project :as project-handler]
[frontend.state :as state]
[clojure.string :as string]

View File

@ -1,7 +1,6 @@
(ns frontend.components.reference
(:require [rum.core :as rum]
[frontend.util :as util]
[frontend.handler :as handler]
[frontend.state :as state]
[clojure.string :as string]
[frontend.db :as db]

View File

@ -4,7 +4,6 @@
[frontend.ui :as ui]
[frontend.state :as state]
[frontend.db :as db]
[frontend.handler :as handler]
[frontend.handler.repo :as repo-handler]
[frontend.handler.route :as route-handler]
[frontend.handler.export :as export-handler]

View File

@ -7,7 +7,6 @@
[frontend.components.block :as block]
[frontend.extensions.graph-2d :as graph-2d]
[frontend.components.onboarding :as onboarding]
[frontend.handler :as handler]
[frontend.handler.route :as route-handler]
[frontend.handler.editor :as editor-handler]
[frontend.handler.page :as page-handler]

View File

@ -1,7 +1,6 @@
(ns frontend.components.search
(:require [rum.core :as rum]
[frontend.util :as util]
[frontend.handler :as handler]
[frontend.handler.route :as route]
[frontend.handler.editor :as editor-handler]
[frontend.handler.page :as page-handler]

View File

@ -1,7 +1,6 @@
(ns frontend.components.settings
(:require [rum.core :as rum]
[frontend.ui :as ui]
[frontend.handler :as handler]
[frontend.handler.notification :as notification]
[frontend.handler.user :as user-handler]
[frontend.handler.ui :as ui-handler]

View File

@ -16,7 +16,6 @@
[goog.crypt.base64 :as b64]
[frontend.util :as util]
[frontend.state :as state]
[frontend.handler :as handler]
[frontend.handler.notification :as notification]
[frontend.handler.ui :as ui-handler]
[frontend.handler.user :as user-handler]

View File

@ -1,7 +1,6 @@
(ns frontend.components.widgets
(:require [rum.core :as rum]
[frontend.util :as util]
[frontend.handler :as handler]
[frontend.handler.user :as user-handler]
[frontend.handler.git :as git-handler]
[frontend.handler.repo :as repo-handler]

View File

@ -6,7 +6,6 @@
[frontend.routes :as routes]
[frontend.util :as util]
[reitit.frontend :as rf]
[frontend.config :as config]
[reitit.frontend.easy :as rfe]))
(defn set-router!

View File

@ -1,6 +1,5 @@
(ns frontend.graph
(:require [frontend.handler :as handler]
[frontend.handler.ui :as ui-handler]
(:require [frontend.handler.ui :as ui-handler]
[frontend.handler.route :as route-handler]
[frontend.util :as util]
[clojure.string :as string]

View File

@ -15,12 +15,6 @@
[frontend.history :as history]
[frontend.ui :as ui]))
(defn load-more-journals!
[]
(let [current-length (:journals-length @state/state)]
(when (< current-length (db/get-journals-length))
(state/update-state! :journals-length inc))))
(defn- watch-for-date!
[]
(js/setInterval (fn []

View File

@ -1,6 +1,5 @@
(ns frontend.handler.dnd
(:require [frontend.handler :as handler]
[frontend.handler.notification :as notification]
(:require [frontend.handler.notification :as notification]
[frontend.handler.repo :as repo-handler]
[frontend.config :as config]
[frontend.util :as util :refer-macros [profile]]

View File

@ -6,7 +6,6 @@
[frontend.util :as util :refer-macros [profile]]
[frontend.tools.html-export :as html-export]
[frontend.config :as config]
[frontend.handler :as handler]
[frontend.handler.route :as route-handler]
[frontend.handler.file :as file-handler]
[frontend.handler.git :as git-handler]
@ -321,3 +320,9 @@
:with-level? true
:new-level 2
:current-page "Contents"})))
(defn load-more-journals!
[]
(let [current-length (:journals-length @state/state)]
(when (< current-length (db/get-journals-length))
(state/update-state! :journals-length inc))))

View File

@ -1,6 +1,5 @@
(ns frontend.keyboards
(:require [frontend.handler :as handler]
[frontend.handler.editor :as editor-handler]
(:require [frontend.handler.editor :as editor-handler]
[frontend.handler.history :as history-handler]
[frontend.handler.ui :as ui-handler]
[frontend.handler.route :as route-handler]

View File

@ -0,0 +1,51 @@
(ns frontend.publishing
(:require [frontend.state :as state]
[datascript.core :as d]
[frontend.db :as db]
[frontend.db-schema :as db-schema]
[rum.core :as rum]
[frontend.handler.route :as route]
[frontend.page :as page]
[frontend.routes :as routes]
[frontend.util :as util]
[reitit.frontend :as rf]
[reitit.frontend.easy :as rfe]))
;; The publishing site should be as thin as possible.
;; Both files and git libraries can be removed.
;; Maybe we can remove some handlers and components too.
(defn restore-from-transit-str!
[]
(state/set-current-repo! "local")
(when-let [data js/window.logseq_db]
(let [db-conn (d/create-conn db-schema/schema)
_ (swap! db/conns assoc "local" db-conn)
db (string->db logseq_db)]
(reset! db-conn db))))
(defn set-router!
[]
(rfe/start!
(rf/router routes/routes {})
route/set-route-match!
;; set to false to enable HistoryAPI
{:use-fragment false}))
(defn start []
(when-let [node (.getElementById js/document "root")]
(set-router!)
(rum/mount (page/current-page) node)))
(defn ^:export init []
;; init is called ONCE when the page loads
;; this is called in the index.html and must be exported
;; so it is available even in :advanced release builds
(db/restore-from-transit-str!)
(start))
(defn stop []
;; stop is called before any code is reloaded
;; this is controlled by :before-load in the config
(js/console.log "stop"))