diff --git a/formatters/html-data/telegram-history-dump.css b/formatters/html-data/telegram-history-dump.css index 4c26158..3bc4599 100644 --- a/formatters/html-data/telegram-history-dump.css +++ b/formatters/html-data/telegram-history-dump.css @@ -121,3 +121,7 @@ body { padding-top: 15px; } +.fwd-name { + font-style: normal; + font-weight: bold; +} diff --git a/formatters/html.rb b/formatters/html.rb index 580a6d7..a197796 100644 --- a/formatters/html.rb +++ b/formatters/html.rb @@ -63,7 +63,7 @@ def format_dialog(dialog, messages) messages.reverse_each do |msg| if not msg['out'] and dialog['type'] != 'user' # If this is an incoming message in a group chat, display the author - author = '
%s:
'% get_full_name(msg['from']) + author = CGI::escapeHTML(get_full_name(msg['from'])) else author = '' end @@ -81,6 +81,7 @@ def format_dialog(dialog, messages) end msg_body = '' + author_newline = false if msg['text'] msg_body = replace_urls(msg['text']).gsub("\n", '
') if msg['media'] and msg['media']['type'] == 'webpage' and msg['media']['description'] @@ -98,7 +99,6 @@ def format_dialog(dialog, messages) end msg_body += '
%s%s
' % [title, description] end - author += ' ' if author != '' # In text messages (unlike media), author is followed by a space, not a new line elsif msg['media'] and msg['media']['file'] relative_url = URI.escape(File.join("../../media", safe_name, File.basename(msg['media']['file']))) extension = File.extname(msg['media']['file']) @@ -126,7 +126,7 @@ def format_dialog(dialog, messages) msg_body += ">Your browser does not support inline playback.
Download #{filetype}" end end - author += '
' if author != '' # In file messages (unlike text messages), author is followed by a new line + author_newline = true elsif msg['media'] and msg['media']['type'] == 'geo' lat = msg['media']['latitude'].to_s lon = msg['media']['longitude'].to_s @@ -177,6 +177,15 @@ def format_dialog(dialog, messages) end if msg_body != '' in_out = (msg['out'] ? 'out' : 'in') + fwd_from_name = msg['fwd_from'] ? CGI::escapeHTML(get_full_name(msg['fwd_from'])) : nil + if fwd_from_name + author_newline = true + leadin = if author.empty? then 'F' else ' f' end + fwd_from_text = if fwd_from_name.empty? then '' else " from #{fwd_from_name}" end + author += "#{leadin}orwarded message#{fwd_from_text}" + end + author_suffix = if author_newline then '
' else ' ' end + author = "
#{author}:
#{author_suffix}" unless author.empty? backup_file.puts("
#{author}#{msg_body}
") end