-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Bookmarks api * Lint fix * first pass * Lint fix * comment * bookmarks, loading feedSources, and pagination * comment * null check --------- Co-authored-by: github-action linter <[email protected]>
- Loading branch information
Showing
23 changed files
with
510 additions
and
192 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
65 changes: 65 additions & 0 deletions
65
playlet-lib/src/components/Web/PlayletWebServer/Middleware/BookmarksRouter.bs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
import "pkg:/source/utils/RegistryUtils.bs" | ||
|
||
namespace Http | ||
|
||
class BookmarksRouter extends HttpRouter | ||
|
||
function new() | ||
super() | ||
|
||
m.Get("/api/bookmarks", function(context as object) as boolean | ||
response = context.response | ||
|
||
bookmarksString = RegistryUtils.Read(RegistryUtils.BOOKMARKS) | ||
if bookmarksString = invalid | ||
response.Json({ | ||
groups: [] | ||
}) | ||
return true | ||
end if | ||
|
||
response.SetBodyDataString(bookmarksString) | ||
response.ContentType("application/json") | ||
response.http_code = 200 | ||
|
||
return true | ||
end function) | ||
|
||
m.Get("/api/bookmarks/feeds", function(context as object) as boolean | ||
response = context.response | ||
router = context.router | ||
bookmarks = context.server.task.bookmarks | ||
|
||
feeds = router.BookmarksContentToFeeds(bookmarks.content) | ||
|
||
response.Json(feeds) | ||
|
||
return true | ||
end function) | ||
end function | ||
|
||
' TODO:P1 refactor to share code with Bookmarks screen | ||
function BookmarksContentToFeeds(bookmarksContent as object) as object | ||
bookmarkGroupNodes = bookmarksContent.getChildren(-1, 0) | ||
|
||
feeds = [] | ||
for each bookmarkGroupNode in bookmarkGroupNodes | ||
bookmarkNodes = bookmarkGroupNode.getChildren(-1, 0) | ||
|
||
feedSources = [] | ||
for each bookmarkNode in bookmarkNodes | ||
feedSources.push(bookmarkNode.feedSource) | ||
end for | ||
|
||
feeds.push({ | ||
"title": bookmarkGroupNode.title, | ||
"feedSources": feedSources | ||
}) | ||
end for | ||
|
||
return feeds | ||
end function | ||
|
||
end class | ||
|
||
end namespace |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.