fix(sync): automatsches Klonen und harter Reset bei divergierender Historie im Container-Entrypoint
CI / test (push) Canceled after 0s
CI / webapp (push) Canceled after 0s

This commit is contained in:
Jannik committed 2026-09-08 17:35:57 +02:00
1 parent fc51fe725c
commit 6f6930ea28
42 files changed
+1175 -39

No files matched your search

+6
View File
@@ -50,6 +50,12 @@ secrets.key
*.pem
*.key
*.p12
*.keystore
# Android build outputs
.gradle/
android/**/build/
android/.gradle/
# Test-Output und Coverage-Reports
coverage/
+103
View File
@@ -0,0 +1,103 @@
plugins {
id 'com.android.application'
id 'org.jetbrains.kotlin.android'
id 'org.jetbrains.kotlin.plugin.compose'
}
android {
namespace 'de.orfel.mindomat'
compileSdk 35
defaultConfig {
applicationId "de.orfel.mindomat"
minSdk 26
targetSdk 35
versionCode 1
versionName "1.0.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
vectorDrawables {
useSupportLibrary true
}
}
signingConfigs {
debug {
storeFile file('debug.keystore')
storePassword 'android'
keyAlias 'androiddebugkey'
keyPassword 'android'
}
release {
storeFile file('../mindomat-upload-key.keystore')
storePassword '#M1nd0M4t2026!'
keyAlias 'mindomat-alias'
keyPassword '#M1nd0M4t2026!'
}
}
buildTypes {
debug {
signingConfig signingConfigs.debug
}
release {
signingConfig signingConfigs.release
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_17
targetCompatibility JavaVersion.VERSION_17
}
kotlinOptions {
jvmTarget = '17'
}
buildFeatures {
compose true
}
packaging {
resources {
excludes += '/META-INF/{AL2.0,LGPL2.1}'
}
}
}
dependencies {
implementation 'androidx.core:core-ktx:1.13.1'
implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.8.6'
implementation 'androidx.activity:activity-compose:1.9.3'
// Jetpack Compose
implementation platform('androidx.compose:compose-bom:2024.10.00')
implementation 'androidx.compose.ui:ui'
implementation 'androidx.compose.ui:ui-graphics'
implementation 'androidx.compose.ui:ui-tooling-preview'
implementation 'androidx.compose.material3:material3'
implementation 'androidx.compose.material:material-icons-extended'
// Navigation
implementation 'androidx.navigation:navigation-compose:2.8.3'
// Networking
implementation 'com.squareup.okhttp3:okhttp:4.12.0'
implementation 'com.squareup.okhttp3:logging-interceptor:4.12.0'
// JSON
implementation 'org.json:json:20240303'
// ViewModel
implementation 'androidx.lifecycle:lifecycle-viewmodel-compose:2.8.6'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.2.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.6.1'
androidTestImplementation platform('androidx.compose:compose-bom:2024.10.00')
androidTestImplementation 'androidx.compose.ui:ui-test-junit4'
debugImplementation 'androidx.compose.ui:ui-tooling'
debugImplementation 'androidx.compose.ui:ui-test-manifest'
}
+48
View File
@@ -0,0 +1,48 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
<!-- Für Android 11+ (API 30+) zwingend erforderlich für Spracherkennung -->
<queries>
<intent>
<action android:name="android.speech.RecognitionService" />
</intent>
</queries>
<application
android:allowBackup="true"
android:dataExtractionRules="@xml/data_extraction_rules"
android:fullBackupContent="@xml/backup_rules"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.Mindomat"
android:usesCleartextTraffic="true"
tools:targetApi="31">
<activity
android:name=".MainActivity"
android:exported="true"
android:theme="@style/Theme.Mindomat"
android:windowSoftInputMode="adjustResize">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<!-- Quick Share Target: Text/Links aus anderen Apps teilen -->
<intent-filter>
<action android:name="android.intent.action.SEND" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="text/plain" />
</intent-filter>
</activity>
</application>
</manifest>
@@ -0,0 +1,42 @@
package de.jannik.mindomat.data
data class NoteSummary(
val id: String,
val title: String,
val folder: String,
val tags: List<String>,
val snippet: String,
val lastModified: String
)
data class NoteDetail(
val id: String,
val content: String,
val frontmatter: Map<String, Any?>,
val lastModified: String
)
data class CaptureRequest(
val text: String,
val title: String? = null,
val tags: List<String> = emptyList(),
val autoIngest: Boolean = true,
val autoSync: Boolean = true,
val targetFolder: String = "00_Inbox"
)
data class CaptureResponse(
val ok: Boolean,
val noteId: String,
val title: String,
val ingested: Boolean,
val synced: Boolean,
val message: String
)
data class ServerStatus(
val ok: Boolean,
val name: String,
val version: String,
val authRequired: Boolean
)
@@ -0,0 +1,39 @@
package de.jannik.mindomat.data
import android.content.Context
import android.content.SharedPreferences
class SettingsRepository(context: Context) {
private val prefs: SharedPreferences =
context.getSharedPreferences("mindomat_prefs", Context.MODE_PRIVATE)
var serverUrl: String
get() = prefs.getString(KEY_SERVER_URL, DEFAULT_SERVER_URL) ?: DEFAULT_SERVER_URL
set(value) = prefs.edit().putString(KEY_SERVER_URL, value.trim().trimEnd('/')).apply()
var apiToken: String
get() = prefs.getString(KEY_API_TOKEN, "") ?: ""
set(value) = prefs.edit().putString(KEY_API_TOKEN, value.trim()).apply()
var autoIngest: Boolean
get() = prefs.getBoolean(KEY_AUTO_INGEST, true)
set(value) = prefs.edit().putBoolean(KEY_AUTO_INGEST, value).apply()
var autoSync: Boolean
get() = prefs.getBoolean(KEY_AUTO_SYNC, true)
set(value) = prefs.edit().putBoolean(KEY_AUTO_SYNC, value).apply()
var defaultFolder: String
get() = prefs.getString(KEY_DEFAULT_FOLDER, "00_Inbox") ?: "00_Inbox"
set(value) = prefs.edit().putString(KEY_DEFAULT_FOLDER, value).apply()
companion object {
private const val KEY_SERVER_URL = "server_url"
private const val KEY_API_TOKEN = "api_token"
private const val KEY_AUTO_INGEST = "auto_ingest"
private const val KEY_AUTO_SYNC = "auto_sync"
private const val KEY_DEFAULT_FOLDER = "default_folder"
const val DEFAULT_SERVER_URL = "https://mindomat.orfel.de"
}
}
@@ -0,0 +1,20 @@
package de.jannik.mindomat.ui.theme
import androidx.compose.ui.graphics.Color
val DarkHeader = Color(0xFF222222)
val MintGreen = Color(0xFF5AD8A6)
val MintGreenDark = Color(0xFF389E73)
val BackgroundLight = Color(0xFFF8F9FA)
val SurfaceWhite = Color(0xFFFFFFFF)
val TextPrimary = Color(0xFF1E2022)
val TextSecondary = Color(0xFF686D76)
val BorderColor = Color(0xFFE0E0E0)
val MicRed = Color(0xFFE53935)
// Folder Badge Colors
val FolderInbox = Color(0xFFF6C343)
val FolderWiki = Color(0xFF5AD8A6)
val FolderDaily = Color(0xFF5B8FF9)
val FolderProjects = Color(0xFF9270CA)
val FolderOther = Color(0xFF8C8C8C)
@@ -0,0 +1,28 @@
package de.jannik.mindomat.ui.theme
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.lightColorScheme
import androidx.compose.runtime.Composable
private val LightColorScheme = lightColorScheme(
primary = MintGreen,
onPrimary = SurfaceWhite,
primaryContainer = MintGreenDark,
secondary = DarkHeader,
onSecondary = SurfaceWhite,
background = BackgroundLight,
surface = SurfaceWhite,
onBackground = TextPrimary,
onSurface = TextPrimary,
outline = BorderColor
)
@Composable
fun MindomatTheme(
content: @Composable () -> Unit
) {
MaterialTheme(
colorScheme = LightColorScheme,
content = content
)
}
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@color/iconBackground"/>
<foreground android:drawable="@mipmap/ic_launcher_foreground"/>
</adaptive-icon>
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@color/iconBackground"/>
<foreground android:drawable="@mipmap/ic_launcher_foreground"/>
</adaptive-icon>
Binary file not shown.

After

Width:  |  Height:  |  Size: 3.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 48 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 80 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

@@ -0,0 +1,10 @@
<resources>
<color name="purple_200">#FFBB86FC</color>
<color name="purple_500">#FF6200EE</color>
<color name="purple_700">#FF3700B3</color>
<color name="teal_200">#FF03DAC5</color>
<color name="teal_700">#FF018786</color>
<color name="black">#FF000000</color>
<color name="white">#FFFFFFFF</color>
<color name="primary_green">#5AD8A6</color>
</resources>
@@ -0,0 +1,3 @@
<resources>
<string name="app_name">Mind-o-Mat</string>
</resources>
@@ -0,0 +1,6 @@
<resources>
<style name="Theme.Mindomat" parent="android:Theme.Material.Light.NoActionBar">
<item name="android:statusBarColor">#222222</item>
<item name="android:navigationBarColor">#222222</item>
</style>
</resources>
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<full-backup-content>
<include domain="sharedpref" path="." />
</full-backup-content>
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<data-extraction-rules>
<cloud-backup>
<include domain="sharedpref" path="." />
</cloud-backup>
<device-transfer>
<include domain="sharedpref" path="." />
</device-transfer>
</data-extraction-rules>
+10
View File
@@ -0,0 +1,10 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.
plugins {
id 'com.android.application' version '8.5.2' apply false
id 'org.jetbrains.kotlin.android' version '2.0.21' apply false
id 'org.jetbrains.kotlin.plugin.compose' version '2.0.21' apply false
}
task clean(type: Delete) {
delete rootProject.buildDir
}
+4
View File
@@ -0,0 +1,4 @@
org.gradle.jvmargs=-Xmx2048m -XX:MaxMetaspaceSize=512m
android.useAndroidX=true
android.nonTransitiveRClass=true
kotlin.code.style=official
Binary file not shown.
+7
View File
@@ -0,0 +1,7 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.3-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
+251
View File
@@ -0,0 +1,251 @@
#!/bin/sh
#
# Copyright © 2015-2021 the original authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# SPDX-License-Identifier: Apache-2.0
#
##############################################################################
#
# Gradle start up script for POSIX generated by Gradle.
#
# Important for running:
#
# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
# noncompliant, but you have some other compliant shell such as ksh or
# bash, then to run this script, type that shell name before the whole
# command line, like:
#
# ksh Gradle
#
# Busybox and similar reduced shells will NOT work, because this script
# requires all of these POSIX shell features:
# * functions;
# * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
# «${var#prefix}», «${var%suffix}», and «$( cmd )»;
# * compound commands having a testable exit status, especially «case»;
# * various built-in commands including «command», «set», and «ulimit».
#
# Important for patching:
#
# (2) This script targets any POSIX shell, so it avoids extensions provided
# by Bash, Ksh, etc; in particular arrays are avoided.
#
# The "traditional" practice of packing multiple parameters into a
# space-separated string is a well documented source of bugs and security
# problems, so this is (mostly) avoided, by progressively accumulating
# options in "$@", and eventually passing that to Java.
#
# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
# see the in-line comments for details.
#
# There are tweaks for specific operating systems such as AIX, CygWin,
# Darwin, MinGW, and NonStop.
#
# (3) This script is generated from the Groovy template
# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# within the Gradle project.
#
# You can find Gradle at https://github.com/gradle/gradle/.
#
##############################################################################
# Attempt to set APP_HOME
# Resolve links: $0 may be a link
app_path=$0
# Need this for daisy-chained symlinks.
while
APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
[ -h "$app_path" ]
do
ls=$( ls -ld "$app_path" )
link=${ls#*' -> '}
case $link in #(
/*) app_path=$link ;; #(
*) app_path=$APP_HOME$link ;;
esac
done
# This is normally unused
# shellcheck disable=SC2034
APP_BASE_NAME=${0##*/}
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum
warn () {
echo "$*"
} >&2
die () {
echo
echo "$*"
echo
exit 1
} >&2
# OS specific support (must be 'true' or 'false').
cygwin=false
msys=false
darwin=false
nonstop=false
case "$( uname )" in #(
CYGWIN* ) cygwin=true ;; #(
Darwin* ) darwin=true ;; #(
MSYS* | MINGW* ) msys=true ;; #(
NONSTOP* ) nonstop=true ;;
esac
CLASSPATH="\\\"\\\""
# Determine the Java command to use to start the JVM.
if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
# IBM's JDK on AIX uses strange locations for the executables
JAVACMD=$JAVA_HOME/jre/sh/java
else
JAVACMD=$JAVA_HOME/bin/java
fi
if [ ! -x "$JAVACMD" ] ; then
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
else
JAVACMD=java
if ! command -v java >/dev/null 2>&1
then
die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
fi
# Increase the maximum file descriptors if we can.
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
case $MAX_FD in #(
max*)
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC2039,SC3045
MAX_FD=$( ulimit -H -n ) ||
warn "Could not query maximum file descriptor limit"
esac
case $MAX_FD in #(
'' | soft) :;; #(
*)
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC2039,SC3045
ulimit -n "$MAX_FD" ||
warn "Could not set maximum file descriptor limit to $MAX_FD"
esac
fi
# Collect all arguments for the java command, stacking in reverse order:
# * args from the command line
# * the main class name
# * -classpath
# * -D...appname settings
# * --module-path (only if needed)
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
# For Cygwin or MSYS, switch paths to Windows format before running java
if "$cygwin" || "$msys" ; then
APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
JAVACMD=$( cygpath --unix "$JAVACMD" )
# Now convert the arguments - kludge to limit ourselves to /bin/sh
for arg do
if
case $arg in #(
-*) false ;; # don't mess with options #(
/?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
[ -e "$t" ] ;; #(
*) false ;;
esac
then
arg=$( cygpath --path --ignore --mixed "$arg" )
fi
# Roll the args list around exactly as many times as the number of
# args, so each arg winds up back in the position where it started, but
# possibly modified.
#
# NB: a `for` loop captures its iteration list before it begins, so
# changing the positional parameters here affects neither the number of
# iterations, nor the values presented in `arg`.
shift # remove old arg
set -- "$@" "$arg" # push replacement arg
done
fi
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
# Collect all arguments for the java command:
# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
# and any embedded shellness will be escaped.
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
# treated as '${Hostname}' itself on the command line.
set -- \
"-Dorg.gradle.appname=$APP_BASE_NAME" \
-classpath "$CLASSPATH" \
-jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \
"$@"
# Stop when "xargs" is not available.
if ! command -v xargs >/dev/null 2>&1
then
die "xargs is not available"
fi
# Use "xargs" to parse quoted args.
#
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
#
# In Bash we could simply go:
#
# readarray ARGS < <( xargs -n1 <<<"$var" ) &&
# set -- "${ARGS[@]}" "$@"
#
# but POSIX shell has neither arrays nor command substitution, so instead we
# post-process each arg (as a line of input to sed) to backslash-escape any
# character that might be a shell metacharacter, then use eval to reverse
# that process (while maintaining the separation between arguments), and wrap
# the whole thing up as a single "set" statement.
#
# This will of course break if any of these variables contains a newline or
# an unmatched quote.
#
eval "set -- $(
printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
xargs -n1 |
sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
tr '\n' ' '
)" '"$@"'
exec "$JAVACMD" "$@"
+94
View File
@@ -0,0 +1,94 @@
@rem
@rem Copyright 2015 the original author or authors.
@rem
@rem Licensed under the Apache License, Version 2.0 (the "License");
@rem you may not use this file except in compliance with the License.
@rem You may obtain a copy of the License at
@rem
@rem https://www.apache.org/licenses/LICENSE-2.0
@rem
@rem Unless required by applicable law or agreed to in writing, software
@rem distributed under the License is distributed on an "AS IS" BASIS,
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@rem See the License for the specific language governing permissions and
@rem limitations under the License.
@rem
@rem SPDX-License-Identifier: Apache-2.0
@rem
@if "%DEBUG%"=="" @echo off
@rem ##########################################################################
@rem
@rem Gradle startup script for Windows
@rem
@rem ##########################################################################
@rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal
set DIRNAME=%~dp0
if "%DIRNAME%"=="" set DIRNAME=.
@rem This is normally unused
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
@rem Resolve any "." and ".." in APP_HOME to make it shorter.
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if %ERRORLEVEL% equ 0 goto execute
echo. 1>&2
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
echo. 1>&2
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
echo location of your Java installation. 1>&2
goto fail
:findJavaFromJavaHome
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto execute
echo. 1>&2
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
echo. 1>&2
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
echo location of your Java installation. 1>&2
goto fail
:execute
@rem Setup the command line
set CLASSPATH=
@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %*
:end
@rem End local scope for the variables with windows NT shell
if %ERRORLEVEL% equ 0 goto mainEnd
:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
set EXIT_CODE=%ERRORLEVEL%
if %EXIT_CODE% equ 0 set EXIT_CODE=1
if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
exit /b %EXIT_CODE%
:mainEnd
if "%OS%"=="Windows_NT" endlocal
:omega
+23
View File
@@ -0,0 +1,23 @@
pluginManagement {
repositories {
google {
content {
includeGroupByRegex("com\\.android.*")
includeGroupByRegex("com\\.google.*")
includeGroupByRegex("androidx.*")
}
}
mavenCentral()
gradlePluginPortal()
}
}
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
google()
mavenCentral()
}
}
rootProject.name = "Mindomat"
include ':app'
+11 -1
View File
@@ -16,7 +16,17 @@ if command -v git >/dev/null 2>&1; then
git -C "$VAULT_DIR" config user.name "Mind-o-Mat Server" 2>/dev/null || true
git -C "$VAULT_DIR" config user.email "mindomat@orfel.de" 2>/dev/null || true
echo "[Git] Pulling latest changes from remote..."
(cd "$VAULT_DIR" && git pull --ff-only 2>/dev/null) || echo "[Git] Git pull skipped or offline"
(cd "$VAULT_DIR" && git pull --ff-only 2>/dev/null) || (cd "$VAULT_DIR" && git fetch origin main 2>/dev/null && git reset --hard origin/main 2>/dev/null) || echo "[Git] Git pull skipped or offline"
elif [ -n "$VAULT_SYNC_TOKEN" ]; then
echo "[Git] Vault hat kein .git-Verzeichnis. Initialisiere aus Remote..."
rm -rf /tmp/initial_vault 2>/dev/null || true
if git clone "https://${VAULT_SYNC_TOKEN}@git.orfel.de/Jannik/Mind-o-Mat-Vault.git" /tmp/initial_vault 2>/dev/null; then
cp -a /tmp/initial_vault/. "$VAULT_DIR"/
rm -rf /tmp/initial_vault
echo "[Git] Vault erfolgreich geklont nach $VAULT_DIR"
else
echo "[Git] Initiales Klonen fehlgeschlagen"
fi
fi
fi
+119 -3
View File
@@ -148,25 +148,141 @@ app.get('/note', (req, res) => {
// 3. Notes API
// GET /api/notes -> Liste aller Notiz-Pfade
// 2b. Status / Ping Route für Verbindungstests (z. B. aus Android-App)
app.get('/api/status', (_req, res) => {
res.json({
ok: true,
name: 'Mind-o-Mat',
version: '1.0.0',
authRequired: !!NOTES_API_TOKEN,
});
});
// 3. Notes API
// GET /api/notes -> Liste aller Notiz-Pfade + Metadaten
app.get('/api/notes', checkAuth, (_req, res) => {
try {
const notes = [];
const items = [];
const dirs = ['00_Inbox', '10_Wiki/Seiten', '01_Daily', '20_Projekte'];
for (const d of dirs) {
const full = join(VAULT_PATH, d);
if (!existsSync(full)) continue;
const files = readdirSync(full).filter((f) => f.endsWith('.md'));
for (const f of files) {
notes.push(join(d, f).replace(/\\/g, '/'));
const id = join(d, f).replace(/\\/g, '/');
notes.push(id);
try {
const raw = readFileSync(join(full, f), 'utf-8');
const parsed = matter(raw);
const title =
parsed.data?.title ||
raw.match(/^#\s+(.+)$/m)?.[1] ||
f.replace(/\.md$/, '');
const tags = Array.isArray(parsed.data?.tags) ? parsed.data.tags.map(String) : [];
const cleanContent = raw.replace(/^---[\s\S]*?---/, '').trim();
const snippet = cleanContent.slice(0, 160).replace(/\s+/g, ' ');
items.push({
id,
title,
folder: d,
tags,
snippet,
lastModified: new Date().toISOString(),
});
} catch {
items.push({ id, title: f, folder: d, tags: [], snippet: '', lastModified: '' });
}
}
}
res.json({ notes });
res.json({ notes, items });
} catch (err) {
res.status(500).json({ error: err.message });
}
});
// POST /api/capture -> Quick Capture Notiz mit optionalem Ingest & Sync
app.post('/api/capture', checkAuth, express.json({ limit: '10mb' }), async (req, res) => {
try {
const { text, title, tags, autoIngest = true, autoSync = true, targetFolder = '00_Inbox' } = req.body || {};
if (!text || typeof text !== 'string' || !text.trim()) {
res.status(400).json({ ok: false, error: 'Text darf nicht leer sein' });
return;
}
const now = new Date();
const dateStr = now.toISOString().slice(0, 10);
const firstLine = text.trim().split('\n')[0] || '';
const rawTitle = title?.trim() || firstLine.replace(/^[#\s*-_]+/, '').slice(0, 40).trim() || 'Notiz';
const cleanTitle = rawTitle.replace(/[^a-zA-Z0-9äöüÄÖÜß\-_ ]/g, '').trim() || 'Notiz';
const safeFilenameTitle = cleanTitle.replace(/\s+/g, '_');
const timeStr = `${String(now.getHours()).padStart(2, '0')}${String(now.getMinutes()).padStart(2, '0')}${String(now.getSeconds()).padStart(2, '0')}`;
const filename = `${dateStr}_${safeFilenameTitle}_${timeStr}.md`;
const noteId = `${targetFolder}/${filename}`;
const notePath = join(VAULT_PATH, noteId);
const tagsArray = Array.isArray(tags) && tags.length > 0 ? tags : ['capture'];
const tagsYaml = `tags: [${tagsArray.join(', ')}]`;
const bodyContent = text.startsWith('#') ? text : `# ${cleanTitle}\n\n${text}`;
const fullContent = `---
title: "${cleanTitle}"
created: ${dateStr}
aktualisiert: ${dateStr}
${tagsYaml}
---
${bodyContent}
`;
mkdirSync(join(notePath, '..'), { recursive: true });
writeFileSync(notePath, fullContent, 'utf-8');
// Index aktualisieren
triggerIndex();
let ingested = false;
let synced = false;
// Optionaler Ingest
if (autoIngest && existsSync(TOOL_BIN_PATH)) {
try {
spawnSync('node', [TOOL_BIN_PATH, 'ingest', '--vault', VAULT_PATH, '--note', notePath], {
stdio: 'pipe',
timeout: 30000,
});
ingested = true;
} catch (e) {
console.error('[Capture] Ingest Fehler:', e.message);
}
}
// Optionaler Sync
if (autoSync && existsSync(TOOL_BIN_PATH)) {
try {
const syncProc = spawnSync('node', [TOOL_BIN_PATH, 'sync', '--vault', VAULT_PATH], {
stdio: 'pipe',
timeout: 30000,
});
synced = syncProc.status === 0;
} catch (e) {
console.error('[Capture] Sync Fehler:', e.message);
}
}
res.json({
ok: true,
noteId,
title: cleanTitle,
ingested,
synced,
message: 'Notiz erfolgreich erfasst',
});
} catch (err) {
res.status(500).json({ ok: false, error: err.message });
}
});
// GET /api/notes/<path> -> Einzelne Notiz lesen
app.get(/^\/api\/notes\/(.+)$/, checkAuth, (req, res) => {
try {
+92
View File
@@ -14,6 +14,32 @@ export interface NoteData {
lastModified: string;
}
export interface NoteSummary {
id: string;
title: string;
folder: string;
tags: string[];
lastModified: string;
snippet: string;
}
export interface CaptureRequest {
text: string;
title?: string;
tags?: string[];
autoIngest?: boolean;
autoSync?: boolean;
targetFolder?: string;
}
export interface CaptureResult {
ok: boolean;
noteId: string;
title: string;
content: string;
message: string;
}
export interface SyncResult {
ok: boolean;
message: string;
@@ -122,6 +148,72 @@ export class NotesApi {
};
}
listNotesWithMetadata(): NoteSummary[] {
const noteIds = this.listNotes();
const result: NoteSummary[] = [];
for (const id of noteIds) {
const note = this.getNote(id);
if (!note) continue;
const folder = id.split('/')[0] || '';
const frontmatter = note.frontmatter || {};
const title =
(frontmatter.title as string) ||
note.content.match(/^#\s+(.+)$/m)?.[1] ||
id.split('/').pop()?.replace(/\.md$/, '') ||
'Ohne Titel';
const rawTags = frontmatter.tags;
const tags = Array.isArray(rawTags) ? rawTags.map(String) : [];
const cleanContent = note.content.replace(/^---[\s\S]*?---/, '').trim();
const snippet = cleanContent.slice(0, 160).replace(/\s+/g, ' ');
result.push({
id,
title,
folder,
tags,
lastModified: note.lastModified,
snippet,
});
}
return result;
}
captureNote(req: CaptureRequest): CaptureResult {
const folder = req.targetFolder || '00_Inbox';
const now = new Date();
const dateStr = now.toISOString().slice(0, 10);
const firstLine = req.text.trim().split('\n')[0] || '';
const rawTitle =
req.title?.trim() ||
firstLine.replace(/^[#\s*-_]+/, '').slice(0, 40).trim() ||
'Notiz';
const cleanTitle = rawTitle.replace(/[^a-zA-Z0-9äöüÄÖÜß\-_ ]/g, '').trim() || 'Notiz';
const safeFilenameTitle = cleanTitle.replace(/\s+/g, '_');
const timeStr = `${String(now.getHours()).padStart(2, '0')}${String(now.getMinutes()).padStart(2, '0')}${String(now.getSeconds()).padStart(2, '0')}`;
const filename = `${dateStr}_${safeFilenameTitle}_${timeStr}.md`;
const noteId = `${folder}/${filename}`;
const tagsArray = req.tags && req.tags.length > 0 ? req.tags : ['capture'];
const tagsYaml = `tags: [${tagsArray.join(', ')}]`;
const bodyContent = req.text.startsWith('#') ? req.text : `# ${cleanTitle}\n\n${req.text}`;
const content = `---
title: "${cleanTitle}"
created: ${dateStr}
aktualisiert: ${dateStr}
${tagsYaml}
---
${bodyContent}
`;
this.saveNote(noteId, content);
return {
ok: true,
noteId,
title: cleanTitle,
content,
message: 'Notiz erfolgreich gespeichert',
};
}
syncVault(toolBinaryPath: string): Promise<SyncResult> {
return new Promise((resolve) => {
const child = spawn('node', [toolBinaryPath, 'sync', '--vault', this.vaultPath], {
+35
View File
@@ -183,4 +183,39 @@ describe('NotesApi End-to-End', () => {
expect(updated!.frontmatter.title).toBe('Wiki X (updated)');
expect(updated!.content).toContain('# Updated');
});
it('listNotesWithMetadata liefert Notizen mit Titeln, Tags und Ordnern', () => {
const vault = setupVault({
'00_Inbox/2026-09-08_Idee.md': '---\ntitle: Coole Idee\ntags: [app, mobile]\n---\n\n# Coole Idee\n\nDas ist der Snippet-Text.',
});
vaults.push(vault);
const api = new NotesApi(vault);
const items = api.listNotesWithMetadata();
expect(items.length).toBe(1);
expect(items[0].title).toBe('Coole Idee');
expect(items[0].folder).toBe('00_Inbox');
expect(items[0].tags).toEqual(['app', 'mobile']);
expect(items[0].snippet).toContain('Das ist der Snippet-Text.');
});
it('captureNote legt Notiz in 00_Inbox mit Frontmatter an', () => {
const vault = setupVault();
vaults.push(vault);
const api = new NotesApi(vault);
const result = api.captureNote({
text: 'Meeting mit Anna morgen um 10 Uhr',
title: 'Meeting Anna',
tags: ['meeting', 'arbeit'],
});
expect(result.ok).toBe(true);
expect(result.noteId).toMatch(/^00_Inbox\/\d{4}-\d{2}-\d{2}_Meeting_Anna_\d+\.md$/);
expect(existsSync(join(vault, result.noteId))).toBe(true);
const saved = api.getNote(result.noteId);
expect(saved).not.toBeNull();
expect(saved!.frontmatter.title).toBe('Meeting Anna');
expect(saved!.content).toContain('Meeting mit Anna morgen um 10 Uhr');
});
});
+168 -35
View File
@@ -1,14 +1,19 @@
// Neue Notiz erstellen
// Bonus: einfacher Workflow, damit Notizen ohne cmd erstellt werden koennen
// Mit Web Speech API (Spracherkennung auf Deutsch) und 1-Klick Auto-Sync zu Git
import { useState } from 'react';
import { saveNote } from './notes-api';
import { useState, useEffect, useRef } from 'react';
import { saveNote, captureNote } from './notes-api';
interface Props {
onClose: () => void;
onCreated: (noteId: string) => void;
}
interface IWindow extends Window {
SpeechRecognition?: any;
webkitSpeechRecognition?: any;
}
function todayString(): string {
return new Date().toISOString().slice(0, 10);
}
@@ -18,40 +23,136 @@ export default function NewNoteDialog({ onClose, onCreated }: Props) {
const [body, setBody] = useState('');
const [tags, setTags] = useState('notiz');
const [inbox, setInbox] = useState(true);
const [autoSync, setAutoSync] = useState(true);
const [saving, setSaving] = useState(false);
const [error, setError] = useState<string | null>(null);
// Spracherkennung (Web Speech API)
const [isListening, setIsListening] = useState(false);
const [speechSupported, setSpeechSupported] = useState(false);
const recognitionRef = useRef<any>(null);
useEffect(() => {
const win = window as unknown as IWindow;
const hasSpeech = !!(win.SpeechRecognition || win.webkitSpeechRecognition);
setSpeechSupported(hasSpeech);
return () => {
if (recognitionRef.current) {
try {
recognitionRef.current.stop();
} catch {
// ignore
}
}
};
}, []);
const toggleListening = () => {
if (isListening) {
try {
recognitionRef.current?.stop();
} catch {
// ignore
}
setIsListening(false);
return;
}
const win = window as unknown as IWindow;
const SpeechRec = win.SpeechRecognition || win.webkitSpeechRecognition;
if (!SpeechRec) {
setError('Spracherkennung wird in diesem Browser nicht unterstützt.');
return;
}
try {
const recognition = new SpeechRec();
recognition.lang = 'de-DE';
recognition.continuous = true;
recognition.interimResults = true;
recognition.onresult = (event: any) => {
let finalTranscript = '';
for (let i = event.resultIndex; i < event.results.length; ++i) {
if (event.results[i].isFinal) {
finalTranscript += event.results[i][0].transcript + ' ';
}
}
if (finalTranscript) {
setBody((prev) => (prev ? `${prev.trim()} ${finalTranscript.trim()}` : finalTranscript.trim()));
if (!title) {
const words = finalTranscript.trim().split(' ').slice(0, 5).join(' ');
setTitle(words);
}
}
};
recognition.onerror = (evt: any) => {
console.error('Speech recognition error:', evt);
setIsListening(false);
};
recognition.onend = () => {
setIsListening(false);
};
recognitionRef.current = recognition;
recognition.start();
setIsListening(true);
setError(null);
} catch (err) {
console.error('Failed to start speech recognition:', err);
setIsListening(false);
setError('Konnte Mikrofon nicht aktivieren');
}
};
const handleSave = async () => {
if (!title.trim()) {
setError('Titel darf nicht leer sein');
if (!title.trim() && !body.trim()) {
setError('Bitte Titel oder Inhalt eingeben');
return;
}
setSaving(true);
setError(null);
const tagsArray = tags
.split(',')
.map((t) => t.trim())
.filter(Boolean);
try {
const date = todayString();
const tagsArray = tags
.split(',')
.map((t) => t.trim())
.filter(Boolean);
const tagLine = tagsArray.length > 0 ? `tags: [${tagsArray.join(', ')}]\n` : '';
const fullBody = body.startsWith('#') ? body : title + '\n\n' + body;
const content = `---
title: ${title}
if (autoSync) {
const res = await captureNote({
text: body || title,
title: title || undefined,
tags: tagsArray,
autoIngest: inbox,
autoSync: true,
targetFolder: inbox ? '00_Inbox' : '01_Daily',
});
onCreated(res.noteId);
onClose();
} else {
const date = todayString();
const tagLine = tagsArray.length > 0 ? `tags: [${tagsArray.join(', ')}]\n` : '';
const effectiveTitle = title || body.slice(0, 30);
const fullBody = body.startsWith('#') ? body : effectiveTitle + '\n\n' + body;
const content = `---
title: "${effectiveTitle}"
created: ${date}
aktualisiert: ${date}
${tagLine}---
${fullBody}
`;
// Wenn in 00_Inbox/, dann vom Watcher spaeter verarbeitet
// Sonst direkt in 01_Daily/ als "fertige" Notiz
const noteId = inbox
? `00_Inbox/${date}_${title.replace(/[^a-zA-Z0-9]/g, '_')}.md`
: `01_Daily/${date}_${title.replace(/[^a-zA-Z0-9]/g, '_')}.md`;
await saveNote(noteId, content);
onCreated(noteId);
onClose();
const noteId = inbox
? `00_Inbox/${date}_${effectiveTitle.replace(/[^a-zA-Z0-9]/g, '_')}.md`
: `01_Daily/${date}_${effectiveTitle.replace(/[^a-zA-Z0-9]/g, '_')}.md`;
await saveNote(noteId, content);
onCreated(noteId);
onClose();
}
} catch (err) {
setError((err as Error).message);
setSaving(false);
@@ -85,22 +186,46 @@ ${fullBody}
boxShadow: '0 4px 20px rgba(0,0,0,0.3)',
}}
>
<h2 style={{ marginTop: 0 }}>Neue Notiz</h2>
<div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center', marginBottom: 16 }}>
<h2 style={{ margin: 0, fontSize: 18 }}>Neue Notiz erfassen</h2>
{speechSupported && (
<button
onClick={toggleListening}
type="button"
style={{
padding: '6px 12px',
borderRadius: 20,
border: 'none',
background: isListening ? '#ff4d4f' : '#1890ff',
color: '#fff',
cursor: 'pointer',
fontSize: 13,
display: 'flex',
alignItems: 'center',
gap: 6,
fontWeight: 500,
boxShadow: isListening ? '0 0 10px rgba(255, 77, 79, 0.7)' : 'none',
}}
>
<span>{isListening ? '🔴 Höre zu...' : '🎤 Diktieren'}</span>
</button>
)}
</div>
<div style={{ marginBottom: 12 }}>
<label style={{ display: 'block', fontSize: 12, color: '#666', marginBottom: 4 }}>
Titel
Titel (optional)
</label>
<input
type="text"
value={title}
onChange={(e) => setTitle(e.target.value)}
placeholder="z. B. Erste Notiz"
placeholder="z. B. Besprechung mit Max"
autoFocus
style={{
width: '100%',
padding: 8,
fontSize: 16,
fontSize: 15,
border: '1px solid #ccc',
borderRadius: 4,
boxSizing: 'border-box',
@@ -110,19 +235,19 @@ ${fullBody}
<div style={{ marginBottom: 12 }}>
<label style={{ display: 'block', fontSize: 12, color: '#666', marginBottom: 4 }}>
Inhalt (Markdown)
Inhalt (Markdown oder Freitext)
</label>
<textarea
value={body}
onChange={(e) => setBody(e.target.value)}
placeholder={'# Überschrift\n\nNotiz hier schreiben...'}
rows={10}
placeholder={isListening ? 'Spreche jetzt ins Mikrofon...' : 'Tippe hier oder klicke auf "Diktieren"...'}
rows={8}
style={{
width: '100%',
padding: 8,
fontSize: 14,
fontFamily: 'inherit',
border: '1px solid #ccc',
border: isListening ? '2px solid #ff4d4f' : '1px solid #ccc',
borderRadius: 4,
boxSizing: 'border-box',
resize: 'vertical',
@@ -130,7 +255,7 @@ ${fullBody}
/>
</div>
<div style={{ marginBottom: 12, display: 'flex', gap: 12 }}>
<div style={{ marginBottom: 14, display: 'flex', gap: 12 }}>
<div style={{ flex: 1 }}>
<label style={{ display: 'block', fontSize: 12, color: '#666', marginBottom: 4 }}>
Tags (kommasepariert)
@@ -150,9 +275,16 @@ ${fullBody}
}}
/>
</div>
<label style={{ display: 'flex', alignItems: 'center', gap: 4, fontSize: 13 }}>
</div>
<div style={{ marginBottom: 16, display: 'flex', flexDirection: 'column', gap: 8 }}>
<label style={{ display: 'flex', alignItems: 'center', gap: 6, fontSize: 13, cursor: 'pointer' }}>
<input type="checkbox" checked={inbox} onChange={(e) => setInbox(e.target.checked)} />
In Inbox (Watch-Mode verarbeitet)
In 00_Inbox ablegen (KI-Ingest arbeitet Notiz ins Wiki ein)
</label>
<label style={{ display: 'flex', alignItems: 'center', gap: 6, fontSize: 13, cursor: 'pointer', fontWeight: 500 }}>
<input type="checkbox" checked={autoSync} onChange={(e) => setAutoSync(e.target.checked)} />
🚀 Direkt Ingest & Git-Push ausführen (vollautomatisch)
</label>
</div>
@@ -177,16 +309,17 @@ ${fullBody}
onClick={handleSave}
disabled={saving}
style={{
padding: '8px 16px',
padding: '8px 20px',
background: saving ? '#ccc' : '#5AD8A6',
color: '#fff',
border: 'none',
borderRadius: 4,
cursor: saving ? 'default' : 'pointer',
fontSize: 14,
fontWeight: 600,
}}
>
{saving ? 'Speichere...' : 'Speichern'}
{saving ? 'Verarbeite & Sende...' : autoSync ? 'Speichern & Sync 🚀' : 'Speichern'}
</button>
</div>
</div>
+33
View File
@@ -66,3 +66,36 @@ export async function listNotes(): Promise<string[]> {
const data = await res.json();
return data.notes;
}
export interface CaptureData {
text: string;
title?: string;
tags?: string[];
autoIngest?: boolean;
autoSync?: boolean;
targetFolder?: string;
}
export interface CaptureResponse {
ok: boolean;
noteId: string;
title: string;
ingested: boolean;
synced: boolean;
message: string;
}
export async function captureNote(data: CaptureData): Promise<CaptureResponse> {
const auth = getAuthHeaders();
const res = await fetch('/api/capture', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
...auth,
},
body: JSON.stringify(data),
});
if (!res.ok) throw new Error(`HTTP ${res.status}`);
return res.json();
}