Skip to content

Commit 9ce9516

Browse files
committed
Merge branch 'v0.0.2'
# Conflicts: # README.md
2 parents c2e2ff2 + 2c221da commit 9ce9516

File tree

7 files changed

+70
-26
lines changed

7 files changed

+70
-26
lines changed

README.md

Lines changed: 32 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,26 @@ will be prompted to provide the required values, which will be saved locally.
4747
```
4848

4949
- `databaseUrl`: The database URL (without username or password).
50-
- `databaseUser`: The username for your database.
51-
- `databasePassword`: The password for your database.
52-
- `hostAddress`: The host address of the server. If not provided, defaults to `0.0.0.0`.
53-
- `serverPort`: The port number on which the server runs. If not provided, defaults to `8080`.
50+
- `databaseUrl` should always start with the name of the database you're using:
51+
- PGSQL (or) PostgreSQL :
52+
```
53+
postgresql://someAddress:port/linkora
54+
```
55+
- MySQL :
56+
```
57+
mysql://someAddress:port/linkora
58+
```
59+
- SQLite :
60+
```
61+
sqlite:path-to-db
62+
```
63+
`path-to-db` should look something like `sqlite:/home/saketh/Documents/sqlite/databaseFileName`
64+
- `databaseUser`: The username of the database you want to connect to.
65+
- If you are using SQLite, leave this blank or press Enter when the setup prompts for it.
66+
- `databasePassword`: The password of the database you want to connect to.
67+
- If you are using SQLite, leave this blank or press Enter when the setup prompts for it.
68+
- `hostAddress`: The host address of the server. If not provided, it defaults to the `IPv4` of the network currently connected to. When connecting from Linkora apps, you should pass this address instead of `localhost`.
69+
- `serverPort`: The port number on which the server runs. If not provided, defaults to `45454`.
5470
- `serverAuthToken`: A secure token used to authenticate requests from the Linkora app. Treat this like a password and
5571
keep it confidential.
5672
@@ -65,13 +81,15 @@ set:
6581
6682
- `LINKORA_SERVER_USE_ENV_VAL`: Set this to `true` to enable the use of environment variables. This must always be `true` when using environment variables.
6783
- `LINKORA_DATABASE_URL`: The database URL (without username or password).
68-
- `LINKORA_DATABASE_USER`: The username for your database.
69-
- `LINKORA_DATABASE_PASSWORD`: The password for your database.
84+
- `LINKORA_DATABASE_USER`: The username of the database you want to connect to.
85+
- If you are using SQLite, leave this blank.
86+
- `LINKORA_DATABASE_PASSWORD`: The password of the database you want to connect to.
87+
- If you are using SQLite, leave this blank.
7088
- `LINKORA_SERVER_AUTH_TOKEN`: A secure token used to authenticate requests from the Linkora app. Treat this like a
7189
password and
7290
keep it confidential.
73-
- `LINKORA_HOST_ADDRESS`: The host address of the server. If not provided, defaults to `0.0.0.0`.
74-
- `LINKORA_SERVER_PORT`: The port number on which the server runs. If not provided, defaults to `8080`.
91+
- `LINKORA_HOST_ADDRESS`: The host address of the server. If not provided, it defaults to the `IPv4` of the network currently connected to. When connecting from Linkora apps, you should pass this address instead of `localhost`.
92+
- `LINKORA_SERVER_PORT`: The port number on which the server runs. If not provided, defaults to `45454`.
7593
7694
### 3. Hosting Options
7795
@@ -178,6 +196,12 @@ systemctl start linkora.service
178196
systemctl enable linkora.service
179197
```
180198

199+
#### Workflow of Linkora, which should make it easier to understand how everything works:
200+
201+
<a href="https://github.com/user-attachments/assets/bb2d9b7e-92c4-41ed-82d3-ad821cc65638" onclick="window.open(this.href, '_blank'); return false;">
202+
<img alt="linkora-outline.png" src="https://github.com/user-attachments/assets/bb2d9b7e-92c4-41ed-82d3-ad821cc65638" style="max-width: 100%; height: auto;">
203+
</a>
204+
181205
### Join the Community
182206

183207
[![Join us on Discord](https://discord.com/api/guilds/1214971383352664104/widget.png?style=banner2)](https://discord.gg/ZDBXNtv8MD)

src/main/kotlin/com/sakethh/linkora/Application.kt

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ import io.ktor.server.netty.*
1515
import io.ktor.server.websocket.*
1616
import kotlinx.serialization.encodeToString
1717
import kotlinx.serialization.json.Json
18+
import java.awt.Desktop
19+
import java.net.InetAddress
20+
import java.net.URI
1821
import java.nio.file.Files
1922
import java.nio.file.Paths
2023
import java.nio.file.StandardOpenOption
@@ -89,11 +92,11 @@ object ServerConfiguration {
8992
// manually throw the exception as `getenv` may return null, and no conversion is happening here to auto-throw
9093
System.getenv(SysEnvKey.LINKORA_HOST_ADDRESS.name) ?: throw NullPointerException()
9194
} catch (_: Exception) {
92-
"0.0.0.0"
95+
InetAddress.getLocalHost().hostAddress
9396
}, serverPort = try {
9497
System.getenv(SysEnvKey.LINKORA_SERVER_PORT.name).toInt()
9598
} catch (_: Exception) {
96-
8080
99+
45454
97100
},
98101
serverAuthToken = System.getenv(SysEnvKey.LINKORA_SERVER_AUTH_TOKEN.name)
99102
)
@@ -128,11 +131,9 @@ fun Application.module() {
128131
maxFrameSize = Long.MAX_VALUE
129132
}
130133
configureEventsWebSocket()
131-
val currentOS = System.getProperty("os.name").lowercase()
132-
val serverConfiguredPage = serverConfig.hostAddress+ ":"+ serverConfig.serverPort + "/"+ SyncRoute.SERVER_IS_CONFIGURED.name
133-
when {
134-
currentOS.contains("win") -> Runtime.getRuntime().exec("rundll32 url.dll,FileProtocolHandler $serverConfiguredPage")
135-
currentOS.contains("mac") -> Runtime.getRuntime().exec("open $serverConfiguredPage")
136-
currentOS.contains("nix") || currentOS.contains("nux") -> Runtime.getRuntime().exec("xdg-open $serverConfiguredPage")
134+
val serverConfiguredPage =
135+
"http://" + serverConfig.hostAddress + ":" + serverConfig.serverPort + "/" + SyncRoute.SERVER_IS_CONFIGURED.name
136+
if (Desktop.isDesktopSupported() && Desktop.getDesktop().isSupported(Desktop.Action.BROWSE)) {
137+
Desktop.getDesktop().browse(URI(serverConfiguredPage))
137138
}
138139
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
package com.sakethh.linkora
22

33
object Constants {
4-
const val SERVER_VERSION = "0.0.1"
4+
const val SERVER_VERSION = "0.0.2"
55
}

src/main/kotlin/com/sakethh/linkora/data/repository/MarkdownManagerRepoImpl.kt

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,22 @@ class MarkdownManagerRepoImpl : MarkdownManagerRepo {
1313
private val markdownFlavour = CommonMarkFlavourDescriptor()
1414
private val mdParser = MarkdownParser(markdownFlavour)
1515

16-
override fun getRawHtmlBasedOnMD(fileLocation: String, placeHolder: Pair<PlaceHolder, PlaceHolderValue>): String {
16+
override fun getRawHtmlBasedOnMDFile(
17+
fileLocation: String,
18+
placeHolder: Pair<PlaceHolder, PlaceHolderValue>
19+
): String {
1720
val file = this::class.java.getResourceAsStream(fileLocation)
1821
val rawMDText = file.use { it?.bufferedReader()?.readText().toString() }
1922
.replace(placeHolder.first, placeHolder.second)
2023
val parseTree = mdParser.buildMarkdownTreeFromString(rawMDText)
2124
return HtmlGenerator(markdownText = rawMDText, parseTree, markdownFlavour).generateHtml()
2225
}
26+
27+
override fun getRawHtmlBasedOnRawMD(rawMD: String): String {
28+
return HtmlGenerator(
29+
markdownText = rawMD,
30+
mdParser.buildMarkdownTreeFromString(rawMD),
31+
markdownFlavour
32+
).generateHtml()
33+
}
2334
}

src/main/kotlin/com/sakethh/linkora/domain/repository/MarkdownManagerRepo.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,6 @@ import com.sakethh.linkora.domain.PlaceHolder
44
import com.sakethh.linkora.domain.PlaceHolderValue
55

66
interface MarkdownManagerRepo {
7-
fun getRawHtmlBasedOnMD(fileLocation: String, placeHolder: Pair<PlaceHolder, PlaceHolderValue>): String
7+
fun getRawHtmlBasedOnMDFile(fileLocation: String, placeHolder: Pair<PlaceHolder, PlaceHolderValue>): String
8+
fun getRawHtmlBasedOnRawMD(rawMD:String): String
89
}

src/main/kotlin/com/sakethh/linkora/presentation/routing/Routing.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package com.sakethh.linkora.presentation.routing
22

3+
import com.sakethh.linkora.Constants
34
import com.sakethh.linkora.Security
45
import com.sakethh.linkora.data.repository.FoldersImplementation
56
import com.sakethh.linkora.data.repository.LinksImplementation
@@ -19,6 +20,7 @@ import io.ktor.server.application.*
1920
import io.ktor.server.auth.*
2021
import io.ktor.server.response.*
2122
import io.ktor.server.routing.*
23+
import org.jetbrains.exposed.sql.Database
2224
import java.net.InetAddress
2325

2426
fun Application.configureRouting(serverConfig: ServerConfig, markdownManagerRepo: MarkdownManagerRepo) {
@@ -45,7 +47,7 @@ fun Application.configureRouting(serverConfig: ServerConfig, markdownManagerRepo
4547
} else {
4648
""
4749
}
48-
val requiredHtml = markdownManagerRepo.getRawHtmlBasedOnMD(
50+
val requiredHtml = markdownManagerRepo.getRawHtmlBasedOnRawMD("The sync-server version is **${Constants.SERVER_VERSION}**.\n\nYou are currently connected to the **${Database.getDialectName(serverConfig.databaseUrl)}** database, which will be **used by the server to store data**.")+markdownManagerRepo.getRawHtmlBasedOnMDFile(
4951
fileLocation = "/raw/SERVER_IS_CONFIGURED.md", placeHolder = "#{PLACEHOLDER_1}" to placeHolderValue
5052
)
5153
call.respondText(contentType = ContentType.Text.Html, text = requiredHtml)

src/main/resources/raw/SERVER_IS_CONFIGURED.md

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
It seems you've correctly configured the sync server.
2-
3-
Before anything, check out this video where I explained how to connect the app and the server. That should clear up most things.
1+
It seems you've configured the sync-server correctly; to check if it's running, browse to this endpoint or refresh—if the page loads again, the server is up; ensure the connected database is also running.
42

53
This server is meant to communicate only with the **[Linkora](https://github.com/LinkoraApp/Linkora)** apps, available on **Android** and **Desktop**. There's no web-based frontend yet, so you can’t control anything through a web interface. That said, if you’re willing to build your own custom solution from scratch that connects to this server and does what it needs to, then it’s totally possible.
64

@@ -37,7 +35,14 @@ This server is meant to communicate only with the **[Linkora](https://github.com
3735
- Except for this route, every other route is secured by an auth token. Access is only granted if the client provides the correct auth token that you’ve set. Without it, they won’t be able to access anything.
3836

3937
## Troubleshooting & Additional Help
40-
- If something isn’t covered here, check out the **YouTube video** where I explained how to connect the app and the server.
41-
- Also, go through **[GitHub issues](https://github.com/LinkoraApp/sync-server/issues)**; you might find the solution there.
38+
- Always go through the [README](https://github.com/LinkoraApp/sync-server/blob/master/README.md); it covers most of the info you're probably looking for.
39+
- If something isn’t covered here, go through **[GitHub issues](https://github.com/LinkoraApp/sync-server/issues)**; you might find the solution there.
4240
- If not, **[create an issue on GitHub](https://github.com/LinkoraApp/sync-server/issues/new)**, and I'll fix it when I get some time.
43-
- You can also [join the Discord](https://discord.gg/ZDBXNtv8MD) if you want. It’s there for questions, updates, or just to hang out.
41+
- You can also [join the Discord](https://discord.gg/ZDBXNtv8MD) if you want. It’s there for questions, updates, or just to hang out.
42+
43+
---
44+
#### Workflow of Linkora, which should make it easier to understand how everything works:
45+
46+
<a href="https://github.com/user-attachments/assets/bb2d9b7e-92c4-41ed-82d3-ad821cc65638" onclick="window.open(this.href, '_blank'); return false;">
47+
<img alt="linkora-outline.png" src="https://github.com/user-attachments/assets/bb2d9b7e-92c4-41ed-82d3-ad821cc65638" style="max-width: 100%; height: auto;">
48+
</a>

0 commit comments

Comments
 (0)