Sophie

Sophie

distrib > Mageia > 7 > armv7hl > media > core-release > by-pkgid > d8544620e4ac7bee48ddb48c85d55709 > files > 538

ikiwiki-3.20190228-1.mga7.noarch.rpm

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Importing posts from Wordpress</title>
<meta name="viewport" content="width=device-width, initial-scale=1" />

<link rel="stylesheet" href="../style.css" type="text/css" />

<link rel="stylesheet" href="../local.css" type="text/css" />










</head>
<body>

<div class="page">

<div class="pageheader">
<div class="header">
<span>
<span class="parentlinks">

<a href="../index.html">ikiwiki</a>/ 

<a href="../tips.html">tips</a>/ 

</span>
<span class="title">
Importing posts from Wordpress

</span>
</span>



</div>









</div>





<div id="pagebody">

<div id="content" role="main">
<p>Use case: You want to move away from Wordpress to Ikiwiki as your blogging/website platform, but you want to retain your old posts.</p>

<p><a href="https://chris-lamb.co.uk/projects/ikiwiki-wordpress-import">This</a> is a simple tool that generates <a href="http://www.kernel.org/pub/software/scm/git/docs/git-fast-import.html">git-fast-import</a>-compatible data from a WordPress export XML file.</p>

<p>WordPress categories are mapped onto Ikiwiki tags. The ability to import comments is planned.</p>

<p>The script uses the <a href="http://www.crummy.com/software/BeautifulSoup/">BeautifulSoup</a> module.</p>

<hr />

<p>I include a modified version of this script. This version includes the ability to write [[!tag  foo]] directives, which the original intended, but didn't actually do.</p>

<p>-- <span class="createlink">simonraven</span></p>

<p><a href="./importing_posts_from_wordpress/ikiwiki-wordpress-import.html">ikiwiki-wordpress-import</a></p>

<hr />

<p>Perhaps slightly insane, but here's an XSLT style sheet that handles my pages.  It's basic, but sufficient to get started.
Note that I had to break up the ikiwiki meta strings to post this.</p>

<p>-- JasonRiedy</p>

<pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
&lt;xsl:stylesheet version="2.0"
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  xmlns:content="http://purl.org/rss/1.0/modules/content/"
  xmlns:wp="http://wordpress.org/export/1.0/"&gt;

&lt;xsl:output method="text"/&gt;
&lt;xsl:output method="text" name="txt"/&gt;

&lt;xsl:variable name='newline'&gt;&lt;xsl:text&gt;
&lt;/xsl:text&gt;&lt;/xsl:variable&gt;

&lt;xsl:template match="channel"&gt;
  &lt;xsl:apply-templates select="item[wp:post_type = 'post']"/&gt;
&lt;/xsl:template&gt;

&lt;xsl:template match="item"&gt;
  &lt;xsl:variable name="idnum" select="format-number(wp:post_id,'0000')" /&gt;
  &lt;xsl:variable name="basename"
        select="concat('wp-posts/post-',&#036;idnum)" /&gt;
  &lt;xsl:variable name="filename"
        select="concat(&#036;basename, '.html')" /&gt;
  &lt;xsl:text&gt;Creating &lt;/xsl:text&gt;
  &lt;xsl:value-of select="concat(&#036;filename, &#036;newline)" /&gt;
  &lt;xsl:result-document href="{&#036;filename}" format="txt"&gt;
    &lt;xsl:text&gt;[[&lt;/xsl:text&gt;&lt;xsl:text&gt;meta title="&lt;/xsl:text&gt;
    &lt;xsl:value-of select="replace(title, '&amp;quot;', '&amp;amp;ldquo;')"/&gt;
    &lt;xsl:text&gt;"]]&lt;/xsl:text&gt;&lt;xsl:value-of select="&#036;newline"/&gt;
    &lt;xsl:text&gt;[[&lt;/xsl:text&gt;&lt;xsl:text&gt;meta date="&lt;/xsl:text&gt;
    &lt;xsl:value-of select="pubDate"/&gt;
    &lt;xsl:text&gt;"]]&lt;/xsl:text&gt;&lt;xsl:value-of select="&#036;newline"/&gt;
    &lt;xsl:text&gt;[[&lt;/xsl:text&gt;&lt;xsl:text&gt;meta updated="&lt;/xsl:text&gt;
    &lt;xsl:value-of select="pubDate"/&gt;
    &lt;xsl:text&gt;"]]&lt;/xsl:text&gt; &lt;xsl:value-of select="&#036;newline"/&gt;
    &lt;xsl:value-of select="&#036;newline"/&gt;
    &lt;xsl:value-of select="content:encoded"/&gt;
    &lt;xsl:text&gt;

&lt;/xsl:text&gt;
    &lt;xsl:apply-templates select="category[@domain='tag' and not(@nicename)]"&gt;
      &lt;xsl:sort select="name()"/&gt;
    &lt;/xsl:apply-templates&gt;
  &lt;/xsl:result-document&gt;
  &lt;xsl:apply-templates select="wp:comment"&gt;
    &lt;xsl:sort select="date"/&gt;
    &lt;xsl:with-param name="basename"&gt;&#036;basename&lt;/xsl:with-param&gt;
  &lt;/xsl:apply-templates&gt;
&lt;/xsl:template&gt;

&lt;xsl:template match="wp:comment"&gt;
  &lt;xsl:param name="basename"/&gt;
  &lt;xsl:variable name="cnum" select="format-number(wp:comment_id, '000')" /&gt;
  &lt;xsl:variable name="filename" select="concat(&#036;basename, '/comment_', &#036;cnum, '._comment')"/&gt;
  &lt;xsl:variable name="nickname" select="concat(' nickname=&amp;quot;', wp:comment_author, '&amp;quot;')" /&gt;
  &lt;xsl:variable name="username" select="concat(' username=&amp;quot;', wp:comment_author_url, '&amp;quot;')" /&gt;
  &lt;xsl:variable name="ip" select="concat(' ip=&amp;quot;', wp:comment_author_IP, '&amp;quot;')" /&gt;
  &lt;xsl:variable name="date" select="concat(' date=&amp;quot;', wp:comment_date_gmt, '&amp;quot;')" /&gt;
  &lt;xsl:result-document href="{&#036;filename}" format="txt"&gt;
    &lt;xsl:text&gt;[[&lt;/xsl:text&gt;&lt;xsl:text&gt;comment format=html&lt;/xsl:text&gt;&lt;xsl:value-of select="&#036;newline"/&gt;
    &lt;xsl:value-of select="&#036;nickname"/&gt;
    &lt;xsl:value-of select="&#036;username"/&gt;
    &lt;xsl:value-of select="&#036;ip"/&gt;
    &lt;xsl:value-of select="&#036;date"/&gt;
    &lt;xsl:text&gt;subject=""&lt;/xsl:text&gt;&lt;xsl:value-of select="&#036;newline"/&gt;
    &lt;xsl:text&gt;content="""&lt;/xsl:text&gt;&lt;xsl:value-of select="&#036;newline"/&gt;
    &lt;xsl:value-of select="wp:comment_content"/&gt;
    &lt;xsl:value-of select="&#036;newline"/&gt;
    &lt;xsl:text&gt;"""]]&lt;/xsl:text&gt;&lt;xsl:value-of select="&#036;newline"/&gt;
  &lt;/xsl:result-document&gt;
&lt;/xsl:template&gt;

&lt;xsl:template match="category"&gt;
  &lt;xsl:text&gt;[&lt;/xsl:text&gt;&lt;xsl:text&gt;[&lt;/xsl:text&gt;&lt;xsl:text&gt;!tag "&lt;/xsl:text&gt;&lt;xsl:value-of select="."/&gt;&lt;xsl:text&gt;"]]&lt;/xsl:text&gt;
  &lt;xsl:value-of select="&#036;newline"/&gt;
&lt;/xsl:template&gt;

&lt;/xsl:stylesheet&gt;
</code></pre>

</div>







</div>

<div id="footer" class="pagefooter" role="contentinfo">

<div id="pageinfo">











<div class="pagedate">
Last edited <span class="date">Tue Feb 26 23:01:54 2019</span>
<!-- Created <span class="date">Fri Oct  5 06:59:14 2007</span> -->
</div>

</div>


<!-- from ikiwiki -->
</div>

</div>

</body>
</html>