forked from pedrofranceschi/Blogode
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed a bug when loading the MySQL driver (it was being loaded each t…
…ime a MySQL request was made).
- Loading branch information
1 parent
1ce4b53
commit e63b560
Showing
8 changed files
with
41 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,16 @@ | ||
var sys = require('sys'), | ||
database = require('./database.js'); | ||
|
||
database.initialize(); | ||
|
||
exports.getCommentsOfPost = function(postId, callback) { | ||
database.getDatabaseConnection(function (mysql_client) { | ||
mysql_client.query("SELECT * FROM comments WHERE id='" + escape(postId) + "';", function (error, results, fields) { | ||
mysql_client.query("SELECT * FROM comments WHERE post_id='" + escape(postId) + "';", function (error, results, fields) { | ||
if(error) { | ||
throw "Error getting comment: " + error; | ||
} | ||
|
||
callback(results[0]); | ||
callback(results); | ||
}); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,9 @@ | ||
<h1>Manage posts</h1> | ||
|
||
<% for (var i=0; i < posts.length; i++) { %> | ||
<b><%= unescape(posts[i].title) %></b> (by <%= posts[i].user_name %>) - <a href="/admin/posts/<%= posts[i].id %>">Edit</a> - <a href="/admin/posts/destroy/<%= posts[i].id %>">Delete</a><br/><br/> | ||
<% if(posts != undefined) { %> | ||
<% for (var i=0; i < posts.length; i++) { %> | ||
<b><%= unescape(posts[i].title) %></b> (by <%= posts[i].user_name %>) - <a href="/admin/posts/<%= posts[i].id %>">Edit</a> - <a href="/admin/posts/destroy/<%= posts[i].id %>">Delete</a><br/><br/> | ||
<% } %> | ||
<% } %> | ||
|
||
<a href="/admin/posts/new">New post</a> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,11 @@ | ||
<% for (var i=0; i < posts.length; i++) { %> | ||
<h2><a href="/<%= posts[i].id %>"><%= unescape(posts[i].title) %></a></h2> | ||
<p>by <%= posts[i].user_name %></p> | ||
<% if(unescape(posts[i].body).indexOf("###") >= 0) { %> | ||
<p><%- unescape(posts[i].body).split("###")[0] %></p><br/> | ||
<% } else { %> | ||
<p><%- unescape(posts[i].body) %></p><br/> | ||
<% if(posts != undefined) { %> | ||
<% for (var i=0; i < posts.length; i++) { %> | ||
<h2><a href="/<%= posts[i].id %>"><%= unescape(posts[i].title) %></a></h2> | ||
<p>by <%= posts[i].user_name %></p> | ||
<% if(unescape(posts[i].body).indexOf("###") >= 0) { %> | ||
<p><%- unescape(posts[i].body).split("###")[0] %></p><br/> | ||
<% } else { %> | ||
<p><%- unescape(posts[i].body) %></p><br/> | ||
<% } %> | ||
<% } %> | ||
<% } %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,10 @@ | ||
<h1><%= unescape(post.title) %></h1> | ||
<p>by <%= post.user_name %></p> | ||
<p><%- unescape(post.body) %></p> | ||
<p><%- unescape(post.body) %></p> | ||
|
||
<h1>Comments</h1> | ||
|
||
<% for (var i=0; i < comments.length; i++) { %> | ||
<h4><%= comments[i].author_name %></h4> | ||
<p><%= comments[i].comment %></p> | ||
<% } %> |