Skip to content
Permalink
Browse files

Resolve #77 Blogs sitemaps (#81)

* Sitemap builder finished
  • Loading branch information...
bgornicki committed Mar 5, 2019
1 parent bacac24 commit 789be1e05da00bed859bb613183f798c14ae2108
Showing with 3,089 additions and 13 deletions.
  1. +3 −0 .gitmodules
  2. +1 −0 development-deploy.sh
  3. +5 −0 docker-compose.dblog.production.yml
  4. +11 −0 docker-compose.engrave.development.yml
  5. +5 −0 docker-compose.engrave.production.yml
  6. +1 −1 engrave-api-gateway/src/submodules/engrave-shared
  7. +1 −1 engrave-auth/src/submodules/engrave-shared
  8. +1 −1 engrave-blockchain-tracker/src/submodules/engrave-shared
  9. +2 −0 engrave-blogs-renderer/src/routes/frontend/frontend.routes.ts
  10. +27 −0 engrave-blogs-renderer/src/routes/frontend/routes/sitemap.ts
  11. +24 −0 engrave-blogs-renderer/src/services/sitemap/actions/getSitemap.ts
  12. +7 −0 engrave-blogs-renderer/src/services/sitemap/sitemap.service.ts
  13. +1 −1 engrave-blogs-renderer/src/submodules/engrave-shared
  14. +21 −3 engrave-front-dashboard/src/routes/dashboard/posts.ts
  15. +24 −0 engrave-front-dashboard/src/services/sitemap/actions/getSitemap.ts
  16. +24 −0 engrave-front-dashboard/src/services/sitemap/actions/rebuildSitemap.ts
  17. +9 −0 engrave-front-dashboard/src/services/sitemap/sitemap.service.ts
  18. +1 −1 engrave-front-dashboard/src/submodules/engrave-shared
  19. +1 −1 engrave-image-uploader/src/submodules/engrave-shared
  20. +1 −1 engrave-mailer/src/submodules/engrave-shared
  21. +1 −1 engrave-nginx-configurator/src/submodules/engrave-shared
  22. +19 −0 engrave-sitemap-builder/Dockerfile.development
  23. +19 −0 engrave-sitemap-builder/Dockerfile.production
  24. +2,616 −0 engrave-sitemap-builder/package-lock.json
  25. +42 −0 engrave-sitemap-builder/package.json
  26. +10 −0 engrave-sitemap-builder/src/app/app.routes.ts
  27. +8 −0 engrave-sitemap-builder/src/app/app.settings.ts
  28. +11 −0 engrave-sitemap-builder/src/app/app.ts
  29. +4 −0 engrave-sitemap-builder/src/index.ts
  30. +8 −0 engrave-sitemap-builder/src/routes/health/health.routes.ts
  31. +20 −0 engrave-sitemap-builder/src/routes/health/routes/ping.ts
  32. +29 −0 engrave-sitemap-builder/src/routes/sitemap/routes/get.ts
  33. +29 −0 engrave-sitemap-builder/src/routes/sitemap/routes/rebuild.ts
  34. +10 −0 engrave-sitemap-builder/src/routes/sitemap/sitemap.routes.ts
  35. +16 −0 engrave-sitemap-builder/src/services/sitemap/actions/getSitemap.ts
  36. +43 −0 engrave-sitemap-builder/src/services/sitemap/actions/rebuildSitemap.ts
  37. +9 −0 engrave-sitemap-builder/src/services/sitemap/sitemap.service.ts
  38. +1 −0 engrave-sitemap-builder/src/submodules/engrave-shared
  39. +18 −0 engrave-sitemap-builder/tsconfig.json
  40. +1 −1 engrave-ssl/src/submodules/engrave-shared
  41. +1 −1 engrave-statistics/src/submodules/engrave-shared
  42. +2 −0 images-build-dblog.sh
  43. +2 −0 images-build-engrave.sh
@@ -28,3 +28,6 @@
[submodule "engrave-mailer/src/submodules/engrave-shared"]
path = engrave-mailer/src/submodules/engrave-shared
url = https://github.com/wise-team/engrave-shared.git
[submodule "engrave-sitemap-builder/src/submodules/engrave-shared"]
path = engrave-sitemap-builder/src/submodules/engrave-shared
url = https://github.com/wise-team/engrave-shared.git
@@ -10,6 +10,7 @@ docker build ./engrave-blogs-renderer/ -f ./engrave-blogs-renderer/Dockerfile.de
docker build ./engrave-blockchain-tracker/ -f ./engrave-blockchain-tracker/Dockerfile.development -t bgornicki/engrave-blockchain-tracker
docker build ./engrave-auth/ -f ./engrave-auth/Dockerfile.development -t bgornicki/engrave-auth
docker build ./engrave-mailer/ -f ./engrave-mailer/Dockerfile.development -t bgornicki/engrave-mailer
docker build ./engrave-sitemap-builder/ -f ./engrave-sitemap-builder/Dockerfile.development -t bgornicki/engrave-sitemap-builder

docker build ./nginx/ -f ./nginx/Dockerfile.development -t bgornicki/nginx

@@ -121,6 +121,11 @@ services:
secrets:
- MAILGUN_DOMAIN
- MAILGUN_API_KEY

sitemap-builder:
image: bgornicki/engrave-sitemap-builder
environment:
- WAIT_HOSTS=redis:6379

nginx:
image: bgornicki/nginx
@@ -169,6 +169,17 @@ services:
- 3015:3000
- 3016:3001

sitemap-builder:
image: bgornicki/engrave-sitemap-builder
environment:
- WAIT_HOSTS=redis:6379
volumes:
- ./engrave-sitemap-builder/src:/app/src
- ./engrave-sitemap-builder/dist:/app/dist
ports:
- 3017:3000
- 3018:3001

mongo:
image: mongo
volumes:
@@ -122,6 +122,11 @@ services:
- MAILGUN_DOMAIN
- MAILGUN_API_KEY

sitemap-builder:
image: bgornicki/engrave-sitemap-builder
environment:
- WAIT_HOSTS=redis:6379

nginx:
image: bgornicki/nginx
ports:
@@ -2,11 +2,13 @@ import * as express from "express";
import index from "./routes/index";
import article from "./routes/article";
import category from "./routes/category";
import sitemap from "./routes/sitemap";

const frontendApi: express.Router = express.Router();

frontendApi.get('/', index.middleware, index.handler);
frontendApi.get('/category/:slug', category.middleware, category.handler);
frontendApi.get('/sitemap.xml', sitemap.middleware, sitemap.handler);
frontendApi.get('/:permlink', article.middleware, article.handler);

export default frontendApi;
@@ -0,0 +1,27 @@
import { Request, Response } from 'express';
import { handleResponseError } from '../../../submodules/engrave-shared';
import { getBlog } from '../../../submodules/engrave-shared/services/cache/cache';
import sitemap from '../../../services/sitemap/sitemap.service';

const middleware: any[] = [];

async function handler(req: Request, res: Response) {

return handleResponseError(async () => {

const { hostname } = req;

const blog = await getBlog(hostname);

const xml = await sitemap.getSitemap(blog);

res.header('Content-Type', 'application/xml');
return res.send(xml);

}, req, res);
}

export default {
middleware,
handler
}
@@ -0,0 +1,24 @@
import { Blog } from "../../../submodules/engrave-shared/interfaces/IBlog";
import { handleServiceError } from "../../../submodules/engrave-shared";
import axios from 'axios';

export default async (blog: Blog) => {

return handleServiceError(async () => {

const options = {
url: "http://sitemap-builder:3000/sitemap",
method: 'GET',
data: {
domain: blog.domain,
username: blog.username
}
};

const { data } = await axios(options);

return data;

})

}
@@ -0,0 +1,7 @@
import getSitemap from './actions/getSitemap';

const sitemap = {
getSitemap
}

export default sitemap;
@@ -6,7 +6,9 @@ import { RoutesVlidators } from '../../validators/RoutesValidators';
import { DashboardSteemConnect } from '../../modules/SteemConnect';
import { Onesignal } from '../../modules/Onesignal';
import { PublishedArticlesModule } from '../../modules/PublishedArticles';
import { removeArticle } from '../../submodules/engrave-shared/services/cache/cache';
import { removeArticle, getBlog, setArticle } from '../../submodules/engrave-shared/services/cache/cache';
import sitemap from '../../services/sitemap/sitemap.service';
import { getSteemArticle } from '../../submodules/engrave-shared/services/steem/steem';

let steem = require('steem');
let router = express.Router();
@@ -136,6 +138,10 @@ router.post('/delete', RoutesVlidators.isLoggedAndConfigured, async (req: IExten

try {
await removeArticle(req.session.blogger.steem_username, article.permlink);

const blog = await getBlog(req.session.blogger.domain);
await sitemap.rebuildSitemap(blog);

} catch (error) {
console.log(error);
}
@@ -160,12 +166,18 @@ router.post('/publish', RoutesVlidators.isLoggedAndConfigured, async (req: IExte

console.log("New article has been posted by @" + req.session.steemconnect.name);

await redis.set(`engrave:${req.session.steemconnect.name}:${post.permlink}`, "");

await PublishedArticlesModule.create(req.session.blogger, post);

Onesignal.sendNotification(req.session.blogger, post.title, post.image, post.permlink);

await redis.set(`engrave:${req.session.steemconnect.name}:${post.permlink}`, "");

const steemArticle = await getSteemArticle(req.session.steemconnect.name, post.permlink);
await setArticle(req.session.blogger.domain, req.session.steemconnect.name, post.permlink, steemArticle);

const blog = await getBlog(req.session.blogger.domain);
await sitemap.rebuildSitemap(blog);

if (post._id && post._id != '') {
await Posts.deleteOne({ _id: post._id });
res.json({ success: "Article published", draft: true });
@@ -265,6 +277,12 @@ router.post('/draft/publish', RoutesVlidators.isLoggedAndConfigured, async (req:

Onesignal.sendNotification(req.session.blogger, post.title, post.image, post.permlink);

const steemArticle = await getSteemArticle(req.session.steemconnect.name, post.permlink);
await setArticle(req.session.blogger.domain, req.session.steemconnect.name, post.permlink, steemArticle);

const blog = await getBlog(req.session.blogger.domain);
await sitemap.rebuildSitemap(blog);

if (post._id && post._id != '') {
await Posts.deleteOne({ _id: post._id });
res.json({ success: "Article published", draft: true });
@@ -0,0 +1,24 @@
import { Blog } from "../../../submodules/engrave-shared/interfaces/IBlog";
import { handleServiceError } from "../../../submodules/engrave-shared";
import axios from 'axios';

export default async (blog: Blog) => {

return handleServiceError(async () => {

const options = {
url: "http://sitemap-builder:3000/sitemap",
method: 'GET',
data: {
domain: blog.domain,
username: blog.username
}
};

const { data } = await axios(options);

return data;

})

}
@@ -0,0 +1,24 @@
import { Blog } from "../../../submodules/engrave-shared/interfaces/IBlog";
import { handleServiceError } from "../../../submodules/engrave-shared";
import axios from 'axios';

export default async (blog: Blog) => {

return handleServiceError(async () => {

const options = {
url: "http://sitemap-builder:3000/sitemap",
method: 'POST',
data: {
domain: blog.domain,
username: blog.username
}
};

const { data } = await axios(options);

return data;

})

}
@@ -0,0 +1,9 @@
import getSitemap from './actions/getSitemap';
import rebuildSitemap from './actions/rebuildSitemap';

const sitemap = {
getSitemap,
rebuildSitemap
}

export default sitemap;
@@ -0,0 +1,19 @@
FROM node:alpine

RUN npm install -g typescript nodemon

WORKDIR /app
COPY package*.json ./
COPY tsconfig.json ./
RUN npm install

COPY src src

RUN npm run build

## Add the wait script to the image
ADD https://github.com/ufoscout/docker-compose-wait/releases/download/2.4.0/wait /wait
RUN chmod +x /wait

## Launch the wait tool and then your application
CMD /wait && npm run watch
@@ -0,0 +1,19 @@
FROM node:alpine

RUN npm install -g typescript

WORKDIR /app
COPY package*.json ./
COPY tsconfig.json ./
RUN npm install

COPY src src

RUN npm run build

## Add the wait script to the image
ADD https://github.com/ufoscout/docker-compose-wait/releases/download/2.4.0/wait /wait
RUN chmod +x /wait

## Launch the wait tool and then your application
CMD /wait && npm run start
Oops, something went wrong.

0 comments on commit 789be1e

Please sign in to comment.
You can’t perform that action at this time.