Commit 18bb86b1a55882ca6a6a329be0ca8151b82140b5

Authored by Georg Hopp
1 parent 262bf239

Some improvements to build

1   -.PHONY: start wasm build run clean
2   -
3 1 PROFILE ?= dev
4 2 ifeq "$(PROFILE)" "release"
5 3 CARGO_PROFILE = --release
6 4 WASM_PROFILE = --release
7 5 WASM_EXTRA = --no-default-features --features wee_alloc
  6 +SERVER_TARGET = target/release/artshop-server
  7 +WASM_TARGET = ui/target/wasm32-unknown-unknown/release/artshop_frontend.wasm
8 8 else
9 9 CARGO_PROFILE =
10 10 WASM_PROFILE = --dev
11 11 WASM_EXTRA =
  12 +SERVER_TARGET = target/debug/artshop-server
  13 +WASM_TARGET = ui/target/wasm32-unknown-unknown/debug/artshop_frontend.wasm
12 14 endif
13 15
  16 +SERVER_SOURCES = common/Cargo.toml \
  17 + server/Cargo.toml \
  18 + $(shell find common -name "*.rs") \
  19 + $(shell find server -name "*.rs")
  20 +WASM_DEPLOY = static/ui/artshop_frontend_bg.wasm
  21 +WASM_SOURCES = common/Cargo.toml \
  22 + ui/Cargo.toml \
  23 + $(shell find common -name "*.rs") \
  24 + $(shell find ui -name "*.rs")
  25 +
14 26 define msg
  27 + @printf "\033[38;5;197m%s\033[0m" "$(1)"
  28 +endef
  29 +
  30 +define msgnl
15 31 @printf "\033[38;5;197m%s\033[0m\n" "$(1)"
16 32 endef
17 33
  34 +.PHONY: start run wasm build clean release
  35 +
18 36 start:
19   - systemfd --no-pid -s 0.0.0.0:3000 -- \
20   - cargo watch -i static/ -i var/ -s "PROFILE=$(PROFILE) make run"
  37 + $(call msgnl,NOTIFY REBUILD RUN)
  38 + @systemfd --no-pid -s 0.0.0.0:3000 -- \
  39 + cargo watch -i static/ -i var/ \
  40 + -s "PROFILE=$(PROFILE) make run"
  41 +
  42 +run: build wasm
  43 + $(call msgnl,RUN SERVER)
  44 + @PROFILE=$(PROFILE) cargo run $(CARGO_PROFILE) --bin artshop-server
  45 +
  46 +wasm: $(WASM_DEPLOY)
  47 +
  48 +build: $(SERVER_TARGET)
  49 +
  50 +clean:
  51 + $(call msgnl,CLEAN WORKSPACE)
  52 + @PROFILE=$(PROFILE) cargo clean
  53 + $(call msgnl,CLEAN INSTALLED WASM)
  54 + @rm -Rf ./static/ui
  55 + $(call msgnl,CLEAN INSTALLED WASM)
  56 + @pushd ui; PROFILE=$(PROFILE) cargo clean; popd
  57 +
  58 +$(WASM_TARGET): $(WASM_SOURCES)
  59 + $(call msgnl,BUILD WASM UI)
  60 + @PROFILE=$(PROFILE) wasm-pack build $(WASM_PROFILE) -d ../static/ui \
  61 + -t web --mode no-install ./ui -- $(WASM_EXTRA)
21 62
22   -wasm:
23   - $(call msg,BUILD WASM UI)
  63 +$(WASM_DEPLOY): $(WASM_TARGET)
  64 + $(call msgnl,INSTALL WASM UI)
24 65 @PROFILE=$(PROFILE) wasm-pack build $(WASM_PROFILE) -d ../static/ui \
25 66 -t web ./ui -- $(WASM_EXTRA)
26 67
27   -build:
28   - $(call msg,PATCH DIFFY)
29   - @cargo patch
30   - $(call msg,BUILD SERVER)
  68 +$(SERVER_TARGET): $(SERVER_SOURCES)
  69 + $(call msgnl,PATCH DIFFY)
  70 + @PROFILE=$(PROFILE) cargo patch
  71 + $(call msgnl,BUILD SERVER)
31 72 @PROFILE=$(PROFILE) cargo build $(CARGO_PROFILE) --bin artshop-server
32 73
33   -run: build wasm
34   - $(call msg,RUN SERVER)
35   - @PROFILE=$(PROFILE) cargo run $(CARGO_PROFILE) --bin artshop-server
36   -
37 74 release:
38 75 docker build -t artshop -f build/Dockerfile .
39 76
  77 +.PHONY: createdb devdb downdb enterdb rootdb
  78 +
  79 +createdb: downdb devdb
  80 + $(call msg,TRY TO CONNECT TO DB )
  81 + @while true;\
  82 + do\
  83 + echo "SELECT VERSION();"|\
  84 + docker exec -i mariadb-dev \
  85 + mysql -p123456 >/dev/null 2>&1 && break;\
  86 + echo -n ".";\
  87 + sleep 3;\
  88 + done; echo
  89 + $(call msgnl,INITIALIZE APPLICATION DB)
  90 + echo "CREATE DATABASE artshop CHARACTER SET = 'utf8mb3' \
  91 + COLLATE = 'utf8mb3_general_ci'; \
  92 + GRANT ALL PRIVILEGES ON artshop.* TO 'artshop'@'%'"|\
  93 + docker exec -i mariadb-dev mysql -p123456
  94 + $(call msgnl,RUN MIGRATIONS)
  95 + @diesel migration run
  96 +
  97 +downdb:
  98 + $(call msgnl,STOP DB CONTAINER)
  99 + @docker stop mariadb-dev||true
  100 + $(call msgnl,REMOVE DB CONTAINER)
  101 + @docker rm -v mariadb-dev||true
  102 +
40 103 devdb:
41   - docker network create mariadb-dev-network
42   - docker run --detach --network mariadb-dev-network --name mariadb-dev \
  104 + $(call msgnl,CREATE DB CONTAINER)
  105 + @docker run --detach --name mariadb-dev \
43 106 -p 3306:3306 \
44 107 --env MARIADB_USER=artshop \
45 108 --env MARIADB_PASSWORD=123456 \
46 109 --env MARIADB_ROOT_PASSWORD=123456 mariadb:latest
47 110
48 111 enterdb:
49   - docker exec -it mariadb-dev mysql -D artshop -u artshop -p
  112 + docker exec -it mariadb-dev mysql -D artshop -u artshop -p123456||true
50 113 # docker run -it --network mariadb-dev-network --rm mariadb:latest \
51 114 # mysql -h mariadb-dev -u artshop -p
52 115
53 116 rootdb:
54   - docker exec -it mariadb-dev mysql -p
55   -
56   -clean:
57   - cargo clean
58   - rm -Rf ./static/ui
  117 + docker exec -it mariadb-dev mysql -p123456||true
... ...
... ... @@ -102,7 +102,7 @@ erstellen. Theoretisch könnte für solche Böcke dann Syntax-Highliting eingeba
102 102 ```shell
103 103 #!/bin/env sh
104 104
105   -FOO="foo"
  105 +FOO=\"foo\"
106 106
107 107 function func() {
108 108 local BAR=bar
... ... @@ -193,6 +193,6 @@ wie hier.</pre>
193 193 </ul>
194 194
195 195 [lnk1]: https://heise.de/tp/ 'Telepolis'
196   -[lnk2]: https://arkdown.land/markdown-table 'markdown.land' "
  196 +[lnk2]: https://arkdown.land/markdown-table 'markdown.land'"
197 197 , '2022-01-29 21:33:34.000'
198 198 , '2022-01-29 21:33:34.000' );
... ...
... ... @@ -91,6 +91,8 @@ macro_rules! upload_filename {
91 91
92 92
93 93 impl Image {
  94 + // TODO some handling for files that are not processed now
  95 + // that is uuid is still None.
94 96 pub(crate) fn path(&self, size :Size) -> String {
95 97 let uuid = Uuid::try_from( self.uuid
96 98 . as_ref()
... ...
... ... @@ -62,6 +62,12 @@
62 62 background: #f7f7f7;
63 63 }
64 64
  65 +.markdown img {
  66 + display: block;
  67 + margin-left: auto;
  68 + margin-right: auto;
  69 +}
  70 +
65 71 .markdown p {
66 72 text-align: justify;
67 73 text-indent: .5em;
... ...
... ... @@ -27,7 +27,7 @@ pub(super) async fn markdown_logic( mut rx_logic: broadcast::Receiver<MarkdownLo
27 27 MarkdownLogic::Store => {
28 28 let new_md = state.get_md();
29 29 if md.json.content != new_md {
30   - md.json.content = state.get_md();
  30 + md.json.content = new_md;
31 31 md.save().await.unwrap();
32 32 }
33 33 },
... ...
Please register or login to post a comment