Skip to content

Commit 01f4f91

Browse files
committed
feat: open browser to SERVER_IS_CONFIGURED page upon successful server startup
1 parent 0867910 commit 01f4f91

2 files changed

Lines changed: 16 additions & 5 deletions

File tree

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

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import com.sakethh.linkora.data.configureDatabase
44
import com.sakethh.linkora.data.repository.MarkdownManagerRepoImpl
55
import com.sakethh.linkora.domain.model.ServerConfig
66
import com.sakethh.linkora.domain.repository.MarkdownManagerRepo
7+
import com.sakethh.linkora.domain.routes.SyncRoute
78
import com.sakethh.linkora.presentation.routing.configureRouting
89
import com.sakethh.linkora.presentation.routing.websocket.configureEventsWebSocket
910
import com.sakethh.linkora.utils.SysEnvKey
@@ -118,12 +119,20 @@ fun Application.module() {
118119
configureDatabase()
119120
configureSecurity()
120121
configureSerialization()
121-
val mdManagerRepo: MarkdownManagerRepo = MarkdownManagerRepoImpl()
122-
configureRouting(serverConfig = ServerConfiguration.readConfig(), markdownManagerRepo = mdManagerRepo)
122+
val mdManagerRepo : MarkdownManagerRepo = MarkdownManagerRepoImpl()
123+
val serverConfig =ServerConfiguration.readConfig()
124+
configureRouting(serverConfig = serverConfig, markdownManagerRepo = mdManagerRepo)
123125
install(WebSockets) {
124126
pingPeriod = 15.seconds
125127
timeout = 15.seconds
126128
maxFrameSize = Long.MAX_VALUE
127129
}
128130
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")
137+
}
129138
}

src/main/resources/raw/SERVER_IS_CONFIGURED.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ It seems you've correctly configured the sync server.
22

33
Before anything, check out this video where I explained how to connect the app and the server. That should clear up most things.
44

5-
This server is only meant to communicate with the **Linkora** apps that are available on both **Android** and **Desktop**. You can't use this server with them as there's no frontend client on web yet. Well, you can if you set up your own thing from scratch that connects to this server and does what it's supposed to do.
5+
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.
66

77
## Important Notes
88

@@ -34,8 +34,10 @@ This server is only meant to communicate with the **Linkora** apps that are avai
3434

3535
### **Blank Pages on Other Routes**
3636
- If you're seeing blank pages for other routes, that's completely normal since there's no UI with this server except for this page.
37+
- 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.
3738

3839
## Troubleshooting & Additional Help
3940
- If something isn’t covered here, check out the **YouTube video** where I explained how to connect the app and the server.
40-
- Also, go through **GitHub issues**; you might find the solution there.
41-
- If not, **create an issue on GitHub**, and I'll fix it when I get some time.
41+
- Also, go through **[GitHub issues](https://github.com/LinkoraApp/sync-server/issues)**; you might find the solution there.
42+
- 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.

0 commit comments

Comments
 (0)