Page encoding now supports non-asciis

pull/645/head
Tienson Qin 2020-07-06 15:48:01 +08:00
parent 1ccd78eb86
commit 6743212321
8 changed files with 29 additions and 27 deletions

View File

@ -173,7 +173,7 @@
[page]
(let [page (string/lower-case page)]
[:a.page-ref
{:href (str "/page/" (util/url-encode page))
{:href (str "/page/" (util/encode-str page))
:on-click (fn [e]
(util/stop e)
(when (gobj/get e "shiftKey")

View File

@ -46,7 +46,7 @@
repo (state/get-current-repo)
raw-headings (db/get-page-headings repo page)
headings (db/with-dummy-heading raw-headings format nil true)
encoded-page-name (util/url-encode page)
encoded-page-name (util/encode-str page)
today? (= (string/lower-case title)
(string/lower-case (date/journal-name)))]
[:div.flex-1

View File

@ -171,7 +171,7 @@
[:div.alias.ml-1.mb-1.content {:key "page-alias"}
[:span.font-bold.mr-1 "Page aliases: "]
(for [item alias]
[:a {:href (str "/page/" (util/url-encode item))}
[:a {:href (str "/page/" (util/encode-str item))}
[:span.mr-1 (util/capitalize-all item)]])])))
;; headings
@ -216,9 +216,9 @@
[:th "Last modified at"]]]
[:tbody
(for [[page modified-at] pages]
(let [page-id (util/url-encode page)]
[:tr {:key page-id}
[:td [:a.text-gray-700 {:href (str "/page/" page-id)}
(let [encoded-page (util/encode-str page)]
[:tr {:key encoded-page}
[:td [:a.text-gray-700 {:href (str "/page/" encoded-page)}
(util/capitalize-all page)]]
[:td [:span.text-gray-500.text-sm
(if (zero? modified-at)

View File

@ -65,11 +65,11 @@
:page
(handler/redirect! {:to :page
:path-params {:name (util/url-encode data)}})
:path-params {:name (util/encode-str data)}})
:block
(let [page (:page/name (:heading/page data))
path (str "/page/" (util/url-encode page) "#ls-heading-" (:heading/uuid data))]
path (str "/page/" (util/encode-str page) "#ls-heading-" (:heading/uuid data))]
(handler/redirect-with-fragment! path))
nil))
:item-render (fn [{:keys [type data]}]

View File

@ -47,7 +47,7 @@
[:div.cursor-pointer.flex.flex-col.overflow-hidden
(if (seq starred)
(for [page starred]
(let [encoded-page (util/url-encode page)]
(let [encoded-page (util/encode-str page)]
[:a.mt-1.group.flex.items-center.pl-5.py-2.text-base.leading-6.hover:text-gray-200.transition.ease-in-out.duration-150.star-page
{:key encoded-page
:class (if (page-active? encoded-page) "text-gray-200" "text-gray-500")
@ -224,10 +224,10 @@
[:div.h-7.w-7.rounded-full.bg-base-3])])
(let [logged? (:name me)]
(->>
[(when logged?
[(when current-repo
{:title "New page"
:options {:href "/new-page"}})
(when logged?
(when current-repo
{:title "Graph"
:options {:href "/graph"}})
(when logged?
@ -239,8 +239,9 @@
(when logged?
{:title "All files"
:options {:href "/all-files"}})
(when current-repo
{:title "Settings"
:options {:href (str "/file/" (util/url-encode config/config-file))}}
:options {:href (str "/file/" (util/encode-str config/config-file))}})
{:title "Bug report"
:options {:href "https://github.com/logseq/logseq/issues/new"
:target "_blank"}}

View File

@ -40,10 +40,10 @@
[:h1.title
"Set Github personal access token"]
[:div.pl-1
[:p.text-sm
[:p
"The token will be encrypted and stored in the browser localstorage."
[:br]
"The server will never try to store or read it."]
"The server will never store it."]
[:div.mt-4.mb-4.relative.rounded-md.shadow-sm.max-w-xs
[:input#repo.form-input.block.w-full.sm:text-sm.sm:leading-5
{:on-change (fn [e]
@ -145,7 +145,7 @@
[:div
[:h1.title.mb-1
"Import your notes"]
[:p.text-sm.text-gray-500.pl-1 "You can import your notes from a repo on Github."]
[:p "You can import your notes from a repo on Github."]
[:div.mt-4.mb-2.relative.rounded-md.shadow-sm.max-w-xs
[:input#repo.form-input.block.w-full.sm:text-sm.sm:leading-5
{:autoFocus true

View File

@ -829,11 +829,11 @@
(defn create-new-page!
[title]
(let [format (name (state/get-preferred-format))
page (util/url-encode title)
path (str (-> title
page (-> title
(string/lower-case)
(string/replace #"\s+" "_")
(util/url-encode)) "." format)
(string/replace #"\s+" "_"))
page (util/encode-str page)
path (str page "." format)
file-path (str "/" path)
repo (state/get-current-repo)
dir (util/get-repo-dir repo)]
@ -936,7 +936,7 @@
(let [format (name format)
path (str (-> (:page/name page)
(string/replace #"\s+" "_")
(util/url-encode)) "." format)
(util/encode-str)) "." format)
file-path (str "/" path)
dir (util/get-repo-dir repo)]
(p/let [exists? (fs/file-exists? dir file-path)]
@ -1002,7 +1002,7 @@
(let [format (name format)
path (str (-> (:page/name page)
(string/replace #"\s+" "_")
(util/url-encode)) "." format)
(util/encode-str)) "." format)
file-path (str "/" path)
dir (util/get-repo-dir repo)]
(p/let [exists? (fs/file-exists? dir file-path)]

View File

@ -669,10 +669,11 @@
[tag-name]
(re-find regex/valid-tag-pattern tag-name))
;; TODO: emoji, unicode alphanum, spaces, _, -
;; (defn page-title-valid?
;; [page-title]
;; )
(defn encode-str
[s]
(if (tag-valid? s)
s
(url-encode s)))
(defn- get-clipboard-as-html
[event]