%
% anyremote configuration file for RSS reading. (Server-mode)
% based on configuration file from Domjan Svilkovic
%

% STATUS unknown
% XTEST no
% SOUND no
% ENV no

GuiAppName=RSS Reader
GuiAppIcon=view_text.png
GuiAppType=Custom
GuiAppBinary=true
GuiAppProtocols=Server
GuiAppDesc=Read RSS on the phone's screen

[Protocol]=Server

% Not parsed correctly
%http://rss.slashdot.org/Slashdot/slashdot

(Init)=Include($(CfgDir)/Utils/aliases-server.cfg);\
	Exec(echo 'if [ ! -f $HOME/.rssfeeds ]; then echo "http://feeds.feedburner.com/spaceheadlines,http://newsrss.bbc.co.uk/rss/newsonline_uk_edition/world/rss.xml,http://newsrss.bbc.co.uk/rss/newsonline_uk_edition/sci/tech/rss.xml" > $HOME/.rssfeeds; fi;'|bash -f -s);

(Connect)=Set(icons,Rss Reader,1,folder,2,default,3,default,4,default,5,default,6,default,7,default,8,default,9,default,*,question,0,default,#,default);\
	Macro(SHOW_FEEDS);\
	Set(menu,replace,Select);

Back=Set(text,close);

1=Macro(SHOW_FEEDS);Set(menu,replace,Select);
* *=Set(text,replace,Help,Press 1 to show list of feeds)

SHOW_FEEDS=\
	ExecAndSet(list,replace,List of feeds,cat $HOME/.rssfeeds);
	

LOAD_FEED=\
	Set(popup,show,Please wait);\
        Make(var,dummy_used_to_sync,echo 'wget $(Param) -O - 2>/dev/null|perl -pe "s/\n//g;s/</\n</g;s/\r/\n</g;" > $HOME/.anyRemote/feed.txt'|bash -f -s);\
        Macro(SHOW_TITLES);\
        Macro(PARSE_DSC);\
        Set(menu,replace,Select);\
	Set(popup,hide);\
        Make(mode,FEED);
	
SET_ARTNUM=\
        Make(var,artname,echo "$(Index)/`cat $HOME/.anyRemote/titles.txt|wc -l|tr -d  ' '`");

GET_FEEDNAME=\
        Make(var,feedname,grep '<title>' $HOME/.anyRemote/feed.txt |head -1|cut -f 2 -d '>');

SHOW_TITLES=\
	Macro(GET_FEEDNAME);\
	ExecAndSet(list,replace,$(feedname),cat $HOME/.anyRemote/feed.txt|awk '{ i=index($0,"\074item "); if(i==0) i=index($0,"\074item\076"); if(i==0) nextline; else { j=0; while (getline && j==0) { k=index($0,"\074title"); if(k!=0) { print $0;j=1; } } } }'|sed "s/&apos;/\'/g"|cut -f 2 -d ">"|sed 's/,/\r/;s/\$/USD/g;s/$/,/' > $HOME/.anyRemote/titles.txt;cat $HOME/.anyRemote/titles.txt);
PARSE_DSC=\
	Exec(cat $HOME/.anyRemote/feed.txt|awk '{ i=index($0,"\074item "); if(i==0) i=index($0,"\074item\076"); if(i==0) nextline; else { j=0; while (getline && j==0) { k=index($0,"\074description"); if(k!=0) { print $0;j=1; } } } }'|cut -f 2 -d ">" > $HOME/.anyRemote/descr.txt);
TYPE_TTL=\
	ExecAndSet(list,replace,List of articles,cat $HOME/.anyRemote/titles.txt);
SHOW_ARTICLE=\
	ExecAndSet(text,replace,$(artname),cat $HOME/.anyRemote/descr.txt|head -$(Index)|tail -1|sed "s/&apos;/\'/g;s/&gt;/>/g;s/&lt;/</g");\
	Make(var,feed_idx,echo $(Index));

Select($$)=Macro(LOAD_FEED);
Push($$)=Macro(Select($$));
Back($$)=Set(list,close);

[Mode]=FEED

Select($$)=\
	Set(popup,show,Loading ...);\
	Macro(SET_ARTNUM);\
	Macro(SHOW_ARTICLE);\
	Set(popup,hide);
	
Push($$)=Macro(Select($$));

Back=\
	Macro(TYPE_TTL);\
	Set(list,select,$(feed_idx));\
	Set(menu,replace,Select);
Back($$)=\
	Macro(SHOW_FEEDS);\
	Make(mode,default);

[ModeEnd]

[End]
