import bookmark add create_at
This commit is contained in:
parent
e9a3252443
commit
e3c0aa7349
|
|
@ -18,7 +18,7 @@ var parsehtml = function (file, callback) {
|
||||||
var add_date, name, bookmark, tags, url;
|
var add_date, name, bookmark, tags, url;
|
||||||
url = $(e).attr("href");
|
url = $(e).attr("href");
|
||||||
name = $(e).text() || "无标题";
|
name = $(e).text() || "无标题";
|
||||||
add_date = $(e).attr("add_date");
|
add_date = parseInt($(e).attr("add_date")) * 1000;
|
||||||
|
|
||||||
// 只允许用一个标签
|
// 只允许用一个标签
|
||||||
// 只允许用一个标签
|
// 只允许用一个标签
|
||||||
|
|
|
||||||
|
|
@ -63,6 +63,9 @@ db.getBookmarkbyUrl = function(user_id, url) {
|
||||||
|
|
||||||
db.addBookmark = function(user_id, bookmark) {
|
db.addBookmark = function(user_id, bookmark) {
|
||||||
var sql = "INSERT INTO `bookmarks` (`user_id`, `title`, `description`, `url`, `public`, `click_count`) VALUES ('" + user_id + "', " + client.escape(bookmark.title) + ", " + client.escape(bookmark.description) + ", " + client.escape(bookmark.url) + ", '" + bookmark.public + "', '1')";
|
var sql = "INSERT INTO `bookmarks` (`user_id`, `title`, `description`, `url`, `public`, `click_count`) VALUES ('" + user_id + "', " + client.escape(bookmark.title) + ", " + client.escape(bookmark.description) + ", " + client.escape(bookmark.url) + ", '" + bookmark.public + "', '1')";
|
||||||
|
if (bookmark.created_at) {
|
||||||
|
sql = "INSERT INTO `bookmarks` (`user_id`, `title`, `description`, `url`, `public`, `created_at`, `click_count`) VALUES ('" + user_id + "', " + client.escape(bookmark.title) + ", " + client.escape(bookmark.description) + ", " + client.escape(bookmark.url) + ", '" + bookmark.public+ "', '" + bookmark.created_at + "', '1')";
|
||||||
|
}
|
||||||
console.log(sql);
|
console.log(sql);
|
||||||
return new Promise(function(resolve, reject) {
|
return new Promise(function(resolve, reject) {
|
||||||
client.query(sql, (err, result) => {
|
client.query(sql, (err, result) => {
|
||||||
|
|
|
||||||
|
|
@ -785,6 +785,7 @@ api.post('/uploadBookmarkFile', upload.single('bookmark'), function(req, res) {
|
||||||
bookmark.description = "";
|
bookmark.description = "";
|
||||||
bookmark.url = item.url;
|
bookmark.url = item.url;
|
||||||
bookmark.public = '1';
|
bookmark.public = '1';
|
||||||
|
bookmark.created_at = new Date(item.add_date).format('yyyy-MM-dd hh:mm:ss')
|
||||||
if (item.tags.length == 0) {
|
if (item.tags.length == 0) {
|
||||||
item.tags.push("未分类")
|
item.tags.push("未分类")
|
||||||
}
|
}
|
||||||
|
|
@ -1551,7 +1552,7 @@ api.get('/download', function(req, res) {
|
||||||
db.getExportBookmarksByTag(tag.id)
|
db.getExportBookmarksByTag(tag.id)
|
||||||
.then((bookmarks) => {
|
.then((bookmarks) => {
|
||||||
bookmarks.forEach((bookmark) => {
|
bookmarks.forEach((bookmark) => {
|
||||||
$('#' + bookmark.tag_id).append('<DT><A HREF="' + bookmark.url + '">' + bookmark.title + '</A></DT>');
|
$('#' + bookmark.tag_id).append('<DT><A HREF="' + bookmark.url + '" ADD_DATE="' + parseInt(new Date(bookmark.created_at).getTime() / 1000) + '">' + bookmark.title + '</A></DT>');
|
||||||
});
|
});
|
||||||
if (tagIndex == tags.length - 1) {
|
if (tagIndex == tags.length - 1) {
|
||||||
console.log('export bookmarks document construct end...');
|
console.log('export bookmarks document construct end...');
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue