-
-
Notifications
You must be signed in to change notification settings - Fork 38
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
Add html link helper #240
Conversation
src/deliver/render_message.rs
Outdated
@@ -177,6 +199,13 @@ fn truncate(s: &str, max_chars: usize) -> String { | |||
result.trim().to_string() | |||
} | |||
|
|||
fn create_links(urls: &str)-> String { |
There was a problem hiding this comment.
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
src/deliver/render_message.rs
Outdated
@@ -132,6 +152,8 @@ impl MessageRenderer { | |||
} | |||
} | |||
|
|||
|
|||
|
There was a problem hiding this comment.
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
src/deliver/render_message.rs
Outdated
@@ -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"; |
There was a problem hiding this comment.
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?
@athulkrishnaaei can you please resolve conflicts? |
There was a problem hiding this 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" | |||
|
|||
|
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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() |
There was a problem hiding this comment.
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
src/deliver/render_message.rs
Outdated
@@ -50,6 +58,7 @@ pub struct MessageRenderer { | |||
} | |||
|
|||
impl MessageRenderer { | |||
|
There was a problem hiding this comment.
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
src/deliver/render_message.rs
Outdated
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)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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)); |
src/deliver/render_message.rs
Outdated
handlebars_helper!(substring: |string: String, length: usize| truncate(&string, length)); | ||
|
||
#[derive(Builder)] | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
src/deliver/render_message.rs
Outdated
@@ -161,7 +173,10 @@ fn truncate_and_check(s: &str) -> String { | |||
message_without_empty_chars | |||
} | |||
} | |||
|
|||
fn create_hyper_link(url: &str) -> String { |
There was a problem hiding this comment.
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" | |||
|
|||
|
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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
2b57612
to
ce8e403
Compare
added create_link helper function