#!/usr/bin/perl -X # vim: foldmethod=marker use strict; use warnings; use 5.010; use utf8;use open qw/:std :utf8/; use ORFText; use Text::Wrap; $Text::Wrap::columns = 60; =pod ORFText News for VT100 compatible terminals intended to be called like so (query strings supported): curl -s http://foo/ | less -R TODO: * =cut my @pages = ( 101, 113 .. 125, # Politik: Österreich/EU 127 .. 134, # Politik: International 102,#136 .. 144, # Chronik # 701 .. 709 # Bundesländer (W-NÖ-B-OÖ-S-T-V-K-St) # 471 .. 478 # Nachrichten leicht verständlich # 103, 146 .. 149 # Leute # 104, 151 .. 159 # Wirtschaft # 161,167,169, # Börse # 170,172,174 # -"- # 105, 203 .. 209, # Sport vom Tag # 210 .. 259, # Sportarten # 261 .. 278, # Wintersport & Großereignisse # 107,110,191..198, # Show und Kultur 108,#461 .. 465, # Web/Media # 468 .. 469, # Webtipps # Special Flags: "_noqna", # hide Q-and-A ); if ($ENV{QUERY_STRING}) { @pages = split /&/, ($ENV{QUERY_STRING} =~ s/(\d{3})-(\d{3})/${\join'&',$1..$2}/gr); } print "Content-type: text/plain\r\n\r\n"; # terminal output formatting {{{ my $BOLD = "\033[1m"; my $ITAL = "\033[3m"; my $GREY = "\033[2m"; my $INVR = "\033[7m"; my $RESET= "\033[0m"; $ORFText::REF_MARKUP = sub { my ($text, $ref) = @_; return "$text$ref"; #Note: can't put escape sequences here, or they'll be dropped by ORFText::trim_ws() }; sub format_table { my $text = join("\n",map{s/[\x00-\x20]/ /gr}@{%{$_[0]}{raw}})=~s/^ ,,+//msr=~s/\n+$//r; return {%$_, text=>$text}; } sub format_vt100 { my %page = %{$_[0] or return}; no warnings 'numeric'; use List::Util qw[max]; sub ifdef { $_[1]? "$_[0]$_[1]":"" } my $pagespec = substr($page{page},0,1) ."00/$page{page}_000".max($page{subpage},1); my $text = $page{text}; $text =~ s{
}{\n}g; $text =~ s{(.*?)}{${ITAL}$1${RESET}}g; $text =~ s{(.*?)}{${BOLD}$1${RESET}}g; $text =~ s{