Permalink
Browse files

started with the change to abstract the presentation and make it poss…

…ible to show multiple presentations
  • Loading branch information...
1 parent 90a067f commit b1556f7f5701e9109bb56ec2029d1e4427fc1c86 @jettro committed Jun 5, 2011
View
30 app.js
@@ -1,9 +1,16 @@
var pub = __dirname + '/public';
-
var Slide = require('./slide');
+var Presentation = require('./presentation');
+
var express = require('express')
- , app = express.createServer()
- , slide = new Slide();
+ , app = express.createServer();
+
+var presentations = [];
+var createPresentationNodejs = [];
+createPresentationNodejs.push("intro","Creating a presentation with Node.js");
+createPresentationNodejs.push("goal","Goal");
+presentations.push(new Presentation("Creating a presentation with Node.js","create-presentation-nodejs",createPresentationNodejs,
+ "With this presentation I want to show a way to create a presentation without the usual tools. We are going to create our own tool during the presentation."));
app.configure(function() {
app.set('view engine', 'jade');
@@ -15,12 +22,23 @@ app.configure(function() {
});
app.get('/', function(req, res) {
- res.render('index', {locals: {slides:slide.allSlides()}});
+ res.render('index', {locals: {presentations:presentations}});
});
-app.get('/slide/:id', slide.index);
-app.post('/slide/:id', slide.command);
+//app.get('/slide/:id', presentation.index);
+//app.post('/slide/:id', slide.command);
app.listen(8018);
console.log('Express server started on port %s', app.address().port);
+//function Slide() {
+// slides.push("Creating a presentation with Node.js",
+// "Goal",
+// "Requirements",
+// "Technology",
+// "Configure url handling",
+// "Handle requests",
+// "View content",
+// "The Future",
+// "Questions");
+//}
View
@@ -0,0 +1,74 @@
+
+var title; // title of the slide as shown on the slide
+var urlIdentifier; // used for url mapping and finding this presentation
+var slides; // collection of the slides, array of slide objects
+var description; // Description of the presentation
+
+/**
+ * Create a new presentation, each presentation has a title, a url identifier, the slides and the description
+ * of the presentation. You can also add an image of the presentation and a logo.
+ *
+ * @param title The title of the presentation
+ * @param urlIdentifier Identifier of the presentaion
+ * @param slides The slides of the presentation
+ */
+function Presentation(title, urlIdentifier, slides, description) {
+ this.title = title;
+ this.urlIdentifier = urlIdentifier;
+ this.slides = slides;
+ this.description = description;
+}
+
+/**
+ * Starts the presentation by rendering the first slide.
+ *
+ * @param req Request object
+ * @param res Response object
+ */
+Presentation.prototype.start = function(req,res) {
+ renderSlide(req,res,1);
+};
+
+/**
+ * Renders the description page of the presentation.
+ *
+ * @param req Request object
+ * @param res Response object
+ */
+Presentation.prototype.renderDescription = function(req,res) {
+ res.render('description', {locals: {description:this.description}});
+};
+
+/**
+ *
+ * @param req
+ * @param res
+ */
+Presentation.prototype.command = function(req,res) {
+ var id = req.params.id;
+ var command = req.body.command;
+ if (command == 'next' || command == 'n' || command == '') {
+ if (id < slides.length) id++;
+ } else if (command == 'previous' || command == 'p' || command == 'prev') {
+ if (id > 1) id--;
+ } else if (!isNaN(command)) {
+ var commandNum = parseInt(command);
+ if(commandNum > 0 && commandNum <= slides.length) id = commandNum;
+ }
+
+ console.log("Command: %s", command);
+ res.redirect(this.urlIdentifier + '/slide/' + this.slides[id].identifier);
+};
+
+Presentation.prototype.allSlides = function() {
+ console.log("Num slides: %s",slides.length);
+ return slides;
+};
+
+
+function renderSlide(req,res,numSlide) {
+ res.render('slide/num'+numSlide, {locals: {numSlide:req.params.id,totalSlide:slides.length,titleSlide:slides[numSlide-1]}});
+}
+
+
+module.exports = Presentation;
View
@@ -47,6 +47,10 @@ img.shadow {
box-shadow: 10px 10px 5px #888;
margin-top:20px;
}
+
+div.description {
+ font-size: smaller;
+}
/* Positioning the different components */
#fullscreen {
min-height: 100%;
View
@@ -1,44 +1,17 @@
-var slides = [];
-function Slide() {
- slides.push("Creating a presentation with Node.js",
- "Goal",
- "Requirements",
- "Technology",
- "Configure url handling",
- "Handle requests",
- "View content",
- "The Future",
- "Questions");
-}
-
-Slide.prototype.index = function(req,res) {
- renderSlide(req,res,req.params.id);
-};
+var identifier;
+var title;
-Slide.prototype.command = function(req,res) {
- var id = req.params.id;
- var command = req.body.command;
- if (command == 'next' || command == 'n' || command == '') {
- if (id < slides.length) id++;
- } else if (command == 'previous' || command == 'p' || command == 'prev') {
- if (id > 1) id--;
- } else if (!isNaN(command)) {
- var commandNum = parseInt(command);
- if(commandNum > 0 && commandNum <= slides.length) id = commandNum;
- }
+function Slide(identifier,title) {
+ this.identifier = identifier;
+ this.title = title;
+}
- console.log("Command: %s", command);
- res.redirect('/slide/'+id);
+Slide.prototype.identifier = function() {
+ return this.identifier;
};
-Slide.prototype.allSlides = function() {
- console.log("Num slides: %s",slides.length);
- return slides;
+Slide.prototype.description = function() {
+ return this.description;
};
-function renderSlide(req,res,numSlide) {
- res.render('slide/num'+numSlide, {locals: {numSlide:req.params.id,totalSlide:slides.length,titleSlide:slides[numSlide-1]}});
-}
-
-
module.exports = Slide;
@@ -0,0 +1 @@
+blockquote Show you how easy it is to create a presentation as a nerd
@@ -0,0 +1,4 @@
+img(src='/images/logo.jpg')
+div.heading author
+div.heading Jettro Coenradie
+img(src='/images/nature.jpg', class="shadow")
View
@@ -1,5 +1,6 @@
-p available slides
+div#title available presentations
ul
- - each slide,index in slides
+ - each presentation,index in presentations
li
- a(href='/slide/' + (index + 1)) #{slide}
+ a(href=presentation.urlIdentifier + '/slide/' + (index + 1)) #{presentation.title}
+ div.description #{presentation.description}

0 comments on commit b1556f7

Please sign in to comment.