All scripts in one repository
This commit is contained in:
parent
a0a86492ee
commit
9f9304d6aa
61 changed files with 6668 additions and 681 deletions
pblog2rangitaki
22
pblog2rangitaki/LICENSE
Normal file
22
pblog2rangitaki/LICENSE
Normal file
|
@ -0,0 +1,22 @@
|
|||
COPYRIGHT (c) 2015 mmk2410
|
||||
|
||||
MIT License
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
"Software"), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to
|
||||
permit persons to whom the Software is furnished to do so, subject to
|
||||
the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be
|
||||
included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
31
pblog2rangitaki/README.md
Normal file
31
pblog2rangitaki/README.md
Normal file
|
@ -0,0 +1,31 @@
|
|||
# pblog2rangitaki
|
||||
|
||||
This is a small script which converts pBlog/Rangitaki 0.2.x XML files into Rangitaki blog posts
|
||||
|
||||
## Usage
|
||||
|
||||
You don't need to install this script on your computer, it's enough to make it executable:
|
||||
|
||||
```
|
||||
chmod +x pblog2rangitaki.php
|
||||
```
|
||||
|
||||
Run it then:
|
||||
|
||||
```
|
||||
./pblog2rangitaki.php posts.xml
|
||||
```
|
||||
|
||||
Where `posts.xml` is your pBlog/Rangitaki 0.2 XML file.
|
||||
|
||||
The Rangitaki blog posts are saved in `articles/`
|
||||
|
||||
**The `<otherlinks>` tag is not supported.**
|
||||
|
||||
## HHVM
|
||||
|
||||
This script works also in HHVM. Just replace the first line with
|
||||
|
||||
```
|
||||
#!/bin/hhvm
|
||||
```
|
85
pblog2rangitaki/pblog2rangitaki.php
Executable file
85
pblog2rangitaki/pblog2rangitaki.php
Executable file
|
@ -0,0 +1,85 @@
|
|||
#!/bin/php
|
||||
<?php
|
||||
// This is a php script for converting a pBlog / Rangitaki 0.2.x XML file into rangitaki blog posts
|
||||
if(in_array($argv[1], array("-h", "--help", "--usage", "-?"))) {
|
||||
help();
|
||||
} else if (isset($argv[1])) {
|
||||
$content = file_get_contents("$argv[1]");
|
||||
$xml = new SimpleXMLElement($content);
|
||||
foreach ($xml->post as $entry) {
|
||||
// TITLE
|
||||
$title = $entry->title;
|
||||
|
||||
// CONTENT
|
||||
$content = $entry->content;
|
||||
|
||||
// Pubdate
|
||||
$pubdate = $entry->pubdate;
|
||||
date_default_timezone_set("UTC");
|
||||
$pubdate = date("d F Y", strtotime($pubdate));
|
||||
|
||||
|
||||
|
||||
// FILENAME
|
||||
$date = $entry->pubdate;
|
||||
$date = date("Y-m-d-H-i", strtotime($date));
|
||||
$filetitle = str_replace(" ", "-", $title);
|
||||
$filename = $date . "-" . $filetitle . ".md";
|
||||
|
||||
if(isset($entry->mainlink)){
|
||||
$filecontent = <<<EOD
|
||||
%TITLE: $title
|
||||
%DATE: $pubdate
|
||||
|
||||
$content
|
||||
|
||||
[$entry->mainlink]($entry->mainurl)
|
||||
EOD;
|
||||
} else {
|
||||
$filecontent = <<<EOD
|
||||
%TITLE: $title
|
||||
%DATE: $pubdate
|
||||
|
||||
$content
|
||||
EOD;
|
||||
}
|
||||
|
||||
// Make a output directory
|
||||
if(!(file_exists("articles"))) {
|
||||
mkdir("articles");
|
||||
}
|
||||
|
||||
// Save the file
|
||||
$handle = fopen("articles/$filename", "c");
|
||||
fwrite($handle, $filecontent);
|
||||
fclose($handle);
|
||||
}
|
||||
} else {
|
||||
help();
|
||||
}
|
||||
|
||||
function help() {
|
||||
$help = <<<EOD
|
||||
|
||||
blogger2rangitaki
|
||||
|
||||
A small PHP script which converts pBlog/Rangitaki 0.2.x XML files to Rangitaki blog posts.
|
||||
|
||||
COPYRIGHT © 2015 Rangitaki Project
|
||||
|
||||
MIT License
|
||||
|
||||
Usage:
|
||||
|
||||
./pblog2rangitaki filename.xml
|
||||
|
||||
Where filename.xml is the pBlog XML file.
|
||||
|
||||
The articels are saved in articles/
|
||||
|
||||
The <otherlinks> tag are not supported.
|
||||
|
||||
EOD;
|
||||
|
||||
echo $help;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue