Initial commit

This commit is contained in:
chris062689
2017-02-26 16:24:53 -05:00
parent dfec052adc
commit 0330cac113
153 changed files with 9720 additions and 1 deletions

2
scripts/twitter/.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
node_modules/
*.log

37
scripts/twitter/app.js Normal file
View File

@ -0,0 +1,37 @@
var fs = require('fs');
var logger = require('winston');
var jsonfile = require('jsonfile');
var outputFile = '../../site/data/twitter.json';
var tweets = [
{
"id": "817201197065109505",
"order": 1,
"date": "01/05/2017",
"author": "citraemu",
"image": "https://pbs.twimg.com/profile_images/699782793736359936/eMLbnRNR_normal.png",
"message": "Citra nightlies are back up and better than ever! Sorry for the delay and Happy New Year!"
},
{
"id": "776626520110399488",
"order": 2,
"date": "09/15/2016",
"author": "citraemu",
"image": "https://pbs.twimg.com/profile_images/699782793736359936/eMLbnRNR_normal.png",
"message": "After much anticipation, Citra now has a JIT! Props again to @MerryMage for another massive contribution to the project!!"
},
{
"id": "733831257398747137",
"order": 3,
"date": "05/20/2016",
"author": "citraemu",
"image": "https://pbs.twimg.com/profile_images/699782793736359936/eMLbnRNR_normal.png",
"message": "Props to @MerryMage for a fantastic job on Citra's audio support https://t.co/Z23AWxcDkf"
}
];
jsonfile.writeFile(outputFile, tweets, function (err) {
if (err) { logger.error(err); return; }
logger.info(`Wrote ${tweets.length} tweets to ${outputFile}`)
})

View File

@ -0,0 +1,15 @@
{
"name": "citra-twitter",
"version": "1.0.0",
"description": "Used in Citra Hugo to import Twitter tweets.",
"homepage": "https://citra-emu.org/",
"author": "Flame Sage <chris062689@gmail.com>",
"main": "app.js",
"dependencies": {
"jsonfile": "^2.4.0",
"winston": "^2.2.0"
},
"preferGlobal": false,
"private": true,
"license": "GPLv3"
}

3
scripts/wiki/.gitignore vendored Normal file
View File

@ -0,0 +1,3 @@
node_modules/
citra.wiki/
*.log

90
scripts/wiki/app.js Normal file
View File

@ -0,0 +1,90 @@
var fs = require('fs');
var util = require('util');
var logger = require('winston');
var sanitizeHtml = require('sanitize-html');
var del = require('delete');
var exec = require('sync-exec');
var inputDirectory = './citra.wiki/';
var outputDirectory = '../../site/content/wiki/';
function url(title) {
return '/wiki/' + title.replace(/\s+/g, '-');
}
if (fs.existsSync(inputDirectory)) {
logger.info(`Purging input directory: ${outputDirectory}`);
del.sync(outputDirectory, {force: true});
}
exec('git clone https://github.com/citra-emu/citra.wiki.git');
if (fs.existsSync(outputDirectory) == false) {
logger.info(`Creating missing output directory: ${outputDirectory}`);
fs.mkdirSync(outputDirectory);
}
fs.readdir(inputDirectory, function(err, items) {
try {
// Look for all .md files within the wiki directory.
items.filter(file => file.substr(-3) === '.md').forEach(function(item) {
// Generate the title from the filename.
let title = item.replace(/-/g, ' ').slice(0, -3);
var stats = fs.statSync(`${inputDirectory}${item}`);
var modified = new Date(util.inspect(stats.mtime));
// Read the .md file.
fs.readFile(`${inputDirectory}${item}`, 'utf8', function (err,data) {
if (err) { logger.error(err); return; }
try {
// Convert various data inside of the markdown language.
let cleanData = sanitizeHtml(data);
// Blackfriday Markdown Rendering requires a blank line before lists.
try {
var lines = cleanData.split(/\r?\n/);
for(var i = 0; i < lines.length; i++) {
// If it's the start of the file, ignore to prevent an index issue.
if (i > lines.length) { return; }
if (i == 0 || lines[i] == '\n') { continue; }
// Search for the start of a list designated by the * character.
if (lines[i].startsWith("* ") && lines[i - 1].startsWith("* ") == false) {
i = i + 1;
lines.splice(i - 1, 0, '');
}
}
cleanData = lines.join('\n');
} catch (ex) {
logger.error(ex);
}
// Replacing tags like [[Common Issues on Windows|Common Issues]]
cleanData = cleanData.replace(/\[\[(.*)\|(.*)\]\]/g, function(match, p1, p2) {
return `[${p1}](${url(p2)})`
});
// Replacing tags like [[Common Issues]]
cleanData = cleanData.replace(/\[\[(.*)\]\]/g, function(match, p1) {
return `[${p1}](${url(p1)})`
});
// Create the new markdown header for Hugo.
let newFileContents = `+++\ntitle = "${title}"\ndate = "${modified.toISOString()}"\n+++\n${cleanData}`;
fs.writeFile(`${outputDirectory}${item}`, newFileContents, function(err) {
if (err) return logger.error(err);
logger.info(`Wrote file ${item} to filesystem.`);
});
} catch (ex) {
logger.error(ex);
}
});
});
} catch (ex) {
logger.error(ex);
}
});

18
scripts/wiki/package.json Normal file
View File

@ -0,0 +1,18 @@
{
"name": "citra-wiki",
"version": "1.0.0",
"description": "Used in Citra Hugo to import Wiki articles.",
"homepage": "https://citra-emu.org/",
"author": "Flame Sage <chris062689@gmail.com>",
"main": "app.js",
"dependencies": {
"delete": "^0.3.2",
"rimraf": "^2.6.1",
"sanitize-html": "^1.14.1",
"sync-exec": "^0.6.2",
"winston": "^2.2.0"
},
"preferGlobal": false,
"private": true,
"license": "GPLv3"
}