From 87325927ed82672c17638befec9cc21be0344793 Mon Sep 17 00:00:00 2001 From: Your Name Date: Wed, 15 Oct 2025 15:31:44 -0400 Subject: [PATCH] v0.7.18 - Fixed duplicate login modal bug and improved header layout --- Dockerfile.alpine-musl | 14 +- Makefile | 27 +- api/embedded.html | 58 + api/index.css | 245 +- api/index.html | 50 +- api/index.js | 6749 ++++++++++++----------- c_utils_lib | 2 +- docs/c_utils_lib_architecture.md | 457 ++ docs/c_utils_lib_implementation_plan.md | 621 +++ relay.pid | 2 +- src/debug.c | 51 - src/debug.h | 43 - src/embedded_web_content.c | 18 +- tests/test_results_20251011_134617.log | 18 - tests/test_results_20251011_134807.log | 629 --- tests/test_results_20251011_141134.log | 728 --- 16 files changed, 4965 insertions(+), 4747 deletions(-) create mode 100644 api/embedded.html create mode 100644 docs/c_utils_lib_architecture.md create mode 100644 docs/c_utils_lib_implementation_plan.md delete mode 100644 src/debug.c delete mode 100644 src/debug.h delete mode 100644 tests/test_results_20251011_134617.log delete mode 100644 tests/test_results_20251011_134807.log delete mode 100644 tests/test_results_20251011_141134.log diff --git a/Dockerfile.alpine-musl b/Dockerfile.alpine-musl index 541b14a..41cc71c 100644 --- a/Dockerfile.alpine-musl +++ b/Dockerfile.alpine-musl @@ -76,6 +76,15 @@ RUN git submodule update --init --recursive # Copy nostr_core_lib source files (cached unless nostr_core_lib changes) COPY nostr_core_lib /build/nostr_core_lib/ +# Copy c_utils_lib source files (cached unless c_utils_lib changes) +COPY c_utils_lib /build/c_utils_lib/ + +# Build c_utils_lib with MUSL-compatible flags (cached unless c_utils_lib changes) +RUN cd c_utils_lib && \ + sed -i 's/CFLAGS = -Wall -Wextra -std=c99 -O2 -g/CFLAGS = -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=0 -Wall -Wextra -std=c99 -O2 -g/' Makefile && \ + make clean && \ + make + # Build nostr_core_lib with required NIPs (cached unless nostr_core_lib changes) # Disable fortification in build.sh to prevent __*_chk symbol issues # NIPs: 001(Basic), 006(Keys), 013(PoW), 017(DMs), 019(Bech32), 044(Encryption), 059(Gift Wrap - required by NIP-17) @@ -93,12 +102,13 @@ COPY Makefile /build/Makefile # Disable fortification to avoid __*_chk symbols that don't exist in MUSL RUN gcc -static -g -O0 -DDEBUG -Wall -Wextra -std=c99 \ -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=0 \ - -I. -Inostr_core_lib -Inostr_core_lib/nostr_core \ + -I. -Ic_utils_lib/src -Inostr_core_lib -Inostr_core_lib/nostr_core \ -Inostr_core_lib/cjson -Inostr_core_lib/nostr_websocket \ - src/main.c src/config.c src/debug.c src/dm_admin.c src/request_validator.c \ + src/main.c src/config.c src/dm_admin.c src/request_validator.c \ src/nip009.c src/nip011.c src/nip013.c src/nip040.c src/nip042.c \ src/websockets.c src/subscriptions.c src/api.c src/embedded_web_content.c \ -o /build/c_relay_static \ + c_utils_lib/libc_utils.a \ nostr_core_lib/libnostr_core_x64.a \ -lwebsockets -lssl -lcrypto -lsqlite3 -lsecp256k1 \ -lcurl -lz -lpthread -lm -ldl diff --git a/Makefile b/Makefile index 0bac194..cc2be5f 100644 --- a/Makefile +++ b/Makefile @@ -2,15 +2,16 @@ CC = gcc CFLAGS = -Wall -Wextra -std=c99 -g -O2 -INCLUDES = -I. -Inostr_core_lib -Inostr_core_lib/nostr_core -Inostr_core_lib/cjson -Inostr_core_lib/nostr_websocket -LIBS = -lsqlite3 -lwebsockets -lz -ldl -lpthread -lm -L/usr/local/lib -lsecp256k1 -lssl -lcrypto -L/usr/local/lib -lcurl +INCLUDES = -I. -Ic_utils_lib/src -Inostr_core_lib -Inostr_core_lib/nostr_core -Inostr_core_lib/cjson -Inostr_core_lib/nostr_websocket +LIBS = -lsqlite3 -lwebsockets -lz -ldl -lpthread -lm -L/usr/local/lib -lsecp256k1 -lssl -lcrypto -L/usr/local/lib -lcurl -Lc_utils_lib -lc_utils # Build directory BUILD_DIR = build # Source files -MAIN_SRC = src/main.c src/config.c src/debug.c src/dm_admin.c src/request_validator.c src/nip009.c src/nip011.c src/nip013.c src/nip040.c src/nip042.c src/websockets.c src/subscriptions.c src/api.c src/embedded_web_content.c +MAIN_SRC = src/main.c src/config.c src/dm_admin.c src/request_validator.c src/nip009.c src/nip011.c src/nip013.c src/nip040.c src/nip042.c src/websockets.c src/subscriptions.c src/api.c src/embedded_web_content.c NOSTR_CORE_LIB = nostr_core_lib/libnostr_core_x64.a +C_UTILS_LIB = c_utils_lib/libc_utils.a # Architecture detection ARCH = $(shell uname -m) @@ -38,6 +39,11 @@ $(NOSTR_CORE_LIB): @echo "Building nostr_core_lib with required NIPs (including NIP-44 for encryption)..." cd nostr_core_lib && ./build.sh --nips=1,6,13,17,19,44,59 +# Check if c_utils_lib is built +$(C_UTILS_LIB): + @echo "Building c_utils_lib..." + cd c_utils_lib && ./build.sh lib + # Update main.h version information (requires main.h to exist) src/main.h: @if [ ! -f src/main.h ]; then \ @@ -75,18 +81,18 @@ force-version: @$(MAKE) src/main.h # Build the relay -$(TARGET): $(BUILD_DIR) src/main.h src/sql_schema.h $(MAIN_SRC) $(NOSTR_CORE_LIB) +$(TARGET): $(BUILD_DIR) src/main.h src/sql_schema.h $(MAIN_SRC) $(NOSTR_CORE_LIB) $(C_UTILS_LIB) @echo "Compiling C-Relay for architecture: $(ARCH)" - $(CC) $(CFLAGS) $(INCLUDES) $(MAIN_SRC) -o $(TARGET) $(NOSTR_CORE_LIB) $(LIBS) + $(CC) $(CFLAGS) $(INCLUDES) $(MAIN_SRC) -o $(TARGET) $(NOSTR_CORE_LIB) $(C_UTILS_LIB) $(LIBS) @echo "Build complete: $(TARGET)" # Build for specific architectures -x86: $(BUILD_DIR) src/main.h src/sql_schema.h $(MAIN_SRC) $(NOSTR_CORE_LIB) +x86: $(BUILD_DIR) src/main.h src/sql_schema.h $(MAIN_SRC) $(NOSTR_CORE_LIB) $(C_UTILS_LIB) @echo "Building C-Relay for x86_64..." - $(CC) $(CFLAGS) $(INCLUDES) $(MAIN_SRC) -o $(BUILD_DIR)/c_relay_x86 $(NOSTR_CORE_LIB) $(LIBS) + $(CC) $(CFLAGS) $(INCLUDES) $(MAIN_SRC) -o $(BUILD_DIR)/c_relay_x86 $(NOSTR_CORE_LIB) $(C_UTILS_LIB) $(LIBS) @echo "Build complete: $(BUILD_DIR)/c_relay_x86" -arm64: $(BUILD_DIR) src/main.h src/sql_schema.h $(MAIN_SRC) $(NOSTR_CORE_LIB) +arm64: $(BUILD_DIR) src/main.h src/sql_schema.h $(MAIN_SRC) $(NOSTR_CORE_LIB) $(C_UTILS_LIB) @echo "Cross-compiling C-Relay for ARM64..." @if ! command -v aarch64-linux-gnu-gcc >/dev/null 2>&1; then \ echo "ERROR: ARM64 cross-compiler not found."; \ @@ -110,7 +116,7 @@ arm64: $(BUILD_DIR) src/main.h src/sql_schema.h $(MAIN_SRC) $(NOSTR_CORE_LIB) fi @echo "Using aarch64-linux-gnu-gcc with ARM64 libraries..." PKG_CONFIG_PATH=/usr/lib/aarch64-linux-gnu/pkgconfig:/usr/share/pkgconfig \ - aarch64-linux-gnu-gcc $(CFLAGS) $(INCLUDES) $(MAIN_SRC) -o $(BUILD_DIR)/c_relay_arm64 $(NOSTR_CORE_LIB) \ + aarch64-linux-gnu-gcc $(CFLAGS) $(INCLUDES) $(MAIN_SRC) -o $(BUILD_DIR)/c_relay_arm64 $(NOSTR_CORE_LIB) $(C_UTILS_LIB) \ -L/usr/lib/aarch64-linux-gnu $(LIBS) @echo "Build complete: $(BUILD_DIR)/c_relay_arm64" @@ -161,9 +167,10 @@ clean: rm -rf $(BUILD_DIR) @echo "Clean complete" -# Clean everything including nostr_core_lib +# Clean everything including nostr_core_lib and c_utils_lib clean-all: clean cd nostr_core_lib && make clean 2>/dev/null || true + cd c_utils_lib && make clean 2>/dev/null || true # Install dependencies (Ubuntu/Debian) install-deps: diff --git a/api/embedded.html b/api/embedded.html new file mode 100644 index 0000000..7e7c47f --- /dev/null +++ b/api/embedded.html @@ -0,0 +1,58 @@ + + + + + + Embedded NOSTR_LOGIN_LITE + + + +
+
+
+ + + + + + + \ No newline at end of file diff --git a/api/index.css b/api/index.css index 56d0c10..08ea8e1 100644 --- a/api/index.css +++ b/api/index.css @@ -33,11 +33,142 @@ body { background-color: var(--secondary-color); color: var(--primary-color); /* line-height: 1.4; */ - padding: 20px; + padding: 0; + max-width: none; + margin: 0; +} + +/* Header Styles */ +.main-header { + background-color: var(--secondary-color); + border-bottom: var(--border-width) solid var(--border-color); + padding: 15px 20px; + position: sticky; + top: 0; + z-index: 100; max-width: 1200px; margin: 0 auto; } +.header-content { + display: flex; + justify-content: space-between; + align-items: center; + position: relative; +} + +.header-title { + margin: 0; + font-size: 24px; + font-weight: normal; + color: var(--primary-color); + border: none; + padding: 0; + text-align: left; +} + +.header-user-name { + display: block; + font-weight: 500; + color: var(--primary-color); + font-size: 10px; + text-align: center; + margin-top: 4px; +} + +.profile-area { + display: flex; + align-items: center; + position: relative; + cursor: pointer; + padding: 8px 12px; + border-radius: var(--border-radius); + transition: background-color 0.2s ease; + margin-left: auto; +} + +.profile-container { + display: flex; + flex-direction: column; + align-items: center; + gap: 4px; +} + +.profile-area:hover { + background-color: rgba(0, 0, 0, 0.05); +} + +.profile-info { + display: flex; + align-items: center; + gap: 10px; +} + +.header-user-image { + width: 48px; /* 50% larger than 32px */ + height: 48px; /* 50% larger than 32px */ + border-radius: var(--border-radius); /* Curved corners like other elements */ + object-fit: cover; + border: 2px solid transparent; /* Invisible border */ + background-color: var(--secondary-color); +} + + +.logout-dropdown { + position: absolute; + top: 100%; + right: 0; + background-color: var(--secondary-color); + border: var(--border-width) solid var(--border-color); + border-radius: var(--border-radius); + box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15); + min-width: 120px; + z-index: 200; + margin-top: 4px; +} + +.logout-btn { + width: 100%; + padding: 10px 15px; + background: none; + border: none; + color: var(--primary-color); + text-align: left; + cursor: pointer; + font-size: 14px; + font-family: var(--font-family); + border-radius: var(--border-radius); + transition: background-color 0.2s ease; +} + +.logout-btn:hover { + background-color: rgba(0, 0, 0, 0.1); +} + +/* Login Modal Styles */ +.login-modal-overlay { + position: fixed; + top: 0; + left: 0; + width: 100%; + height: 100%; + background-color: rgba(0, 0, 0, 0.8); + display: flex; + justify-content: center; + align-items: center; + z-index: 1000; +} + +.login-modal-content { + background-color: var(--secondary-color); + border: var(--border-width) solid var(--border-color); + border-radius: var(--border-radius); + padding: 30px; + max-width: 400px; + width: 90%; + box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3); +} + h1 { border-bottom: var(--border-width) solid var(--border-color); padding-bottom: 10px; @@ -130,6 +261,40 @@ button:disabled { border-color: #ccc; } +/* Flash animation for refresh button */ +@keyframes flash-red { + 0% { border-color: var(--border-color); } + 50% { border-color: var(--accent-color); } + 100% { border-color: var(--border-color); } +} + +.flash-red { + animation: flash-red 0.5s ease-in-out; +} + +/* Flash animation for updated statistics values */ +@keyframes flash-value { + 0% { color: var(--primary-color); } + 50% { color: var(--accent-color); } + 100% { color: var(--primary-color); } +} + +.flash-value { + animation: flash-value 0.5s ease-in-out; +} + +/* Npub links styling */ +.npub-link { + color: var(--primary-color); + text-decoration: none; + font-weight: normal; + transition: color 0.2s ease; +} + +.npub-link:hover { + color: var(--accent-color); +} + .status { padding: 10px; margin: 10px 0; @@ -286,12 +451,21 @@ button:disabled { .user-info-container { display: flex; - align-items: flex-start; - gap: 20px; + flex-direction: column; + gap: 15px; } .user-details { - flex: 1; + order: -1; /* Show user details first when logged in */ +} + +.login-section { + text-align: center; +} + +.logout-section { + display: flex; + justify-content: flex-end; } .login-logout-btn { @@ -338,6 +512,31 @@ button:disabled { margin: 5px 0; } +/* User profile header with image */ +.user-profile-header { + display: flex; + align-items: flex-start; + gap: 15px; +} + +.user-image-container { + flex-shrink: 0; +} + +.user-profile-image { + width: 60px; + height: 60px; + border-radius: var(--border-radius); + object-fit: cover; + border: 2px solid var(--border-color); + background-color: var(--bg-color); +} + +.user-text-info { + flex: 1; + min-width: 0; /* Allow text to wrap */ +} + .hidden { display: none; } @@ -351,6 +550,40 @@ button:disabled { padding-bottom: 10px; } +.countdown-btn { + width: auto; + min-width: 40px; + padding: 8px 12px; + background: var(--secondary-color); + color: var(--primary-color); + border: var(--border-width) solid var(--border-color); + border-radius: var(--border-radius); + font-family: var(--font-family); + font-size: 10px; + /* font-weight: bold; */ + cursor: pointer; + transition: all 0.2s ease; + margin-left: auto; + position: relative; +} + +.countdown-btn:hover::after { + content: "countdown"; + position: absolute; + top: -30px; + left: 50%; + transform: translateX(-50%); + background: var(--primary-color); + color: var(--secondary-color); + padding: 4px 8px; + border-radius: 4px; + font-size: 12px; + font-weight: normal; + white-space: nowrap; + z-index: 1000; + border: 1px solid var(--border-color); +} + .auth-rules-controls { margin-bottom: 15px; } @@ -464,10 +697,12 @@ button:disabled { /* Main Sections Wrapper */ .main-sections-wrapper { + max-width: 1200px; + margin: 0 auto; + padding: 20px; display: flex; flex-wrap: wrap; gap: var(--border-width); - margin-bottom: 20px; } .flex-section { diff --git a/api/index.html b/api/index.html index 681792c..35b9310 100644 --- a/api/index.html +++ b/api/index.html @@ -4,38 +4,37 @@ - C-Relay Admin API + C-Relay Admin -

C-RELAY ADMIN API

- - -
- - -
-