diff --git a/.gitignore b/.gitignore
index 780103f..39c8249 100644
--- a/.gitignore
+++ b/.gitignore
@@ -37,4 +37,5 @@ jspm_packages
.node_repl_history
# Upload File
-uploads
\ No newline at end of file
+uploads
+/public/images/shot/
\ No newline at end of file
diff --git a/database/db.js b/database/db.js
index e7e09b0..365a4e0 100644
--- a/database/db.js
+++ b/database/db.js
@@ -52,15 +52,15 @@ Date.prototype.format = function(fmt) { //author: meizz
// update delete 返回影响的行数
var db = {
- }
- // var sql = "SELECT * FROM `users` WHERE `username` = 'luchenqun'";
- // client.query(sql, (err, result) => {
- // if (err) {
- // console.log(err);
- // } else {
- // console.log(result);
- // }
- // });
+}
+// var sql = "SELECT * FROM `users` WHERE `username` = 'luchenqun'";
+// client.query(sql, (err, result) => {
+// if (err) {
+// console.log(err);
+// } else {
+// console.log(result);
+// }
+// });
db.addBookmark = function(user_id, bookmark) {
var insertSql = "INSERT INTO `bookmarks` (`user_id`, `title`, `description`, `url`, `public`, `click_count`) VALUES ('" + user_id + "', '" + bookmark.title + "', '" + bookmark.description + "', '" + bookmark.url + "', '" + bookmark.public + "', '1')";
@@ -413,9 +413,14 @@ db.getBookmarksTable = function(params) {
var sql = "SELECT id, user_id, title, description, url, public, click_count, DATE_FORMAT(created_at, '%Y-%m-%d') as created_at, DATE_FORMAT(last_click, '%Y-%m-%d') as last_click FROM `bookmarks` WHERE 1=1";
if (user_id) {
- sql += " AND `user_id` = '" + user_id + "' ORDER BY click_count DESC"
+ sql += " AND `user_id` = '" + user_id + "'";
+ if (params.showStyle == 'card') {
+ sql += " ORDER BY created_at DESC";
+ } else {
+ sql += " ORDER BY click_count DESC";
+ }
}
-
+ console.log(sql);
return new Promise(function(resolve, reject) {
client.query(sql, (err, result) => {
if (err) {
diff --git a/package.json b/package.json
index 282331d..9e48a0a 100644
--- a/package.json
+++ b/package.json
@@ -20,6 +20,7 @@
"mysql": "^2.11.1",
"node-readability": "^2.2.0",
"serve-favicon": "~2.3.0",
- "supervisor": "^0.11.0"
+ "supervisor": "^0.11.0",
+ "webshot": "^0.18.0"
}
}
diff --git a/public/css/style.css b/public/css/style.css
index 14fc086..5d34d06 100644
--- a/public/css/style.css
+++ b/public/css/style.css
@@ -1,8 +1,8 @@
body {
- background-image: url('../images/bg.png');
- background-repeat: repeat;
- background-position: top left;
- background-attachment: scroll;
+ background-image: url('../images/bg.png');
+ background-repeat: repeat;
+ background-position: top left;
+ background-attachment: scroll;
padding: 50px;
font: 14px "Lucida Grande", Helvetica, Arial, sans-serif;
}
@@ -10,7 +10,7 @@ code {
background-color: rgba(0, 0, 0, 0.08);
border-radius: 3px;
display: inline-block;
- font-family: "Monaco","Menlo","Ubuntu Mono","Consolas","source-code-pro",monospace;
+ font-family: "Monaco", "Menlo", "Ubuntu Mono", "Consolas", "source-code-pro", monospace;
font-size: 0.875em;
font-weight: bold;
padding: 1px 6px;
@@ -24,6 +24,13 @@ code {
color: #212121;
border: 1px solid transparent;
}
+.bookmarkTitle {
+ text-overflow: ellipsis;
+ overflow: hidden;
+ display: -webkit-box;
+ -webkit-box-orient: vertical;
+ height: 40px;
+}
.bookmarkNormalHover {
white-space: nowrap;
text-overflow: ellipsis;
diff --git a/public/scripts/controllers/bookmarks-controller.js b/public/scripts/controllers/bookmarks-controller.js
index 6d098b0..e87a284 100644
--- a/public/scripts/controllers/bookmarks-controller.js
+++ b/public/scripts/controllers/bookmarks-controller.js
@@ -4,7 +4,7 @@ app.controller('bookmarksCtr', ['$scope', '$state', '$stateParams', '$filter', '
$scope.showSearch = false; // 搜索对话框
$scope.bookmarkNormalHover = false;
$scope.bookmarkEditHover = false;
- $scope.showStyle = ($stateParams && $stateParams.showStyle) || 'navigate'; // 显示风格'navigate', 'card', 'table'
+ $scope.showStyle = 'card' //($stateParams && $stateParams.showStyle) || 'card'; // 显示风格'navigate', 'card', 'table'
$('.js-radio-' + $scope.showStyle).checkbox('set checked');
$scope.edit = false;
const perPageItems = 20;
@@ -102,7 +102,7 @@ app.controller('bookmarksCtr', ['$scope', '$state', '$stateParams', '$filter', '
function getBookmarks(params) {
if (params.showStyle != 'navigate') {
params.currentPage = $scope.currentPage;
- params.perPageItems = perPageItems;
+ params.perPageItems = params.showStyle == 'table' ? perPageItems : perPageItems * 3;
}
bookmarkService.getBookmarks(params)
.then((data) => {
diff --git a/public/scripts/directives/js-init-directive.js b/public/scripts/directives/js-init-directive.js
index 14f5696..183ecc4 100644
--- a/public/scripts/directives/js-init-directive.js
+++ b/public/scripts/directives/js-init-directive.js
@@ -162,3 +162,15 @@ app.directive('jsMenuInit', function($compile) {
},
};
});
+
+app.directive('errSrc', function() {
+ return {
+ link: function(scope, element, attrs) {
+ element.bind('error', function() {
+ if (attrs.src != attrs.errSrc) {
+ attrs.$set('src', attrs.errSrc);
+ }
+ });
+ }
+ }
+});
diff --git a/public/views/bookmarks.html b/public/views/bookmarks.html
index baa13f0..26ef4fa 100644
--- a/public/views/bookmarks.html
+++ b/public/views/bookmarks.html
@@ -30,7 +30,7 @@
id="{{bookmark.id}}">
-
+
{{ bookmark.title}}