Skip to content

Commit

Permalink
Merge pull request #30 from TopixIM/refine-filekey
Browse files Browse the repository at this point in the history
refine file key for better download experience
  • Loading branch information
NoEgAm committed Oct 27, 2023
2 parents 0468e01 + 0f35f1f commit ea42b35
Show file tree
Hide file tree
Showing 5 changed files with 140 additions and 96 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/upload.yaml
Expand Up @@ -19,15 +19,15 @@ jobs:

- uses: supplypike/setup-bin@v3
with:
uri: 'https://github.com/calcit-lang/calcit/releases/download/0.8.3/cr'
uri: 'https://github.com/calcit-lang/calcit/releases/download/0.8.9/cr'
name: 'cr'
version: '0.8.3'
version: '0.8.9'

- uses: supplypike/setup-bin@v3
with:
uri: 'https://github.com/calcit-lang/calcit/releases/download/0.8.3/caps'
uri: 'https://github.com/calcit-lang/calcit/releases/download/0.8.9/caps'
name: 'caps'
version: '0.8.3'
version: '0.8.9'

- run: caps --ci && cr --entry server --emit-ir -1

Expand Down
52 changes: 44 additions & 8 deletions calcit.cirru

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 10 additions & 2 deletions compact.cirru
Expand Up @@ -59,7 +59,7 @@
read-from-clipboard!
|mount-target $ %{} :CodeEntry (:doc |)
:code $ quote
def mount-target $ .querySelector js/document |.app
def mount-target $ js/document.querySelector |.app
|on-server-data $ %{} :CodeEntry (:doc |)
:code $ quote
defn on-server-data (data)
Expand Down Expand Up @@ -687,6 +687,14 @@
<> $ str "\"uploading: "
.round $ * 100 up
, "\"%"
|decorate-name $ %{} :CodeEntry (:doc "|`paste` event uses default name `image.png` as the file name, need to overwrite that.\n\nalso spaces in filekey causes problems of inline CSS, need to replace that.")
:code $ quote
defn decorate-name (img-name)
if (= "\"image.png" img-name)
str "\"pasted-"
.!toISOString $ new js/Date
, "\".png"
.replace img-name "\" " "\"-"
|style-hidden-input $ %{} :CodeEntry (:doc |)
:code $ quote
defstyle style-hidden-input $ {}
Expand All @@ -697,7 +705,7 @@
let
hash $ js-await (load-md5 file)
file-key $ str hash "\"/"
either (.-name file) "\"clipboard.jpg"
decorate-name $ either (.-name file) "\"clipboard.jpg"
res $ js-await
.!post axios "\"https://cp.topix.im/token"
format-cirru-edn $ {}
Expand Down
4 changes: 2 additions & 2 deletions package.json
Expand Up @@ -15,7 +15,7 @@
"author": "jiyinyiyong",
"license": "MIT",
"dependencies": {
"@calcit/procs": "^0.8.3",
"@calcit/procs": "^0.8.9",
"axios": "^1.5.1",
"mime": "^3.0.0",
"shortid": "^2.2.16"
Expand All @@ -26,6 +26,6 @@
"feather-icons": "^4.29.1",
"spark-md5": "^3.0.2",
"url-parse": "^1.5.10",
"vite": "^4.4.9"
"vite": "^4.5.0"
}
}

0 comments on commit ea42b35

Please sign in to comment.