@@ -2,8 +2,8 @@ package com.yogeshpaliyal.deepr.sync
2
2
3
3
import android.content.Context
4
4
import androidx.core.net.toUri
5
- import com.yogeshpaliyal.deepr.Deepr
6
5
import com.yogeshpaliyal.deepr.DeeprQueries
6
+ import com.yogeshpaliyal.deepr.ListDeeprWithTagsAsc
7
7
import com.yogeshpaliyal.deepr.R
8
8
import com.yogeshpaliyal.deepr.preference.AppPreferenceDataStore
9
9
import com.yogeshpaliyal.deepr.util.RequestResult
@@ -41,7 +41,7 @@ class SyncRepositoryImpl(
41
41
return @withContext RequestResult .Error (context.getString(R .string.no_data_to_export))
42
42
}
43
43
44
- val dataToSync = deeprQueries.listDeeprAsc ().executeAsList()
44
+ val dataToSync = deeprQueries.listDeeprWithTagsAsc ().executeAsList()
45
45
if (dataToSync.isEmpty()) {
46
46
return @withContext RequestResult .Error (context.getString(R .string.no_data_available_export))
47
47
}
@@ -96,7 +96,7 @@ class SyncRepositoryImpl(
96
96
97
97
private fun writeMarkdownData (
98
98
file : OutputStream ,
99
- data : List <Deepr >,
99
+ data : List <ListDeeprWithTagsAsc >,
100
100
) {
101
101
file.use { outputStream ->
102
102
outputStream.bufferedWriter().use { writer ->
@@ -109,14 +109,26 @@ class SyncRepositoryImpl(
109
109
writer.write(" **Warning:** Please maintain the markdown table format when editing this file.\n\n " )
110
110
111
111
// Write markdown table header
112
- writer.write(" | Name | Link | Created At | Opened Count |\n " )
113
- writer.write(" |------|------|------------|--------------|\n " )
112
+ writer.write(" | Name | Link | Created At | Opened Count | Tags | \n " )
113
+ writer.write(" |------|------|------------|--------------|------| \n " )
114
114
115
115
// Write data rows
116
116
data.forEach { item ->
117
117
val escapedName = item.name.replace(" |" , " \\ |" ).replace(" \n " , " " )
118
118
val escapedLink = item.link.replace(" |" , " \\ |" ).replace(" \n " , " " )
119
- val row = " | $escapedName | $escapedLink | ${item.createdAt} | ${item.openedCount} |\n "
119
+
120
+ // Format tags as hashtags
121
+ val tags =
122
+ if (item.tagsNames.isNullOrEmpty()) {
123
+ " "
124
+ } else {
125
+ item.tagsNames
126
+ .split(" , " )
127
+ .filter { it.isNotEmpty() }
128
+ .joinToString(" " ) { " #${it.replace(" " , " " ).replace(" |" , " " )} " }
129
+ }
130
+
131
+ val row = " | $escapedName | $escapedLink | ${item.createdAt} | ${item.openedCount} | $tags |\n "
120
132
writer.write(row)
121
133
}
122
134
@@ -134,9 +146,9 @@ class SyncRepositoryImpl(
134
146
135
147
for (line in lines) {
136
148
val trimmedLine = line.trim()
137
- if (trimmedLine.startsWith(" | Name | Link | Created At | Opened Count |" )) {
149
+ if (trimmedLine.startsWith(" | Name | Link | Created At | Opened Count | Tags | " )) {
138
150
foundHeader = true
139
- } else if (foundHeader && trimmedLine.startsWith(" |------|------|------------|--------------|" )) {
151
+ } else if (foundHeader && trimmedLine.startsWith(" |------|------|------------|--------------|------| " )) {
140
152
foundSeparator = true
141
153
break
142
154
}
0 commit comments