Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

hexo-migrator-joomla

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

hexo-migrator-joomla - npm Package Compare versions

Comparing version 2.0.0 to 2.1.0

170

index.js

@@ -1,84 +0,106 @@

var xml2js = require('xml2js'),
async = require('async'),
entities = require('entities'),
TurndownService = require('turndown'),
request = require('request'),
file = require('fs');
/*
* hexo-migrator-joomla
* https://github.com/welksonramos/hexo-migrator-joomla
*
* Copyright (c) 2015-present, Welkson Ramos
* Licensed under the MIT license.
*/
tdS = new TurndownService({});
'use strict';
hexo.extend.migrator.register('joomla', function(args, callback){
var source = args._.shift();
if (!source){
var help = [
'Usage: hexo migrate joomla <source>',
'',
'For more help, you can check the docs: http://hexo.io/docs/migration.html'
];
return callback();
}
var log = hexo.log,
post = hexo.post;
log.i('Analyzing %s...', source);
async.waterfall([
function(next){
// URL regular expression from: http://blog.mattheworiordan.com/post/13174566389/url-regular-expression-for-links-with-or-without-the
if (source.match(/((([A-Za-z]{3,9}:(?:\/\/)?)(?:[-;:&=\+\$,\w]+@)?[A-Za-z0-9.-]+|(?:www.|[-;:&=\+\$,\w]+@)[A-Za-z0-9.-]+)((?:\/[\+~%\/.\w-_]*)?\??(?:[-\+=&;%@.\w_]*)#?(?:[.\!\/\\w]*))?)/)){
request(source, function(err, res, body){
if (err) throw err;
if (res.statusCode == 200) next(null, body);
});
} else {
file.readFile(source, next);
}
},
function(content, next){
xml2js.parseString(content, next);
},
function(xml, next){
var count = 0;
async.each(xml.j2xml.content, function(content, next){
if (!content){
return next();
}
var title = content.title,
id = content.id,
slug = content.alias,
date = content.created,
category = content.catid,
excerpt = content.introtext,
content = content.fulltext,
status = content.state,
categories = [],
tags = [];
const xml2js = require('xml2js');
const async = require('async');
const entities = require('entities');
const TurndownService = require('turndown');
const request = require('request');
const file = require('fs');
if (!title && !slug) return next();
const tdS = new TurndownService({});
title = entities.decodeHTML(title),
date = entities.decodeHTML(date),
excerpt = entities.decodeHTML(excerpt),
content = entities.decodeHTML(content),
count++;
hexo.extend.migrator.register('joomla', (args, callback) => {
const source = args._.shift();
if (typeof content !== 'string' || typeof title !== 'string') content = ' ';
if (!source){
const help = [
`Usage: hexo migrate joomla <source>,
For more help, you can check the docs: http://hexo.io/docs/migration.html`
];
var data = {
title: title,
categories: category || 'uncategorized',
id: +id,
date: date,
content: tdS.turndown(excerpt).replace('/\r\n/g', '\n') + tdS.turndown(content).replace('/\r\n/g', '\n'),
layout: status === '0' ? 'draft' : 'post',
};
console.log(help.join('\n'));
return callback();
}
if (slug) data.slug = slug;
const log = hexo.log;
const post = hexo.post;
log.i('Found: %s', title);
post.create(data, next);
}, function(err){
if (err) return next(err);
log.i('%d posts migrated with success.', count);
log.i('Analyzing %s...', source);
async.waterfall([
function(next){
// URL regular expression from: http://blog.mattheworiordan.com/post/13174566389/url-regular-expression-for-links-with-or-without-the
if (source.match(/((([A-Za-z]{3,9}:(?:\/\/)?)(?:[-;:&=\+\$,\w]+@)?[A-Za-z0-9.-]+|(?:www.|[-;:&=\+\$,\w]+@)[A-Za-z0-9.-]+)((?:\/[\+~%\/.\w-_]*)?\??(?:[-\+=&;%@.\w_]*)#?(?:[.\!\/\\w]*))?)/)){
request(source, (err, res, body) => {
if (err) throw err;
if (res.statusCode == 200) next(null, body);
});
} else {
file.readFile(source, next);
}
},
function(content, next){
xml2js.parseString(content, next);
},
function(xml, next){
let count = 0;
async.each(xml.j2xml.content, (item, next) => {
if (!item){
return next();
}
], callback);
});
let title = item.title;
let id = item.id;
let slug = item.alias;
let date = item.created;
let category = item.catid;
let excerpt = item.introtext;
let content = item.fulltext;
let status = item.state;
let categories = [];
let tags = [];
if (!title && !slug) return next();
title = entities.decodeHTML(title),
date = entities.decodeHTML(date),
excerpt = entities.decodeHTML(excerpt),
content = entities.decodeHTML(content),
count++;
if (typeof content !== 'string' || typeof title !== 'string') content = ' ';
const data = {
title: title,
categories: category || 'uncategorized',
id: +id,
date: date,
content: tdS.turndown(excerpt).replace('/\r\n/g', '\n') + tdS.turndown(content).replace('/\r\n/g', '\n'),
layout: status === '0' ? 'draft' : 'post',
};
if (slug) data.slug = slug;
log.i('Found: %s', title);
post.create(data, next);
}, err => {
if (err) return next(err);
log.i('%d posts migrated with success! ✔', count);
});
}
], callback);
});
{
"name": "hexo-migrator-joomla",
"version": "2.0.0",
"version": "2.1.0",
"description": "Joomla migrator plugin for Hexo",
"main": "index",
"scripts": {
"contrib:add": "all-contributors add",
"contrib:generate": "all-contributors generate"
},
"repository": {

@@ -19,13 +23,13 @@ "type": "git",

"author": "Welkson Ramos <welksonr@hotmail.com>",
"license": {
"type": "MIT",
"url": "https://raw.github.com/welksonramos/hexo-migrator-joomla/master/LICENSE"
},
"license": "MIT",
"dependencies": {
"async": "^1.4.2",
"entities": "^1.1.1",
"request": "^2.36.0",
"async": "^3.1.0",
"entities": "^2.0.0",
"request": "^2.88.0",
"turndown": "^5.0.3",
"xml2js": "^0.4.2"
"xml2js": "^0.4.22"
},
"devDependencies": {
"all-contributors-cli": "^6.11.0"
}
}

@@ -1,7 +0,10 @@

# Joomla migrator [![npm version](https://img.shields.io/npm/v/hexo-migrator-joomla.svg)](https://www.npmjs.com/package/hexo-migrator-joomla) [![depstatus](https://img.shields.io/david/welksonramos/hexo-migrator-joomla.svg)](https://david-dm.org/welksonramos/hexo-migrator-joomla) [![license](https://img.shields.io/npm/l/hexo-migrator-joomla.svg?style=flat)](https://raw.github.com/welksonramos/hexo-migrator-joomla/blob/master/LICENSE)
# hexo-joomla-migrator
Migrate your blog from Joomla to [Hexo].
[![npm version](https://img.shields.io/npm/v/hexo-migrator-joomla.svg)](https://www.npmjs.com/package/hexo-migrator-joomla) [![depstatus](https://img.shields.io/david/welksonramos/hexo-migrator-joomla.svg)](https://david-dm.org/welksonramos/hexo-migrator-joomla) [![license](https://img.shields.io/npm/l/hexo-migrator-joomla.svg?style=flat)](https://raw.github.com/welksonramos/hexo-migrator-joomla/blob/master/LICENSE) [![All Contributors](https://img.shields.io/badge/all_contributors-1-orange.svg?style=flat-square)](#contributors-)
> Migrate your blog from Joomla to [Hexo](https://hexo.io/).
## Install
In your blog folder, add this npm dependencie to your project :
``` bash

@@ -21,6 +24,23 @@ $ npm install hexo-migrator-joomla --save

[Hexo]: http://zespia.tw/hexo
# License
Lincensed under The MIT License (MIT)
## Contributors ✨
Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/docs/en/emoji-key)):
<!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section -->
<!-- prettier-ignore-start -->
<!-- markdownlint-disable -->
<table>
<tr>
<td align="center"><a href="http://jazg.net"><img src="https://avatars2.githubusercontent.com/u/1109168?v=4" width="100px;" alt="Jorge Zapata"/><br /><sub><b>Jorge Zapata</b></sub></a><br /><a href="https://github.com/welksonramos/hexo-migrator-joomla/commits?author=alimnios72" title="Code">💻</a></td>
</tr>
</table>
<!-- markdownlint-enable -->
<!-- prettier-ignore-end -->
<!-- ALL-CONTRIBUTORS-LIST:END -->
This project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind welcome!

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc