Leggi argomento - [Wordpress] Creare un feed Atom 1.0

Vuoi partecipare? RegistratiRegistrati al forum!

[Wordpress] Creare un feed Atom 1.0

 
Nuovo argomento   Rispondi    Indice del forum -> Servizi e piattaforme
Precedente :: Successivo  
Autore Messaggio
weppos
Amministratore


Registrato: 20/05/06 17:34
Messaggi: 296

MessaggioInviato: Dom Ago 13, 2006 12:27 am    Oggetto: [Wordpress] Creare un feed Atom 1.0 Rispondi citando

L'Atom 1.0 è un formato oramai diffuso e largamente compatibile con la maggior parte dei lettori e parser per feed.
Via via sta sostituendo il precedente Atom 0.3 (con il quale non è retrocompatibile) e lo stesso FeedValidator indica il precedente formato come obsoleto.

E' quindi ora di aggiornare il proprio feed.
Con WordPress è possibile ottenere un feed Atom 1.0 (al posto dello 0.3) seguendo le istruzioni scritte da James Snell.

Scaricate il template http://www.snellspace.com/public/wp.tar.gz e sovrascrivete il vecchio file wp-atom.php nella cartella di WP.
Aggiungete poi anche il file dei commenti.

E' tutto.
Alcuni accorgimenti sono disponibili all'URL http://www.snellspace.com/wp/?p=404

Sembra che questo template non sia compatibile al 100% con PHP 4.
E' comunque disponibile una patch.

Qualcuno ha mai provato questo tutorial?
Top
Profilo Invia messaggio privato
esav
Utente


Registrato: 14/03/07 09:32
Messaggi: 3
Residenza: Toscana - Italy

MessaggioInviato: Mer Mar 14, 2007 9:37 am    Oggetto: Re: [Wordpress] Creare un feed Atom 1.0 Rispondi citando

Provato e funziona ottimamente anche su piattaforma WP 2.0.9

segnalo una correzione da effettuare nei campi Date e Time della patch : Y-m-d\TH:i:s\Z [questa è la giusta sintassi] puoi verificare la validità del feed Atom 1.0 dal footer del mio weblog - inoltre è consigliabile modificare anche il campo title sul link rel presente in header [weblog] : alla voce Atom 0.3 con Atom 1.0

Ad Maiora

esav

notes : attualmente il file di download non risulta disponibile : se dovesse servire dispongo di una copia ! saluti
Top
Profilo Invia messaggio privato HomePage
weppos
Amministratore


Registrato: 20/05/06 17:34
Messaggi: 296

MessaggioInviato: Mer Mar 14, 2007 10:51 am    Oggetto: Rispondi citando

Citazione:
notes : attualmente il file di download non risulta disponibile : se dovesse servire dispongo di una copia ! saluti


Se ti va puoi postarla direttamente qui dentro al tag CODE. Very Happy
Top
Profilo Invia messaggio privato
esav
Utente


Registrato: 14/03/07 09:32
Messaggi: 3
Residenza: Toscana - Italy

MessaggioInviato: Mer Mar 14, 2007 11:41 am    Oggetto: Re: [Wordpress] Creare un feed Atom 1.0 Rispondi citando

Con piacere Simone ... devo molto anche ai tuoi tutorials e articoli ... è il minimo che posso fare !

versione php 5 file wp-atom.php

Codice:

<?php
if (empty($wp)) {
  require_once('wp-config.php');
  wp('feed=atom');
}
header('Content-type: application/atom+xml; charset=' . get_settings('blog_charset'), true);
$more = 1;
?>
<?php echo '<?xml version="1.0"encoding="'.get_settings('blog_charset').'"?'.'>'; ?>
<feed
  xmlns="http://www.w3.org/2005/Atom"
  xmlns:thr="http://purl.org/syndication/thread/1.0"
  xml:lang="<?php echo get_option('rss_language'); ?>"
  xml:base="<?php bloginfo_rss('home') ?>/wp-atom.php">
<? #uncomment and update to include image branding in your feed
   #<icon>/favicon.png</icon>
   #<logo>/feedicon.png</logo> ?>
  <id><?php bloginfo_rss('home') ?>/wp-atom.php</id>
  <updated><?php echo mysql2date('Y-m-d\TH:i:s\Z', get_lastpostmodified('GMT')); ?></updated>
  <title type="text"><?php bloginfo_rss('name') ?></title>
  <subtitle type="text"><?php bloginfo_rss("description") ?></subtitle>
  <link rel="self" type="application/atom+xml" href="<?php bloginfo('url'); ?>/wp-atom.php" />
  <link rel="replies" type="application/atom+xml" href="<?php bloginfo('url'); ?>/wp-commentsatom.php" />
<? #uncomment the following and customize to associate a license with a feed
   #<link rel="license" type="application/rdf+xml" href="http://creativecommons.org/licenses/by-nc/2.5/rdf" /> ?>
  <link href="<?php bloginfo_rss('home') ?>" />
  <rights type="text">Copyright <?php echo mysql2date('Y', get_lastpostdate('blog')); ?></rights>
  <generator uri="http://wordpress.org/" version="<?php bloginfo_rss('version'); ?>">WordPress</generator>
  <?php $items_count = 0; if ($posts) { foreach ($posts as $post) { start_wp(); ?>
  <entry>
    <id><?php the_guid(); ?></id>
    <title type="html"><![CDATA[<?php the_title_rss() ?>]]></title>
<? # this will work if running in PHP5
   #I may just be missing something, but prior to PHP5, it seems the only way to
   #get a properly formatted Atom date is to hard code the timezone offset, e.g.,
   #the_time('Y-m-d\TH:i:s-08:00'); ?>
    <updated><?php the_time('c'); ?></updated>
    <published><?php the_time('c'); ?></published>
    <author>
      <name><?php the_author()?></name>
      <email><?php the_author_email()?></email>
      <uri><?php the_author_url()?></uri>
    </author>
    <? #uncomment the following and customize to associate a license with an entry
    #<link rel="license" type="application/rdf+xml" href="http://creativecommons.org/licenses/by-nc/2.5/rdf" /> ?>
    <link rel="replies" type="application/atom+xml" href="<?php bloginfo_rss('home') ?>/wp-commentsatom.php?p=<?php the_id(); ?>" thr:count="<?php comments_number('0', '1', '%', 'number'); ?>"  />
    <link href="<?php permalink_single_rss() ?>" />
<?php foreach(get_the_category() as $category) { ?>
    <category scheme="<?php bloginfo_rss('home') ?>" term="<?php echo $category->cat_name?>" />
<?php } ?>       
    <summary type="html"><![CDATA[<?php the_excerpt_rss(); ?>]]></summary>
<?php if (!get_settings('rss_use_excerpt')) : ?>
  <?php if ( strlen( $post->post_content ) ) : ?>
    <content type="html" xml:base="<?php permalink_single_rss() ?>"><![CDATA[<?php the_content('', 0, '') ?>]]></content>
  <?php else : ?>
    <content type="html" xml:base="<?php permalink_single_rss() ?>"><![CDATA[<?php the_excerpt_rss(); ?>]]></content>
  <?php endif; ?>
<?php else : ?>
    <content type="html" xml:base="<?php permalink_single_rss() ?>"><![CDATA[<?php the_excerpt_rss() ?>]]></content>
<?php endif; ?>
  </entry>
  <?php $items_count++; if (($items_count == get_settings('posts_per_rss')) && empty($m)) { break; } } } ?>
</feed>


file wp-commentsatom.php

Codice:

<?php
if (empty($wp)) {
  require_once('wp-config.php');
  wp('feed=atom');
}
header('Content-type: application/atom+xml;charset=' . get_settings('blog_charset'), true);
echo '<?xml version="1.0" encoding="'.get_settings('blog_charset').'"?'.'>';
?>
<feed xmlns="http://www.w3.org/2005/Atom"
      xmlns:thr="http://purl.org/syndication/thread/1.0"
      xml:base="<?php (is_single()) ? permalink_single_rss() : bloginfo_rss("url") ?>">
<?php
$i = 0;
if (have_posts()) :
  while (have_posts()) : the_post();
   if ($i < 1) {
      $i++;
?>
  <?#<icon>/favicon.png</icon>
  #<logo>/feedicon.png</logo> ?>
   <id><?php (is_single()) ? permalink_single_rss() : bloginfo_rss("url") ?></id>
   <title type="html"><![CDATA[<?php if (is_single() || is_page()) { echo "Comments on: "; the_title_rss(); } else { bloginfo_rss("name"); echo " Comments"; } ?>]]></title>
  <updated><?php echo mysql2date('Y-m-d\TH:i:s\Z', get_lastpostmodified('GMT')); ?></updated>
   <link rel="self" href="<?php bloginfo_rss('home') ?>/wp-commentsatom.php" />
   <? #<link rel="license" type="application/rdf+xml" href="http://creativecommons.org/licenses/by-nc/2.5/rdf" />?>
  <link href="<?php (is_single()) ? permalink_single_rss() : bloginfo_rss("url") ?>" />   
  <author>
    <name><?php the_author() ?></name>
  </author>
   <generator uri="http://wordpress.org/" version="<?php bloginfo_rss('version'); ?>">WordPress</generator>

<?php
      if (is_single() || is_page()) {
         $comments = $wpdb->get_results("SELECT comment_ID, comment_author, comment_author_email,
         comment_author_url, comment_date, comment_content, comment_post_ID,
         $wpdb->posts.ID, $wpdb->posts.post_password FROM $wpdb->comments
         LEFT JOIN $wpdb->posts ON comment_post_id = id WHERE comment_post_ID = '$id'
         AND $wpdb->comments.comment_approved = '1' AND ($wpdb->posts.post_status = 'publish' OR $wpdb->posts.post_status = 'page')
         AND post_date < '".date("Y-m-d H:i:59")."'
         ORDER BY comment_date LIMIT " . get_settings('posts_per_rss') );
      } else { // if no post id passed in, we'll just ue the last 10 comments.
         $comments = $wpdb->get_results("SELECT comment_ID, comment_author, comment_author_email,
         comment_author_url, comment_date, comment_content, comment_post_ID,
         $wpdb->posts.ID, $wpdb->posts.post_password FROM $wpdb->comments
         LEFT JOIN $wpdb->posts ON comment_post_id = id WHERE $wpdb->posts.post_status = 'publish'
         AND $wpdb->comments.comment_approved = '1' AND post_date < '".date("Y-m-d H:i:s")."' 
         ORDER BY comment_date DESC LIMIT " . get_settings('posts_per_rss') );
      }
   // this line is WordPress' motor, do not delete it.
      if ($comments) {
         foreach ($comments as $comment) {
?>
   <entry>
    <id><?php comment_link() ?></id>
    <updated><?php echo comment_time('c'); ?></updated>
      <title type="html"><![CDATA[by: <?php echo comment_author_rss() ?>]]></title>
     <author>
         <name><?php echo $comment->comment_author() ?></name>
      <uri><?php echo $comment->comment_author_url;?></uri>
      </author>
      <link href="<?php comment_link() ?>" />
      <thr:in-reply-to ref="<?php bloginfo_rss('home') ?>/?p=<?php echo $comment->comment_post_ID;?>" href="<?php bloginfo_rss('home') ?>/?p=<?php echo $comment->comment_post_ID;?>" type="application/xhtml+xml" source="<?php bloginfo_rss('home') ?>/wp-atom.php"/>
      <link rel="related" type="text/html" href="<?php bloginfo_rss('home') ?>/?p=<?php echo $comment->comment_post_ID;?>" />
         <?php
         if (!empty($comment->post_password) && $_COOKIE['wp-postpass'] != $comment->post_password) {
         ?>
      <summary>Protected Comments: Please enter your password to view comments.</summary>
      <content type="html"><![CDATA[<?php echo get_the_password_form() ?>]]></content>
         <?php
         } else {
         ?>
      <summary type="html"><![CDATA[<?php comment_text_rss() ?>]]></summary>
      <content type="html"><![CDATA[<?php comment_text() ?>]]></content>
         <?php
         } // close check for password
         ?>
   </entry>
<?php
         }
      }
   }
endwhile; endif;
?>
</feed>


modifica file php 4 wp-atom.php

Codice:

<?php
if (empty($wp)) {
  require_once('wp-config.php');
  wp('feed=atom');
}
header('Content-type: application/atom+xml; charset=' . get_settings('blog_charset'), true);
$more = 1;
?>
<?php echo '<?xml version="1.0" encoding="'.get_settings('blog_charset').'"?'.'>'; ?>
<feed
  xmlns="http://www.w3.org/2005/Atom"
  xmlns:thr="http://purl.org/syndication/thread/1.0"
  xml:lang="<?php echo get_option('rss_language'); ?>"
  xml:base="<?php bloginfo_rss('home') ?>/wp-atom.php">
<? #uncomment and update to include image branding in your feed
   #<icon>/favicon.png</icon>
   #<logo>/feedicon.png</logo> ?>
  <id><?php bloginfo_rss('home') ?>/wp-atom.php</id>
  <updated><?php echo mysql2date('Y-m-d\TH:i:s\Z', get_lastpostmodified('GMT')); ?></updated>
  <title type="text"><?php bloginfo_rss('name') ?></title>
  <subtitle type="text"><?php bloginfo_rss("description") ?></subtitle>
  <link rel="self" type="application/atom+xml"
href="<?php bloginfo('url'); ?>/feed/atom/" />
  <link rel="replies" type="application/atom+xml" href="<?php bloginfo('url'); ?>/wp-commentsatom.php" />
<? #uncomment the following and customize to associate a license with a feed
   #<link rel="license" type="application/rdf+xml" href="http://creativecommons.org/licenses/by-nc/2.5/rdf" /> ?>
  <link href="<?php bloginfo_rss('home') ?>" />
  <rights type="text">Copyright <?php echo mysql2date('Y', get_lastpostdate('blog')); ?></rights>
  <generator uri="http://wordpress.org/" version="<?php bloginfo_rss('version'); ?>">WordPress</generator>
  <?php $items_count = 0; if ($posts) { foreach ($posts as $post) { start_wp(); ?>
  <entry>
    <id><?php the_guid(); ?></id>
    <title type="html"><![CDATA[<?php the_title_rss() ?>]]></title>
<? # this will work if running in PHP5
   #I may just be missing something, but prior to PHP5, it seems the only way to
   #get a properly formatted Atom date is to hard code the timezone offset, e.g.,
   #the_time('Y-m-d\TH:i:s-08:00'); ?>
    <updated><?php the_time('Y-m-d\TH:i:s\Z'); ?></updated>
<published><?php the_time('Y-m-d\TH:i:s\Z'); ?></published>    <author>
      <name><?php the_author()?></name>
      <email><?php the_author_email()?></email>
      <uri><?php the_author_url()?></uri>
    </author>
    <? #uncomment the following and customize to associate a license with an entry
    #<link rel="license" type="application/rdf+xml" href="http://creativecommons.org/licenses/by-nc/2.5/rdf" /> ?>
    <link rel="replies" type="application/atom+xml" href="<?php bloginfo_rss('home') ?>/wp-commentsatom.php?p=<?php the_id(); ?>" thr:count="<?php comments_number('0', '1', '%', 'number'); ?>"  />
    <link href="<?php permalink_single_rss() ?>" />
<?php foreach(get_the_category() as $category) { ?>
    <category scheme="<?php bloginfo_rss('home') ?>" term="<?php echo $category->cat_name?>" />
<?php } ?>       
    <summary type="html"><![CDATA[<?php the_excerpt_rss(); ?>]]></summary>
<?php if (!get_settings('rss_use_excerpt')) : ?>
  <?php if ( strlen( $post->post_content ) ) : ?>
    <content type="html" xml:base="<?php permalink_single_rss() ?>"><![CDATA[<?php the_content('', 0, '') ?>]]></content>
  <?php else : ?>
    <content type="html" xml:base="<?php permalink_single_rss() ?>"><![CDATA[<?php the_excerpt_rss(); ?>]]></content>
  <?php endif; ?>
<?php else : ?>
    <content type="html" xml:base="<?php permalink_single_rss() ?>"><![CDATA[<?php the_excerpt_rss() ?>]]></content>
<?php endif; ?>
  </entry>
  <?php $items_count++; if (($items_count == get_settings('posts_per_rss')) && empty($m)) { break; } } } ?>
</feed>


php 5 inserire nella directory WP i due file [eliminando il vecchio wp-atom]

php 4 inserire nella directory WP [wp-atom.php] e [wp-comentsatom.php]

saluti spero sia chiaro !

note : copia+incolla listato su blocco notes di windows e salvare con estenzione php
Top
Profilo Invia messaggio privato HomePage
weppos
Amministratore


Registrato: 20/05/06 17:34
Messaggi: 296

MessaggioInviato: Mer Mar 14, 2007 6:26 pm    Oggetto: Rispondi citando

Gentilissimo!

Mi sa che dovrò aggiornare i CSS per rendere il contenuto del tag CODE più leggibile. Rolling Eyes
Top
Profilo Invia messaggio privato
esav
Utente


Registrato: 14/03/07 09:32
Messaggi: 3
Residenza: Toscana - Italy

MessaggioInviato: Gio Mar 15, 2007 9:16 pm    Oggetto: Rispondi citando

Simone ... non sò cosa sia successo ... in anteprima il contenuto del CODE era allineato ... dopo l'invio si è presentato cosi . Cmq se viene copiato su file txt torna corretto .. anche come numeri di linea
saluti e buon lavoro
Top
Profilo Invia messaggio privato HomePage
weppos
Amministratore


Registrato: 20/05/06 17:34
Messaggi: 296

MessaggioInviato: Lun Mar 19, 2007 11:53 pm    Oggetto: Rispondi citando

esav ha scritto:
Simone ... non sò cosa sia successo ... in anteprima il contenuto del CODE era allineato ... dopo l'invio si è presentato cosi . Cmq se viene copiato su file txt torna corretto .. anche come numeri di linea
saluti e buon lavoro


Tranquillo, è il CSS del forum. Wink
Top
Profilo Invia messaggio privato
Mostra prima i messaggi di:   
Nuovo argomento   Rispondi    Indice del forum -> Servizi e piattaforme Tutti i fusi orari sono GMT + 1 ora
Pagina 1 di 1

 
Vai a:  
Non puoi inserire nuovi argomenti
Non puoi rispondere a nessun argomento
Non puoi modificare i tuoi messaggi
Non puoi cancellare i tuoi messaggi
Non puoi votare nei sondaggi