-
Notifications
You must be signed in to change notification settings - Fork 437
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: allow owners and moderators to export poll to JSON file
Signed-off-by: Maksim Sukharev <[email protected]>
- Loading branch information
Showing
3 changed files
with
79 additions
and
8 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/** | ||
* SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors | ||
* SPDX-License-Identifier: AGPL-3.0-or-later | ||
*/ | ||
|
||
/** | ||
* Converts given payload to Data URI scheme | ||
* data:[<mediatype>][;base64],<data> | ||
* | ||
* @param payload data to convert | ||
* @param mediatype a MIME type string | ||
* @param base64Token an optional base64 token if non-textual data is given | ||
*/ | ||
const convertToDataURI = function(payload: string, mediatype: string = 'text/plain;charset=US-ASCII', base64Token: string = ''): string { | ||
return 'data:' + mediatype + base64Token + ',' + encodeURIComponent(payload) | ||
} | ||
|
||
/** | ||
* Converts given JS object to Data URI scheme | ||
* | ||
* @param payload JS object to convert | ||
*/ | ||
const convertToJSONDataURI = function(payload: object): string { | ||
return convertToDataURI(JSON.stringify(payload, null, 2), 'application/json;charset=utf-8') | ||
} | ||
|
||
export { | ||
convertToDataURI, | ||
convertToJSONDataURI, | ||
} |