Skip to content

Commit

Permalink
use template vars instead of hardcoded values for cpp template
Browse files Browse the repository at this point in the history
  • Loading branch information
abhishek97 committed Oct 1, 2018
1 parent dd8cbef commit 9d8d4ca
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 10 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"amqp": "^0.2.7",
"handlebars-pdf": "^1.0.1",
"minio": "^7.0.0",
"moment": "^2.22.2",
"needle": "^2.2.2",
"phantomjs-prebuilt": "^2.1.16",
"raven": "^2.6.4",
Expand Down
6 changes: 5 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@ const PDF = require('handlebars-pdf')
const v4 = require('uuid/v4')
const p = require('path')
const needle = require('needle')
const moment = require('moment')
const fs = require('fs')


const Raven = require('./raven')
const { uploadToMinio, linkForKey } = require('./minio')
const config = require('../config.json')
Expand Down Expand Up @@ -36,7 +38,9 @@ queuePromise.then(q => {
q.subscribe(async function ({ data, callback }) {
try {
data.salt = v4().slice(-4)

data.run.startString = moment.unix(data.run.start).format("MMM YYYY")
data.run.endString = moment.unix(data.run.end).format("MMM YYYY")

// 1. generate html
const path = p.join(__dirname, './certification/' + v4() + ".pdf")
const templatePath = p.join(__dirname, './templates/' + data.template + '.hbs')
Expand Down
12 changes: 3 additions & 9 deletions src/templates/cpp.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -102,21 +102,15 @@
<div class="cb-image text"></div>
<div class="completion text">CERTIFICATE OF COMPLETION</div>
<div class="completion-sub text">This certificate is proudly presented to</div>
<div class="name text">Mohit Yadav</div>
<div class="name text">{{data.user.firstname}} {{data.user.lastname}}</div>
<div class="course-text text">for successfully completing the C++ Online Course
by Coding Blocks
</div>

<img src="img/certi-cpp.png" alt="" class="course-logo text">

<div class="batch text">
<div class="duration">15 May 2018 - 15 Aug 2018</div>
<hr>
<div>Batch</div>
</div>

<div class="batch text">
<div class="duration">15 May 2018 - 15 Aug 2018</div>
<div class="duration">{{data.run.start}} - {{data.run.end}}</div>
<hr>
<div>Batch</div>
</div>
Expand All @@ -131,7 +125,7 @@
</div>

<div class="verify text">
The certificate can be verified at online.codingblocks.com/verify/c++001
The certificate can be verified at https://online.codingblocks.com/certificates/CBOL-{{data.runAttempt.id}}-{{data.salt}}
</div>
</div>

Expand Down
4 changes: 4 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -440,6 +440,10 @@ [email protected], mkdirp@^0.5.1:
dependencies:
minimist "0.0.8"

moment@^2.22.2:
version "2.22.2"
resolved "https://registry.yarnpkg.com/moment/-/moment-2.22.2.tgz#3c257f9839fc0e93ff53149632239eb90783ff66"

[email protected]:
version "2.0.0"
resolved "https://registry.yarnpkg.com/ms/-/ms-2.0.0.tgz#5608aeadfc00be6c2901df5f9861788de0d597c8"
Expand Down

0 comments on commit 9d8d4ca

Please sign in to comment.