diff options
author | Jaakko Keränen <jaakko.keranen@iki.fi> | 2020-12-17 13:07:58 +0200 |
---|---|---|
committer | Jaakko Keränen <jaakko.keranen@iki.fi> | 2020-12-17 13:07:58 +0200 |
commit | d8a95f267f4f1865a58cbed15e6b45349e9d2c09 (patch) | |
tree | 5501245d7ef1209319a10ad824ac29b33e26a428 /src/bookmarks.c | |
parent | 48ba3598db53f249f3a8bfd577ca95afde52c760 (diff) |
Added "about:bookmarks"
A simple way to export all or some of your bookmarks.
Diffstat (limited to 'src/bookmarks.c')
-rw-r--r-- | src/bookmarks.c | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/src/bookmarks.c b/src/bookmarks.c index 54b0407f..6d7302c0 100644 --- a/src/bookmarks.c +++ b/src/bookmarks.c | |||
@@ -70,6 +70,10 @@ static int cmpTimeDescending_Bookmark_(const iBookmark **a, const iBookmark **b) | |||
70 | return iCmp(seconds_Time(&(*b)->when), seconds_Time(&(*a)->when)); | 70 | return iCmp(seconds_Time(&(*b)->when), seconds_Time(&(*a)->when)); |
71 | } | 71 | } |
72 | 72 | ||
73 | static int cmpTitleAscending_Bookmark_(const iBookmark **a, const iBookmark **b) { | ||
74 | return cmpStringCase_String(&(*a)->title, &(*b)->title); | ||
75 | } | ||
76 | |||
73 | /*----------------------------------------------------------------------------------------------*/ | 77 | /*----------------------------------------------------------------------------------------------*/ |
74 | 78 | ||
75 | static const char *fileName_Bookmarks_ = "bookmarks.txt"; | 79 | static const char *fileName_Bookmarks_ = "bookmarks.txt"; |
@@ -222,3 +226,35 @@ const iPtrArray *list_Bookmarks(const iBookmarks *d, iBookmarksCompareFunc cmp, | |||
222 | sort_Array(list, (int (*)(const void *, const void *)) cmp); | 226 | sort_Array(list, (int (*)(const void *, const void *)) cmp); |
223 | return list; | 227 | return list; |
224 | } | 228 | } |
229 | |||
230 | const iString *bookmarkListPage_Bookmarks(const iBookmarks *d) { | ||
231 | iString *str = collectNew_String(); | ||
232 | setCStr_String(str, "Here are all your bookmarks. " | ||
233 | "You can save this page to export them, or you can copy them to " | ||
234 | "the clipboard.\n"); | ||
235 | lock_Mutex(d->mtx); | ||
236 | iConstForEach(PtrArray, i, list_Bookmarks(d, cmpTitleAscending_Bookmark_, NULL, NULL)) { | ||
237 | const iBookmark *bm = i.ptr; | ||
238 | appendFormat_String(str, "\n=> %s %s\n", cstr_String(&bm->url), cstr_String(&bm->title)); | ||
239 | iRangecc tag = iNullRange; | ||
240 | while (nextSplit_Rangecc(range_String(&bm->tags), " ", &tag)) { | ||
241 | if (!isEmpty_Range(&tag)) { | ||
242 | appendCStr_String(str, "* "); | ||
243 | appendRange_String(str, tag); | ||
244 | appendChar_String(str, '\n'); | ||
245 | } | ||
246 | } | ||
247 | } | ||
248 | unlock_Mutex(d->mtx); | ||
249 | appendCStr_String(str, | ||
250 | "\nPAGE FORMAT: " | ||
251 | "Text lines and preformatted text are comments and should be ignored. " | ||
252 | "Each link line represents a bookmark. " | ||
253 | "Folder structure is defined by headings. " | ||
254 | "All links before the first heading are root level bookmarks. " | ||
255 | "Bullet lines following a link are used for tags; each tag gets its own " | ||
256 | "bullet line. Quotes are reserved for additional information about a " | ||
257 | "bookmark.\n"); | ||
258 | appendCStr_String(str, "\nLagrange v" LAGRANGE_APP_VERSION "\n"); | ||
259 | return str; | ||
260 | } | ||