Wikini

AutoDecouverteRss

PagePrincipale :: DerniersChangements :: DerniersCommentaires :: ParametresUtilisateur :: Vous êtes ec2-3-230-76-153.compute-1.amazonaws.com
"" repère automatiquement le fil d’information associé à un site et permet de s’y abonner.
Cette technique est décrite

En utilisant la solution donné par ActionsReseauxNumeriques qui, lui-même, a utilisé le code de DavidDelon, on integre dans le footer une ligne de code (voir plus bas) permettant l'AutoDecouverteRss.

Solution pour réduire la charge sur le serveur lors de la lecture du fil des DerniersChangements : enregistrer un fichier .xml statique lors de l'enregistrement d'une page (et non appeler la base pour générer le fil à chaque requête HTTP)

<?php
/*
update_rss.php

Copyright 2003  David DELON
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA


--
x-arn / 2004
*/



$max 10;

if (
$pages $this->LoadRecentlyChanged($max))
{
    if (!(
$link $this->GetParameter("link"))) $link=$this->config["root_page"];
    
$output "<?xml version=\"1.0\" encoding=\"iso-8859-1\" ?>\n";
    
$output .= "<!-- RSS v0.91 generated by Wikini -->\n";
    
$output .= "<rdf:RDF\n";
    
$output .= "xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\"\n";
    
$output .= "xmlns=\"http://my.netscape.com/publish/formats/rss-0.91.dtd\">\n";
 
    
$output .= "<channel>\n";
    
$output .= "<title> Derniers changements sur "$this->config["wakka_name"]  . "</title>\n";
    
$output .= "<link>" $this->config["base_url"] . $link "</link>\n";
    
$output .= "<description> Derniers changements sur " $this->config["wakka_name"] . " </description>\n";
    
$output .= "<language>fr</language>\n";
    
$output .= "</channel>\n";

    foreach (
$pages as $i => $page)
    {
        list(
$day$time) = explode(" "$page["time"]);
        
$daypreg_replace("/-/"" "$day);
        list(
$hh,$mm,$ss) = explode(":"$time);
        
$output .= "<item>\n";
        
$output .= "<title>" $page["tag"] . "</title>\n";//. " --- par " .$page["user"] . " le " . $day ." - ". $hh .":". $mm .
        
$output .= "<description> Modification de " $page["tag"] . " --- par " .$page["user"] . " le " $day ." - "$hh .":"$mm "</description>\n";
        
$output .= "<link>" $this->config["base_url"] . $page["tag"] . "&amp;time=" rawurlencode($page["time"]) . "</link>\n";
        
$output .= "</item>\n";
    }
    
$output .= "</rdf:RDF>\n";
    
    
$f = @fopen("x/rss.xml","w"); // fichier RSS statique dans le dossier 'x'
    
if($f) {
        
fputs($f,$output) ;
        
fclose($f);
    }
}
?>


Il s'agit d'une simple modification de l'action RSS de DavidDelon, placé à la racine du wiki (pour l'include) et non dans les actions.
Dans le cas présenté, le fichier statique rss.xml est placé dans le même dossier que les styles .css (dossier 'x' dans l'exemple) because ReEcritureURL? et pour que ça marche en SafeMode? ... (dixit ActionsReseauxNumeriques exemple: http://www.x-arn.org/w3/x/rss.xml)

Il suffirait ensuite de rajouter un lien de ce type dans le footer :
<link rel="alternate" type="application/rss+xml" title="RSS" href="url/rss.xml" />

Je suis chez Free, et pour l'instant, l'appel du script update_rss.php donne : Call to a member function on a non-object in /var/www/free.fr/1/b/url/wikini/update_rss.php on line 29

>le script doit être appelé par la fonction SavePage? de wakka.php (cf.ci-dessus) pour être éxécuté à chaque modification de page, et non directement par son url. L'erreur vient-elle de là ?

Pourtant l'icone apparait bien en bas de Firefox mais impossible de le lire dans FireFox...

> je crois que firefox propose les fichiers de type mime application/rss+xml en téléchargement plutot que de les ouvrir directement dans le navigateur. si on met l'adresse du flux dans un agrégateur, ça devrait être ok. à vérifier.

Je pense que cette fonction, assez facile à rajouter en apparence, serait un réel plus à apporter à WikiNi...



Chez moi j'ai modifié le fichier Xml/RSS généré par l'action RecentChangesRSS car Firefox n'arrivait pas à l'exploiter (alors que Thunderbird y arrivait si mes souvenirs sont bons). L'icône RSS apparaissait bien dans la barre d'état, mais le marque-page dynamique n'arrivait pas à charger le contenu. Plus bas le code Php de l'action modifiée - je me suis permis de m'ajouter dans le copyright ! J'ai aussi retouché le format des dates / heures et le nombre d'entrées par défaut (50 étant une liste trop longue dans un marque-page).
Par ailleurs il me semblerait plus logique d'intégrer le tag <link rel="..." ...> dans l'entête Html <head>...</head>, cela ne m'étonnerait pas que ce soit requis pour la conformité XHtml.

-- JmPhilippe

<?php
/*
recentchangesrss.php

Copyright 2003  David DELON
Copyright 2004  Jean-Michel PHILIPPE
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
*/

if ($user $this->GetUser())
{
    
$max $user["changescount"];
}
else
{
    
$max 15;
}

if (
$pages $this->LoadRecentlyChanged($max))
{
    if (!(
$link $this->GetParameter("link"))) $link=$this->config["root_page"];
    
$output "<?xml version=\"1.0\" encoding=\"iso-8859-1\" ?>\n";
    
$output .= "<rss version=\"2.0\">\n";
 
    
$output .= "<channel>\n";
    
$output .= "<title> Derniers changements sur "$this->config["wakka_name"]  . "</title>\n";
    
$output .= "<link>" $this->config["base_url"] . $link "</link>\n";
    
$output .= "<description> Derniers changements sur " $this->config["wakka_name"] . " </description>\n";
    
$output .= "<language>fr</language>\n";

    foreach (
$pages as $i => $page)
    {
        list(
$day$time) = explode(" "$page["time"]);
        list(
$year,$month,$day) = explode("-"$day);
        list(
$hh,$mm,$ss) = explode(":"$time);
        
$output .= "<item>\n";
        
$output .= "<title>" $page["tag"] . " --- par " .$page["user"] . " le $day-$month-$year à $hh"h$mm</title>\n";
        
$output .= "<description> Modification de " $page["tag"] . " --- par " .$page["user"] . " le $day-$month-$year à $hh"h$mm</description>\n";
        
$output .= "<link>" $this->config["base_url"] . $page["tag"] . "&amp;time=" rawurlencode($page["time"]) . "</link>\n";
        
$output .= "</item>\n";
    }
    
$output .= "</channel>\n";
    
$output .= "</rss>\n";
    echo 
$output ;
}
?>



Je confirme le bug sur Firefox (et aussi sur ThunderBird? en fait). Le patch marche nickel. CyriL?
Commentaires [Cacher commentaires/formulaire]