author tk posts set to tykayn
This commit is contained in:
parent
0477346379
commit
948fb0cb82
@ -35,7 +35,7 @@ function postLink() {
|
||||
}
|
||||
|
||||
let configPost = {
|
||||
author: 'curator',
|
||||
author: 'tykayn',
|
||||
message: `# [${postObject.post_title}](${postObject.guid})
|
||||
|
||||
* ${postObject.post_date} - ${postObject.guid}
|
||||
|
@ -20,7 +20,7 @@ const selectionOverrideOfSectionTable = '';
|
||||
const selectionOverrideOfLineTable = '';
|
||||
|
||||
// const reallySendToot = false;
|
||||
const reallySendToot = true;
|
||||
const reallySendToot = false;
|
||||
|
||||
function getRandomWikiOSMPage() {
|
||||
|
||||
@ -106,7 +106,7 @@ export default function getElementCartographique() {
|
||||
// console.log("cellules trouvées", keys.length)
|
||||
|
||||
console.log("\n")
|
||||
let result = {
|
||||
let configPost = {
|
||||
key: '',
|
||||
value: '',
|
||||
description: '',
|
||||
@ -115,17 +115,17 @@ export default function getElementCartographique() {
|
||||
cells.each((i, element) => {
|
||||
// console.log("cell element", i, $(element).text().trim())
|
||||
if (i === 0) {
|
||||
result.key = $(element).text().trim();
|
||||
configPost.key = $(element).text().trim();
|
||||
}
|
||||
if (i === 1) {
|
||||
result.value = $(element).text().trim();
|
||||
configPost.value = $(element).text().trim();
|
||||
}
|
||||
if (i === 3) {
|
||||
result.description = $(element).text().replace(' ', '').replace(' ', '').trim();
|
||||
configPost.description = $(element).text().replace(' ', '').replace(' ', '').trim();
|
||||
}
|
||||
})
|
||||
|
||||
if (!result.key) {
|
||||
if (!configPost.key) {
|
||||
console.error("ERROR no key found", $(cells).html())
|
||||
console.error('no key BOOOOOOOOOOH');
|
||||
getElementCartographique();
|
||||
@ -133,18 +133,18 @@ export default function getElementCartographique() {
|
||||
|
||||
// aller chercher le lien
|
||||
// si la clé est une description avec des espaces, faire un lien vers la Key
|
||||
let pageLink = `FR:Tag:${result.key}=${result.value}`
|
||||
let pageLink = `FR:Tag:${configPost.key}=${configPost.value}`
|
||||
|
||||
if (result.value.indexOf(' ') !== -1) {
|
||||
pageLink = `FR:Key:${result.key}`
|
||||
if (configPost.value.indexOf(' ') !== -1) {
|
||||
pageLink = `FR:Key:${configPost.key}`
|
||||
}
|
||||
result.link = `https://wiki.openstreetmap.org/wiki/${pageLink}`
|
||||
configPost.link = `https://wiki.openstreetmap.org/wiki/${pageLink}`
|
||||
|
||||
const url = result.link
|
||||
const url = configPost.link
|
||||
// get a random page wich is not a discussion
|
||||
|
||||
// certaines valeurs ont des espaces, donc pas utilisable en url
|
||||
if (result.value.indexOf(' ') === -1) {
|
||||
if (configPost.value.indexOf(' ') === -1) {
|
||||
|
||||
console.log("url", url)
|
||||
rp(url).then(function (html) {
|
||||
@ -153,21 +153,21 @@ export default function getElementCartographique() {
|
||||
const filteredHtml = $('.mw-parser-output', html).find('p')
|
||||
|
||||
console.log("filteredHtml", filteredHtml.length)
|
||||
result.long_desc = $(filteredHtml).text().substring(0,250)
|
||||
console.log("filteredHtml", result.long_desc)
|
||||
configPost.long_desc = $(filteredHtml).text().substring(0,250)
|
||||
console.log("filteredHtml", configPost.long_desc)
|
||||
|
||||
// image de description:
|
||||
// let imgSelector = ".description a.image img"
|
||||
console.log("✅ cette page existe bien en Français sur le wiki OSM")
|
||||
sendMessageWikiTagOfTheDay(makePostMessageFromObj(result))
|
||||
sendMessageWikiTagOfTheDay(makePostMessageFromObj(configPost))
|
||||
|
||||
}, (err) => {
|
||||
console.error(err.statusCode)
|
||||
if (err.statusCode == 404) {
|
||||
console.log("\n Cette page n'existe pas encore, c'est le moment de la créer.", `https://wiki.openstreetmap.org/w/index.php?title=FR:${result.key}=${result.value}`) //FR:Tag:boundary%3Dborder_zone&action=edit)
|
||||
console.log("\n Cette page n'existe pas encore, c'est le moment de la créer.", `https://wiki.openstreetmap.org/w/index.php?title=FR:${configPost.key}=${configPost.value}`) //FR:Tag:boundary%3Dborder_zone&action=edit)
|
||||
console.log("Essayez de voir si la version en Anglais existe.")
|
||||
let englishPage = `https://wiki.openstreetmap.org/wiki/Tag:${result.key}=${result.value}`
|
||||
let englishKey = `https://wiki.openstreetmap.org/wiki/Key:${result.key}`
|
||||
let englishPage = `https://wiki.openstreetmap.org/wiki/Tag:${configPost.key}=${configPost.value}`
|
||||
let englishKey = `https://wiki.openstreetmap.org/wiki/Key:${configPost.key}`
|
||||
console.log("-> ", englishPage)
|
||||
checkExistenceOfWebPage(englishPage).catch(err=> {
|
||||
checkExistenceOfWebPage( englishKey)
|
||||
@ -178,12 +178,21 @@ export default function getElementCartographique() {
|
||||
|
||||
})
|
||||
} else {
|
||||
console.log("result", result)
|
||||
sendMessageWikiTagOfTheDay(makePostMessageFromObj(result))
|
||||
console.log("result", configPost)
|
||||
rp(configPost.link).then((result) => {
|
||||
console.log("oui cette page existe!", url)
|
||||
sendMessageWikiTagOfTheDay(makePostMessageFromObj(result))
|
||||
}, (err) => {
|
||||
console.log("hé non. WTF ?")
|
||||
// getElementCartographique()
|
||||
|
||||
})
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
return result;
|
||||
return configPost;
|
||||
|
||||
});
|
||||
|
||||
@ -205,8 +214,8 @@ function checkExistenceOfWebPage(url) {
|
||||
function makePostMessageFromObj(result) {
|
||||
return `
|
||||
# [Le tag OSM du jour : ${result.key}=${result.value} ](${result.link}) 🗺️🏷️
|
||||
${result.description.trim()}
|
||||
> ${result.long_desc.trim()}
|
||||
${result.description ? result.description.trim() : ''}
|
||||
> ${result.long_desc ? result.long_desc.trim() : ''}
|
||||
#osm #openstreetmap #wiki #rtfw
|
||||
`
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user