Added new features - fixed export from WP_activites.

WP_conferences still uses local backup copy.
This commit is contained in:
Julio Ruiz 2026-02-08 05:31:47 -05:00
parent 155db6157d
commit c1b62b0a97
8 changed files with 966 additions and 54 deletions

View File

@ -261,5 +261,5 @@ function writeFile(jsonlData, type) {
//for( let year = 2021; year < 2027; year++){
//generateJson( 'activities_translations' );
generateJson( 'conferences_translations' );
generateJson( 'activities_translations' );
//}

View File

@ -0,0 +1,232 @@
//import fetch from 'node-fetch'; // For ES Modules
const fs = require('fs');
const path = require('path');
const striptags = require('striptags');
const dayjs = require('dayjs');
const he = require('he');
const jsonTojsonl = require('json-to-jsonl');
const fetch = require('node-fetch'); // For CommonJS
const { start } = require('repl');
const request = require('request');
let { render } = require("mustache");
let jsonlData = '';
const DATA_INPUT_FOLDER = './input';
const DATA_OUTPUT_FOLDER = './output';
const TEMPLATES_FOLDER = './templates';
const LOCALE = 'es';
function generateMarkdown(type) {
const folderPath = `${DATA_INPUT_FOLDER}/${type}`;
const files = fs.readdirSync(folderPath);
const jsonFiles = files.filter(file => file.endsWith('.json'));
const summary = [];
jsonFiles.forEach(file => {
const startYear = path.basename(file, '.json');
const filePath = path.join(folderPath, file);
const content = fs.readFileSync(filePath, 'utf8');
const data = JSON.parse(content);
//Init year for summaries
yearObject = {};
yearObject.year = startYear;
yearObject.count = data.length;
//Init months object for summary
let months = {};
let template = fs.readFileSync(`./${TEMPLATES_FOLDER}/${type}.md`).toString()
data.map((conference) => {
let month = conference.date.substring(5, 7);
let output = render(template, conference)
if (!fs.existsSync(`./${DATA_OUTPUT_FOLDER}/${type}`)) {
fs.mkdirSync(`./${DATA_OUTPUT_FOLDER}/${type}`);
}
if (!fs.existsSync(`./${DATA_OUTPUT_FOLDER}/${type}/${startYear}`)) {
fs.mkdirSync(`./${DATA_OUTPUT_FOLDER}/${type}/${startYear}`);
}
if (!fs.existsSync(`./${DATA_OUTPUT_FOLDER}/${type}/${startYear}/${month}`)) {
fs.mkdirSync(`./${DATA_OUTPUT_FOLDER}/${type}/${startYear}/${month}`);
}
fs.writeFileSync(`./${DATA_OUTPUT_FOLDER}/${type}/${startYear}/${month}/${conference.date}-${conference.activity}.md`, output)
//Add month count for summary
const m = conference.date.substring(5, 7);
if (!months.hasOwnProperty(m)) {
months[m] = []
}
months[m].push(m)
})
let monthsArray = [];
for (const month in months) {
let mObject = {};
mObject.month = month;
mObject.count = months[month].length;
monthsArray.push(mObject);
}
//Sort monthsarray
monthsArray.sort((a, b) => b.month - a.month); // b - a for reverse sort
yearObject.months = monthsArray;
summary.push(yearObject);
})
fs.writeFileSync(`./${DATA_OUTPUT_FOLDER}/${type}/${type}.json`, JSON.stringify(summary.reverse(), null, 2));
console.log(`Summary created successfully.`);
}
async function generateJson( type, year ) {
let options = { json: true };
let url
if( type === 'activities' ){
url = `https://actividadeswp.carpa.com/v3/actividades/?f=texts&locale=${LOCALE}&year=${year}&limit=1000`;
} else {
//url = `https://conferenciaswp.carpa.com/v3/conferencias/?f=algolia&locale=${LOCALE}&year=${year}&limit=1000&cache=false`;
url = `http://localhost:10018/v3/conferencias/?f=typesense&locale=${LOCALE}&year=${year}`;
}
request(url, options, async (error, res, body) => {
if (error) {
return console.log(error)
};
if (!error && res.statusCode == 200) {
if( body ){
// do something with JSON, using the 'body' variable
let items = []
console.log( body.length + " items found for year " + year + " and type " + type );
items = body;
if(items.length > 0) {
items.map((item) => {
if( item.id == null || item.id == undefined || item.id == '' ) {
console.log( "Item has no id, skipping." );
return false;
}})
}
let nitems = items.map((item) => {
let nitem = {}
if (type == 'activities') {
nitem.id = item.id.toString()
nitem.type = 'activities'
nitem.title = item.title
nitem.date = dayjs(item.date).unix()
nitem.activity = parseInt(item.activity)
nitem.bible_study = parseInt(item.bible_study)
nitem.place = item.place || null;
nitem.city = item.city || null;
nitem.state = item.state || null;
nitem.country = item.country || null;
nitem.duration = item.duration ?? 0;
nitem.body = item.translations?.[0]?.interventions?.[0]?.text
//nitem.text = striptags(he.decode(item.translations?.[0]?.interventions?.[0]?.text || ''))
nitem.draft = item.draft
nitem.private = false
nitem.year = dayjs(item.date).year().toString()
nitem.month = (dayjs(item.date).month() + 1).toString().padStart(2, "0")
nitem.thumbnail = item.thumbnail
nitem.slug = item.translations[0]?.interventions[0]?.slug
nitem.files = {}
nitem.files.youtube = item.youtube
nitem.files.video = item.files?.videos?.file
nitem.files.audio = item.files?.audios[0]?.[0]?.file2
nitem.files.booklet = item.files?.textos[0]?.[1]?.file2
//Filter out anything before 25/12/2021
if( nitem.date < 1640408400 ) {
return false
}
}
if (type == 'conferences') {
nitem.id = item.id.toString()
nitem.type = 'conferences'
nitem.title = item.title
nitem.date = item.timestamp
nitem.activity = parseInt(item.activity)
//nitem.bible_study = parseInt(item.bible_study)
//nitem.place = item.conferences_id?.place || null;
nitem.city = item.city || null;
nitem.state = item.state || null;
nitem.country = item.country || null;
nitem.duration = item.duration ?? 0;
nitem.body = item.body
nitem.private = item.private == 1 ? true : false;
//nitem.draft = item.draft
nitem.year = dayjs(item.date).year().toString()
nitem.month = (dayjs(item.date).month() + 1).toString().padStart(2, "0")
nitem.thumbnail = item.thumbnail
nitem.slug = item.slug
nitem.files = {}
nitem.files.youtube = item.files?.youtube
nitem.files.video = item.files?.video
nitem.files.audio = item.files?.audio
nitem.files.booklet = item.files?.pdf
nitem.files.simple = item.files?.pdf_simple
}
if (nitem.title && nitem.id) {
return nitem;
}
})
jsonlData += nitems.filter(item => item !== false).map(JSON.stringify).join('\n')
//console.log( documents.length + " documents to write for year " + year + " and type " + type );
writeFile(jsonlData, type, year)
};
}
});
}
async function writeFile(jsonlData, type, year) {
fs.writeFile(`./${DATA_INPUT_FOLDER}/${type}_wp_${LOCALE.toLocaleUpperCase()}.json`, jsonlData, (err) => {
if (err) {
console.error("Error writing file:", err);
return;
}
console.log("File has been written successfully! : " + type + " / " + year);
});
}
//generateJson( 'conferences', 1974);
//generateJson( 'activities' , 2021 );
// setTimeout( () => {
// generateMarkdown( 'conferences' )
// }, 5000 );
//generateMarkdown( 'activities' );
//generateMarkdown( 'conferences' );
for( let year = 1974; year < 2019; year++){
generateJson( 'conferences', year );
}
// for( let year = 2021; year < 2027; year++){
// generateJson( 'activities', year );
// //generateJson( 'activities_translations' );
// }

View File

@ -0,0 +1,102 @@
let mysql = require('mysql');
let con = mysql.createConnection({
host: "192.168.10.68",
user: "admin",
//port: 3306,
password: "210875",
database: "wpconferences"
});
async function getConferences(){
let confResult
let selectConferences = `SELECT
CAST(P.ID as CHAR(10)) as id,
P.post_title AS title,
UNIX_TIMESTAMP(P.post_date) AS date,
P.post_name AS slug,
P.post_content AS content,
CASE
WHEN P.post_status = 'private' THEN true
ELSE false
END AS private,
MD.activity AS duration,
MD.activity AS activity,
MD.city AS city,
MD.state AS state,
MD.country AS country,
PMA.meta_value AS thumbnail,
MF.youtube,
MF.video,
MF.audio,
MF.pdf,
MF.pdf_simple,
MF.videofile,
MF.audiofile,
MF.pdffile,
MF.pdfsimplefile
FROM
wp_posts P
LEFT JOIN wp_messagedata MD ON
P.id = MD.post_id
LEFT JOIN wp_postmeta PM ON
PM.post_id = P.id AND PM.meta_key = '_thumbnail_id'
LEFT JOIN wp_postmeta PMA ON
PM.meta_value = PMA.post_id AND PMA.meta_key = '_wp_attached_file'
LEFT JOIN wp_messagefiles MF ON
MF.post_id = P.id
WHERE
P.post_type = 'conferencias'`;
con.connect(function(err) {
if (err) throw err;
con.query( selectConferences, function (err, result, fields) {
if (err) throw err;
confResult = result
return confResult
});
});
}
let conferences = getConferences().then( console.log ('DONE' ));
console.log( conferences )
// {
// //"id": "51031",
// //"type": "activities",
// //"title": "Jóvenes guiados por la Columna de Fuego en la Enseñanza bajo Carpa",
// //"date": 1703879492,
// //"activity": "1",
// //"bible_study": "",
// //"place": "La Gran Carpa Catedral",
// //"city": "Cayey",
// //"state": null,
// //"country": "PR",
// //"duration": 0,
// //"body": "a",
// //"private": false,
// //"year": "2023",
// //"month": "2023 > 12",
// //"slug": "jovenes-guiados-por-la-columna-de-fuego-en-la-ensenanza-bajo-carpa",
// "links": {
// "youtube": "",
// "audio": "2023/12/2023-12-29-1-JBP-jovenes_guiados_por_la_columna_de_fuego.mp3",
// "booklet": "2023/12/2023-12-29-1-JBP-jovenes_guiados_por_la_columna_de_fuego-booklet.pdf",
// "simple": "2023/12/2023-12-29-1-JBP-jovenes_guiados_por_la_columna_de_fuego-sencillo.pdf"
// },
// "relations": {
// "translations": [
// {
// "locale":"en",
// "id":"5030"
// },
// {
// "locale":"en",
// "id":"5030"
// },
// ]
// }
// }

File diff suppressed because one or more lines are too long

View File

@ -9,11 +9,13 @@
"version": "1.0.0",
"license": "ISC",
"dependencies": {
"cheerio": "^1.2.0",
"dayjs": "^1.11.19",
"he": "^1.2.0",
"json-to-frontmatter-markdown": "^1.0.0",
"json-to-jsonl": "^1.1.0",
"mustache": "^4.2.0",
"mysql": "^2.18.1",
"node-fetch": "^3.3.2",
"request": "^2.88.2",
"striptags": "^3.2.0"
@ -83,12 +85,69 @@
"tweetnacl": "^0.14.3"
}
},
"node_modules/bignumber.js": {
"version": "9.0.0",
"resolved": "https://registry.npmjs.org/bignumber.js/-/bignumber.js-9.0.0.tgz",
"integrity": "sha512-t/OYhhJ2SD+YGBQcjY8GzzDHEk9f3nerxjtfa6tlMXfe7frs/WozhvCNoGvpM0P3bNf3Gq5ZRMlGr5f3r4/N8A==",
"license": "MIT",
"engines": {
"node": "*"
}
},
"node_modules/boolbase": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/boolbase/-/boolbase-1.0.0.tgz",
"integrity": "sha512-JZOSA7Mo9sNGB8+UjSgzdLtokWAky1zbztM3WRLCbZ70/3cTANmQmOdR7y2g+J0e2WXywy1yS468tY+IruqEww==",
"license": "ISC"
},
"node_modules/caseless": {
"version": "0.12.0",
"resolved": "https://registry.npmjs.org/caseless/-/caseless-0.12.0.tgz",
"integrity": "sha512-4tYFyifaFfGacoiObjJegolkwSU4xQNGbVgUiNYVUxbQ2x2lUsFvY4hVgVzGiIe6WLOPqycWXA40l+PWsxthUw==",
"license": "Apache-2.0"
},
"node_modules/cheerio": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/cheerio/-/cheerio-1.2.0.tgz",
"integrity": "sha512-WDrybc/gKFpTYQutKIK6UvfcuxijIZfMfXaYm8NMsPQxSYvf+13fXUJ4rztGGbJcBQ/GF55gvrZ0Bc0bj/mqvg==",
"license": "MIT",
"dependencies": {
"cheerio-select": "^2.1.0",
"dom-serializer": "^2.0.0",
"domhandler": "^5.0.3",
"domutils": "^3.2.2",
"encoding-sniffer": "^0.2.1",
"htmlparser2": "^10.1.0",
"parse5": "^7.3.0",
"parse5-htmlparser2-tree-adapter": "^7.1.0",
"parse5-parser-stream": "^7.1.2",
"undici": "^7.19.0",
"whatwg-mimetype": "^4.0.0"
},
"engines": {
"node": ">=20.18.1"
},
"funding": {
"url": "https://github.com/cheeriojs/cheerio?sponsor=1"
}
},
"node_modules/cheerio-select": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/cheerio-select/-/cheerio-select-2.1.0.tgz",
"integrity": "sha512-9v9kG0LvzrlcungtnJtpGNxY+fzECQKhK4EGJX2vByejiMX84MFNQw4UxPJl3bFbTMw+Dfs37XaIkCwTZfLh4g==",
"license": "BSD-2-Clause",
"dependencies": {
"boolbase": "^1.0.0",
"css-select": "^5.1.0",
"css-what": "^6.1.0",
"domelementtype": "^2.3.0",
"domhandler": "^5.0.3",
"domutils": "^3.0.1"
},
"funding": {
"url": "https://github.com/sponsors/fb55"
}
},
"node_modules/combined-stream": {
"version": "1.0.8",
"resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz",
@ -107,6 +166,34 @@
"integrity": "sha512-3lqz5YjWTYnW6dlDa5TLaTCcShfar1e40rmcJVwCBJC6mWlFuj0eCHIElmG1g5kyuJ/GD+8Wn4FFCcz4gJPfaQ==",
"license": "MIT"
},
"node_modules/css-select": {
"version": "5.2.2",
"resolved": "https://registry.npmjs.org/css-select/-/css-select-5.2.2.tgz",
"integrity": "sha512-TizTzUddG/xYLA3NXodFM0fSbNizXjOKhqiQQwvhlspadZokn1KDy0NZFS0wuEubIYAV5/c1/lAr0TaaFXEXzw==",
"license": "BSD-2-Clause",
"dependencies": {
"boolbase": "^1.0.0",
"css-what": "^6.1.0",
"domhandler": "^5.0.2",
"domutils": "^3.0.1",
"nth-check": "^2.0.1"
},
"funding": {
"url": "https://github.com/sponsors/fb55"
}
},
"node_modules/css-what": {
"version": "6.2.2",
"resolved": "https://registry.npmjs.org/css-what/-/css-what-6.2.2.tgz",
"integrity": "sha512-u/O3vwbptzhMs3L1fQE82ZSLHQQfto5gyZzwteVIEyeaY5Fc7R4dapF/BvRoSYFeqfBk4m0V1Vafq5Pjv25wvA==",
"license": "BSD-2-Clause",
"engines": {
"node": ">= 6"
},
"funding": {
"url": "https://github.com/sponsors/fb55"
}
},
"node_modules/dashdash": {
"version": "1.14.1",
"resolved": "https://registry.npmjs.org/dashdash/-/dashdash-1.14.1.tgz",
@ -143,6 +230,61 @@
"node": ">=0.4.0"
}
},
"node_modules/dom-serializer": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/dom-serializer/-/dom-serializer-2.0.0.tgz",
"integrity": "sha512-wIkAryiqt/nV5EQKqQpo3SToSOV9J0DnbJqwK7Wv/Trc92zIAYZ4FlMu+JPFW1DfGFt81ZTCGgDEabffXeLyJg==",
"license": "MIT",
"dependencies": {
"domelementtype": "^2.3.0",
"domhandler": "^5.0.2",
"entities": "^4.2.0"
},
"funding": {
"url": "https://github.com/cheeriojs/dom-serializer?sponsor=1"
}
},
"node_modules/domelementtype": {
"version": "2.3.0",
"resolved": "https://registry.npmjs.org/domelementtype/-/domelementtype-2.3.0.tgz",
"integrity": "sha512-OLETBj6w0OsagBwdXnPdN0cnMfF9opN69co+7ZrbfPGrdpPVNBUj02spi6B1N7wChLQiPn4CSH/zJvXw56gmHw==",
"funding": [
{
"type": "github",
"url": "https://github.com/sponsors/fb55"
}
],
"license": "BSD-2-Clause"
},
"node_modules/domhandler": {
"version": "5.0.3",
"resolved": "https://registry.npmjs.org/domhandler/-/domhandler-5.0.3.tgz",
"integrity": "sha512-cgwlv/1iFQiFnU96XXgROh8xTeetsnJiDsTc7TYCLFd9+/WNkIqPTxiM/8pSd8VIrhXGTf1Ny1q1hquVqDJB5w==",
"license": "BSD-2-Clause",
"dependencies": {
"domelementtype": "^2.3.0"
},
"engines": {
"node": ">= 4"
},
"funding": {
"url": "https://github.com/fb55/domhandler?sponsor=1"
}
},
"node_modules/domutils": {
"version": "3.2.2",
"resolved": "https://registry.npmjs.org/domutils/-/domutils-3.2.2.tgz",
"integrity": "sha512-6kZKyUajlDuqlHKVX1w7gyslj9MPIXzIFiz/rGu35uC1wMi+kMhQwGhl4lt9unC9Vb9INnY9Z3/ZA3+FhASLaw==",
"license": "BSD-2-Clause",
"dependencies": {
"dom-serializer": "^2.0.0",
"domelementtype": "^2.3.0",
"domhandler": "^5.0.3"
},
"funding": {
"url": "https://github.com/fb55/domutils?sponsor=1"
}
},
"node_modules/ecc-jsbn": {
"version": "0.1.2",
"resolved": "https://registry.npmjs.org/ecc-jsbn/-/ecc-jsbn-0.1.2.tgz",
@ -153,6 +295,31 @@
"safer-buffer": "^2.1.0"
}
},
"node_modules/encoding-sniffer": {
"version": "0.2.1",
"resolved": "https://registry.npmjs.org/encoding-sniffer/-/encoding-sniffer-0.2.1.tgz",
"integrity": "sha512-5gvq20T6vfpekVtqrYQsSCFZ1wEg5+wW0/QaZMWkFr6BqD3NfKs0rLCx4rrVlSWJeZb5NBJgVLswK/w2MWU+Gw==",
"license": "MIT",
"dependencies": {
"iconv-lite": "^0.6.3",
"whatwg-encoding": "^3.1.1"
},
"funding": {
"url": "https://github.com/fb55/encoding-sniffer?sponsor=1"
}
},
"node_modules/entities": {
"version": "4.5.0",
"resolved": "https://registry.npmjs.org/entities/-/entities-4.5.0.tgz",
"integrity": "sha512-V0hjH4dGPh9Ao5p0MoRY6BVqtwCjhz6vI5LT8AJ55H+4g9/4vbHx1I54fS0XuclLhDHArPQCiMjDxjaL8fPxhw==",
"license": "BSD-2-Clause",
"engines": {
"node": ">=0.12"
},
"funding": {
"url": "https://github.com/fb55/entities?sponsor=1"
}
},
"node_modules/extend": {
"version": "3.0.2",
"resolved": "https://registry.npmjs.org/extend/-/extend-3.0.2.tgz",
@ -279,6 +446,37 @@
"he": "bin/he"
}
},
"node_modules/htmlparser2": {
"version": "10.1.0",
"resolved": "https://registry.npmjs.org/htmlparser2/-/htmlparser2-10.1.0.tgz",
"integrity": "sha512-VTZkM9GWRAtEpveh7MSF6SjjrpNVNNVJfFup7xTY3UpFtm67foy9HDVXneLtFVt4pMz5kZtgNcvCniNFb1hlEQ==",
"funding": [
"https://github.com/fb55/htmlparser2?sponsor=1",
{
"type": "github",
"url": "https://github.com/sponsors/fb55"
}
],
"license": "MIT",
"dependencies": {
"domelementtype": "^2.3.0",
"domhandler": "^5.0.3",
"domutils": "^3.2.2",
"entities": "^7.0.1"
}
},
"node_modules/htmlparser2/node_modules/entities": {
"version": "7.0.1",
"resolved": "https://registry.npmjs.org/entities/-/entities-7.0.1.tgz",
"integrity": "sha512-TWrgLOFUQTH994YUyl1yT4uyavY5nNB5muff+RtWaqNVCAK408b5ZnnbNAUEWLTCpum9w6arT70i1XdQ4UeOPA==",
"license": "BSD-2-Clause",
"engines": {
"node": ">=0.12"
},
"funding": {
"url": "https://github.com/fb55/entities?sponsor=1"
}
},
"node_modules/http-signature": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/http-signature/-/http-signature-1.2.0.tgz",
@ -294,12 +492,36 @@
"npm": ">=1.3.7"
}
},
"node_modules/iconv-lite": {
"version": "0.6.3",
"resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.6.3.tgz",
"integrity": "sha512-4fCk79wshMdzMp2rH06qWrJE4iolqLhCUH+OiuIgU++RB0+94NlDL81atO7GX55uUKueo0txHNtvEyI6D7WdMw==",
"license": "MIT",
"dependencies": {
"safer-buffer": ">= 2.1.2 < 3.0.0"
},
"engines": {
"node": ">=0.10.0"
}
},
"node_modules/inherits": {
"version": "2.0.4",
"resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz",
"integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==",
"license": "ISC"
},
"node_modules/is-typedarray": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/is-typedarray/-/is-typedarray-1.0.0.tgz",
"integrity": "sha512-cyA56iCMHAh5CdzjJIa4aohJyeO1YbwLi3Jc35MmRU6poroFjIGZzUzupGiRPOjgHg9TLu43xbpwXk523fMxKA==",
"license": "MIT"
},
"node_modules/isarray": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz",
"integrity": "sha512-VLghIWNM6ELQzo7zwmcg0NmTVyWKYjvIeM83yjp0wRDTmUnrM678fQbcKBo6n2CJEF0szoG//ytg+TKla89ALQ==",
"license": "MIT"
},
"node_modules/isstream": {
"version": "0.1.2",
"resolved": "https://registry.npmjs.org/isstream/-/isstream-0.1.2.tgz",
@ -419,6 +641,27 @@
"mustache": "bin/mustache"
}
},
"node_modules/mysql": {
"version": "2.18.1",
"resolved": "https://registry.npmjs.org/mysql/-/mysql-2.18.1.tgz",
"integrity": "sha512-Bca+gk2YWmqp2Uf6k5NFEurwY/0td0cpebAucFpY/3jhrwrVGuxU2uQFCHjU19SJfje0yQvi+rVWdq78hR5lig==",
"license": "MIT",
"dependencies": {
"bignumber.js": "9.0.0",
"readable-stream": "2.3.7",
"safe-buffer": "5.1.2",
"sqlstring": "2.3.1"
},
"engines": {
"node": ">= 0.6"
}
},
"node_modules/mysql/node_modules/safe-buffer": {
"version": "5.1.2",
"resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz",
"integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==",
"license": "MIT"
},
"node_modules/node-domexception": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/node-domexception/-/node-domexception-1.0.0.tgz",
@ -457,6 +700,18 @@
"url": "https://opencollective.com/node-fetch"
}
},
"node_modules/nth-check": {
"version": "2.1.1",
"resolved": "https://registry.npmjs.org/nth-check/-/nth-check-2.1.1.tgz",
"integrity": "sha512-lqjrjmaOoAnWfMmBPL+XNnynZh2+swxiX3WUE0s4yEHI6m+AwrK2UZOimIRl3X/4QctVqS8AiZjFqyOGrMXb/w==",
"license": "BSD-2-Clause",
"dependencies": {
"boolbase": "^1.0.0"
},
"funding": {
"url": "https://github.com/fb55/nth-check?sponsor=1"
}
},
"node_modules/oauth-sign": {
"version": "0.9.0",
"resolved": "https://registry.npmjs.org/oauth-sign/-/oauth-sign-0.9.0.tgz",
@ -466,12 +721,67 @@
"node": "*"
}
},
"node_modules/parse5": {
"version": "7.3.0",
"resolved": "https://registry.npmjs.org/parse5/-/parse5-7.3.0.tgz",
"integrity": "sha512-IInvU7fabl34qmi9gY8XOVxhYyMyuH2xUNpb2q8/Y+7552KlejkRvqvD19nMoUW/uQGGbqNpA6Tufu5FL5BZgw==",
"license": "MIT",
"dependencies": {
"entities": "^6.0.0"
},
"funding": {
"url": "https://github.com/inikulin/parse5?sponsor=1"
}
},
"node_modules/parse5-htmlparser2-tree-adapter": {
"version": "7.1.0",
"resolved": "https://registry.npmjs.org/parse5-htmlparser2-tree-adapter/-/parse5-htmlparser2-tree-adapter-7.1.0.tgz",
"integrity": "sha512-ruw5xyKs6lrpo9x9rCZqZZnIUntICjQAd0Wsmp396Ul9lN/h+ifgVV1x1gZHi8euej6wTfpqX8j+BFQxF0NS/g==",
"license": "MIT",
"dependencies": {
"domhandler": "^5.0.3",
"parse5": "^7.0.0"
},
"funding": {
"url": "https://github.com/inikulin/parse5?sponsor=1"
}
},
"node_modules/parse5-parser-stream": {
"version": "7.1.2",
"resolved": "https://registry.npmjs.org/parse5-parser-stream/-/parse5-parser-stream-7.1.2.tgz",
"integrity": "sha512-JyeQc9iwFLn5TbvvqACIF/VXG6abODeB3Fwmv/TGdLk2LfbWkaySGY72at4+Ty7EkPZj854u4CrICqNk2qIbow==",
"license": "MIT",
"dependencies": {
"parse5": "^7.0.0"
},
"funding": {
"url": "https://github.com/inikulin/parse5?sponsor=1"
}
},
"node_modules/parse5/node_modules/entities": {
"version": "6.0.1",
"resolved": "https://registry.npmjs.org/entities/-/entities-6.0.1.tgz",
"integrity": "sha512-aN97NXWF6AWBTahfVOIrB/NShkzi5H7F9r1s9mD3cDj4Ko5f2qhhVoYMibXF7GlLveb/D2ioWay8lxI97Ven3g==",
"license": "BSD-2-Clause",
"engines": {
"node": ">=0.12"
},
"funding": {
"url": "https://github.com/fb55/entities?sponsor=1"
}
},
"node_modules/performance-now": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/performance-now/-/performance-now-2.1.0.tgz",
"integrity": "sha512-7EAHlyLHI56VEIdK57uwHdHKIaAGbnXPiw0yWbarQZOKaKpvUIgW0jWRVLiatnM+XXlSwsanIBH/hzGMJulMow==",
"license": "MIT"
},
"node_modules/process-nextick-args": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.1.tgz",
"integrity": "sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag==",
"license": "MIT"
},
"node_modules/psl": {
"version": "1.15.0",
"resolved": "https://registry.npmjs.org/psl/-/psl-1.15.0.tgz",
@ -502,6 +812,27 @@
"node": ">=0.6"
}
},
"node_modules/readable-stream": {
"version": "2.3.7",
"resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.7.tgz",
"integrity": "sha512-Ebho8K4jIbHAxnuxi7o42OrZgF/ZTNcsZj6nRKyUmkhLFq8CHItp/fy6hQZuZmP/n3yZ9VBUbp4zz/mX8hmYPw==",
"license": "MIT",
"dependencies": {
"core-util-is": "~1.0.0",
"inherits": "~2.0.3",
"isarray": "~1.0.0",
"process-nextick-args": "~2.0.0",
"safe-buffer": "~5.1.1",
"string_decoder": "~1.1.1",
"util-deprecate": "~1.0.1"
}
},
"node_modules/readable-stream/node_modules/safe-buffer": {
"version": "5.1.2",
"resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz",
"integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==",
"license": "MIT"
},
"node_modules/request": {
"version": "2.88.2",
"resolved": "https://registry.npmjs.org/request/-/request-2.88.2.tgz",
@ -560,6 +891,15 @@
"integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==",
"license": "MIT"
},
"node_modules/sqlstring": {
"version": "2.3.1",
"resolved": "https://registry.npmjs.org/sqlstring/-/sqlstring-2.3.1.tgz",
"integrity": "sha512-ooAzh/7dxIG5+uDik1z/Rd1vli0+38izZhGzSa34FwR7IbelPWCCKSNIl8jlL/F7ERvy8CB2jNeM1E9i9mXMAQ==",
"license": "MIT",
"engines": {
"node": ">= 0.6"
}
},
"node_modules/sshpk": {
"version": "1.18.0",
"resolved": "https://registry.npmjs.org/sshpk/-/sshpk-1.18.0.tgz",
@ -585,6 +925,21 @@
"node": ">=0.10.0"
}
},
"node_modules/string_decoder": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz",
"integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==",
"license": "MIT",
"dependencies": {
"safe-buffer": "~5.1.0"
}
},
"node_modules/string_decoder/node_modules/safe-buffer": {
"version": "5.1.2",
"resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz",
"integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==",
"license": "MIT"
},
"node_modules/striptags": {
"version": "3.2.0",
"resolved": "https://registry.npmjs.org/striptags/-/striptags-3.2.0.tgz",
@ -622,6 +977,15 @@
"integrity": "sha512-KXXFFdAbFXY4geFIwoyNK+f5Z1b7swfXABfL7HXCmoIWMKU3dmS26672A4EeQtDzLKy7SXmfBu51JolvEKwtGA==",
"license": "Unlicense"
},
"node_modules/undici": {
"version": "7.21.0",
"resolved": "https://registry.npmjs.org/undici/-/undici-7.21.0.tgz",
"integrity": "sha512-Hn2tCQpoDt1wv23a68Ctc8Cr/BHpUSfaPYrkajTXOS9IKpxVRx/X5m1K2YkbK2ipgZgxXSgsUinl3x+2YdSSfg==",
"license": "MIT",
"engines": {
"node": ">=20.18.1"
}
},
"node_modules/uri-js": {
"version": "4.4.1",
"resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.4.1.tgz",
@ -631,6 +995,12 @@
"punycode": "^2.1.0"
}
},
"node_modules/util-deprecate": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz",
"integrity": "sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==",
"license": "MIT"
},
"node_modules/uuid": {
"version": "3.4.0",
"resolved": "https://registry.npmjs.org/uuid/-/uuid-3.4.0.tgz",
@ -663,6 +1033,28 @@
"engines": {
"node": ">= 8"
}
},
"node_modules/whatwg-encoding": {
"version": "3.1.1",
"resolved": "https://registry.npmjs.org/whatwg-encoding/-/whatwg-encoding-3.1.1.tgz",
"integrity": "sha512-6qN4hJdMwfYBtE3YBTTHhoeuUrDBPZmbQaxWAqSALV/MeEnR5z1xd8UKud2RAkFoPkmB+hli1TZSnyi84xz1vQ==",
"deprecated": "Use @exodus/bytes instead for a more spec-conformant and faster implementation",
"license": "MIT",
"dependencies": {
"iconv-lite": "0.6.3"
},
"engines": {
"node": ">=18"
}
},
"node_modules/whatwg-mimetype": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/whatwg-mimetype/-/whatwg-mimetype-4.0.0.tgz",
"integrity": "sha512-QaKxh0eNIi2mE9p2vEdzfagOKHCcj1pJ56EEHGQOVxp8r9/iszLUUV7v89x9O1p/T+NlTM5W7jW6+cz4Fq1YVg==",
"license": "MIT",
"engines": {
"node": ">=18"
}
}
}
}

View File

@ -9,11 +9,13 @@
"license": "ISC",
"description": "",
"dependencies": {
"cheerio": "^1.2.0",
"dayjs": "^1.11.19",
"he": "^1.2.0",
"json-to-frontmatter-markdown": "^1.0.0",
"json-to-jsonl": "^1.1.0",
"mustache": "^4.2.0",
"mysql": "^2.18.1",
"node-fetch": "^3.3.2",
"request": "^2.88.2",
"striptags": "^3.2.0"

View File

@ -0,0 +1,159 @@
<?php
// error_reporting(E_ALL); // Report all PHP errors
// ini_set('display_errors', '1'); // Display errors in the browser
// ini_set('display_startup_errors', '1');
ini_set('max_execution_time', 300);
ini_set('memory_limit', -1);
ob_start();
// specify your own database credentials
$host = "localhost";
$db_name = "wp0075397";
$username = "wpuser15904";
$password = "NYhu7fjlB8H0uCa";
$conn;
try{
$conn = new PDO("mysql:host=" . $host . ";dbname=" . $db_name, $username, $password);
$conn->exec("set names utf8");
}catch(PDOException $exception){
echo "Connection error: " . $exception->getMessage();
}
function translation_list(){ //Default last updated
//Check locale and change accordingly to the right DB prefix for that locale
$locale = "fr";
$prefix = get_blog_by_locale( $locale );
$sql = "SELECT
P.ID,
P.post_title AS title,
P.post_date AS cdate,
P.post_name AS slug,
P.post_content AS content,
P.post_status AS status,
MD.activity AS duration,
MD.activity AS activity,
MD.city AS city,
MD.state AS state,
MD.country AS country,
MD.private AS private,
PMA.meta_value AS thumbnail
FROM
".$prefix."posts P
LEFT JOIN wp_messagedata MD ON
P.id = MD.post_id
LEFT JOIN wp_postmeta PM ON
PM.post_id = P.ID AND PM.meta_key = '_thumbnail_id'
LEFT JOIN wp_postmeta PMA ON
PM.meta_value = PMA.post_id AND PMA.meta_key = '_wp_attached_file'
WHERE
P.post_type = 'conferencias'";
//return $this->execute_sql( $sql );
return $sql;
}
/**
* Helper function to get all blogs and their languages
*/
function get_blog_by_locale($locale){
$r = '';
switch($locale){
case "fr_FR":
case "fr":
$r = "wp_4_";
break;
case "en":
case "en_US":
$r = "wp_2_";
break;
case "pt":
case "pt-br":
case "pt_br":
case "pt_BR":
$r = "wp_3_";
break;
case "es":
case "es_ES":
default:
$r = "wp_";
break;
}
return $r;
}
function hmsToSeconds($hms) {
$parts = explode(':', $hms);
// Use type casting to ensure the values are treated as numbers
$hours = (int)$parts[0];
$minutes = (int)$parts[1];
$seconds = (int)$parts[2];
// Calculate total seconds
$totalSeconds = ($hours * 3600) + ($minutes * 60) + $seconds;
return $totalSeconds;
}
function send_response( $data ){
// set response code - 200 OK
header('Content-Type: application/json; charset=utf-8');
http_response_code(200);
echo json_encode(
$data, JSON_UNESCAPED_UNICODE
);
$output = ob_get_contents();
ob_end_clean();
echo $output;
}
$stmt = $conn->prepare( translation_list() );
$stmt->execute();
$num = $stmt->rowCount();
if($num>0){
$conferences_arr=[];
while ($row = $stmt->fetch(PDO::FETCH_ASSOC)){
extract($row);
$response_item=array(
"id" => (string)$ID,
"type" => "conferences",
"title" => $title,
"date" => strtotime($cdate),
"activity" => (int)$activity,
"slug" => $slug,
"private" => ($private?true:false),
"city" => $city,
"state" => $state,
"country" => $country,
"thumbnail" => $thumbnail,
"slug" => $slug,
"duration" => hmsToSeconds($duration),
"year" => substr($cdate,0,4),
"month" => substr($cdate,0,4) . " > " .substr($cdate,5,2),
"body" => $content
);
array_push( $conferences_arr, $response_item );
}
}
send_response( $conferences_arr );
// nitem.youtube = item.youtube
// nitem.video = item.files?.videos?.file
// nitem.audio = item.files?.audios[0]?.[0]?.file2
// nitem.booklet = item.files?.textos[0]?.[1]?.file2
// nitem.simple = item.files?.textos[0]?.[0]?.file2

View File

@ -1,5 +1,6 @@
{
"name": "activities_ES",
"name": "es_paragraphs",
"enable_nested_fields": true,
"fields": [
{
"name": "id",
@ -7,19 +8,26 @@
"facet": false
},
{
"name": "type",
"name": "objectID",
"type": "string",
"facet": false
},
{
"name": "type",
"type": "string",
"facet": true
},
{
"name": "title",
"type": "string",
"facet": false
"facet": false,
"sort": true
},
{
"name": "date",
"type": "int32",
"facet": false
"facet": false,
"sort": true
},
{
"name": "activity",
@ -27,42 +35,65 @@
"facet":false,
"optional": true
},
{
"name": "bible_study",
"type": "int32",
"facet": false,
"optional": true
},
{
"name": "place",
"type": "string",
"facet": true,
"optional": true
"optional": true,
"sort": true
},
{
"name": "city",
"type": "string",
"facet": true,
"optional": true
"optional": true,
"sort": true
},
{
"name": "state",
"type": "string",
"facet": true,
"optional": true
"optional": true,
"sort": true
},
{
"name": "country",
"type": "string",
"facet": true,
"optional": true
"optional": true,
"sort": true
},
{
"name": "duration",
"type": "int32",
"facet": true,
"optional": true,
"sort": true
},
{
"name": "html",
"type": "string",
"facet": false,
"optional": true
},
{
"name": "body",
"name": "text",
"type": "string",
"facet": false,
"optional": true
},
{
"name": "draft",
"type": "bool",
"facet": true,
"optional": true
},
{
"name": "private",
"type": "bool",
@ -72,36 +103,12 @@
{
"name": "year",
"type": "string",
"facet":true
"facet": true
},
{
"name": "month",
"type": "string",
"facet":true
},
{
"name": "menu_country",
"type": "string",
"facet":true,
"optional": true
},
{
"name": "menu_state",
"type": "string",
"facet":true,
"optional": true
},
{
"name": "menu_city",
"type": "string",
"facet":true,
"optional": true
},
{
"name": "menu_place",
"type": "string",
"facet":true,
"optional": true
"facet": true
},
{
"name": "thumbnail",
@ -116,33 +123,27 @@
"optional": true
},
{
"name": "youtube",
"type": "string",
"facet":true,
"name": "files",
"type": "object[]",
"facet":false,
"optional": true
},
{
"name": "video",
"type": "string",
"facet":true,
"name": "translations",
"type": "object[]",
"facet":false,
"optional": true
},
{
"name": "audio",
"type": "string",
"facet":true,
"name": "relations",
"type": "object[]",
"facet":false,
"optional": true
},
{
"name": "booklet",
"type": "string",
"facet":true,
"optional": true
},
{
"name": "simple",
"type": "string",
"facet":true,
"name": "order",
"type": "int32",
"facet":false,
"optional": true
}
],