diff --git a/config.json b/config.json index a9f33ed..919dc03 100644 --- a/config.json +++ b/config.json @@ -3,10 +3,10 @@ "SESSION_SECRET": "random-data-to-seed-session-data", - "SQL_HOST": "sql-hostname", - "SQL_DATABASE": "sql-database-name", - "SQL_USER": "sql-user", - "SQL_PASSWORD": "sql-password", + "SQL_HOST": "localhost", + "SQL_DATABASE": "jrtechs_blog", + "SQL_USER": "root", + "SQL_PASSWORD": "password", "CAPTCHA_SECRET": "captcha-secret", diff --git a/package.json b/package.json index 9f552d7..f3f3025 100644 --- a/package.json +++ b/package.json @@ -18,6 +18,7 @@ "promise": "^8.0.1", "request": "^2.88.0", "routes": "^2.1.0", + "rss": "^1.2.2", "sanitizer": "^0.1.3", "sendmail": "^1.4.1", "whiskers": "^0.4.0" diff --git a/routes/index.js b/routes/index.js index bc9b491..48c813c 100644 --- a/routes/index.js +++ b/routes/index.js @@ -53,6 +53,10 @@ routes.use('/steam', project); const api = require('./api'); routes.use('/api', api); +const feed = require('./rss'); +routes.use('/rss', feed); + + //blog home page routes.get('/', (request, result) => { diff --git a/routes/rss.js b/routes/rss.js new file mode 100644 index 0000000..9b4edd7 --- /dev/null +++ b/routes/rss.js @@ -0,0 +1,57 @@ +var RSS = require('rss'); + +const routes = require('express').Router(); + +const pageBuilder = require('../utils/pageBuilder'); + +var feed = new RSS({ + title: 'jrtechs', + description: 'Jeffery\'s blog which has everything from data-science to cooking', + feed_url: 'https://jrtechs.net/rss', + site_url: 'https://jrtechs.net', + image_url: 'https://jrtechs.net/includes/img/favicon/android-chrome-512x512.png', + docs: 'https://github.com/jrtechs/NodeJSBlog', + managingEditor: 'Jeffery Russell', + webMaster: 'Jeffery Russell', + copyright: 'Jeffery Russell', + language: 'en', + categories: ['other', 'hardware', 'open-source', 'programming', 'projects', 'web-development', 'data-science'], +}); + + +// var xml = require('xml'); +var xmlFeed = feed.xml(); + +const sql = require('../utils/sql'); + +sql.getRecentPosts().then((data)=> +{ + for(var i = 0; i < data.length; i++) + { + feed.item({ + title: data[i].name, + url: "https://jrtechs.net/" + data[i].category + "/" + data[i].url, + date: data[i].published + }); + } + xmlFeed = feed.xml(); +}).catch((err)=> +{ + console.log(err); +}); + + + + +routes.get('/', (request, result) => +{ + result.set('Content-Type', 'text/xml'); + result.send(xmlFeed); +}); + +routes.get('*', (request, result) => +{ + pageBuilder.print404(result); +}); + +module.exports = routes; \ No newline at end of file diff --git a/sitemap.txt b/sitemap.txt index 1fe179e..86af81d 100644 --- a/sitemap.txt +++ b/sitemap.txt @@ -1,20 +1,41 @@ http://jrtechs.net/ -http://jrtechs.net/category/projects +http://jrtechs.net/category/hardware http://jrtechs.net/category/java -http://jrtechs.net/category/test -http://jrtechs.net/category/testing-2 -http://jrtechs.net/category/testing-three 3 http://jrtechs.net/category/other -http://jrtechs.net/category/web-development -http://jrtechs.net/category/web-development http://jrtechs.net/category/programming -http://jrtechs.net/projects/steam-friends-graph -http://jrtechs.net/projects/java-fibonacci-solver -http://jrtechs.net/projects/musical-floppy-drive-build-log +http://jrtechs.net/category/projects +http://jrtechs.net/category/web-development +http://jrtechs.net/hardware/2018-rochester-maker-faire +http://jrtechs.net/hardware/ddr4-ram-introduction +http://jrtechs.net/hardware/hard-drive-speeds http://jrtechs.net/java/gremlin-in-10-minutes http://jrtechs.net/java/top-three-recommended-java-ides +http://jrtechs.net/java/bash-usr-bin-java-cannot-execute-binary-file +http://jrtechs.net/other/college-cookbook +http://jrtechs.net/other/2018-in-review +http://jrtechs.net/other/morality-of-self-driving-cars http://jrtechs.net/other/my-college-essay -http://jrtechs.net/web-development/node-website-optimization -http://jrtechs.net/web-development/node-website-optimization +http://jrtechs.net/other/deepfakes +http://jrtechs.net/other/why-do-i-blog +http://jrtechs.net/other/ways-to-avoid-getting-hacked +http://jrtechs.net/other/should-you-run-a-server-on-desktop-hardware +http://jrtechs.net/programming/sorting-algorithms +http://jrtechs.net/programming/knapsack-problem +http://jrtechs.net/programming/cs-theory-exam-2-review +http://jrtechs.net/programming/everything-fibonacci http://jrtechs.net/programming/c-to-c++-tutorial -http://jrtechs.net/programming/gremlin-in-10-minutes +http://jrtechs.net/programming/university-vs-teaching-yourself-programming +http://jrtechs.net/programming/using-english-conventions-to-write-clean-code +http://jrtechs.net/projects/steam-friends-graph +http://jrtechs.net/projects/musical-floppy-drive-build-log +http://jrtechs.net/projects/musical-floppy-drives +http://jrtechs.net/projects/java-fibonacci-solver +http://jrtechs.net/projects/ackermann-function-written-in-java +http://jrtechs.net/projects/batch-minecraft-launcher-with-auto-restart +http://jrtechs.net/projects/time-lapse-programming-zombie-game +http://jrtechs.net/projects/time-lapse-programming-pong +http://jrtechs.net/web-development/lazy-loading-youtube-videos +http://jrtechs.net/web-development/node-website-optimization +http://jrtechs.net/web-development/node-vs-php +http://jrtechs.net/web-development/why-i-stopped-using-wordpress +http://jrtechs.net/web-development/history-of-jrtechs diff --git a/utils/sql.js b/utils/sql.js index ad85a1a..5af915e 100644 --- a/utils/sql.js +++ b/utils/sql.js @@ -135,6 +135,7 @@ const fetchWithCategoryInformation = function(sqlPosts) var obj = new Object(); obj.name = post.name; obj.url = post.url; + obj.published = post.published; obj.category = urls[0].url; res(obj); }); @@ -282,7 +283,7 @@ module.exports= { return new Promise(function(resolve, reject) { - var q = "select name,url, category_id from posts order " + + var q = "select name,url, published, category_id from posts order " + "by post_id desc limit 10"; fetch(q).then(function(sqlPosts) {