diff --git a/.git-blame-ignore-revs b/.git-blame-ignore-revs
new file mode 100644
index 00000000..76090127
--- /dev/null
+++ b/.git-blame-ignore-revs
@@ -0,0 +1,2 @@
+# Add prettier to the project
+41024ddb7961b04a5688bbc997cb74de6fab4763
\ No newline at end of file
diff --git a/.gitignore b/.gitignore
index 55365e2e..4dd27d0b 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,8 +1,10 @@
-**/node_modules
-.keys
-.zsign_cache/
db.*
deps/ios_toolchain/
deps/openssl/
dist/
+.keys
+**/node_modules
out
+*.swo
+*.swp
+.zsign_cache/
diff --git a/.prettierignore b/.prettierignore
new file mode 100644
index 00000000..595b4cc1
--- /dev/null
+++ b/.prettierignore
@@ -0,0 +1,14 @@
+node_modules
+src
+deps
+.clang-format
+
+# Minified files
+**/*.min.css
+**/*.min.js
+**/leaflet.*
+**/commonmark*
+**/w3.css
+apps/ssb/tribute.esm.js
+apps/api/app.js
+**/emojis.json
diff --git a/.prettierrc.yaml b/.prettierrc.yaml
new file mode 100644
index 00000000..130ad1e2
--- /dev/null
+++ b/.prettierrc.yaml
@@ -0,0 +1,5 @@
+trailingComma: 'es5'
+useTabs: true
+semi: true
+singleQuote: true
+bracketSpacing: false
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
new file mode 100644
index 00000000..61923ce9
--- /dev/null
+++ b/CONTRIBUTING.md
@@ -0,0 +1,37 @@
+# Contributing to Tilde Friends
+
+Thank you for your interest in Tilde Friends.
+
+Above all, Tilde Friends aims to be a fun, safe place to play. When that is at
+odds with the course of development, we will work through it with respectful
+communication.
+
+## How can I contribute?
+
+The nature of Tilde Friends makes for a wide range of ways to contribute
+
+- Just use it. Really, just kicking the tires will probably shake out issues
+ in useful ways at this point.
+- Report and comment on bugs: https://dev.tildefriends.net/issues.
+- Make apps. You don't need my permission to make and share apps with Tilde
+ Friends. I hope that an ecosystem of good apps grows outside of this
+ repository. If you want to recreate better versions of the stock apps, just
+ do it. If you make a better ssb app or whatever and drop me a line however
+ is most convenient for you, I will probably take a look and consider
+ replacing the stock one with it.
+- Write about it. Docs in the git repository, blog posts, private messages to
+ me with ideas...really there is no wrong answer. Just make some noise, and
+ I'll do my best to incorporate or otherwise link your feedback and make the
+ most of it.
+- Write C code in the git repository. I'm really striving for it to be the
+ case that other people don't really need to meddle in there, but if you can
+ help out, I will gladly review your pull requests via
+ https://dev.tildefriends.net/pulls.
+
+## Best practices
+
+- The C code is formatted with clang-format. Run `make format`.
+- The rest is formatted with prettier. Run `npm run prettier`.
+- We strive to have code compile on all platforms with no warnings and run with
+ no sanitizer issues.
+- There are tests. Run `out/debug/tildefriends test`.
diff --git a/GNUmakefile b/GNUmakefile
index 0baa09f8..107aa0b0 100644
--- a/GNUmakefile
+++ b/GNUmakefile
@@ -3,9 +3,12 @@
MAKEFLAGS += --warn-undefined-variables
MAKEFLAGS += --no-builtin-rules
-VERSION_CODE := 16
-VERSION_NUMBER := 0.0.16-wip
-VERSION_NAME := Medium English breakfast tea.
+VERSION_CODE := 17
+VERSION_NUMBER := 0.0.17-wip
+VERSION_NAME := Please enjoy responsibly.
+
+SQLITE_URL := https://www.sqlite.org/2024/sqlite-amalgamation-3450200.zip
+LIBUV_URL := https://dist.libuv.org/dist/v1.48.0/libuv-v1.48.0.tar.gz
PROJECT = tildefriends
BUILD_DIR ?= out
@@ -14,6 +17,18 @@ UNAME_M := $(shell uname -m)
ANDROID_SDK ?= ~/Android/Sdk
+ifeq ($(UNAME_M),x86_64)
+ifneq ($(UNAME_S),Haiku)
+debug: CFLAGS += -fsanitize=address -fsanitize=undefined -fno-common
+debug: LDFLAGS += -fsanitize=address -fsanitize=undefined
+endif
+endif
+
+ifeq ($(UNAME_M),aarch64)
+debug: CFLAGS += -fsanitize=address -fsanitize=undefined -fno-common
+debug: LDFLAGS += -fsanitize=address -fsanitize=undefined
+endif
+
ifeq ($(UNAME_S),Darwin)
BUILD_TYPES := macosdebug macosrelease iosdebug iosrelease iossimdebug iossimrelease
else ifeq ($(UNAME_S),Linux)
@@ -55,7 +70,7 @@ CFLAGS += \
ANDROID_BUILD_TOOLS := $(ANDROID_SDK)/build-tools/34.0.0
ANDROID_PLATFORM := $(ANDROID_SDK)/platforms/android-34
-ANDROID_NDK ?= $(ANDROID_SDK)/ndk/26.1.10909125
+ANDROID_NDK ?= $(ANDROID_SDK)/ndk/26.2.11394342
ANDROID_MIN_SDK_VERSION := 24
ANDROID_TARGET_SDK_VERSION := 34
@@ -207,18 +222,6 @@ $(IOS_TARGETS): LDFLAGS += -Ldeps/openssl/ios/ios64-xcrun/usr/local/lib
$(IOSSIM_TARGETS): CFLAGS += -Ideps/openssl/ios/iossimulator-xcrun/usr/local/include
$(IOSSIM_TARGETS): LDFLAGS += -Ldeps/openssl/ios/iossimulator-xcrun/usr/local/lib
-ifeq ($(UNAME_M),x86_64)
-ifneq ($(UNAME_S),Haiku)
-debug: CFLAGS += -fsanitize=address -fsanitize=undefined -fno-common
-debug: LDFLAGS += -fsanitize=address -fsanitize=undefined
-endif
-endif
-
-ifeq ($(UNAME_M),aarch64)
-debug: CFLAGS += -fsanitize=address -fsanitize=undefined -fno-common
-debug: LDFLAGS += -fsanitize=address -fsanitize=undefined
-endif
-
get_objs = \
$(foreach build_type,$(BUILD_TYPES),$(addprefix $(BUILD_DIR)/$(build_type)/,$(addsuffix .o,$(basename $(value $(1)))))) \
$(foreach build_type,debug release,$(addprefix $(BUILD_DIR)/$(build_type)/,$(addsuffix .o,$(basename $(value $(1)_unix))))) \
@@ -245,7 +248,6 @@ $(APP_OBJS): CFLAGS += \
-Ideps/quickjs \
-Ideps/sqlite \
-Ideps/valgrind \
- -Ideps/xopt \
-Wdouble-promotion \
-Werror
ifeq ($(UNAME_M),x86_64)
@@ -497,18 +499,6 @@ $(SQLITE_OBJS): CFLAGS += \
-Wno-unused-function \
-Wno-unused-variable
-XOPT_SOURCES := deps/xopt/xopt.c
-XOPT_OBJS := $(call get_objs,XOPT_SOURCES)
-$(filter $(BUILD_DIR)/win%,$(XOPT_OBJS)): CFLAGS += \
- -DHAVE_SNPRINTF \
- -DHAVE_VSNPRINTF \
- -DHAVE_VASNPRINTF \
- -DHAVE_VASPRINTF \
- -Dvsnprintf=rpl_vsnprintf
-$(XOPT_OBJS): CFLAGS += \
- -Wno-implicit-const-int-float-conversion \
- -Wno-pointer-to-int-cast
-
QUICKJS_SOURCES := \
deps/quickjs/cutils.c \
deps/quickjs/libbf.c \
@@ -637,8 +627,7 @@ ALL_APP_OBJS := \
$(QUICKJS_OBJS) \
$(SODIUM_OBJS) \
$(SQLITE_OBJS) \
- $(UV_OBJS) \
- $(XOPT_OBJS)
+ $(UV_OBJS)
DEPS = $(ALL_APP_OBJS:.o=.d)
-include $(DEPS)
@@ -717,7 +706,7 @@ PACKAGE_DIRS := \
deps/prettier/ \
deps/lit/
-RAW_FILES := $(filter-out apps/blog% apps/gg% apps/issues% apps/welcome% apps/journal% %.map, $(shell find $(PACKAGE_DIRS) -type f))
+RAW_FILES := $(filter-out apps/blog% apps/issues% apps/welcome% apps/journal% %.map, $(shell find $(PACKAGE_DIRS) -type f))
out/apk/TildeFriends-arm-debug.unsigned.apk: BUILD_TYPE := debug
out/apk/TildeFriends-arm-release.unsigned.apk: BUILD_TYPE := release
@@ -736,10 +725,11 @@ out/apk/TildeFriends-arm-%.unsigned.apk:
@cp out/android$(BUILD_TYPE)-armv7a/tildefriends out/apk-arm-$(BUILD_TYPE)/lib/armeabi-v7a/tildefriends.so
@$(ANDROID_NDK)/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-strip out/apk-arm-$(BUILD_TYPE)/lib/arm64-v8a/tildefriends.so
@$(ANDROID_NDK)/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-strip out/apk-arm-$(BUILD_TYPE)/lib/armeabi-v7a/tildefriends.so
- @cp out/apk/res.apk $@
+ @cp out/apk/res.apk $@.zip
@cp out/apk/classes.dex out/apk-arm-$(BUILD_TYPE)/
- @cd out/apk-arm-$(BUILD_TYPE) && zip -u ../../$@ -q -9 -r . && cd ../../
- @zip -u $@ -q -9 $(RAW_FILES)
+ @cd out/apk-arm-$(BUILD_TYPE) && zip -u ../../$@.zip -q -9 -r . && cd ../../
+ @zip -u $@.zip -q $(RAW_FILES)
+ @$(ANDROID_BUILD_TOOLS)/zipalign -f 4 $@.zip $@
out/apk/TildeFriends-x86-%.unsigned.apk:
@mkdir -p $(dir $@) out/apk-x86-$(BUILD_TYPE)/lib/x86_64/ out/apk-x86-$(BUILD_TYPE)/lib/x86/
@@ -748,16 +738,22 @@ out/apk/TildeFriends-x86-%.unsigned.apk:
@cp out/android$(BUILD_TYPE)-x86/tildefriends out/apk-x86-$(BUILD_TYPE)/lib/x86/tildefriends.so
@$(ANDROID_NDK)/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-strip out/apk-x86-$(BUILD_TYPE)/lib/x86_64/tildefriends.so
@$(ANDROID_NDK)/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-strip out/apk-x86-$(BUILD_TYPE)/lib/x86/tildefriends.so
- @cp out/apk/res.apk $@
+ @cp out/apk/res.apk $@.zip
@cp out/apk/classes.dex out/apk-x86-$(BUILD_TYPE)/
- @cd out/apk-x86-$(BUILD_TYPE) && zip -u ../../$@ -q -9 -r . && cd ../../
- @zip -u $@ -q -9 $(RAW_FILES)
+ @cd out/apk-x86-$(BUILD_TYPE) && zip -u ../../$@.zip -q -9 -r . && cd ../../
+ @zip -u $@.zip -q $(RAW_FILES)
+ @$(ANDROID_BUILD_TOOLS)/zipalign -f 4 $@.zip $@
out/%.apk: out/apk/%.unsigned.apk
@echo "[apksigner] $(notdir $@)"
- @$(ANDROID_BUILD_TOOLS)/apksigner sign --ks .keys/android.jks --ks-key-alias androidKey --ks-pass pass:android --key-pass pass:android --out $@ $<
+ @$(ANDROID_BUILD_TOOLS)/apksigner sign --ks .keys/android.jks --ks-key-alias androidKey --ks-pass pass:android --key-pass pass:android --min-sdk-version $(ANDROID_MIN_SDK_VERSION) --out $@ $<
-release-apk: out/TildeFriends-arm-release.apk out/TildeFriends-x86-release.apk
+out/%.zopfli.apk: out/%.apk
+ @echo "[zopfli] $(notdir $@)"
+ $(ANDROID_BUILD_TOOLS)/zipalign -f -z 4 $< $@.zopfli
+ @$(ANDROID_BUILD_TOOLS)/apksigner sign --ks .keys/android.jks --ks-key-alias androidKey --ks-pass pass:android --key-pass pass:android --min-sdk-version $(ANDROID_MIN_SDK_VERSION) --out $@ $@.zopfli
+
+release-apk: out/TildeFriends-arm-release.zopfli.apk out/TildeFriends-x86-release.zopfli.apk
.PHONY: release-apk
releaseapkgo: out/TildeFriends-arm-release.apk
@@ -814,11 +810,13 @@ apklog:
fetchdeps:
@echo "[fetch] libuv"
- @test -f out/deps/libuv.tar.gz || (mkdir -p out/deps/ && curl -q https://dist.libuv.org/dist/v1.48.0/libuv-v1.48.0.tar.gz -o out/deps/libuv.tar.gz)
- @test -d deps/libuv/ || (mkdir -p deps/libuv/ && tar -C deps/libuv/ -m --strip=1 -xf out/deps/libuv.tar.gz)
+ @test -f out/deps/libuv.tar.gz && test "$$(cat out/deps/libuv.txt 2>/dev/null)" = $(LIBUV_URL) || (mkdir -p out/deps/ && curl -q $(LIBUV_URL) -o out/deps/libuv.tar.gz)
+ @test -d deps/libuv/ && test "$$(cat out/deps/libuv.txt 2>/dev/null)" = $(LIBUV_URL) || (rm -rf deps/libuv/ && mkdir -p deps/libuv/ && tar -C deps/libuv/ -m --strip=1 -xf out/deps/libuv.tar.gz)
+ @echo -n $(LIBUV_URL) > out/deps/libuv.txt
@echo "[fetch] sqlite"
- @test -f out/deps/sqlite.zip || (mkdir -p out/deps/ && curl -q https://www.sqlite.org/2024/sqlite-amalgamation-3450100.zip -o out/deps/sqlite.zip)
- @test -d deps/sqlite/ || (mkdir -p deps/sqlite/ && unzip -qDj -d deps/sqlite/ out/deps/sqlite.zip)
+ @test -f out/deps/sqlite.zip && test "$$(cat out/deps/sqlite.txt 2>/dev/null)" = $(SQLITE_URL) || (mkdir -p out/deps/ && curl -q $(SQLITE_URL) -o out/deps/sqlite.zip)
+ @test -d deps/sqlite/ && test "$$(cat out/deps/sqlite.txt 2>/dev/null)" = $(SQLITE_URL) || (mkdir -p deps/sqlite/ && unzip -qDjo -d deps/sqlite/ out/deps/sqlite.zip)
+ @echo -n $(SQLITE_URL) > out/deps/sqlite.txt
@echo "[fetch] prettier"
@test -f deps/prettier/standalone.mjs || curl -q --create-dirs -O --output-dir deps/prettier/ https://cdn.jsdelivr.net/npm/prettier@3.2.5/standalone.mjs
@test -f deps/prettier/html.mjs || curl -q --create-dirs -O --output-dir deps/prettier/ https://cdn.jsdelivr.net/npm/prettier@3.2.5/plugins/html.mjs
@@ -839,7 +837,7 @@ $(filter $(BUILD_DIR)/win%,$(APP_OBJS)): | $(WINDOWS_DEPS)
endif
ifeq ($(UNAME_S),Darwin)
-IOS_DEPS := deps/openssl/ios/usr/local/lib/libssl.a
+IOS_DEPS := deps/openssl/ios/ios64-xcrun/usr/local/lib/libssl.a
$(IOS_DEPS):
+@tools/ssl-ios
$(filter $(BUILD_DIR)/ios%,$(APP_OBJS)): | $(IOS_DEPS)
@@ -855,7 +853,6 @@ dist: release-apk iosrelease-ipa
@mkdir -p dist/ out/tildefriends-$(VERSION_NUMBER)
@git archive main | tar -x -C out/tildefriends-$(VERSION_NUMBER)
@tar \
- --exclude=apps/gg* \
--exclude=apps/welcome* \
--exclude=deps/libbacktrace/Isaac.Newton-Opticks.txt \
--exclude=deps/libsodium/builds/msvc/vs* \
@@ -871,11 +868,10 @@ dist: release-apk iosrelease-ipa
--exclude=deps/zlib/contrib/vstudio \
--exclude=deps/zlib/doc \
-caf dist/tildefriends-$(VERSION_NUMBER).tar.xz out/tildefriends-$(VERSION_NUMBER)
- #@rm -rf out/tildefriends-$(VERSION_NUMBER)
@echo "[cp] TildeFriends-x86-$(VERSION_NUMBER).apk"
- @cp out/TildeFriends-x86-release.apk dist/TildeFriends-x86-$(VERSION_NUMBER).apk
+ @cp out/TildeFriends-x86-release.zopfli.apk dist/TildeFriends-x86-$(VERSION_NUMBER).apk
@echo "[cp] TildeFriends-arm-$(VERSION_NUMBER).apk"
- @cp out/TildeFriends-arm-release.apk dist/TildeFriends-arm-$(VERSION_NUMBER).apk
+ @cp out/TildeFriends-arm-release.zopfli.apk dist/TildeFriends-arm-$(VERSION_NUMBER).apk
@echo "[cp] TildeFriends-$(VERSION_NUMBER).ipa"
@cp out/tildefriends-release.ipa dist/TildeFriends-$(VERSION_NUMBER).ipa
.PHONY: dist
@@ -891,6 +887,10 @@ format:
@clang-format -i $(wildcard src/*.c src/*.h src/*.m)
.PHONY: format
+prettier:
+ @npm run prettier
+.PHONY: prettier
+
docs:
@doxygen
.PHONY: docs
diff --git a/README.md b/README.md
index b7c474a2..2ba21b85 100644
--- a/README.md
+++ b/README.md
@@ -1,4 +1,5 @@
# Tilde Friends
+
Tilde Friends is a tool for making and sharing.
A public instance lives at https://www.tildefriends.net/.
@@ -7,37 +8,42 @@ It is both a peer-to-peer social network client, participating in Secure
Scuttlebutt, as well as a platform for writing and running web applications.
## Goals
+
1. Make it easy and fun to run all sorts of web applications.
2. Provide security that is easy to understand and protects your data.
3. Make creating and sharing web applications accessible to anyone with a
browser.
## Building
-Builds on Linux (x86_64 and aarch64), MacOS, OpenBSD, and Haiku. Builds for
+
+Builds on Linux (x86_64 and aarch64), MacOS, OpenBSD, and Haiku. Builds for
all of those host platforms plus mingw64, iOS, and android.
-1. Requires openssl (`libssl-dev`, in debian-speak). All other dependencies
+1. Requires openssl (`libssl-dev`, in debian-speak). All other dependencies
are kept up to date in the tree.
-2. To build, run `make debug` or `make release`. An executable will be
+2. To build, run `make debug` or `make release`. An executable will be
generated in a subdirectory of `out/`.
3. It's possible to build for Android, iOS, and Windows on Linux, if you have
- the right dependencies in the right places. `make windebug winrelease
- iosdebug-ipa iosrelease-ipa release-apk`.
+ the right dependencies in the right places. `make windebug winrelease
+iosdebug-ipa iosrelease-ipa release-apk`.
4. To build in docker, `docker build .`.
5. `make format` will normalize formatting to the coding standard.
## Running
+
By default, running the built `tildefriends` executable will start a web server
-at . `tildefriends -h` lists further options.
+at . `tildefriends -h` lists further options.
The first user to create an account and log in will be granted administrative
-privileges. Further administration can be done at
+privileges. Further administration can be done at
.
## Documentation
+
Docs are a work in progress:
.
## License
+
All code unless otherwise noted in is provided under the
[MIT](https://opensource.org/licenses/MIT) license.
diff --git a/apps/admin.json b/apps/admin.json
index 711779a2..a9a2e723 100644
--- a/apps/admin.json
+++ b/apps/admin.json
@@ -1,4 +1,4 @@
{
- "type": "tildefriends-app",
- "emoji": "๐"
-}
\ No newline at end of file
+ "type": "tildefriends-app",
+ "emoji": "๐"
+}
diff --git a/apps/admin/app.js b/apps/admin/app.js
index 0a1c35e8..5916f11f 100644
--- a/apps/admin/app.js
+++ b/apps/admin/app.js
@@ -18,9 +18,13 @@ async function main() {
for (let user of await core.users()) {
data.users[user] = await core.permissionsForUser(user);
}
- await app.setDocument(utf8Decode(getFile('index.html')).replace('$data', JSON.stringify(data)));
+ await app.setDocument(
+ utf8Decode(getFile('index.html')).replace('$data', JSON.stringify(data))
+ );
} catch {
- await app.setDocument('Only an administrator can modify these settings.');
+ await app.setDocument(
+ 'Only an administrator can modify these settings.'
+ );
}
}
-main();
\ No newline at end of file
+main();
diff --git a/apps/admin/index.html b/apps/admin/index.html
index eabbf708..114ab1b9 100644
--- a/apps/admin/index.html
+++ b/apps/admin/index.html
@@ -1,10 +1,12 @@
-
+
-
+
Tilde Friends Administration
-
\ No newline at end of file
+