Browse Source

Merge pull request #84 from jrtechs/rss

RSS (Closes #83)
pull/86/head
Jeffery Russell 4 years ago
committed by GitHub
parent
commit
08e88cb2ab
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 101 additions and 17 deletions
  1. +4
    -4
      config.json
  2. +1
    -0
      package.json
  3. +4
    -0
      routes/index.js
  4. +57
    -0
      routes/rss.js
  5. +33
    -12
      sitemap.txt
  6. +2
    -1
      utils/sql.js

+ 4
- 4
config.json View File

@ -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",

+ 1
- 0
package.json View File

@ -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"

+ 4
- 0
routes/index.js View File

@ -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) =>
{

+ 57
- 0
routes/rss.js View File

@ -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;

+ 33
- 12
sitemap.txt View File

@ -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

+ 2
- 1
utils/sql.js View File

@ -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)
{

Loading…
Cancel
Save