Another blog move

(0 comments)

Got access to a new, more powerful server, moved my blog from Mnemosyne to Wordpress, hopefully did not flood p.d.o, did not move the comments over yet.

And not to flood the planet.d.o with the move I did this little change to the Wordpress feed - at the very end of the wp-atom.php file there is this line:


<?php $items_count++; if (($items_count == get_settings('posts_per_rss')) && empty ...

So I changed it to this:


<?php $items_count++; if ((($items_count == get_settings('posts_per_rss')) || $post->post_date < 1150758000 ) && empty ...

Where 1150758000 is the UNIX time of some point between the last post from the old blog and the first post in the new blog.

And I also imported my old posts entries from an Atom feed using the rss feed import as a base. The diff is after the break


--- rss.php 2005-12-28 22:24:12.000000000 +0200
+++ atom.php 2006-06-18 18:26:03.000000000 +0300
@@ -1,13 +1,13 @@
< ?php

-class RSS_Import {
+class Atom_Import {

var $posts = array ();
var $file;

function header() {
echo '<div class="wrap">';
- echo '<h2>'.__('Import RSS').'</h2>';
+ echo '<h2>'.__('Import Atom').'</h2>';
}

function footer() {
@@ -21,8 +21,8 @@
}

function greet() {
- echo '<p>'.__('Howdy! This importer allows you to extract posts from any RSS 2.0 file into your blog. This is useful if you want to import your posts from a system that is not handled by a custom import tool. Pick an RSS file to upload and click Import.').'</p>';
- wp_import_upload_form("admin.php?import=rss&step=1");
+ echo '<p>'.__('Howdy! This importer allows you to extract posts from any ATOM 1.0 file into your blog. This is useful if you want to import your posts from a system that is not handled by a custom import tool. Pick an Atom file to upload and click Import.').'</p>';
+ wp_import_upload_form("admin.php?import=atom&step=1");
}

function get_posts() {
@@ -33,14 +33,14 @@
$importdata = implode('', $datalines); // squish it
$importdata = str_replace(array ("\r\n", "\r"), "\n", $importdata);

- preg_match_all('|<item>(.*?)</item>|is', $importdata, $this->posts);
+ preg_match_all('|<entry>(.*?)</entry>|is', $importdata, $this->posts);
$this->posts = $this->posts[1];
$index = 0;
foreach ($this->posts as $post) {
- preg_match('|<title>(.*?)</title>|is', $post, $post_title);
+ preg_match('|<title [^>]*>(.*?)</title>|is', $post, $post_title);
$post_title = $wpdb->escape(trim($post_title[1]));

- preg_match('|<pubdate>(.*?)</pubdate>|is', $post, $post_date);
+ preg_match('|<published>(.*?)</published>|is', $post, $post_date);

if ($post_date) {
$post_date = strtotime($post_date[1]);
@@ -68,13 +68,13 @@
$cat_index++;
}

- preg_match('|<guid .+?>(.*?)</guid>|is', $post, $guid);
+ preg_match('|<id>(.*?)</id>|is', $post, $guid);
if ($guid)
$guid = $wpdb->escape(trim($guid[1]));
else
$guid = '';

- preg_match('|<content :encoded>(.*?)</content>|is', $post, $post_content);
+ preg_match('|<content [^>]*?>.*?<div .*?>(.*?)</div>\s*?</content>|is', $post, $post_content);
$post_content = str_replace(array ('< ![CDATA[', ']]>'), '', $wpdb->escape(trim($post_content[1])));

if (!$post_content) {
@@ -85,6 +85,7 @@

// Clean up content
$post_content = preg_replace('|< (/?[A-Z]+)|e', "'<' . strtolower('$1')", $post_content);
+ $post_content = str_replace('\n', ' ', $post_content);
$post_content = str_replace('<br>', '<br />', $post_content);
$post_content = str_replace('<hr />', '<hr />', $post_content);

@@ -160,12 +161,12 @@
$this->footer();
}

- function RSS_Import() {
+ function Atom_Import() {
// Nothing.
}
}

-$rss_import = new RSS_Import();
+$atom_import = new Atom_Import();

-register_importer('rss', 'RSS', __('Import posts from an RSS feed'), array ($rss_import, 'dispatch'));
+register_importer('atom', 'Atom', __('Import posts from an Atom feed'), array ($atom_import, 'dispatch'));
?>

Currently unrated

Comments

There are currently no comments

New Comment

required

required (not published)

optional

Recent Posts

Archive

2017
2016
2015
2014
2013
2012
2011
2010
2009
2008
2007
2006
2005

Categories

Authors

Feeds

RSS / Atom