diff --git a/Makefile b/Makefile index 0689bca..ee8dd0f 100644 --- a/Makefile +++ b/Makefile @@ -39,6 +39,10 @@ all: $(MAKE) make_pagescobj $(MAKE) $(TARGET) +install_deps: + cpan HTML::Escape + cpan Template::Toolkit + make_ctmpls: $(TMPLS_C) make_pages: $(PAGES_CMP) make_pagesc: $(PAGES_C) @@ -103,4 +107,4 @@ clean_deps: clean_all: clean clean_deps -.PHONY: all filec clean update clean clean_deps clean_all test +.PHONY: all filec clean update clean clean_deps clean_all test install_deps diff --git a/dist/treebird.css b/dist/treebird.css index 4e07b0f..e096a33 100644 --- a/dist/treebird.css +++ b/dist/treebird.css @@ -85,10 +85,9 @@ a, a:visited, a:hover, a:active border-radius: 3px; } -.greentext -{ - color: #00aa00; -} +.greentext { color: #00aa00; } +.bluetext { color: #0060aa; } +.yellowtext { color: #cccc00; } /* Cleans up most of the tables */ table.ui-table td @@ -1038,6 +1037,15 @@ input[type=checkbox].hidden:not(:checked) + .reply-form display: block; } +.status-content .title +{ + display: block; + padding: 2px 2px 7px; + margin-bottom: 7px; + font-style: italic; + border-bottom: 1px solid #cacaca; +} + .status .status-content p, .status .status-content a { @@ -1509,12 +1517,7 @@ p} { display: inline-block; padding: 3px 0px 3px; - min-width: 35px; -} - -.status-interact .statbtn-last -{ - min-width: 26px; + min-width: 25px; } .status-interact .statbtn.view-btn diff --git a/docs/INSTALL.md b/docs/INSTALL.md index 3a942ec..e83fc9c 100644 --- a/docs/INSTALL.md +++ b/docs/INSTALL.md @@ -24,6 +24,20 @@ Run `make`. This will also clone mastodont-c, and compile both it and Treebird. If you `fossil update` any changes, `make update` should be run after updating +## Perl dependencies + +Treebird renders most of the content that you see in Perl using the Template Toolkit. + +You can install it by running `make install_deps` + +If that doesn't work, you can open a CPAN shell + +``` +perl -MCPAN -e shell +install Template::Toolkit +install HTML::Escape +``` + ## Installation Run `# make install` diff --git a/perl/status.pm b/perl/status.pm index 4faabd7..1d61534 100644 --- a/perl/status.pm +++ b/perl/status.pm @@ -1,7 +1,8 @@ package status; use strict; use warnings; -use string_helpers qw( reltime_to_str ); +use HTML::Escape 'escape_html'; +use string_helpers qw( reltime_to_str greentextify emojify format_username ); use icons qw( get_icon visibility_to_icon ); use attachments 'generate_attachment'; use emojis 'generate_emoji'; @@ -19,9 +20,16 @@ sub generate_status prefix => '', ssn => $ssn, status => $status, + # Functions icon => \&get_icon, rel_to_str => \&reltime_to_str, vis_to_icon => \&visibility_to_icon, + make_att => \&generate_attachment, + make_emoji => \&generate_emoji, + greentextify => \&greentextify, + emojify => \&emojify, + escape => \&escape_html, + format_username => \&format_username, ); to_template(\%vars, \$data->{'status.tt'}); @@ -40,8 +48,6 @@ sub content_status statuses_after => $statuses_after, # Functions create_status => \&generate_status, - make_att => \&generate_attachment, - make_emoji => \&generate_emoji, ); diff --git a/perl/string_helpers.pm b/perl/string_helpers.pm index 8dff450..28b95b6 100644 --- a/perl/string_helpers.pm +++ b/perl/string_helpers.pm @@ -1,10 +1,10 @@ package string_helpers; use strict; use warnings; - +use HTML::Escape 'escape_html'; use Exporter 'import'; -our @EXPORT = qw( &reltime_to_str ); +our @EXPORT = qw( reltime_to_str greentextify emojify format_username ); sub reltime_to_str { @@ -17,3 +17,31 @@ sub reltime_to_str return int($since / (60 * 60 * 24 * 31)) . 'mon' if $since < 60 * 60 * 24 * 365; return int($since / (60 * 60 * 24 * 365)) . 'yr'; } + +sub greentextify +{ + my $text = shift; + $text =~ s/((?:^|| )>.*?)(?:|$)/$1<\/span>
/gs; + $text =~ s/((?:^|| )<.*?)(?:|$)/$1<\/span>
/gs; + $text =~ s/((?:^|| )\^.*?)(?:|$)/$1<\/span>
/gs; + $text; +} + +sub emojify +{ + my ($text, $emojis) = @_; + foreach my $emoji (@{$emojis}) + { + my $emo = $emoji->{shortcode}; + my $url = $emoji->{url}; + $text =~ s/:$emo://gsi; + } + $text; +} + +sub format_username +{ + my $username = shift; + emojify escape_html($username); +} + diff --git a/templates/status.tt b/templates/status.tt index 2a4075f..1868547 100644 --- a/templates/status.tt +++ b/templates/status.tt @@ -8,7 +8,7 @@
- [% status.account.display_name %] + [% format_username(status.account.display_name) %] [% status.account.acct %]