[Dillo-dev]dillo .filter.dpi mini mini howto
Hello. The DPIP is here, but it seems that developers(external ones) do not make a big use of it. I have made a litle PI to learn how to use DPIs that can help others. This filter dpi uses tidy to see a bad writen page. If i have write this dpi is only because it was more easy to write in shell script than a download dpi with progres indicator, thah was my other option. I agree that tidy is a big thing but in the server side. First of all a filter.dpi is a executable file that reads dillo comands from stdin an ouputs commands and html to stdout. It can be write in any language that can do this. It is possible to do it in shell programing. This file must be in a directory in /usr/local/lib/dillo/ for a local compiled dillo. When you enter a url dpi:/name/otherthings a file /usr/local/lib/dillo/name/name.filter.dpi is executed and a command <dpi cmd='open_url' url='dpi:/name/otherthings'> is send to it. Then the PI can send commands or html page that dillo show. I have try to send more than a page, with and without the reload command, and use another comands but for the moment this do not work for dpi filters. If you add a filter dpi with dpid running do not forget to restart it or reload DPIs using dpidc. To install this PI create a tidy directory in the dillo DPIs directory and copy it named tidy.filter.dpi You can use it to see some bad writen pages with a url like dpi:/tidy/http://page_that_you_can_view_with The PI do not add index.htm automaticaly so put it in the url. I hope that this help somebody to write some better PIs. Diego. ------------------------ #!/bin/sh # characters delimiting the fields for read IFS=" '/" # Read dillo's request read -d'>' tag cmd cmd_value url url_tag1 url_tag2 url_value_e # read put each field in a variable. them looks like: # tag "<dpi" # cmd "cmd=" it can be intersting to test this strings # cmd_value "open_url" for this aplication. Dillo can send "add_bookmark" and # "chat" too.(0.8.0 version) With a case we can respond to every dillo command# url "url=" for this command # url_tag1 "dpi:" for this app ... # url_tag2 "tidy" # url_value_e "http://server.com/path/file.html'" we do not want that final ' # so we delete it url_value=`echo -n "$url_value_e" | tr -d "'"` # get the name of the file name=`basename "$url_value"` # with the follow lines we get the url without the filename without using awk u_tmp1=` echo -n "$url_value" | tr "." "\n" ` u_tmp2=` echo -n "$u_tmp1" | tr "/" "." ` n_tmp=` echo -n "$name" | tr "." "\n" ` b_tmp1=` basename "$u_tmp2" ".$n_tmp" ` b_tmp2=` echo -n "$b_tmp1" | tr "." "/" ` base=` echo -n "$b_tmp2" | tr "\n" "." ` # we change status line with send_status_message PI to Dillo command echo "<dpi cmd='send_status_message' msg='tidy up $url_value. please wait'>" ## we send a wait page with the start_send_page command. We can command dillo## to "reload_request" and "chat" too. (0.8.0 version) #cat <<EOF #<dpi cmd='start_send_page' url='dpi:/tidy/wait.html'> #Content-type: text/html # #<html> # <head> # <title> Wait a moment TYDY up this MESS </title> # </head> # <body> # <h1> # Tidy up this mess ($url_value) <br> # Please wait a moment # </h1> # </body> #</html> # # #EOF # we download the page url_value to /tmp with wget wget --no-parent -nc -nH --cut-dirs=30 -P /tmp/ $url_value # with this the page works in local like from inet. Tidy move base to the# right html place echo "<base href=$base >" >> /tmp/$name # we send the html header # Don't forget the empty line after the Content-type cat <<EOF <dpi cmd='start_send_page' url='$url_value'> Content-type: text/html EOF # and tidy do the rest tidy /tmp/$name # clean up the tmp files rm /tmp/$name ---------------------------------------------
Sorry. The file seems a mess because the new lines was all moved. I try it again. If this not work i will send it atachement. Diego. #!/bin/sh # characters delimiting the fields for read IFS=" '/" # Read dillo's request read -d'>' tag cmd cmd_value url url_tag1 url_tag2 url_value_e # read put each field in a variable. them looks like: # tag "<dpi" # cmd "cmd=" it can be intersting to test this strings # cmd_value "open_url" for this aplication. Dillo can send "add_bookmark" and # "chat" too.(0.8.0 version) With a case we can respond to every dillo command # url "url=" for this command # url_tag1 "dpi:" for this app ... # url_tag2 "tidy" # url_value_e "http://server.com/path/file.html'" we do not want that final ' # so we delete it url_value=`echo -n "$url_value_e" | tr -d "'"` # get the name of the file name=`basename "$url_value"` # with the follow lines we get the url without the filename without using awk u_tmp1=` echo -n "$url_value" | tr "." "\n" ` u_tmp2=` echo -n "$u_tmp1" | tr "/" "." ` n_tmp=` echo -n "$name" | tr "." "\n" ` b_tmp1=` basename "$u_tmp2" ".$n_tmp" ` b_tmp2=` echo -n "$b_tmp1" | tr "." "/" ` base=` echo -n "$b_tmp2" | tr "\n" "." ` # we change status line with send_status_message PI to Dillo command echo "<dpi cmd='send_status_message' msg='tidy up $url_value. please wait'>" ## we send a wait page with the start_send_page command. We can command dillo ## to "reload_request" and "chat" too. (0.8.0 version) #cat <<EOF #<dpi cmd='start_send_page' url='dpi:/tidy/wait.html'> #Content-type: text/html # #<html> # <head> # <title> Wait a moment TYDY up this MESS </title> # </head> # <body> # <h1> # Tidy up this mess ($url_value) <br> # Please wait a moment # </h1> # </body> #</html> # # #EOF # we download the page url_value to /tmp with wget wget --no-parent -nc -nH --cut-dirs=30 -P /tmp/ $url_value # with this the page works in local like from inet. Tidy move base to the # right html place echo "<base href=$base >" >> /tmp/$name # we send the html header # Don't forget the empty line after the Content-type cat <<EOF <dpi cmd='start_send_page' url='$url_value'> Content-type: text/html EOF # and tidy do the rest tidy /tmp/$name # clean up the tmp files rm /tmp/$name
participants (1)
-
Diego Sáenz