-
Notifications
You must be signed in to change notification settings - Fork 81
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
338 additions
and
50 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
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,33 @@ | ||
export const createLinkMarkup = (text, color) => { | ||
// Define the components of the regex pattern | ||
|
||
// Matches optional protocol (http:// or https://) | ||
const protocol = '(https?://)?'; | ||
|
||
// Matches any domain or subdomain | ||
const domain = '([a-zA-Z0-9-]+\\.)+[a-zA-Z]{2,}'; | ||
|
||
// Matches paths and query strings, excluding certain special characters | ||
const pathAndQuery = '(\\/[^\\s()$@]*)?(\\?[\\w=&-]*)?(#[\\w\\-]*)?'; | ||
|
||
// Combine all parts into the final regex pattern | ||
const urlRegex = new RegExp( | ||
`(${protocol})?(${domain})(?=\\s|\\/|$)${pathAndQuery}(?=\\s|$)`, | ||
'gi' | ||
); | ||
|
||
return text.replace(urlRegex, (fullMatch) => { | ||
const decodedUrl = decodeURIComponent(fullMatch); | ||
|
||
// Determine the correct href value for the anchor tag | ||
let href = ''; | ||
if (decodedUrl.startsWith('https://') || decodedUrl.startsWith('http://')) { | ||
href = decodedUrl; | ||
} else { | ||
href = `https://${decodedUrl}`; | ||
} | ||
|
||
// Return the HTML string for the anchor tag with the correct href and style | ||
return `<a href="${href}" style="color: ${color};" target="_blank" rel="noopener noreferrer">${fullMatch}</a>`; | ||
}); | ||
}; |
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,64 @@ | ||
# TODO: This file will be replaced by using the SDK directly | ||
|
||
|
||
def post_feed_message(client, target_uri, target_type, content): | ||
query = { | ||
'operationName': 'PostFeedMessage', | ||
'variables': { | ||
'targetUri': target_uri, | ||
'targetType': target_type, | ||
'input': {'content': content}, | ||
}, | ||
'query': """ | ||
mutation PostFeedMessage( | ||
$targetUri: String! | ||
$targetType: String! | ||
$input: FeedMessageInput! | ||
) { | ||
postFeedMessage( | ||
targetUri: $targetUri | ||
targetType: $targetType | ||
input: $input | ||
) { | ||
feedMessageUri | ||
content | ||
created | ||
creator | ||
} | ||
} | ||
""", | ||
} | ||
response = client.query(query=query) | ||
return response.data.postFeedMessage | ||
|
||
|
||
def get_feed(client, target_uri, target_type, filter={}): | ||
query = { | ||
'operationName': 'GetFeed', | ||
'variables': {'targetUri': target_uri, 'targetType': target_type, 'filter': filter}, | ||
'query': """ | ||
query GetFeed( | ||
$targetUri: String! | ||
$targetType: String! | ||
$filter: FeedMessageFilter | ||
) { | ||
getFeed(targetUri: $targetUri, targetType: $targetType) { | ||
messages(filter: $filter) { | ||
count | ||
hasNext | ||
hasPrevious | ||
page | ||
pages | ||
nodes { | ||
content | ||
feedMessageUri | ||
creator | ||
created | ||
} | ||
} | ||
} | ||
} | ||
""", | ||
} | ||
response = client.query(query=query) | ||
return response.data.getFeed |
Oops, something went wrong.