Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add html link helper #240

Merged
merged 0 commits into from
Aug 23, 2022
Merged

Conversation

athulkrishnaaei
Copy link
Contributor

added create_link helper function

Cargo.toml Outdated Show resolved Hide resolved
@@ -177,6 +199,13 @@ fn truncate(s: &str, max_chars: usize) -> String {
result.trim().to_string()
}

fn create_links(urls: &str)-> String {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this function is not needed. let's format the string directly in the create_link helper on the line 37

@@ -132,6 +152,8 @@ impl MessageRenderer {
}
}



Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's remove the new lines that you added here, line 110, lines 65-66. 41-42 and all other

@@ -21,15 +21,27 @@ const BOT_ITEM_LINK: &str = "bot_item_link";
const BOT_ITEM_DESCRIPTION: &str = "bot_item_description";

const SUBSTRING_HELPER: &str = "substring";
const CREATE_LINK_HELPER: &str = "create_link";
const BOLD_HELPER: &str = "bold";
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe let's italic helper also?

@ayrat555 ayrat555 mentioned this pull request Aug 22, 2022
@ayrat555 ayrat555 changed the title Develop 2 Add html link helper Aug 22, 2022
@ayrat555
Copy link
Owner

@athulkrishnaaei can you please resolve conflicts?

Copy link
Owner

@ayrat555 ayrat555 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please take a look at the Github workflow. it's failing

Cargo.toml Outdated
@@ -30,5 +30,6 @@ tokio = { version = "1", features = ["full"] }
typed-builder = "0.10"
url = "2"


Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you don't need changes in this file

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this comment is not addressed

.env Outdated
@@ -1,4 +1,4 @@
TELEGRAM_BOT_TOKEN= # insert @BotFather token here
TELEGRAM_BOT_TOKEN=# insert @BotFather token here
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you don't need changes in this file

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this comment is not addressed

@@ -414,7 +414,9 @@ mod tests {

assert_eq!(
result[0].0,
// "FeedTitle\r\n\r\nTitle\r\n\r\nDescription\r\n\r\n2020-05-13 19:59:02 +00:05\r\n\r\ndsd".to_string()
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you don't need these changes

@@ -50,6 +58,7 @@ pub struct MessageRenderer {
}

impl MessageRenderer {

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please remove news lines that you added in this file

const DEFAULT_TEMPLATE: &str = "{{bot_feed_name}}\n\n{{bot_item_name}}\n\n{{bot_item_description}}\n\n{{bot_date}}\n\n{{bot_item_link}}\n\n";
const MAX_CHARS: usize = 4000;

const RENDER_ERROR: &str = "Failed to render template";
const EMPTY_MESSAGE_ERROR: &str = "According to your template the message is empty. Telegram doesn't support empty messages. That's why we're sending this placeholder message.";

handlebars_helper!(create_link: |string: String,link: String| format!("<a href={}>{}</a>",create_hyper_link(&link),&string));
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
handlebars_helper!(create_link: |string: String,link: String| format!("<a href={}>{}</a>",create_hyper_link(&link),&string));
handlebars_helper!(create_link: |string: String, link: String| format!("<a href=\"{}\">{}</a>", link, string));

handlebars_helper!(substring: |string: String, length: usize| truncate(&string, length));

#[derive(Builder)]

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change

@@ -161,7 +173,10 @@ fn truncate_and_check(s: &str) -> String {
message_without_empty_chars
}
}

fn create_hyper_link(url: &str) -> String {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please remove this function

Cargo.toml Outdated
@@ -30,5 +30,6 @@ tokio = { version = "1", features = ["full"] }
typed-builder = "0.10"
url = "2"


Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this comment is not addressed

.env Outdated
@@ -1,4 +1,4 @@
TELEGRAM_BOT_TOKEN= # insert @BotFather token here
TELEGRAM_BOT_TOKEN=# insert @BotFather token here
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this comment is not addressed

.gitignore Outdated
@@ -1 +1,2 @@
/target
.env
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's not added .env to .gitignore yet

tests are failing because it's missing

@athulkrishnaaei athulkrishnaaei merged commit ce8e403 into ayrat555:master Aug 23, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants