Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified .DS_Store
Binary file not shown.
1 change: 1 addition & 0 deletions final_updated/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules
13 changes: 13 additions & 0 deletions final_updated/.meteor/.finished-upgraders
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# This file contains information which helps Meteor properly upgrade your
# app when you run 'meteor update'. You should check it into version control
# with your project.

notices-for-0.9.0
notices-for-0.9.1
0.9.4-platform-file
notices-for-facebook-graph-api-2
1.2.0-standard-minifiers-package
1.2.0-meteor-platform-split
1.2.0-cordova-changes
1.2.0-breaking-changes
1.3.0-split-minifiers-package
1 change: 1 addition & 0 deletions final_updated/.meteor/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
local
7 changes: 7 additions & 0 deletions final_updated/.meteor/.id
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# This file contains a token that is unique to your project.
# Check it into your repository along with the rest of this directory.
# It can be used for purposes such as:
# - ensuring you don't accidentally deploy one app on top of another
# - providing package authors with aggregated statistics

c8pbxo1uogycx8r6ciz
28 changes: 28 additions & 0 deletions final_updated/.meteor/packages
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Meteor packages used by this project, one per line.
# Check this file (and the other files in this directory) into your repository.
#
# 'meteor add' and 'meteor remove' will edit this file for you,
# but you can also edit it by hand.

meteor-base # Packages every Meteor app needs to have
mobile-experience # Packages for a great mobile UX
mongo # The database Meteor supports right now
blaze-html-templates # Compile .html files into Meteor Blaze views
session # Client-side reactive dictionary for your app
jquery # Helpful client-side library
tracker # Meteor's client-side reactive programming library

es5-shim # ECMAScript 5 compatibility for older browsers.
ecmascript # Enable ECMAScript2015+ syntax in app code

autopublish # Publish all data to the clients (for prototyping)
insecure # Allow all DB writes from clients (for prototyping)
aldeed:autoform
twbs:bootstrap
aldeed:collection2
kadira:flow-router
kadira:blaze-layout

meteorhacks:ssr
standard-minifier-css
standard-minifier-js
2 changes: 2 additions & 0 deletions final_updated/.meteor/platforms
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
server
browser
1 change: 1 addition & 0 deletions final_updated/.meteor/release
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
METEOR@1.3.2.4
84 changes: 84 additions & 0 deletions final_updated/.meteor/versions
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
aldeed:autoform@5.8.1
aldeed:collection2@2.9.1
aldeed:collection2-core@1.1.1
aldeed:schema-deny@1.0.1
aldeed:schema-index@1.0.1
aldeed:simple-schema@1.5.3
allow-deny@1.0.4
autopublish@1.0.7
autoupdate@1.2.9
babel-compiler@6.6.4
babel-runtime@0.1.8
base64@1.0.8
binary-heap@1.0.8
blaze@2.1.7
blaze-html-templates@1.0.4
blaze-tools@1.0.8
boilerplate-generator@1.0.8
caching-compiler@1.0.4
caching-html-compiler@1.0.6
callback-hook@1.0.8
check@1.2.1
ddp@1.2.5
ddp-client@1.2.7
ddp-common@1.2.5
ddp-server@1.2.6
deps@1.0.12
diff-sequence@1.0.5
ecmascript@0.4.3
ecmascript-runtime@0.2.10
ejson@1.0.11
es5-shim@4.5.10
fastclick@1.0.11
geojson-utils@1.0.8
hot-code-push@1.0.4
html-tools@1.0.9
htmljs@1.0.9
http@1.1.5
id-map@1.0.7
insecure@1.0.7
jquery@1.11.8
kadira:blaze-layout@2.3.0
kadira:flow-router@2.12.1
launch-screen@1.0.11
livedata@1.0.18
logging@1.0.12
mdg:validation-error@0.2.0
meteor@1.1.14
meteor-base@1.0.4
meteorhacks:ssr@2.2.0
minifier-css@1.1.11
minifier-js@1.1.11
minimongo@1.0.16
mobile-experience@1.0.4
mobile-status-bar@1.0.12
modules@0.6.1
modules-runtime@0.6.3
momentjs:moment@2.10.6
mongo@1.1.7
mongo-id@1.0.4
npm-mongo@1.4.43
observe-sequence@1.0.11
ordered-dict@1.0.7
promise@0.6.7
raix:eventemitter@0.1.3
random@1.0.9
reactive-dict@1.1.7
reactive-var@1.0.9
reload@1.1.8
retry@1.0.7
routepolicy@1.0.10
session@1.1.5
spacebars@1.0.11
spacebars-compiler@1.0.11
standard-minifier-css@1.0.6
standard-minifier-js@1.0.6
templating@1.1.9
templating-tools@1.0.4
tracker@1.0.13
twbs:bootstrap@3.3.6
ui@1.0.11
underscore@1.0.8
url@1.0.9
webapp@1.2.8
webapp-hashing@1.0.9
11 changes: 11 additions & 0 deletions final_updated/client/head.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<head>
<title>Meteor PDF Tutorial</title>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]-->
</head>
34 changes: 34 additions & 0 deletions final_updated/client/templates/home.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<template name="Home">
<div class="container">
<div class="row">
<div class="col-sm-8 col-sm-offset-2">
<h1 class="text-center">Meteor PDF Tutorial</h1>
</div>
</div>
<div class="row">
<div class="col-sm-6 col-sm-offset-3" style="text-align: center">
<a href="#" class="btn btn-primary generate-pdf">Generate PDF</a>
</div>
</div>
<div class="row">
<div class="col-sm-6 col-sm-offset-3">
{{> quickForm collection="Pokemon" id="insertPokemonForm" type="insert"}}
</div>
</div>
<div class="row">
<div class="col-sm-6 col-sm-offset-3">
{{#each pokemon}}
<div class="row">
<div class="col-sm-3 col-sm-offset-2">
<img src="{{image_url}}" width="75" alt="">
</div>
<div class="col-sm-7">
<h4>{{name}}</h4>
<p>{{description}}</p>
</div>
</div>
{{/each}}
</div>
</div>
</div>
</template>
21 changes: 21 additions & 0 deletions final_updated/client/templates/home.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
Template.Home.events({
'click .generate-pdf': function(e, tmpl) {
e.preventDefault();

Meteor.call('pokemon/generate_pdf', function(err, res) {
if (err) {
console.error(err);
} else if (res) {
window.open("data:application/pdf;base64, " + res);
// OPTIONAL: Open in same window
// window.location.assign("data:application/pdf;base64, " + res);
}
})
}
});

Template.Home.helpers({
pokemon: function() {
return Pokemon.find({});
}
});
16 changes: 16 additions & 0 deletions final_updated/lib/collections/pokemon.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
Pokemon = new Mongo.Collection('pokemon');

Pokemon.attachSchema(new SimpleSchema({
name: {
type: String,
label: "Name"
},
description: {
type: String,
label: "Description"
},
image_url: {
type: String,
label: "Image URL"
}
}));
5 changes: 5 additions & 0 deletions final_updated/lib/router.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
FlowRouter.route('/', {
action: function(params, queryParams) {
BlazeLayout.render("Home");
}
});
18 changes: 18 additions & 0 deletions final_updated/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"name": "final_updated",
"version": "1.0.0",
"description": "",
"main": "index.js",
"dependencies": {
"fibers": "^1.0.10",
"meteor-node-stubs": "^0.2.3",
"phantomjs": "^2.1.7",
"webshot": "0.16.0"
},
"devDependencies": {},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC"
}
13 changes: 13 additions & 0 deletions final_updated/private/layout.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{{{getDocType}}}
<html lang="en">
<head>
<style type="text/css">
{{css}}
</style>
</head>
<body>

{{> Template.dynamic template=template data=data}}

</body>
</html>
22 changes: 22 additions & 0 deletions final_updated/private/pokemon-report.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<div class="container">
<div class="row">
<div class="col-sm-8 col-sm-offset-2">
<h1 class="text-center">Meteor PDF Tutorial</h1>
</div>
</div>
<div class="row">
<div class="col-sm-6 col-sm-offset-3">
{{#each pokemon}}
<div class="row">
<div class="col-sm-3 col-sm-offset-2">
<img src="{{image_url}}" width="75" alt="">
</div>
<div class="col-sm-7">
<h4>{{name}}</h4>
<p>{{description}}</p>
</div>
</div>
{{/each}}
</div>
</div>
</div>
6 changes: 6 additions & 0 deletions final_updated/private/style.css

Large diffs are not rendered by default.

65 changes: 65 additions & 0 deletions final_updated/server/methods.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
import webshot from 'webshot';
import fs from 'fs';
import Future from 'fibers/future';

Meteor.methods({
'pokemon/generate_pdf': function() {
// SETUP
// Grab required packages
var fut = new Future();
var fileName = "pokemon-report.pdf";

// GENERATE HTML STRING
var css = Assets.getText('style.css');

SSR.compileTemplate('layout', Assets.getText('layout.html'));

Template.layout.helpers({
getDocType: function() {
return "<!DOCTYPE html>";
}
});

SSR.compileTemplate('pokemon_report', Assets.getText('pokemon-report.html'));

// PREPARE DATA
var pokemon = Pokemon.find({});
var data = {
pokemon: pokemon
}

var html_string = SSR.render('layout', {
css: css,
template: "pokemon_report",
data: data
});

// WEBSHOT OPTIONS
var options = {
"paperSize": {
"format": "Letter",
"orientation": "portrait",
"margin": "1cm"
},
siteType: 'html'
};

// COMMENCE WEBSHOT
console.log("Commencing webshot...");
webshot(html_string, fileName, options, function(err) {
fs.readFile(fileName, function (err, data) {
if (err) {
return console.log(err);
}

fs.unlinkSync(fileName);
fut.return(data);
});
});

let pdfData = fut.wait();
let base64String = new Buffer(pdfData).toString('base64');

return base64String;
}
});
30 changes: 30 additions & 0 deletions final_updated/server/seed.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
Meteor.startup(function() {
if (Pokemon.find().count() < 1) {
var pokemon = [
{
name: 'Pikachu',
description: 'A cute electric shock',
image_url: 'http://img1.wikia.nocookie.net/__cb20150717063932/pokemon/images/c/c0/025Pikachu_OS_anime_2.png'
},
{
name: 'Charmander',
description: 'A cute flame',
image_url: 'http://vignette3.wikia.nocookie.net/pokemon/images/b/b9/004Charmander_Dream.png/revision/latest?cb=20140603214923'
},
{
name: 'Squirtle',
description: 'A cute water beast',
image_url: 'http://vignette2.wikia.nocookie.net/pokemontowerdefense/images/3/39/007Squirtle.png/revision/latest?cb=20130104234028'
},
{
name: 'Bulbasaur',
description: 'A cute plant thing',
image_url: 'http://vignette1.wikia.nocookie.net/pokemon/images/b/b8/001Bulbasaur_Dream.png/revision/latest?cb=20140903033758'
}
];

pokemon.forEach(function(pokemon) {
Pokemon.insert(pokemon);
});
}
});